-
Notifications
You must be signed in to change notification settings - Fork 0
Theme #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
comfrt1k
wants to merge
23
commits into
master
Choose a base branch
from
feat/theme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Theme #3
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6444a5d
feat(ui-theme): light theme colors
comfrt1k 6e87965
feat(ui-theme): dark theme colors
comfrt1k 2fa8744
feat(ui-theme): ttf files
comfrt1k 7d61f5f
feat(ui-theme): next and theme generator deps
comfrt1k 83785b1
feat(ui-theme): font vars
comfrt1k 7507468
feat(ui-theme): sf pro display font
comfrt1k 8a9c0c3
feat(ui-theme): semantic typography
comfrt1k 6df0fcf
feat(ui-theme): effects tokens
comfrt1k 0cd400c
feat(ui-theme): layout tokens
comfrt1k 242610e
feat(ui-theme): typography tokens
comfrt1k 9d2e6f9
feat(frontend): entrypoint vanilla config
comfrt1k 9d37760
feat(ui-theme): theme constants
comfrt1k ddf4b4a
feat(ui-theme): reference types for font
comfrt1k ea4e29e
feat(ui-theme): theme store
comfrt1k f1430e4
feat(ui-theme): tokens
comfrt1k 32f1210
feat(ui-theme): global styles
comfrt1k c9c5705
feat(ui-theme): css themes
comfrt1k 5465ebf
Merge branch 'master' into feat/theme
comfrt1k 0da4364
feat(ui-theme): effector deps
comfrt1k 078cd09
feat(common): remove changelog files and format yarnrc
comfrt1k f427f1e
refactor(ui-theme): font usage
comfrt1k 3e37dfe
refactor(ui-theme): simplify model
comfrt1k 81caa55
fix(ui-theme): simplify global style
comfrt1k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use client' | ||
|
|
||
| import type { ReactNode } from 'react' | ||
|
|
||
| import { ThemeProvider } from '@frontend/ui-theme' | ||
|
|
||
| export const Providers = ({ children }: { children: ReactNode }) => ( | ||
| <ThemeProvider>{children}</ThemeProvider> | ||
| ) |
This file was deleted.
Oops, something went wrong.
Binary file added
BIN
+404 KB
frontend/ui/theme/assets/fonts/sf-pro-display/SF-Pro-Display-Regular.ttf
Binary file not shown.
Binary file added
BIN
+425 KB
frontend/ui/theme/assets/fonts/sf-pro-display/SF-Pro-Display-Semibold.ttf
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const fontsVars = { | ||
| sfProDisplay: '--font-sf-pro-display', | ||
| } as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export * from './font-vars.js' | ||
| export * from './theme.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export const ThemeEnum = { | ||
| LIGHT: 'light', | ||
| DARK: 'dark', | ||
| } as const | ||
|
|
||
| export type ThemeValue = (typeof ThemeEnum)[keyof typeof ThemeEnum] | ||
|
|
||
| export const DEFAULT_THEME = ThemeEnum.LIGHT | ||
|
|
||
| export const THEME_KEY = 'widget-theme' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /// <reference path="./next-font.d.ts" /> | ||
|
|
||
| export * from './sf-pro-display.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /// <reference types="next" /> | ||
|
|
||
| declare module 'next/font/local' { | ||
| import localFont from 'next/dist/compiled/@next/font/local' | ||
|
|
||
| export default localFont.default | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import localFont from 'next/font/local' | ||
|
|
||
| export const sfProDisplayFont = localFont({ | ||
| src: [ | ||
| { | ||
| path: '../../assets/fonts/sf-pro-display/SF-Pro-Display-Regular.ttf', | ||
| weight: '400', | ||
| style: 'normal', | ||
| }, | ||
| { | ||
| path: '../../assets/fonts/sf-pro-display/SF-Pro-Display-Semibold.ttf', | ||
| weight: '600', | ||
| style: 'normal', | ||
| }, | ||
| ], | ||
| display: 'swap', | ||
| variable: '--font-sf-pro-display', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не используется константа fontsVars |
||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './store/index.js' | ||
| export * from './theme.css.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './typography.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { fontSizes } from '../tokens/base/typography/font-sizes.js' | ||
| import { fontWeights } from '../tokens/base/typography/font-weights.js' | ||
| import { fonts } from '../tokens/base/typography/fonts.js' | ||
| import { lineHeights } from '../tokens/base/typography/line-heights.js' | ||
|
|
||
| export const typography = { | ||
| displayLarge: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.giant, | ||
| lineHeight: lineHeights.giant, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| displayMedium: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.massive, | ||
| lineHeight: lineHeights.massive, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| displaySmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.huge, | ||
| lineHeight: lineHeights.huge, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
|
|
||
| headingLarge: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xxxxl, | ||
| lineHeight: lineHeights.xxxxl, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| headingMedium: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xxxl, | ||
| lineHeight: lineHeights.xxxl, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| headingSmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xxl, | ||
| lineHeight: lineHeights.xxl, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
|
|
||
| subheadingLarge: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xl, | ||
| lineHeight: lineHeights.xl, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| subheadingMedium: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.lg, | ||
| lineHeight: lineHeights.lg, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
| subheadingSmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.md, | ||
| lineHeight: lineHeights.md, | ||
| fontWeight: fontWeights.semibold, | ||
| }, | ||
|
|
||
| bodyLarge: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xl, | ||
| lineHeight: lineHeights.xl, | ||
| fontWeight: fontWeights.regular, | ||
| }, | ||
| bodyMedium: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.lg, | ||
| lineHeight: lineHeights.lg, | ||
| fontWeight: fontWeights.regular, | ||
| }, | ||
| bodySmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.md, | ||
| lineHeight: lineHeights.md, | ||
| fontWeight: fontWeights.regular, | ||
| }, | ||
|
|
||
| captionSmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.sm, | ||
| lineHeight: lineHeights.sm, | ||
| fontWeight: fontWeights.regular, | ||
| }, | ||
|
|
||
| labelSmall: { | ||
| fontFamily: fonts.primary, | ||
| fontSize: fontSizes.xs, | ||
| lineHeight: lineHeights.xs, | ||
| fontWeight: fontWeights.regular, | ||
| }, | ||
| } as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './provider.js' | ||
| export * from './model.js' | ||
| export type * from './interfaces.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import type { PropsWithChildren } from 'react' | ||
|
|
||
| import type { ThemeValue } from '../constants/index.js' | ||
|
|
||
| export type ApplyTheme = (theme: string) => void | ||
|
|
||
| export interface ThemeProviderProps extends PropsWithChildren { | ||
| forcedTheme?: ThemeValue | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type { ThemeValue } from '../constants/index.js' | ||
| import type { ApplyTheme } from './interfaces.js' | ||
|
|
||
| import { createEvent } from 'effector' | ||
| import { createStore } from 'effector' | ||
|
|
||
| import { DEFAULT_THEME } from '../constants/index.js' | ||
|
|
||
| export const changeTheme = createEvent<ThemeValue>() | ||
| export const changeApplyTheme = createEvent<ApplyTheme>() | ||
|
|
||
| export const $theme = createStore<ThemeValue>(DEFAULT_THEME) | ||
| export const $applyTheme = createStore<ApplyTheme>(() => undefined) | ||
|
|
||
| $theme.on(changeTheme, (state, theme) => theme) | ||
|
|
||
| $applyTheme.on(changeTheme, (apply, theme) => { | ||
| apply(theme) | ||
| return apply | ||
| }) | ||
| $applyTheme.on(changeApplyTheme, (state, apply) => apply) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use client' | ||
|
|
||
| import type { ThemeProviderProps } from './interfaces.js' | ||
|
|
||
| import { ThemeProvider as NextThemeProvider } from 'next-themes' | ||
|
|
||
| import { ThemeEnum } from '../constants/index.js' | ||
| import { THEME_KEY } from '../constants/index.js' | ||
| import { UseTheme } from './use-theme.js' | ||
| import { darkTheme } from '../theme.css.js' | ||
| import { lightTheme } from '../theme.css.js' | ||
|
|
||
| export const ThemeProvider = ({ children, forcedTheme }: ThemeProviderProps) => ( | ||
| <NextThemeProvider | ||
| attribute='class' | ||
| storageKey={THEME_KEY} | ||
| defaultTheme={ThemeEnum.LIGHT} | ||
| forcedTheme={forcedTheme} | ||
| themes={Object.values(ThemeEnum)} | ||
| value={{ | ||
| [ThemeEnum.LIGHT]: lightTheme, | ||
| [ThemeEnum.DARK]: darkTheme, | ||
| }} | ||
| > | ||
| <UseTheme forcedTheme={forcedTheme} /> | ||
| {children} | ||
| </NextThemeProvider> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 'use client' | ||
|
|
||
| import type { ThemeProviderProps } from './interfaces.js' | ||
|
|
||
| import { useUnit } from 'effector-react' | ||
| import { useTheme } from 'next-themes' | ||
| import { useEffect } from 'react' | ||
|
|
||
| import { $theme } from './model.js' | ||
| import { isThemeEnum } from '../utils/index.js' | ||
| import { changeTheme } from './model.js' | ||
| import { changeApplyTheme } from './model.js' | ||
|
|
||
| export const UseTheme = ({ forcedTheme }: ThemeProviderProps): null => { | ||
| const { resolvedTheme, setTheme } = useTheme() | ||
| const [activeTheme, setActiveTheme, setApplyTheme] = useUnit([ | ||
| $theme, | ||
| changeTheme, | ||
| changeApplyTheme, | ||
| ]) | ||
|
|
||
| useEffect(() => { | ||
| setApplyTheme(setTheme) | ||
| }, [setApplyTheme, setTheme]) | ||
|
|
||
| useEffect(() => { | ||
| if (forcedTheme && isThemeEnum(forcedTheme)) { | ||
| if (forcedTheme !== activeTheme) setActiveTheme(forcedTheme) | ||
| return | ||
| } | ||
|
|
||
| if (resolvedTheme && isThemeEnum(resolvedTheme) && resolvedTheme !== activeTheme) { | ||
| setActiveTheme(resolvedTheme) | ||
| } | ||
| }, [forcedTheme, resolvedTheme, activeTheme, setActiveTheme]) | ||
|
|
||
| return null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { globalStyle } from '@vanilla-extract/css' | ||
|
|
||
| globalStyle('html', { | ||
| margin: 0, | ||
| padding: 0, | ||
| WebkitFontSmoothing: 'antialiased', | ||
| WebkitOverflowScrolling: 'touch', | ||
| height: '100%', | ||
| }) | ||
|
|
||
| globalStyle('body', { | ||
| margin: 0, | ||
| padding: 0, | ||
| minHeight: '100%', | ||
| overflowX: 'hidden', | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавь сразу
suppressHydrationWarning, чтобы не было warnings из за next-themes