Skip to content
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

Added global design tokens - spacing, duration, curves #22607

Merged
merged 6 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Exported new theme types",
"packageName": "@fluentui/react-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Added global theme types and tokens",
"packageName": "@fluentui/react-theme",
"email": "[email protected]",
"dependentChangeType": "patch"
}
15 changes: 15 additions & 0 deletions packages/react-components/etc/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { createDOMRenderer } from '@griffel/react';
import { createHighContrastTheme } from '@fluentui/react-theme';
import { createLightTheme } from '@fluentui/react-theme';
import { createTeamsDarkTheme } from '@fluentui/react-theme';
import { CurveTokens } from '@fluentui/react-theme';
import { Display } from '@fluentui/react-text';
import { displayClassName } from '@fluentui/react-text';
import { displayClassNames } from '@fluentui/react-text';
Expand All @@ -102,6 +103,7 @@ import { dividerClassNames } from '@fluentui/react-divider';
import { DividerProps } from '@fluentui/react-divider';
import { DividerSlots } from '@fluentui/react-divider';
import { DividerState } from '@fluentui/react-divider';
import { DurationTokens } from '@fluentui/react-theme';
import { elementContains } from '@fluentui/react-portal';
import { FluentProvider } from '@fluentui/react-provider';
import { fluentProviderClassName } from '@fluentui/react-provider';
Expand All @@ -121,6 +123,7 @@ import { getSlots } from '@fluentui/react-utilities';
import { Headline } from '@fluentui/react-text';
import { headlineClassName } from '@fluentui/react-text';
import { headlineClassNames } from '@fluentui/react-text';
import { HorizontalSpacingTokens } from '@fluentui/react-theme';
import { Image as Image_2 } from '@fluentui/react-image';
import { imageClassName } from '@fluentui/react-image';
import { imageClassNames } from '@fluentui/react-image';
Expand Down Expand Up @@ -305,6 +308,7 @@ import { SliderState } from '@fluentui/react-slider';
import { Slot } from '@fluentui/react-utilities';
import { SlotClassNames } from '@fluentui/react-utilities';
import { SlotPropsRecord } from '@fluentui/react-utilities';
import { SpacingTokens } from '@fluentui/react-theme';
import { SplitButton } from '@fluentui/react-button';
import { splitButtonClassName } from '@fluentui/react-button';
import { splitButtonClassNames } from '@fluentui/react-button';
Expand Down Expand Up @@ -443,6 +447,7 @@ import { useToggleButton_unstable } from '@fluentui/react-button';
import { useToggleButtonStyles_unstable } from '@fluentui/react-button';
import { useTooltip_unstable } from '@fluentui/react-tooltip';
import { useTooltipStyles_unstable } from '@fluentui/react-tooltip';
import { VerticalSpacingTokens } from '@fluentui/react-theme';
import { webDarkTheme } from '@fluentui/react-theme';
import { webHighContrastTheme } from '@fluentui/react-theme';
import { webLightTheme } from '@fluentui/react-theme';
Expand Down Expand Up @@ -625,6 +630,8 @@ export { createLightTheme }

export { createTeamsDarkTheme }

export { CurveTokens }

export { Display }

export { displayClassName }
Expand All @@ -643,6 +650,8 @@ export { DividerSlots }

export { DividerState }

export { DurationTokens }

export { elementContains }

export { FluentProvider }
Expand Down Expand Up @@ -681,6 +690,8 @@ export { headlineClassName }

export { headlineClassNames }

export { HorizontalSpacingTokens }

export { Image_2 as Image }

export { imageClassName }
Expand Down Expand Up @@ -1049,6 +1060,8 @@ export { SlotClassNames }

export { SlotPropsRecord }

export { SpacingTokens }

export { SplitButton }

export { splitButtonClassName }
Expand Down Expand Up @@ -1325,6 +1338,8 @@ export { useTooltip_unstable }

export { useTooltipStyles_unstable }

export { VerticalSpacingTokens }

export { webDarkTheme }

