From 7704c8371ae4d84d1b8188f637255e25b3b5ec11 Mon Sep 17 00:00:00 2001 From: Daniil Suvorov Date: Wed, 26 Jul 2023 15:47:48 +0300 Subject: [PATCH] chore: styles object --- .../SubnavigationButton.tsx | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/vkui/src/components/SubnavigationButton/SubnavigationButton.tsx b/packages/vkui/src/components/SubnavigationButton/SubnavigationButton.tsx index 41ac18a857..aa0afefd8c 100644 --- a/packages/vkui/src/components/SubnavigationButton/SubnavigationButton.tsx +++ b/packages/vkui/src/components/SubnavigationButton/SubnavigationButton.tsx @@ -9,6 +9,23 @@ import { Caption } from '../Typography/Caption/Caption'; import { Subhead } from '../Typography/Subhead/Subhead'; import styles from './SubnavigationButton.module.css'; +const appearanceStyles = { + accent: styles['SubnavigationButton--appearance-accent'], + neutral: styles['SubnavigationButton--appearance-neutral'], +}; + +const modeStyles = { + primary: styles['SubnavigationButton--mode-primary'], + outline: styles['SubnavigationButton--mode-outline'], + tertiary: styles['SubnavigationButton--mode-tertiary'], +}; + +const sizeStyles = { + s: styles['SubnavigationButton--size-s'], + m: styles['SubnavigationButton--size-m'], + l: styles['SubnavigationButton--size-l'], +}; + const sizeYClassNames = { none: styles['SubnavigationButton--sizeY-none'], [SizeType.COMPACT]: styles['SubnavigationButton--sizeY-compact'], @@ -77,20 +94,9 @@ export const SubnavigationButton = ({ focusVisibleMode="outside" className={classNames( styles['SubnavigationButton'], - { - s: styles['SubnavigationButton--size-s'], - m: styles['SubnavigationButton--size-m'], - l: styles['SubnavigationButton--size-l'], - }[size], - { - primary: styles['SubnavigationButton--mode-primary'], - outline: styles['SubnavigationButton--mode-outline'], - tertiary: styles['SubnavigationButton--mode-tertiary'], - }[mode], - { - accent: styles['SubnavigationButton--appearance-accent'], - neutral: styles['SubnavigationButton--appearance-neutral'], - }[appearance], + sizeStyles[size], + modeStyles[mode], + appearanceStyles[appearance], selected && styles['SubnavigationButton--selected'], sizeY !== SizeType.REGULAR && sizeYClassNames[sizeY], className,