-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Theme designer v9 #27861
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
Merged
Micah Godbolt (micahgodbolt)
merged 123 commits into
microsoft:master
from
ms-acalzaretto:theme-designer-v9
May 22, 2023
Merged
Theme designer v9 #27861
Changes from 110 commits
Commits
Show all changes
123 commits
Select commit
Hold shift + click to select a range
d6d0b9c
Test of pipeline.
timbellay 61e1c25
Merge branch 'master' of https://github.com/ms-acalzaretto/fluentui i…
timbellay 5d4f307
Fix unessesary debounce complications.
timbellay b06ffdd
rem logs.
timbellay 11ac5cd
Expand copy hex to full color div.
timbellay d6a994d
First batch of refactoring the state-store
ms-acalzaretto 9adce5b
Clean up left nav.
timbellay 7f49a1d
More refactoring
ms-acalzaretto ecbfbf8
merge to dev
timbellay 7f1051d
Dark theme fixes
ms-acalzaretto fb8b35f
Merge branch 'state-store-refactor' of https://github.com/ms-acalzare…
ms-acalzaretto 718a6be
More polishing
ms-acalzaretto ec14413
Fix export link and themeName.
timbellay 54458b0
Merge branch 'state-store-refactor' of https://github.com/ms-acalzare…
timbellay eea0122
Contet fixes
ms-acalzaretto 040f297
Merge branch 'state-store-refactor' into theme-designer-v9
ms-acalzaretto b976cb0
Merge branch 'master' into theme-designer-v9
ms-acalzaretto 3f5cc80
Bug fixes
ms-acalzaretto ec84eeb
Move export to Form and make a Panel.
timbellay 8c17fd0
Lint exceptions.
timbellay b50f9b0
Removed most of header
ms-acalzaretto 24a083b
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto b83a20e
Added debounce for keycolor
ms-acalzaretto 76ab673
Added key color banner
ms-acalzaretto 7af1f44
Fixed linting issues
ms-acalzaretto 933fec5
Fix build.
timbellay ff0ad5d
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay 15a7df9
Added title & description
ms-acalzaretto 8040e65
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 8b27385
Cleaned up nav for input
ms-acalzaretto ef33fec
Updated keycolor name
ms-acalzaretto 502760f
Changed hard-coded spacing to token
ms-acalzaretto cc59a17
Export panel
timbellay 84cb546
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay 55de683
Export panel styling.
timbellay 92b1182
Fixed padding issues
ms-acalzaretto 74178f4
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto e6b585d
Fix build
timbellay a166c1a
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay d90ccd1
Added key color text
ms-acalzaretto b7207b6
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 8d8d647
Fix more nav styling.
timbellay 9f58fb9
Exclude exportPanel from custom theme.
timbellay 399fb10
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 3cbd2a9
Handle empty theme name and use dark theme only for label of switch
timbellay d1d9dc7
Update stickersheet.
timbellay 916d1ba
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 3805a9b
Test objects.
timbellay 4fcf7bf
Merged
ms-acalzaretto 69dd794
Fixed contrast issue bug
ms-acalzaretto 383714c
Resolved state bug with changing theme mode
ms-acalzaretto 3f04912
Fix showing keycolor hex in content.
timbellay 7c3c0dc
Move switch for dark mode and clean up luminosity test labels.
timbellay 068bfe8
Added padding on blur for keycolor change
ms-acalzaretto 8bb1fd5
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 44d5bd5
Added contrast ratio for failed test
ms-acalzaretto eda43ff
Made calculate offset more readable
ms-acalzaretto f07302c
Fixed hue torision bug
ms-acalzaretto 9ff4b75
int fixes
ms-acalzaretto 065c499
Re-added lint rule
ms-acalzaretto c39a8d3
Added luminosity in sidebar
ms-acalzaretto d42e724
Fix showing multiple tests per test for luminosity checks.
timbellay 6db6740
Added basic table WiP
ms-acalzaretto cf8008d
Resolved JSON and removed extra unused tabs
ms-acalzaretto 0c1a659
Unset justify content
ms-acalzaretto f2685e1
Work table cell style and widths pt. 1
timbellay 258c5ab
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay c9864ee
Clean up tables.
timbellay f8d7cfc
Fixed export to sandbox
ms-acalzaretto aa27d01
some table styling
timbellay 1ef1942
Merge branches 'theme-designer-v9' and 'theme-designer-v9' of https:/…
timbellay ba46f93
Added modifications to panel
ms-acalzaretto 1a5ceea
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto 9c29525
Fixed tests showing multiple times
ms-acalzaretto aef16e5
Removed comments
ms-acalzaretto 74d50cb
Added MFST logo
ms-acalzaretto fc05a94
Fixed duplicate contrast/luminosity bug
ms-acalzaretto 15abf84
Styling fixes
ms-acalzaretto 0347b84
Fix logo spacing
timbellay 8b1d25e
Differentiate error vs warning for contrast and luminostiy
ms-acalzaretto fb6f048
More polishing
ms-acalzaretto 8796a46
More polishing
ms-acalzaretto ead6aea
Added more spacing in the table
ms-acalzaretto f402cb8
More polishing
ms-acalzaretto 0439ba5
Refactored code to remove duplicates
ms-acalzaretto 5a8d297
Fixed lint issues
ms-acalzaretto bfa9a6c
Fixed theme designer layout
ms-acalzaretto 30d9303
Removed luminosity
ms-acalzaretto 8fb3c49
Fixed thorttle issues
ms-acalzaretto 46de166
Merge branch 'master' into theme-designer-v9
ms-acalzaretto 96f020c
Use perceived lum as midpoint for points to pick off curve.
timbellay 6e34c26
Fix interpolation.
timbellay 23471bb
Fix for linter.
timbellay dca855c
calculate first and third snapping point based on that desired for red.
timbellay 5276144
Better snapping points.
timbellay f70809d
Fix for build errors.
timbellay ec4ea09
Tuned snapping points.
timbellay 7dd7c87
Fixes for Build.
timbellay ca288c8
Cleanup some curve vals and feedback button.
timbellay 16c6639
Fix for linter.
timbellay a9f5c45
Fix for inconsistent lint.
timbellay 9df8d46
Set correct brand values for dark mode and cleanup.
timbellay 0f67288
Merge branch 'master' into theme-designer-v9
timbellay bf95862
Wrap createDarkTheme to pull correct values since master util is not …
timbellay 2f74381
linter fix.
timbellay 678a36d
lint fixes.
timbellay 2fe98d5
Fix export link inter error.
timbellay eb29542
Fix export to handle darkmode map.
timbellay 364d718
Merge branch 'master' into theme-designer-v9
timbellay 9c623a5
Merge branch 'master' into theme-designer-v9
micahgodbolt 291519b
Review fixes.
timbellay ac67d42
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay a351fe0
Merge branch 'master' into theme-designer-v9
timbellay 9f0b91a
Review fixes.
timbellay 8de9903
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay bb42801
Merge branch 'master' into theme-designer-v9
timbellay d158f6c
Fix unsed.
timbellay e1c11c3
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay 184900b
Fix for build.
timbellay 8d09aa3
Merge branch 'master' into theme-designer-v9
timbellay 710a650
Merge branch 'master' into theme-designer-v9
timbellay dcc5b22
Merge branch 'master' into theme-designer-v9
micahgodbolt aaff821
Merge branch 'master' into theme-designer-v9
timbellay 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
196 changes: 196 additions & 0 deletions
196
packages/react-components/theme-designer/src/Context/ThemeDesignerContext.tsx
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,196 @@ | ||
| import * as React from 'react'; | ||
| import type { BrandVariants, Theme } from '@fluentui/react-components'; | ||
| import { createLightTheme } from '@fluentui/react-components'; | ||
| import { brandWeb } from '../utils/brandColors'; | ||
| import { getBrandTokensFromPalette } from '../utils/getBrandTokensFromPalette'; | ||
| import { getOverridableTokenBrandColors } from '../utils/getOverridableTokenBrandColors'; | ||
| import { Brands } from '@fluentui/react-theme'; | ||
| import { createDarkThemeWithUpdatedMapping } from '../utils/getOverridableTokenBrandColors'; | ||
|
|
||
| export type ColorOverrideBrands = Record<string, Brands>; | ||
|
|
||
| export type ColorOverridePayload = { | ||
| colorToken: string; | ||
| newColor: string; | ||
| brand: number; | ||
| }; | ||
|
|
||
| export type CustomAttributes = { | ||
| keyColor: string; | ||
| hueTorsion: number; | ||
| vibrancy: number; | ||
| }; | ||
|
|
||
| interface ThemeDesignerContextProps { | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| type Action = | ||
| | { type: 'isDark'; payload: boolean } | ||
| | { type: 'override'; payload: Partial<Theme> } | ||
| | { type: 'reset' } | ||
| | { type: 'updateThemeWithCustomerAttributes'; payload: CustomAttributes } | ||
| | { type: 'addOverride'; payload: ColorOverridePayload } | ||
| | { type: 'themeName'; payload: string } | ||
| | { type: 'showExportPanel'; payload: boolean }; | ||
|
|
||
| type Dispatch = (action: Action) => void; | ||
|
|
||
| export type ThemeDesignerState = { | ||
| themeName: string; | ||
| keyColorHex: string; | ||
| brand: BrandVariants; | ||
| theme: Theme; | ||
| themeWithOverrides: Theme; | ||
| isDark: boolean; | ||
| lightThemeOverrides: Partial<Theme>; | ||
| darkThemeOverrides: Partial<Theme>; | ||
| lightBrandOverrides: ColorOverrideBrands; | ||
| darkBrandOverrides: ColorOverrideBrands; | ||
| showExportPanel: boolean; | ||
| }; | ||
|
|
||
| export const defaultThemePlaceholderName = 'myNewTheme'; | ||
|
|
||
| export const initialThemeDesignerState: ThemeDesignerState = { | ||
| themeName: defaultThemePlaceholderName, | ||
| keyColorHex: '#0F6CBD', | ||
| brand: brandWeb, | ||
| theme: createLightTheme(brandWeb), | ||
| themeWithOverrides: createLightTheme(brandWeb), | ||
| isDark: false, | ||
| lightThemeOverrides: {}, | ||
| darkThemeOverrides: {}, | ||
| lightBrandOverrides: getOverridableTokenBrandColors(createLightTheme(brandWeb), brandWeb), | ||
| darkBrandOverrides: getOverridableTokenBrandColors(createDarkThemeWithUpdatedMapping(brandWeb), brandWeb), | ||
| showExportPanel: false, | ||
| }; | ||
|
|
||
| export const ThemeDesignerContext = React.createContext<{ state: ThemeDesignerState; dispatch: Dispatch } | undefined>( | ||
| undefined, | ||
| ); | ||
|
|
||
| const createCustomTheme = ({ hueTorsion, keyColor, vibrancy }: CustomAttributes): BrandVariants => { | ||
| return getBrandTokensFromPalette(keyColor, { | ||
| hueTorsion, | ||
| darkCp: vibrancy, | ||
| lightCp: vibrancy, | ||
| }); | ||
| }; | ||
|
|
||
| export const ThemeDesignerReducer = (state: ThemeDesignerState, action: Action): ThemeDesignerState => { | ||
| switch (action.type) { | ||
| case 'isDark': | ||
| const theme = action.payload ? createDarkThemeWithUpdatedMapping(state.brand) : createLightTheme(state.brand); | ||
|
|
||
| return { | ||
| ...state, | ||
| theme, | ||
| isDark: action.payload, | ||
| themeWithOverrides: { | ||
| ...theme, | ||
| ...(action.payload ? state.darkThemeOverrides : state.lightThemeOverrides), | ||
| }, | ||
| }; | ||
| case 'reset': | ||
| const resetTheme = state.isDark ? createDarkThemeWithUpdatedMapping(state.brand) : createLightTheme(state.brand); | ||
| return { | ||
| ...state, | ||
| theme: resetTheme, | ||
| themeWithOverrides: resetTheme, | ||
| lightThemeOverrides: {}, | ||
| darkThemeOverrides: {}, | ||
| lightBrandOverrides: getOverridableTokenBrandColors( | ||
| createDarkThemeWithUpdatedMapping(state.brand), | ||
| state.brand, | ||
| ), | ||
| darkBrandOverrides: getOverridableTokenBrandColors(createDarkThemeWithUpdatedMapping(state.brand), state.brand), | ||
| }; | ||
| case 'updateThemeWithCustomerAttributes': | ||
| const newBrand = createCustomTheme(action.payload); | ||
| const newTheme = state.isDark ? createDarkThemeWithUpdatedMapping(newBrand) : createLightTheme(newBrand); | ||
| return { | ||
| ...state, | ||
| keyColorHex: action.payload.keyColor, | ||
| brand: newBrand, | ||
| theme: newTheme, | ||
| themeWithOverrides: newTheme, | ||
| lightThemeOverrides: {}, | ||
| darkThemeOverrides: {}, | ||
| // new overrides -- reset | ||
| lightBrandOverrides: getOverridableTokenBrandColors(createLightTheme(newBrand), newBrand), | ||
| darkBrandOverrides: getOverridableTokenBrandColors(createDarkThemeWithUpdatedMapping(newBrand), newBrand), | ||
| }; | ||
| case 'addOverride': | ||
| if (state.isDark) { | ||
| const overrides = { | ||
| ...state.darkThemeOverrides, | ||
| // This overrides a THEME token to a new color | ||
| [action.payload.colorToken]: action.payload.newColor, | ||
| }; | ||
| return { | ||
| ...state, | ||
| darkBrandOverrides: { | ||
| ...state.darkBrandOverrides, | ||
| // this is signifying for e.g. 'colorBrandBackground2' = 8 (which is the 8th sqaure in the color wheel) | ||
| [action.payload.colorToken]: action.payload.brand, | ||
| } as ColorOverrideBrands, | ||
| darkThemeOverrides: overrides, | ||
| themeWithOverrides: { | ||
| ...createDarkThemeWithUpdatedMapping(state.brand), | ||
| ...overrides, | ||
| }, | ||
| }; | ||
| } else { | ||
| const overrides = { | ||
| ...state.lightThemeOverrides, | ||
| // This overrides a THEME token to a new color | ||
| [action.payload.colorToken]: action.payload.newColor, | ||
| }; | ||
| return { | ||
| ...state, | ||
| lightBrandOverrides: { | ||
| ...state.lightBrandOverrides, | ||
| // this is signifying for e.g. 'colorBrandBackground2' = 8 (which is the 8th sqaure in the color wheel) | ||
| [action.payload.colorToken]: action.payload.brand, | ||
| } as ColorOverrideBrands, | ||
| lightThemeOverrides: overrides, | ||
| themeWithOverrides: { | ||
| ...createLightTheme(state.brand), | ||
| ...overrides, | ||
| }, | ||
| }; | ||
| } | ||
| case 'themeName': | ||
| return { | ||
| ...state, | ||
| themeName: action.payload, | ||
| }; | ||
| case 'showExportPanel': | ||
| return { | ||
| ...state, | ||
| showExportPanel: action.payload, | ||
| }; | ||
|
|
||
| default: | ||
| return { | ||
| ...state, | ||
| }; | ||
| } | ||
| }; | ||
|
|
||
| export const useThemeDesigner = () => { | ||
| const context = React.useContext(ThemeDesignerContext); | ||
| if (context === undefined) { | ||
| throw new Error('useWizard must be used within a WizardProvider'); | ||
| } | ||
| return context; | ||
| }; | ||
|
|
||
| export const ThemeDesignerContextProvider = ({ children }: ThemeDesignerContextProps) => { | ||
| const [state, dispatch] = React.useReducer(ThemeDesignerReducer, initialThemeDesignerState); | ||
|
|
||
| const value = { state, dispatch }; | ||
|
|
||
| return <ThemeDesignerContext.Provider value={value}>{children}</ThemeDesignerContext.Provider>; | ||
| }; | ||
27 changes: 26 additions & 1 deletion
27
packages/react-components/theme-designer/src/ThemeDesigner.stories.mdx
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,6 +1,31 @@ | ||
| import { ThemeDesigner } from './index'; | ||
| import { Meta } from '@storybook/addon-docs'; | ||
|
|
||
| <Meta title="ThemeDesigner" /> | ||
| <Meta | ||
| title="ThemeDesigner" | ||
| parameters={{ | ||
| showToolbar: false, | ||
| viewMode: 'canvas', | ||
| toolbar: { | ||
| hidden: true, | ||
| title: { hidden: true }, | ||
| zoom: { hidden: true }, | ||
| eject: { hidden: true }, | ||
| copy: { hidden: true }, | ||
| fullscreen: { hidden: true }, | ||
| 'storybook/fluentui-react-addon/strict-mode': { hidden: true }, | ||
| 'storybook/fluentui-react-addon/theme': { hidden: true }, | ||
| }, | ||
| backgrounds: { | ||
| disable: true, | ||
| grid: { | ||
| disable: true, | ||
| }, | ||
| outline: { | ||
| disable: true, | ||
| }, | ||
| }, | ||
| }} | ||
| /> | ||
|
|
||
| <ThemeDesigner /> |
41 changes: 7 additions & 34 deletions
41
packages/react-components/theme-designer/src/ThemeDesigner.tsx
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,53 +1,26 @@ | ||
| import * as React from 'react'; | ||
| import type { ThemeDesignerProps } from './ThemeDesigner.types'; | ||
| import { useStaticStyles, useStyles } from './ThemeDesigner.styles'; | ||
| import { AppState, DispatchTheme, initialAppState, useThemeDesignerReducer } from './useThemeDesignerReducer'; | ||
| import { useStyles } from './ThemeDesigner.styles'; | ||
| import { ThemeDesignerContextProvider } from './Context/ThemeDesignerContext'; | ||
| import { FluentProvider, webLightTheme } from '@fluentui/react-components'; | ||
| import { createContext } from '@fluentui/react-context-selector'; | ||
| import { Nav } from './components/Nav/Nav'; | ||
| import { Header } from './components/Header/Header'; | ||
| import { Sidebar } from './components/Sidebar/Sidebar'; | ||
| import { Content } from './components/Content/Content'; | ||
|
|
||
| export type AppContextValue = { | ||
| appState: AppState; | ||
| dispatchAppState: React.Dispatch<DispatchTheme>; | ||
| name: string; | ||
| setName: React.Dispatch<React.SetStateAction<string>>; | ||
| }; | ||
|
|
||
| // eslint-disable-next-line @fluentui/no-context-default-value | ||
| export const AppContext = createContext<AppContextValue>({ | ||
| appState: initialAppState, | ||
| dispatchAppState: () => null, | ||
| name: 'Untitled', | ||
| setName: () => null, | ||
| }); | ||
|
|
||
| /** | ||
| * ThemeDesigner component - TODO: add more docs | ||
|
timbellay marked this conversation as resolved.
Outdated
|
||
| */ | ||
| export const ThemeDesigner: React.FC<ThemeDesignerProps> = props => { | ||
| const styles = useStyles(); | ||
| useStaticStyles(); | ||
|
|
||
| const [appState, dispatchAppState] = useThemeDesignerReducer(); | ||
| const [name, setName] = React.useState<string>('myTheme'); | ||
|
|
||
| const { darkOverrides, isDark, lightOverrides, theme } = appState; | ||
| const overrides = isDark ? darkOverrides : lightOverrides; | ||
| const overridenTheme = { ...theme, ...overrides }; | ||
|
|
||
| return ( | ||
| <FluentProvider theme={webLightTheme}> | ||
| <AppContext.Provider value={{ appState, dispatchAppState, name, setName }}> | ||
| <ThemeDesignerContextProvider> | ||
| <div className={styles.root}> | ||
| <Nav className={styles.nav} /> | ||
| <Header className={styles.nav} /> | ||
| <Sidebar className={styles.sidebar} /> | ||
| <FluentProvider theme={overridenTheme}> | ||
| <Content className={styles.content} /> | ||
| </FluentProvider> | ||
| <Content className={styles.content} /> | ||
| </div> | ||
| </AppContext.Provider> | ||
| </ThemeDesignerContextProvider> | ||
| </FluentProvider> | ||
| ); | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.