diff --git a/src/frontend/apps/impress/src/components/Card.tsx b/src/frontend/apps/impress/src/components/Card.tsx index 08aec938..9e884bf4 100644 --- a/src/frontend/apps/impress/src/components/Card.tsx +++ b/src/frontend/apps/impress/src/components/Card.tsx @@ -18,7 +18,7 @@ export const Card = ({ $background="white" $radius="4px" $css={css` - border: 1px solid ${colorsTokens()['greyscale-200']}; + border: 1px solid ${colorsTokens['greyscale-200']}; ${$css} `} {...props} diff --git a/src/frontend/apps/impress/src/components/DropdownMenu.tsx b/src/frontend/apps/impress/src/components/DropdownMenu.tsx index 2664e928..8758588e 100644 --- a/src/frontend/apps/impress/src/components/DropdownMenu.tsx +++ b/src/frontend/apps/impress/src/components/DropdownMenu.tsx @@ -35,9 +35,7 @@ export const DropdownMenu = ({ label, topMessage, }: PropsWithChildren) => { - const theme = useCunninghamTheme(); - const spacings = theme.spacingsTokens(); - const colors = theme.colorsTokens(); + const { spacingsTokens, colorsTokens } = useCunninghamTheme(); const [isOpen, setIsOpen] = useState(false); const blockButtonRef = useRef(null); @@ -120,11 +118,11 @@ export const DropdownMenu = ({ key={option.label} $align="center" $justify="space-between" - $background={colors['greyscale-000']} - $color={colors['primary-600']} + $background={colorsTokens['greyscale-000']} + $color={colorsTokens['primary-600']} $padding={{ vertical: 'xs', horizontal: 'base' }} $width="100%" - $gap={spacings['base']} + $gap={spacingsTokens['base']} $css={css` border: none; ${index === 0 && @@ -148,7 +146,11 @@ export const DropdownMenu = ({ } `} > - + {option.icon && ( { const { t } = useTranslation(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); if (children) { return ( @@ -44,7 +43,7 @@ export const QuickSearchInput = ({ $direction="row" $align="center" className="quick-search-input" - $gap={spacing['2xs']} + $gap={spacingsTokens['2xs']} $padding={{ all: 'base' }} > {!loading && } diff --git a/src/frontend/apps/impress/src/components/quick-search/QuickSearchItemContent.tsx b/src/frontend/apps/impress/src/components/quick-search/QuickSearchItemContent.tsx index 94dc5efc..09330bd5 100644 --- a/src/frontend/apps/impress/src/components/quick-search/QuickSearchItemContent.tsx +++ b/src/frontend/apps/impress/src/components/quick-search/QuickSearchItemContent.tsx @@ -17,7 +17,6 @@ export const QuickSearchItemContent = ({ right, }: QuickSearchItemContentProps) => { const { spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); const { isDesktop } = useResponsiveStore(); @@ -32,7 +31,7 @@ export const QuickSearchItemContent = ({ {left} diff --git a/src/frontend/apps/impress/src/components/separators/HorizontalSeparator.tsx b/src/frontend/apps/impress/src/components/separators/HorizontalSeparator.tsx index 4b98621a..f8ab9bd1 100644 --- a/src/frontend/apps/impress/src/components/separators/HorizontalSeparator.tsx +++ b/src/frontend/apps/impress/src/components/separators/HorizontalSeparator.tsx @@ -26,7 +26,7 @@ export const HorizontalSeparator = ({ $background={ variant === SeparatorVariant.DARK ? '#e5e5e533' - : colorsTokens()['greyscale-100'] + : colorsTokens['greyscale-100'] } className="--docs--horizontal-separator" /> diff --git a/src/frontend/apps/impress/src/components/separators/SeparatedSection.tsx b/src/frontend/apps/impress/src/components/separators/SeparatedSection.tsx index 6a8f7790..0411f5b0 100644 --- a/src/frontend/apps/impress/src/components/separators/SeparatedSection.tsx +++ b/src/frontend/apps/impress/src/components/separators/SeparatedSection.tsx @@ -13,17 +13,15 @@ export const SeparatedSection = ({ showSeparator = true, children, }: PropsWithChildren) => { - const theme = useCunninghamTheme(); - const colors = theme.colorsTokens(); - const spacings = theme.spacingsTokens(); + const { colorsTokens, spacingsTokens } = useCunninghamTheme(); return ( diff --git a/src/frontend/apps/impress/src/cunningham/__tests__/useCunninghamTheme.spec.tsx b/src/frontend/apps/impress/src/cunningham/__tests__/useCunninghamTheme.spec.tsx index c3c6bcfd..425781d6 100644 --- a/src/frontend/apps/impress/src/cunningham/__tests__/useCunninghamTheme.spec.tsx +++ b/src/frontend/apps/impress/src/cunningham/__tests__/useCunninghamTheme.spec.tsx @@ -4,7 +4,7 @@ describe('', () => { it('has the logo correctly set', () => { const { themeTokens, setTheme } = useCunninghamTheme.getState(); setTheme('default'); - const logo = themeTokens().logo; + const logo = themeTokens.logo; expect(logo?.src).toBe('/assets/logo-gouv.svg'); expect(logo?.widthHeader).toBe('110px'); expect(logo?.widthFooter).toBe('220px'); diff --git a/src/frontend/apps/impress/src/cunningham/useCunninghamTheme.tsx b/src/frontend/apps/impress/src/cunningham/useCunninghamTheme.tsx index 81cc478c..7cc5e662 100644 --- a/src/frontend/apps/impress/src/cunningham/useCunninghamTheme.tsx +++ b/src/frontend/apps/impress/src/cunningham/useCunninghamTheme.tsx @@ -3,39 +3,53 @@ import { create } from 'zustand'; import { tokens } from './cunningham-tokens'; -type Tokens = typeof tokens.themes.default; +type Tokens = typeof tokens.themes.default & + Partial<(typeof tokens.themes)[keyof typeof tokens.themes]>; type ColorsTokens = Tokens['theme']['colors']; type FontSizesTokens = Tokens['theme']['font']['sizes']; type SpacingsTokens = Tokens['theme']['spacings']; type ComponentTokens = Tokens['components']; export type Theme = keyof typeof tokens.themes; -interface AuthStore { - theme: string; +interface ThemeStore { + theme: Theme; setTheme: (theme: Theme) => void; - themeTokens: () => Partial; - colorsTokens: () => Partial; - fontSizesTokens: () => Partial; - spacingsTokens: () => Partial; - componentTokens: () => ComponentTokens; + themeTokens: Partial; + colorsTokens: Partial; + fontSizesTokens: Partial; + spacingsTokens: Partial; + componentTokens: ComponentTokens; } -export const useCunninghamTheme = create((set, get) => { - const currentTheme = () => - merge( - tokens.themes['default'], - tokens.themes[get().theme as keyof typeof tokens.themes], - ) as Tokens; +const getMergedTokens = (theme: Theme) => { + return merge({}, tokens.themes['default'], tokens.themes[theme]); +}; - return { - theme: 'default', - themeTokens: () => currentTheme().theme, - colorsTokens: () => currentTheme().theme.colors, - componentTokens: () => currentTheme().components, - spacingsTokens: () => currentTheme().theme.spacings, - fontSizesTokens: () => currentTheme().theme.font.sizes, - setTheme: (theme: Theme) => { - set({ theme }); - }, - }; -}); +const DEFAULT_THEME: Theme = 'default'; +const defaultTokens = getMergedTokens(DEFAULT_THEME); + +const initialState: ThemeStore = { + theme: DEFAULT_THEME, + setTheme: () => {}, + themeTokens: defaultTokens.theme, + colorsTokens: defaultTokens.theme.colors, + componentTokens: defaultTokens.components, + spacingsTokens: defaultTokens.theme.spacings, + fontSizesTokens: defaultTokens.theme.font.sizes, +}; + +export const useCunninghamTheme = create((set) => ({ + ...initialState, + setTheme: (theme: Theme) => { + const newTokens = getMergedTokens(theme); + + set({ + theme, + themeTokens: newTokens.theme, + colorsTokens: newTokens.theme.colors, + componentTokens: newTokens.components, + spacingsTokens: newTokens.theme.spacings, + fontSizesTokens: newTokens.theme.font.sizes, + }); + }, +})); diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx index 41a2467d..d7e23aa5 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx @@ -67,7 +67,7 @@ export const DocEditor = ({ doc, versionId }: DocEditorProps) => { ); }, diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/QuoteBlock.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/QuoteBlock.tsx index a034c466..f52a5c70 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/QuoteBlock.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/QuoteBlock.tsx @@ -27,7 +27,7 @@ export const QuoteBlock = createReactBlockSpec( $margin="0 0 1rem 0" $padding="0.5rem 1rem" style={{ - borderLeft: `4px solid ${colorsTokens()['greyscale-300']}`, + borderLeft: `4px solid ${colorsTokens['greyscale-300']}`, fontStyle: 'italic', flexGrow: 1, }} diff --git a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerDocx.tsx b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerDocx.tsx index 49df88f1..406002e4 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerDocx.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerDocx.tsx @@ -14,7 +14,7 @@ export const blockMappingDividerDocx: DocsExporterDocx['mappings']['blockMapping }, border: { top: { - color: colorsTokens()['greyscale-300'], + color: colorsTokens['greyscale-300'], size: 1, style: 'single', space: 1, diff --git a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerPDF.tsx b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerPDF.tsx index 844185d1..ca5e7c18 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerPDF.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/dividerPDF.tsx @@ -12,7 +12,7 @@ export const blockMappingDividerPDF: DocsExporterPDF['mappings']['blockMapping'] diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx index 87656a79..8aebcd17 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx @@ -22,8 +22,6 @@ interface DocHeaderProps { export const DocHeader = ({ doc }: DocHeaderProps) => { const { colorsTokens, spacingsTokens } = useCunninghamTheme(); const { isDesktop } = useResponsiveStore(); - const spacings = spacingsTokens(); - const colors = colorsTokens(); const { t } = useTranslation(); const docIsPublic = doc.link_reach === LinkReach.PUBLIC; @@ -36,21 +34,21 @@ export const DocHeader = ({ doc }: DocHeaderProps) => { {(docIsPublic || docIsAuth) && ( { $align="center" $maxWidth="100%" > - + diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx index faad51db..b838ef44 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx @@ -116,7 +116,7 @@ const DocTitleInput = ({ doc }: DocTitleProps) => { onBlurCapture={(event) => handleTitleSubmit(event.target.textContent || '') } - $color={colorsTokens()['greyscale-1000']} + $color={colorsTokens['greyscale-1000']} $minHeight="40px" $padding={{ right: 'big' }} $css={css` diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx index f9b399de..77a1fe50 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx @@ -47,9 +47,6 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => { const { spacingsTokens, colorsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); - const colors = colorsTokens(); - const [isModalRemoveOpen, setIsModalRemoveOpen] = useState(false); const [isModalExportOpen, setIsModalExportOpen] = useState(false); const selectHistoryModal = useModal(); @@ -182,7 +179,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => { $direction="row" $align="center" $margin={{ left: 'auto' }} - $gap={spacings['2xs']} + $gap={spacingsTokens['2xs']} > {!isSmallMobile && ( <> @@ -245,12 +242,12 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => { $css={css` border-radius: 4px; &:hover { - background-color: ${colors['greyscale-100']}; + background-color: ${colorsTokens['greyscale-100']}; } ${isSmallMobile ? css` padding: 10px; - border: 1px solid ${colors['greyscale-300']}; + border: 1px solid ${colorsTokens['greyscale-300']}; ` : ''} `} diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx index c5a2259c..fd8e9199 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx @@ -12,7 +12,6 @@ interface DocVersionHeaderProps { export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => { const { spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); const { t } = useTranslation(); return ( @@ -20,7 +19,7 @@ export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => { diff --git a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareAddMemberList.tsx b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareAddMemberList.tsx index 861fc0c7..fdded178 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareAddMemberList.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareAddMemberList.tsx @@ -43,8 +43,6 @@ export const DocShareAddMemberList = ({ const { spacingsTokens, colorsTokens } = useCunninghamTheme(); const [invitationRole, setInvitationRole] = useState(Role.EDITOR); const canShare = doc.abilities.accesses_manage; - const spacing = spacingsTokens(); - const color = colorsTokens(); const { mutateAsync: createInvitation } = useCreateDocInvitation(); const { mutateAsync: createDocAccess } = useCreateDocAccess(); @@ -115,12 +113,12 @@ export const DocShareAddMemberList = ({ @@ -129,7 +127,7 @@ export const DocShareAddMemberList = ({ $align="center" $wrap="wrap" $flex={1} - $gap={spacing.xs} + $gap={spacingsTokens.xs} > {selectedUsers.map((user) => ( ))} - + { const { spacingsTokens, colorsTokens, fontSizesTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); - const color = colorsTokens(); - const fontSize = fontSizesTokens(); + return ( diff --git a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareInvitationItem.tsx b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareInvitationItem.tsx index 6a186e43..76a04fbd 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareInvitationItem.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocShareInvitationItem.tsx @@ -24,7 +24,6 @@ type Props = { export const DocShareInvitationItem = ({ doc, invitation }: Props) => { const { t } = useTranslation(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); const fakeUser: User = { id: invitation.email, full_name: invitation.email, @@ -91,7 +90,7 @@ export const DocShareInvitationItem = ({ doc, invitation }: Props) => { alwaysShowRight={true} user={fakeUser} right={ - + { const { toast } = useToastProvider(); const { isDesktop } = useResponsiveStore(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); const isNotAllowed = isOtherOwner || !!isLastOwner || !doc.abilities.accesses_manage; @@ -78,7 +77,7 @@ export const DocShareMemberItem = ({ doc, access }: Props) => { alwaysShowRight={true} user={access.user} right={ - + { const { toast } = useToastProvider(); const { isDesktop } = useResponsiveStore(); const { spacingsTokens, colorsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); - const colors = colorsTokens(); const canManage = doc.abilities.accesses_manage; const [linkReach, setLinkReach] = useState(doc.link_reach); const [docLinkRole, setDocLinkRole] = useState(doc.link_role); @@ -90,7 +88,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { @@ -100,7 +98,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { $direction="row" $align="center" $justify="space-between" - $gap={spacing['xs']} + $gap={spacingsTokens['xs']} $width="100%" $wrap="nowrap" > @@ -108,18 +106,18 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { $direction="row" $align={isDesktop ? 'center' : undefined} $padding={{ horizontal: '2xs' }} - $gap={canManage ? spacing['3xs'] : spacing['base']} + $gap={canManage ? spacingsTokens['3xs'] : spacingsTokens['base']} > - + { )} {showLinkRoleOptions && ( - + {linkReach !== LinkReach.RESTRICTED && ( { const hasFullName = user.full_name != null && user.full_name !== ''; const { spacingsTokens, colorsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); - const colors = colorsTokens(); return ( diff --git a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx index 4865f892..e069d92c 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/Heading.tsx @@ -58,7 +58,7 @@ export const Heading = ({ }); }} $radius="4px" - $background={isActive ? `${colorsTokens()['greyscale-100']}` : 'none'} + $background={isActive ? `${colorsTokens['greyscale-100']}` : 'none'} $css="text-align: left;" className="--docs--table-content-heading" > diff --git a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx index d4e793c0..1d4fe2bc 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-table-content/components/TableContent.tsx @@ -13,7 +13,6 @@ export const TableContent = () => { const { headings } = useHeadingStore(); const { editor } = useEditorStore(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); const [headingIdHighlight, setHeadingIdHighlight] = useState(); @@ -158,7 +157,7 @@ export const TableContent = () => { { const { colorsTokens, spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); const [isModalVersionOpen, setIsModalVersionOpen] = useState(false); @@ -33,13 +32,13 @@ export const VersionItem = ({ { const { isDesktop } = useResponsiveStore(); const { flexLeft, flexRight } = useResponsiveDocGrid(); const { spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); const shareModal = useModal(); const isPublic = doc.link_reach === LinkReach.PUBLIC; const isAuthenticated = doc.link_reach === LinkReach.AUTHENTICATED; @@ -63,7 +62,7 @@ export const DocsGridItem = ({ doc }: DocsGridItemProps) => { data-testid={`docs-grid-name-${doc.id}`} $direction="row" $align="center" - $gap={spacings.xs} + $gap={spacingsTokens.xs} $flex={flexLeft} $padding={{ right: isDesktop ? 'md' : '3xs' }} $maxWidth="100%" @@ -119,7 +118,7 @@ export const DocsGridItem = ({ doc }: DocsGridItemProps) => { )} - + {isDesktop && ( @@ -73,7 +72,7 @@ export const SimpleDocItem = ({ diff --git a/src/frontend/apps/impress/src/features/footer/Footer.tsx b/src/frontend/apps/impress/src/features/footer/Footer.tsx index 28fa3543..92f249e2 100644 --- a/src/frontend/apps/impress/src/features/footer/Footer.tsx +++ b/src/frontend/apps/impress/src/features/footer/Footer.tsx @@ -18,7 +18,7 @@ const BlueStripe = styled.div` export const Footer = () => { const { t } = useTranslation(); const { themeTokens } = useCunninghamTheme(); - const logo = themeTokens().logo; + const logo = themeTokens.logo; return ( diff --git a/src/frontend/apps/impress/src/features/header/components/Header.tsx b/src/frontend/apps/impress/src/features/header/components/Header.tsx index b808f5ce..73b15d7e 100644 --- a/src/frontend/apps/impress/src/features/header/components/Header.tsx +++ b/src/frontend/apps/impress/src/features/header/components/Header.tsx @@ -16,12 +16,9 @@ import { Title } from './Title'; export const Header = () => { const { t } = useTranslation(); - const theme = useCunninghamTheme(); + const { spacingsTokens, colorsTokens } = useCunninghamTheme(); const { isDesktop } = useResponsiveStore(); - const spacings = theme.spacingsTokens(); - const colors = theme.colorsTokens(); - return ( { align-items: center; justify-content: space-between; height: ${HEADER_HEIGHT}px; - padding: 0 ${spacings['base']}; - background-color: ${colors['greyscale-000']}; - border-bottom: 1px solid ${colors['greyscale-200']}; + padding: 0 ${spacingsTokens['base']}; + background-color: ${colorsTokens['greyscale-000']}; + border-bottom: 1px solid ${colorsTokens['greyscale-200']}; `} className="--docs--header" > @@ -45,7 +42,7 @@ export const Header = () => { { {!isDesktop ? ( - + ) : ( - + diff --git a/src/frontend/apps/impress/src/features/header/components/LaGaufre.tsx b/src/frontend/apps/impress/src/features/header/components/LaGaufre.tsx index dce37284..8f99198d 100644 --- a/src/frontend/apps/impress/src/features/header/components/LaGaufre.tsx +++ b/src/frontend/apps/impress/src/features/header/components/LaGaufre.tsx @@ -15,7 +15,7 @@ const GaufreStyle = createGlobalStyle` export const LaGaufre = () => { const { componentTokens } = useCunninghamTheme(); - if (!componentTokens()['la-gauffre'].activated) { + if (!componentTokens['la-gauffre'].activated) { return null; } diff --git a/src/frontend/apps/impress/src/features/header/components/Title.tsx b/src/frontend/apps/impress/src/features/header/components/Title.tsx index b1117ed8..be3b2706 100644 --- a/src/frontend/apps/impress/src/features/header/components/Title.tsx +++ b/src/frontend/apps/impress/src/features/header/components/Title.tsx @@ -6,14 +6,13 @@ import { useCunninghamTheme } from '@/cunningham'; export const Title = () => { const { t } = useTranslation(); - const theme = useCunninghamTheme(); - const spacings = theme.spacingsTokens(); + const { spacingsTokens } = useCunninghamTheme(); return ( DocLogo diff --git a/src/frontend/apps/impress/src/features/home/components/HomeHeader.tsx b/src/frontend/apps/impress/src/features/home/components/HomeHeader.tsx index 2fce7c68..2c285d14 100644 --- a/src/frontend/apps/impress/src/features/home/components/HomeHeader.tsx +++ b/src/frontend/apps/impress/src/features/home/components/HomeHeader.tsx @@ -18,8 +18,7 @@ export const getHeaderHeight = (isSmallMobile: boolean) => export const HomeHeader = () => { const { t } = useTranslation(); const { themeTokens, spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); - const logo = themeTokens().logo; + const logo = themeTokens.logo; const { isSmallMobile } = useResponsiveStore(); return ( @@ -57,7 +56,7 @@ export const HomeHeader = () => { )} { const { t } = useTranslation(); const { spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); const { isSmallMobile } = useResponsiveStore(); @@ -97,17 +96,17 @@ export const HomeSection = ({ > - + {availableSoon && ( @@ -200,14 +199,14 @@ const SectionTag = ({ availableSoon?: boolean; }) => { const { colorsTokens, spacingsTokens } = useCunninghamTheme(); - const spacings = spacingsTokens(); - const colors = colorsTokens(); return ( { const pathname = usePathname(); const { togglePanel } = useLeftPanelStore(); const { colorsTokens, spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); - const colors = colorsTokens(); const searchParams = useSearchParams(); const target = @@ -52,7 +50,7 @@ export const LeftPanelTargetFilters = () => { {defaultQueries.map((query) => { @@ -67,17 +65,17 @@ export const LeftPanelTargetFilters = () => { aria-selected={isActive} $align="center" $justify="flex-start" - $gap={spacing['xs']} - $radius={spacing['3xs']} + $gap={spacingsTokens['xs']} + $radius={spacingsTokens['3xs']} $padding={{ all: '2xs' }} $css={css` cursor: pointer; background-color: ${isActive - ? colors['greyscale-100'] + ? colorsTokens['greyscale-100'] : undefined}; font-weight: ${isActive ? 700 : undefined}; &:hover { - background-color: ${colors['greyscale-100']}; + background-color: ${colorsTokens['greyscale-100']}; } `} > diff --git a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx index 9c613509..f877e84e 100644 --- a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx +++ b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx @@ -23,12 +23,10 @@ const MobileLeftPanelStyle = createGlobalStyle` export const LeftPanel = () => { const { isDesktop } = useResponsiveStore(); - const theme = useCunninghamTheme(); + const { colorsTokens, spacingsTokens } = useCunninghamTheme(); const { togglePanel, isPanelOpen } = useLeftPanelStore(); const pathname = usePathname(); - const colors = theme.colorsTokens(); - const spacings = theme.spacingsTokens(); useEffect(() => { togglePanel(false); @@ -44,7 +42,7 @@ export const LeftPanel = () => { width: 300px; min-width: 300px; overflow: hidden; - border-right: 1px solid ${colors['greyscale-200']}; + border-right: 1px solid ${colorsTokens['greyscale-200']}; `} className="--docs--left-panel-desktop" > @@ -81,13 +79,17 @@ export const LeftPanel = () => { width: 100%; justify-content: center; align-items: center; - gap: ${spacings['base']}; + gap: ${spacingsTokens['base']}; `} > - + diff --git a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelDocContent.tsx b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelDocContent.tsx index dc0b2acc..50573578 100644 --- a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelDocContent.tsx +++ b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelDocContent.tsx @@ -8,7 +8,6 @@ import { SimpleDocItem } from '@/docs/docs-grid'; export const LeftPanelDocContent = () => { const { currentDoc } = useDocStore(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); if (!currentDoc) { return null; } @@ -24,7 +23,7 @@ export const LeftPanelDocContent = () => { { const shareModal = useModal(); const { spacingsTokens } = useCunninghamTheme(); const { isDesktop } = useResponsiveStore(); - const spacing = spacingsTokens(); + return ( { const { t } = useTranslation(); const { spacingsTokens } = useCunninghamTheme(); - const spacing = spacingsTokens(); const docs = useInfiniteDocs({ page: 1, @@ -29,7 +28,7 @@ export const LeftPanelFavorites = () => { diff --git a/src/frontend/apps/impress/src/layouts/MainLayout.tsx b/src/frontend/apps/impress/src/layouts/MainLayout.tsx index ca185459..c5dde3bd 100644 --- a/src/frontend/apps/impress/src/layouts/MainLayout.tsx +++ b/src/frontend/apps/impress/src/layouts/MainLayout.tsx @@ -19,7 +19,6 @@ export function MainLayout({ }: PropsWithChildren) { const { isDesktop } = useResponsiveStore(); const { colorsTokens } = useCunninghamTheme(); - const colors = colorsTokens(); const currentBackgroundColor = !isDesktop ? 'white' : backgroundColor; return ( @@ -43,8 +42,8 @@ export function MainLayout({ }} $background={ currentBackgroundColor === 'white' - ? colors['greyscale-000'] - : colors['greyscale-050'] + ? colorsTokens['greyscale-000'] + : colorsTokens['greyscale-050'] } $css={css` overflow-y: auto; diff --git a/src/frontend/apps/impress/src/pages/accessibility/index.tsx b/src/frontend/apps/impress/src/pages/accessibility/index.tsx index d89f2ee1..cec42d66 100644 --- a/src/frontend/apps/impress/src/pages/accessibility/index.tsx +++ b/src/frontend/apps/impress/src/pages/accessibility/index.tsx @@ -14,7 +14,7 @@ const Page: NextPageWithLayout = () => { diff --git a/src/frontend/apps/impress/src/pages/legal-notice/index.tsx b/src/frontend/apps/impress/src/pages/legal-notice/index.tsx index 0abbf939..ed762ccf 100644 --- a/src/frontend/apps/impress/src/pages/legal-notice/index.tsx +++ b/src/frontend/apps/impress/src/pages/legal-notice/index.tsx @@ -14,7 +14,7 @@ const Page: NextPageWithLayout = () => { diff --git a/src/frontend/apps/impress/src/pages/personal-data-cookies/index.tsx b/src/frontend/apps/impress/src/pages/personal-data-cookies/index.tsx index 1a064006..6e4800c6 100644 --- a/src/frontend/apps/impress/src/pages/personal-data-cookies/index.tsx +++ b/src/frontend/apps/impress/src/pages/personal-data-cookies/index.tsx @@ -14,7 +14,7 @@ const Page: NextPageWithLayout = () => {