export { webHighContrastTheme }
Expand Down
5 changes: 5 additions & 0 deletions packages/react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export type {
ShadowBrandTokens,
ShadowTokens,
StrokeWidthTokens,
SpacingTokens,
HorizontalSpacingTokens,
VerticalSpacingTokens,
DurationTokens,
CurveTokens,
Theme,
} from '@fluentui/react-theme';
export {
Expand Down
71 changes: 70 additions & 1 deletion packages/react-theme/etc/react-theme.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,30 @@ export const createLightTheme: (brand: BrandVariants) => Theme;
// @public (undocumented)
export const createTeamsDarkTheme: (brand: BrandVariants) => Theme;

// @public (undocumented)
export type CurveTokens = {
curveAccelerateMax: string;
curveAccelerateMid: string;
curveAccelerateMin: string;
curveDecelerateMax: string;
curveDecelerateMid: string;
curveDecelerateMin: string;
curveEasyEaseMax: string;
curveEasyEase: string;
curveLinear: string;
};

// @public (undocumented)
export type DurationTokens = {
durationUltraFast: string;
durationFaster: string;
durationFast: string;
durationNormal: string;
durationSlow: string;
durationSlower: string;
durationUltraSlow: string;
};

// @public (undocumented)
export type FontFamilyTokens = {
fontFamilyBase: string;
Expand Down Expand Up @@ -352,6 +376,21 @@ export type FontWeightTokens = {
fontWeightSemibold: number;
};

// @public (undocumented)
export type HorizontalSpacingTokens = {
spacingHorizontalNone: string;
spacingHorizontalXXS: string;
GeoffCoxMSFT marked this conversation as resolved.
Show resolved Hide resolved
spacingHorizontalXS: string;
spacingHorizontalSNudge: string;
spacingHorizontalS: string;
spacingHorizontalMNudge: string;
spacingHorizontalM: string;
spacingHorizontalL: string;
spacingHorizontalXL: string;
spacingHorizontalXXL: string;
spacingHorizontalXXXl: string;
GeoffCoxMSFT marked this conversation as resolved.
Show resolved Hide resolved
};

// @public (undocumented)
export type LineHeightTokens = {
lineHeightBase100: string;
Expand Down Expand Up @@ -389,6 +428,21 @@ export type ShadowTokens = {
shadow64: string;
};

// @public (undocumented)
export type SpacingTokens = {
GeoffCoxMSFT marked this conversation as resolved.
Show resolved Hide resolved
none: string;
xxs: string;
xs: string;
sNudge: string;
s: string;
mNudge: string;
m: string;
l: string;
xl: string;
xxl: string;
xxxl: string;
};

// @public (undocumented)
export type StrokeWidthTokens = {
strokeWidthThin: string;
Expand All @@ -407,14 +461,29 @@ export const teamsHighContrastTheme: Theme;
export const teamsLightTheme: Theme;

// @public (undocumented)
export type Theme = FontSizeTokens & LineHeightTokens & BorderRadiusTokens & StrokeWidthTokens & ShadowTokens & ShadowBrandTokens & FontFamilyTokens & FontWeightTokens & ColorPaletteTokens & ColorTokens;
export type Theme = FontSizeTokens & LineHeightTokens & BorderRadiusTokens & StrokeWidthTokens & HorizontalSpacingTokens & VerticalSpacingTokens & DurationTokens & CurveTokens & ShadowTokens & ShadowBrandTokens & FontFamilyTokens & FontWeightTokens & ColorPaletteTokens & ColorTokens;

// @public
export function themeToTokensObject<TTheme extends Theme>(theme: TTheme): Record<keyof TTheme, string>;

// @public (undocumented)
export const tokens: Record<keyof Theme, string>;

// @public (undocumented)
export type VerticalSpacingTokens = {
spacingVerticalNone: string;
spacingVerticalXXS: string;
spacingVerticalXS: string;
spacingVerticalSNudge: string;
spacingVerticalS: string;
spacingVerticalMNudge: string;
spacingVerticalM: string;
spacingVerticalL: string;
spacingVerticalXL: string;
spacingVerticalXXL: string;
spacingVerticalXXXl: string;
};

// @public (undocumented)
export const webDarkTheme: Theme;

Expand Down
13 changes: 13 additions & 0 deletions packages/react-theme/src/global/curves.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { CurveTokens } from '../types';

export const curves: CurveTokens = {
curveAccelerateMax: 'cubic-bezier(1,0,1,1)',
curveAccelerateMid: 'cubic-bezier(0.7,0,1,0.5)',
curveAccelerateMin: 'cubic-bezier(0.8,0,1,1)',
curveDecelerateMax: 'cubic-bezier(0,0,0,1)',
curveDecelerateMid: 'cubic-bezier(0.1,0.9,0.2,1)',
curveDecelerateMin: 'cubic-bezier(0.33,0,0.1,1)',
curveEasyEaseMax: 'cubic-bezier(0.8,0,0.1,1)',
curveEasyEase: 'cubic-bezier(0.33,0,0.67,1)',
curveLinear: 'cubic-bezier(0,0,1,1)',
};
11 changes: 11 additions & 0 deletions packages/react-theme/src/global/durations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { DurationTokens } from '../types';

export const durations: DurationTokens = {
durationUltraFast: '50',
durationFaster: '100',
durationFast: '150',
durationNormal: '200',
durationSlow: '300',
durationSlower: '400',
durationUltraSlow: '500',
};
5 changes: 4 additions & 1 deletion packages/react-theme/src/global/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export * from './borderRadius';
export * from './colors';
export * from './curves';
export * from './durations';
export * from './fonts';
export * from './spacings';
export * from './strokeWidths';
export * from './borderRadius';
43 changes: 43 additions & 0 deletions packages/react-theme/src/global/spacings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { HorizontalSpacingTokens, SpacingTokens, VerticalSpacingTokens } from '../types';

export const spacings: SpacingTokens = {
none: '0',
xxs: '2',
xs: '4',
sNudge: '6',
s: '8',
mNudge: '10',
m: '12',
l: '16',
xl: '20',
xxl: '24',
xxxl: '32',
};

export const horizontalSpacings: HorizontalSpacingTokens = {
spacingHorizontalNone: spacings.none,
spacingHorizontalXXS: spacings.xxs,
spacingHorizontalXS: spacings.xs,
spacingHorizontalSNudge: spacings.sNudge,
spacingHorizontalS: spacings.s,
spacingHorizontalMNudge: spacings.mNudge,
spacingHorizontalM: spacings.m,
spacingHorizontalL: spacings.l,
spacingHorizontalXL: spacings.xl,
spacingHorizontalXXL: spacings.xxl,
spacingHorizontalXXXl: spacings.xxxl,
};

export const verticalSpacings: VerticalSpacingTokens = {
spacingVerticalNone: spacings.none,
spacingVerticalXXS: spacings.xxs,
spacingVerticalXS: spacings.xs,
spacingVerticalSNudge: spacings.sNudge,
spacingVerticalS: spacings.s,
spacingVerticalMNudge: spacings.mNudge,
spacingVerticalM: spacings.m,
spacingVerticalL: spacings.l,
spacingVerticalXL: spacings.xl,
spacingVerticalXXL: spacings.xxl,
spacingVerticalXXXl: spacings.xxxl,
};
5 changes: 5 additions & 0 deletions packages/react-theme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export type {
LineHeightTokens,
BorderRadiusTokens,
StrokeWidthTokens,
SpacingTokens,
HorizontalSpacingTokens,
VerticalSpacingTokens,
DurationTokens,
CurveTokens,
ShadowTokens,
ShadowBrandTokens,
FontFamilyTokens,
Expand Down
45 changes: 45 additions & 0 deletions packages/react-theme/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,49 @@ export const tokens: Record<keyof Theme, string> = {
strokeWidthThick: 'var(--strokeWidthThick)',
strokeWidthThicker: 'var(--strokeWidthThicker)',
strokeWidthThickest: 'var(--strokeWidthThickest)',

// Spacings
spacingHorizontalNone: 'var(--spacingHorizontalNone)',
spacingHorizontalXXS: 'var(--spacingHorizontalXXS)',
spacingHorizontalXS: 'var(--spacingHorizontalXS)',
spacingHorizontalSNudge: 'var(--spacingHorizontalSNudge)',
spacingHorizontalS: 'var(--spacingHorizontalS)',
spacingHorizontalMNudge: 'var(--spacingHorizontalMNudge)',
spacingHorizontalM: 'var(--spacingHorizontalM)',
spacingHorizontalL: 'var(--spacingHorizontalL)',
spacingHorizontalXL: 'var(--spacingHorizontalXL)',
spacingHorizontalXXL: 'var(--spacingHorizontalXXL)',
spacingHorizontalXXXl: 'var(--spacingHorizontalXXXl)',

spacingVerticalNone: 'var(--spacingVerticalNone)',
spacingVerticalXXS: 'var(--spacingVerticalXXS)',
spacingVerticalXS: 'var(--spacingVerticalXS)',
spacingVerticalSNudge: 'var(--spacingVerticalSNudge)',
spacingVerticalS: 'var(--spacingVerticalS)',
spacingVerticalMNudge: 'var(--spacingVerticalMNudge)',
spacingVerticalM: 'var(--spacingVerticalM)',
spacingVerticalL: 'var(--spacingVerticalL)',
spacingVerticalXL: 'var(--spacingVerticalXL)',
spacingVerticalXXL: 'var(--spacingVerticalXXL)',
spacingVerticalXXXl: 'var(--spacingVerticalXXXl)',

// Durations
durationUltraFast: 'var(--durationUltraFast)',
durationFaster: 'var(--durationFaster)',
durationFast: 'var(--durationFast)',
durationNormal: 'var(--durationNormal)',
durationSlow: 'var(--durationSlow)',
durationSlower: 'var(--durationSlower)',
durationUltraSlow: 'var(--durationUltraSlow)',

// Curves
curveAccelerateMax: 'var(--curveAccelerateMax)',
curveAccelerateMid: 'var(--curveAccelerateMid)',
curveAccelerateMin: 'var(--curveAccelerateMin)',
curveDecelerateMax: 'var(--curveDecelerateMax)',
curveDecelerateMid: 'var(--curveDecelerateMid)',
curveDecelerateMin: 'var(--curveDecelerateMin)',
curveEasyEaseMax: 'var(--curveEasyEaseMax)',
curveEasyEase: 'var(--curveEasyEase)',
curveLinear: 'var(--curveLinear)',
};
Loading