Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
d6d0b9c
Test of pipeline.
timbellay Mar 21, 2023
61e1c25
Merge branch 'master' of https://github.com/ms-acalzaretto/fluentui i…
timbellay Mar 22, 2023
5d4f307
Fix unessesary debounce complications.
timbellay Mar 22, 2023
b06ffdd
rem logs.
timbellay Mar 22, 2023
11ac5cd
Expand copy hex to full color div.
timbellay Mar 22, 2023
d6a994d
First batch of refactoring the state-store
ms-acalzaretto Mar 24, 2023
9adce5b
Clean up left nav.
timbellay Mar 24, 2023
7f49a1d
More refactoring
ms-acalzaretto Mar 24, 2023
ecbfbf8
merge to dev
timbellay Mar 24, 2023
7f1051d
Dark theme fixes
ms-acalzaretto Mar 24, 2023
fb8b35f
Merge branch 'state-store-refactor' of https://github.com/ms-acalzare…
ms-acalzaretto Mar 24, 2023
718a6be
More polishing
ms-acalzaretto Mar 24, 2023
ec14413
Fix export link and themeName.
timbellay Mar 24, 2023
54458b0
Merge branch 'state-store-refactor' of https://github.com/ms-acalzare…
timbellay Mar 24, 2023
eea0122
Contet fixes
ms-acalzaretto Mar 27, 2023
040f297
Merge branch 'state-store-refactor' into theme-designer-v9
ms-acalzaretto Mar 27, 2023
b976cb0
Merge branch 'master' into theme-designer-v9
ms-acalzaretto Mar 27, 2023
3f5cc80
Bug fixes
ms-acalzaretto Mar 27, 2023
ec84eeb
Move export to Form and make a Panel.
timbellay Mar 27, 2023
8c17fd0
Lint exceptions.
timbellay Mar 27, 2023
b50f9b0
Removed most of header
ms-acalzaretto Mar 27, 2023
24a083b
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 27, 2023
b83a20e
Added debounce for keycolor
ms-acalzaretto Mar 27, 2023
76ab673
Added key color banner
ms-acalzaretto Mar 27, 2023
7af1f44
Fixed linting issues
ms-acalzaretto Mar 27, 2023
933fec5
Fix build.
timbellay Mar 27, 2023
ff0ad5d
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay Mar 27, 2023
15a7df9
Added title & description
ms-acalzaretto Mar 28, 2023
8040e65
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 28, 2023
8b27385
Cleaned up nav for input
ms-acalzaretto Mar 28, 2023
ef33fec
Updated keycolor name
ms-acalzaretto Mar 28, 2023
502760f
Changed hard-coded spacing to token
ms-acalzaretto Mar 28, 2023
cc59a17
Export panel
timbellay Mar 28, 2023
84cb546
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay Mar 28, 2023
55de683
Export panel styling.
timbellay Mar 28, 2023
92b1182
Fixed padding issues
ms-acalzaretto Mar 28, 2023
74178f4
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 28, 2023
e6b585d
Fix build
timbellay Mar 28, 2023
a166c1a
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay Mar 28, 2023
d90ccd1
Added key color text
ms-acalzaretto Mar 28, 2023
b7207b6
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 28, 2023
8d8d647
Fix more nav styling.
timbellay Mar 28, 2023
9f58fb9
Exclude exportPanel from custom theme.
timbellay Mar 28, 2023
399fb10
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 28, 2023
3cbd2a9
Handle empty theme name and use dark theme only for label of switch
timbellay Mar 29, 2023
d1d9dc7
Update stickersheet.
timbellay Mar 30, 2023
916d1ba
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Mar 31, 2023
3805a9b
Test objects.
timbellay Mar 31, 2023
4fcf7bf
Merged
ms-acalzaretto Mar 31, 2023
69dd794
Fixed contrast issue bug
ms-acalzaretto Mar 31, 2023
383714c
Resolved state bug with changing theme mode
ms-acalzaretto Mar 31, 2023
3f04912
Fix showing keycolor hex in content.
timbellay Apr 3, 2023
7c3c0dc
Move switch for dark mode and clean up luminosity test labels.
timbellay Apr 3, 2023
068bfe8
Added padding on blur for keycolor change
ms-acalzaretto Apr 3, 2023
8bb1fd5
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Apr 3, 2023
44d5bd5
Added contrast ratio for failed test
ms-acalzaretto Apr 3, 2023
eda43ff
Made calculate offset more readable
ms-acalzaretto Apr 3, 2023
f07302c
Fixed hue torision bug
ms-acalzaretto Apr 3, 2023
9ff4b75
int fixes
ms-acalzaretto Apr 3, 2023
065c499
Re-added lint rule
ms-acalzaretto Apr 3, 2023
c39a8d3
Added luminosity in sidebar
ms-acalzaretto Apr 3, 2023
d42e724
Fix showing multiple tests per test for luminosity checks.
timbellay Apr 3, 2023
6db6740
Added basic table WiP
ms-acalzaretto Apr 4, 2023
cf8008d
Resolved JSON and removed extra unused tabs
ms-acalzaretto Apr 4, 2023
0c1a659
Unset justify content
ms-acalzaretto Apr 4, 2023
f2685e1
Work table cell style and widths pt. 1
timbellay Apr 4, 2023
258c5ab
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay Apr 4, 2023
c9864ee
Clean up tables.
timbellay Apr 4, 2023
f8d7cfc
Fixed export to sandbox
ms-acalzaretto Apr 5, 2023
aa27d01
some table styling
timbellay Apr 5, 2023
1ef1942
Merge branches 'theme-designer-v9' and 'theme-designer-v9' of https:/…
timbellay Apr 5, 2023
ba46f93
Added modifications to panel
ms-acalzaretto Apr 5, 2023
1a5ceea
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
ms-acalzaretto Apr 5, 2023
9c29525
Fixed tests showing multiple times
ms-acalzaretto Apr 5, 2023
aef16e5
Removed comments
ms-acalzaretto Apr 5, 2023
74d50cb
Added MFST logo
ms-acalzaretto Apr 5, 2023
fc05a94
Fixed duplicate contrast/luminosity bug
ms-acalzaretto Apr 5, 2023
15abf84
Styling fixes
ms-acalzaretto Apr 5, 2023
0347b84
Fix logo spacing
timbellay Apr 5, 2023
8b1d25e
Differentiate error vs warning for contrast and luminostiy
ms-acalzaretto Apr 6, 2023
fb6f048
More polishing
ms-acalzaretto Apr 6, 2023
8796a46
More polishing
ms-acalzaretto Apr 6, 2023
ead6aea
Added more spacing in the table
ms-acalzaretto Apr 6, 2023
f402cb8
More polishing
ms-acalzaretto Apr 6, 2023
0439ba5
Refactored code to remove duplicates
ms-acalzaretto Apr 6, 2023
5a8d297
Fixed lint issues
ms-acalzaretto Apr 6, 2023
bfa9a6c
Fixed theme designer layout
ms-acalzaretto Apr 6, 2023
30d9303
Removed luminosity
ms-acalzaretto Apr 12, 2023
8fb3c49
Fixed thorttle issues
ms-acalzaretto Apr 12, 2023
46de166
Merge branch 'master' into theme-designer-v9
ms-acalzaretto Apr 12, 2023
96f020c
Use perceived lum as midpoint for points to pick off curve.
timbellay Apr 20, 2023
6e34c26
Fix interpolation.
timbellay Apr 20, 2023
23471bb
Fix for linter.
timbellay Apr 20, 2023
dca855c
calculate first and third snapping point based on that desired for red.
timbellay Apr 20, 2023
5276144
Better snapping points.
timbellay Apr 26, 2023
f70809d
Fix for build errors.
timbellay Apr 26, 2023
ec4ea09
Tuned snapping points.
timbellay Apr 28, 2023
7dd7c87
Fixes for Build.
timbellay May 3, 2023
ca288c8
Cleanup some curve vals and feedback button.
timbellay May 5, 2023
16c6639
Fix for linter.
timbellay May 5, 2023
a9f5c45
Fix for inconsistent lint.
timbellay May 5, 2023
9df8d46
Set correct brand values for dark mode and cleanup.
timbellay May 8, 2023
0f67288
Merge branch 'master' into theme-designer-v9
timbellay May 8, 2023
bf95862
Wrap createDarkTheme to pull correct values since master util is not …
timbellay May 8, 2023
2f74381
linter fix.
timbellay May 8, 2023
678a36d
lint fixes.
timbellay May 8, 2023
2fe98d5
Fix export link inter error.
timbellay May 8, 2023
eb29542
Fix export to handle darkmode map.
timbellay May 8, 2023
364d718
Merge branch 'master' into theme-designer-v9
timbellay May 16, 2023
9c623a5
Merge branch 'master' into theme-designer-v9
micahgodbolt May 16, 2023
291519b
Review fixes.
timbellay May 18, 2023
ac67d42
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay May 18, 2023
a351fe0
Merge branch 'master' into theme-designer-v9
timbellay May 18, 2023
9f0b91a
Review fixes.
timbellay May 19, 2023
8de9903
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay May 19, 2023
bb42801
Merge branch 'master' into theme-designer-v9
timbellay May 19, 2023
d158f6c
Fix unsed.
timbellay May 19, 2023
e1c11c3
Merge branch 'theme-designer-v9' of https://github.com/ms-acalzaretto…
timbellay May 19, 2023
184900b
Fix for build.
timbellay May 19, 2023
8d09aa3
Merge branch 'master' into theme-designer-v9
timbellay May 19, 2023
710a650
Merge branch 'master' into theme-designer-v9
timbellay May 22, 2023
dcc5b22
Merge branch 'master' into theme-designer-v9
micahgodbolt May 22, 2023
aaff821
Merge branch 'master' into theme-designer-v9
timbellay May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import * as React_2 from 'react';

// @public
// @public (undocumented)
export const ThemeDesigner: React_2.FC<ThemeDesignerProps>;

// (No @packageDocumentation comment for this package)
Expand Down
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('useThemeDesigner must be used within a ThemeProvider Context');
}
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>;
};
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 />
44 changes: 7 additions & 37 deletions packages/react-components/theme-designer/src/ThemeDesigner.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,23 @@
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
*/
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>
);
};
Loading