diff --git a/.changeset/tidy-stories-wait.md b/.changeset/tidy-stories-wait.md new file mode 100644 index 00000000000..c6d6188a730 --- /dev/null +++ b/.changeset/tidy-stories-wait.md @@ -0,0 +1,5 @@ +--- +"@fluentui-react-native/storybook-desktop": patch +--- + +Separate cold first-render waiting from service startup in the reusable smoke lifecycle, and report story navigation deadlines with their underlying causes. diff --git a/.changeset/warm-carpets-smile.md b/.changeset/warm-carpets-smile.md new file mode 100644 index 00000000000..cd91eb916d3 --- /dev/null +++ b/.changeset/warm-carpets-smile.md @@ -0,0 +1,15 @@ +--- +"@fluentui-react-native/avatar": patch +"@fluentui-react-native/badge": patch +"@fluentui-react-native/button": patch +"@fluentui-react-native/checkbox": patch +"@fluentui-react-native/menu": patch +"@fluentui-react-native/radio-group": patch +"@fluentui-react-native/switch": patch +"@fluentui-react-native/tablist": patch +"@fluentui-react-native/text": patch +"@fluentui-react-native/experimental-shimmer": patch +"@fluentui-react-native/spinner": patch +--- + +Use Win32 styling and token values as the shared default for Windows and Win32. diff --git a/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.test.ts b/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.test.ts index 25a73a4a9e7..eba279386dc 100644 --- a/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.test.ts +++ b/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.test.ts @@ -458,6 +458,103 @@ describe('DesktopStorybookCli', () => { } }); + test.each([undefined, 150_000])( + 'allows a cold development bundle to take longer than the service startup timeout (initialRenderTimeoutMs: %s)', + async (initialRenderTimeoutMs) => { + jest.useFakeTimers(); + try { + const runner = new RecordingRunner(); + const readyAt = Date.now() + 130_000; + const output = { write: jest.fn() }; + const fetch: typeof globalThis.fetch = async (input) => { + if (String(input).includes('select-story-sync')) { + await new Promise((resolve) => setTimeout(resolve, 1000)); + if (Date.now() < readyAt) { + return new Response(JSON.stringify({ error: 'Storybook runtime is not connected yet.' }), { status: 408 }); + } + return new Response('{}'); + } + return new Response(JSON.stringify({ entries: { first: { id: 'first--story', type: 'story' } } })); + }; + const cli = new DesktopStorybookCli( + makeConfig({ + macos: { run: { command: 'launch-storybook' }, smoke: { initialRenderTimeoutMs, stop: { command: 'stop-storybook' } } }, + }), + { ...nativeDriverTestOptions, runner, fetch, output, errorOutput: { write: () => true }, isPortAvailable: async () => true }, + ); + + const result = cli.smoke('macos').catch((error: unknown) => error); + await jest.advanceTimersByTimeAsync(131_000); + expect(await result).toBeUndefined(); + expect(output.write).toHaveBeenCalledWith('Rendered 1 stories.\n'); + expect(runner.stopped).toBe(2); + } finally { + jest.useRealTimers(); + } + }, + ); + + test.each([ + { smokeOptions: {}, firstRenders: false, timeoutMs: 300_000 }, + { smokeOptions: { startupTimeoutMs: 2000 }, firstRenders: false, timeoutMs: 2000 }, + { smokeOptions: { startupTimeoutMs: 10_000, initialRenderTimeoutMs: 2000 }, firstRenders: false, timeoutMs: 2000 }, + { smokeOptions: { initialRenderTimeoutMs: 60_000 }, firstRenders: true, timeoutMs: 15_000 }, + ])('bounds navigation and preserves the cause (%j)', async ({ smokeOptions, firstRenders, timeoutMs }) => { + jest.useFakeTimers(); + try { + const runner = new RecordingRunner(); + const fetch: typeof globalThis.fetch = async (input, init) => { + const url = String(input); + if (url.includes('select-story-sync')) { + if (firstRenders && url.endsWith('first--story')) { + return new Response('{}'); + } + return new Promise((_resolve, reject) => { + init!.signal!.addEventListener('abort', () => reject(init!.signal!.reason), { once: true }); + }); + } + return new Response( + JSON.stringify({ + entries: { + first: { id: 'first--story', type: 'story' }, + second: { id: 'second--story', type: 'story' }, + }, + }), + ); + }; + const cli = new DesktopStorybookCli( + makeConfig({ + macos: { run: { command: 'launch-storybook' }, smoke: { ...smokeOptions, stop: { command: 'stop-storybook' } } }, + }), + { + ...nativeDriverTestOptions, + runner, + fetch, + output: { write: () => true }, + errorOutput: { write: () => true }, + isPortAvailable: async () => true, + }, + ); + + const result = cli.smoke('macos').catch((error: unknown) => error); + await jest.advanceTimersByTimeAsync(timeoutMs); + const error = await result; + expect(error).toBeInstanceOf(AggregateError); + if (!(error instanceof AggregateError)) { + throw new Error('Expected smoke to report a navigation failure.'); + } + expect(error.errors).toHaveLength(1); + expect(error.errors[0].cause).toMatchObject({ + message: `Timed out after ${timeoutMs} ms waiting for Storybook story "${firstRenders ? 'second' : 'first'}--story" to render.`, + cause: { name: 'AbortError' }, + }); + expect(runner.foreground.at(-1)?.command).toBe('stop-storybook'); + expect(runner.stopped).toBe(2); + } finally { + jest.useRealTimers(); + } + }); + test('runs authored tests after traversing the complete story index', async () => { const runner = new RecordingRunner(); const resolveNativeDriver = jest.fn(async () => nativeDriverArtifact); diff --git a/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.ts b/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.ts index 871be532cf0..314cb13648e 100644 --- a/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.ts +++ b/packages/agentic/storybook-desktop/src/cli/DesktopStorybookCli.ts @@ -407,7 +407,7 @@ export class DesktopStorybookCli { } await this.writeMacOSApplicationLease(instance.driverManifestPath, smoke.startupTimeoutMs ?? 120_000); } - await this.renderEveryStory(serverUrl, smoke.settleMs ?? 0, smoke.startupTimeoutMs); + await this.renderEveryStory(serverUrl, smoke.settleMs ?? 0, smoke.initialRenderTimeoutMs ?? smoke.startupTimeoutMs); if (mode === 'stories-and-tests') { const result = await this.runSmokeTests({ config: this.config, @@ -532,7 +532,7 @@ export class DesktopStorybookCli { }; } - private async renderEveryStory(serverUrl: string, settleMs: number, startupTimeoutMs = 120_000): Promise { + private async renderEveryStory(serverUrl: string, settleMs: number, initialRenderTimeoutMs = 300_000): Promise { const storyIndex = await this.getJson(new URL('/index.json', serverUrl)); const entries = Object.values((storyIndex.entries ?? {}) as Record).filter( (entry) => entry.type === 'story' && entry.id, @@ -545,7 +545,7 @@ export class DesktopStorybookCli { let consecutiveFailures = 0; for (const [entryIndex, { id }] of entries.entries()) { try { - await this.selectStory(serverUrl, id!, entryIndex === 0 ? startupTimeoutMs : 15_000); + await this.selectStory(serverUrl, id!, entryIndex === 0 ? initialRenderTimeoutMs : 15_000); consecutiveFailures = 0; if (settleMs > 0) { await delay(settleMs); @@ -586,7 +586,7 @@ export class DesktopStorybookCli { } } } while (Date.now() < deadline); - throw lastError; + throw new Error(`Timed out after ${timeoutMs} ms waiting for Storybook story "${storyId}" to render.`, { cause: lastError }); } private async waitForUrl(url: string, process: RunningDesktopCommand, timeoutMs = 120_000): Promise { diff --git a/packages/agentic/storybook-desktop/src/cli/README.md b/packages/agentic/storybook-desktop/src/cli/README.md index 72d112a0540..decc16468ff 100644 --- a/packages/agentic/storybook-desktop/src/cli/README.md +++ b/packages/agentic/storybook-desktop/src/cli/README.md @@ -156,6 +156,15 @@ app stop command. For Windows Fabric and the prebuilt REX Win32 host, configure `createWindowsSmokeOptions`, `createWin32RunCommand`, and `createWin32SmokeCommand`; do not copy lifecycle scripts into the consumer. +The reusable lifecycle waits up to two minutes for its services, then up to +five minutes for the first story after native launch. Metro's status endpoint +can be ready before a cold development bundle finishes, and a successful +release bundle does not prewarm the Debug app's development bundle. First +render therefore has a separate budget. Set `platformOptions.macos.smoke.initialRenderTimeoutMs` +to override it; an explicitly configured `startupTimeoutMs` remains its +fallback. Later stories retain their 15-second navigation deadline. A timeout +reports the story, elapsed budget, and underlying request failure. + For a broader E2E suite, let the test coordinator own the service processes: 1. Start `storybook server` and Metro with one platform environment. diff --git a/packages/agentic/storybook-desktop/src/config/commands.ts b/packages/agentic/storybook-desktop/src/config/commands.ts index 0acc9411970..1061ef93508 100644 --- a/packages/agentic/storybook-desktop/src/config/commands.ts +++ b/packages/agentic/storybook-desktop/src/config/commands.ts @@ -115,6 +115,13 @@ export type DesktopSmokeOptions = { */ startupTimeoutMs?: number; + /** + * Maximum time to wait for the first story, including cold development bundling and runtime startup. + * Falls back to an explicitly configured startupTimeoutMs. + * @default 300000 + */ + initialRenderTimeoutMs?: number; + /** * Delay after selecting each story. * @default 0 diff --git a/packages/components/Avatar/src/AvatarColorTokens.test.windows.ts b/packages/components/Avatar/src/AvatarColorTokens.test.windows.ts new file mode 100644 index 00000000000..bb7482d0848 --- /dev/null +++ b/packages/components/Avatar/src/AvatarColorTokens.test.windows.ts @@ -0,0 +1,9 @@ +import { createColorPinningTheme, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings } from './Avatar.styling'; + +it('pins Avatar color tokens on Windows', () => { + const theme = createColorPinningTheme(); + + expect(resolveV1ColorTokens(stylingSettings.tokens, theme)).toMatchSnapshot(); +}); diff --git a/packages/components/Avatar/src/AvatarTokens.win32.ts b/packages/components/Avatar/src/AvatarTokens.macos.ts similarity index 97% rename from packages/components/Avatar/src/AvatarTokens.win32.ts rename to packages/components/Avatar/src/AvatarTokens.macos.ts index 62a9351646b..484988f1adf 100644 --- a/packages/components/Avatar/src/AvatarTokens.win32.ts +++ b/packages/components/Avatar/src/AvatarTokens.macos.ts @@ -22,7 +22,7 @@ import { getNamedColorSet, type NamedColorSet } from './Avatar.colors'; export const defaultAvatarTokens: TokenSettings = (t: Theme) => ({ - badgeSize: 'tiny', + badgeSize: 'small', color: t.colors.neutralForeground3, backgroundColor: t.colors.neutralBackground6, avatarOpacity: 1, @@ -191,11 +191,10 @@ export const defaultAvatarTokens: TokenSettings = (t: Theme * @returns object of props - backgroundColor, color and ringColor */ function getColorProps(color: NamedColorSet, theme: Theme) { - const themeAppearance = theme.name; const colorSet = getNamedColorSet(color); + const themeAppearance = theme.host.appearance; switch (themeAppearance) { - case 'White': - case 'Colorful': + case 'light': default: return { backgroundColor: colorSet.tint40, @@ -203,15 +202,14 @@ function getColorProps(color: NamedColorSet, theme: Theme) { iconColor: colorSet.shade30, ringColor: colorSet.primary, }; - case 'DarkGray': - case 'Black': + case 'dark': return { backgroundColor: colorSet.shade30, color: colorSet.tint40, iconColor: colorSet.tint40, ringColor: colorSet.tint30, }; - case 'HighContrast': + case 'highContrast': return { backgroundColor: theme.colors.neutralBackground6, color: theme.colors.neutralForeground3, diff --git a/packages/components/Avatar/src/AvatarTokens.ts b/packages/components/Avatar/src/AvatarTokens.ts index 484988f1adf..62a9351646b 100644 --- a/packages/components/Avatar/src/AvatarTokens.ts +++ b/packages/components/Avatar/src/AvatarTokens.ts @@ -22,7 +22,7 @@ import { getNamedColorSet, type NamedColorSet } from './Avatar.colors'; export const defaultAvatarTokens: TokenSettings = (t: Theme) => ({ - badgeSize: 'small', + badgeSize: 'tiny', color: t.colors.neutralForeground3, backgroundColor: t.colors.neutralBackground6, avatarOpacity: 1, @@ -191,10 +191,11 @@ export const defaultAvatarTokens: TokenSettings = (t: Theme * @returns object of props - backgroundColor, color and ringColor */ function getColorProps(color: NamedColorSet, theme: Theme) { + const themeAppearance = theme.name; const colorSet = getNamedColorSet(color); - const themeAppearance = theme.host.appearance; switch (themeAppearance) { - case 'light': + case 'White': + case 'Colorful': default: return { backgroundColor: colorSet.tint40, @@ -202,14 +203,15 @@ function getColorProps(color: NamedColorSet, theme: Theme) { iconColor: colorSet.shade30, ringColor: colorSet.primary, }; - case 'dark': + case 'DarkGray': + case 'Black': return { backgroundColor: colorSet.shade30, color: colorSet.tint40, iconColor: colorSet.tint40, ringColor: colorSet.tint30, }; - case 'highContrast': + case 'HighContrast': return { backgroundColor: theme.colors.neutralBackground6, color: theme.colors.neutralForeground3, diff --git a/packages/components/Avatar/src/__snapshots__/AvatarColorTokens.test.windows.ts.snap b/packages/components/Avatar/src/__snapshots__/AvatarColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..5fba1ab7347 --- /dev/null +++ b/packages/components/Avatar/src/__snapshots__/AvatarColorTokens.test.windows.ts.snap @@ -0,0 +1,221 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`pins Avatar color tokens on Windows 1`] = ` +{ + "anchor": { + "backgroundColor": "#bcc3c7", + "color": "#202427", + "iconColor": "#202427", + "ringColor": "#394146", + }, + "backgroundColor": "#e6e6e6", + "beige": { + "backgroundColor": "#d7d4d4", + "color": "#444241", + "iconColor": "#444241", + "ringColor": "#7a7574", + }, + "blue": { + "backgroundColor": "#a9d3f2", + "color": "#004377", + "iconColor": "#004377", + "ringColor": "#0078d4", + }, + "borderColor": "#969696", + "brand": { + "backgroundColor": "#185abd", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + "ringColor": "#00000000", + }, + "brass": { + "backgroundColor": "#e0cea2", + "color": "#553e06", + "iconColor": "#553e06", + "ringColor": "#986f0b", + }, + "brown": { + "backgroundColor": "#ddc3b0", + "color": "#50301a", + "iconColor": "#50301a", + "ringColor": "#8e562e", + }, + "burgundy": { + "backgroundColor": "#e4afb2", + "color": "#5c1519", + "iconColor": "#5c1519", + "ringColor": "#a4262c", + }, + "color": "#616161", + "cornflower": { + "backgroundColor": "#c8d1fa", + "color": "#2c3c85", + "iconColor": "#2c3c85", + "ringColor": "#4f6bed", + }, + "cranberry": { + "backgroundColor": "#eeacb2", + "color": "#6e0811", + "iconColor": "#6e0811", + "ringColor": "#c50f1f", + }, + "darkGreen": { + "backgroundColor": "#9ad29a", + "color": "#063b06", + "iconColor": "#063b06", + "ringColor": "#0b6a0b", + }, + "darkRed": { + "backgroundColor": "#d69ca5", + "color": "#420610", + "iconColor": "#420610", + "ringColor": "#750b1c", + }, + "forest": { + "backgroundColor": "#bdd99b", + "color": "#294903", + "iconColor": "#294903", + "ringColor": "#498205", + }, + "gold": { + "backgroundColor": "#ecdfa5", + "color": "#6c5700", + "iconColor": "#6c5700", + "ringColor": "#c19c00", + }, + "grape": { + "backgroundColor": "#d9a7e0", + "color": "#4c0d55", + "iconColor": "#4c0d55", + "ringColor": "#881798", + }, + "hotPink": { + "backgroundColor": "#f7adda", + "color": "#7f004e", + "iconColor": "#7f004e", + "ringColor": "#e3008c", + }, + "iconColor": "#616161", + "lavender": { + "backgroundColor": "#d2ccf8", + "color": "#3f3682", + "iconColor": "#3f3682", + "ringColor": "#7160e8", + }, + "lightTeal": { + "backgroundColor": "#a6e9ed", + "color": "#00666d", + "iconColor": "#00666d", + "ringColor": "#00b7c3", + }, + "lilac": { + "backgroundColor": "#e6bfed", + "color": "#63276d", + "iconColor": "#63276d", + "ringColor": "#b146c2", + }, + "magenta": { + "backgroundColor": "#eca5d1", + "color": "#6b0043", + "iconColor": "#6b0043", + "ringColor": "#bf0077", + }, + "marigold": { + "backgroundColor": "#f9e2ae", + "color": "#835b00", + "iconColor": "#835b00", + "ringColor": "#eaa300", + }, + "mink": { + "backgroundColor": "#cecccb", + "color": "#343231", + "iconColor": "#343231", + "ringColor": "#5d5a58", + }, + "navy": { + "backgroundColor": "#a3b2e8", + "color": "#001665", + "iconColor": "#001665", + "ringColor": "#0027b4", + }, + "neutral": { + "backgroundColor": "#e6e6e6", + "color": "#616161", + "iconColor": "#616161", + "ringColor": "#00000000", + }, + "orchid": { + "backgroundColor": "#d7caea", + "color": "#4c3867", + "iconColor": "#4c3867", + "ringColor": "#8764b8", + }, + "peach": { + "backgroundColor": "#ffddb3", + "color": "#8f4e00", + "iconColor": "#8f4e00", + "ringColor": "#ff8c00", + }, + "pink": { + "backgroundColor": "#f7c0e3", + "color": "#80215d", + "iconColor": "#80215d", + "ringColor": "#e43ba6", + }, + "platinum": { + "backgroundColor": "#cdd6d8", + "color": "#3b4447", + "iconColor": "#3b4447", + "ringColor": "#69797e", + }, + "plum": { + "backgroundColor": "#d696c0", + "color": "#43002b", + "iconColor": "#43002b", + "ringColor": "#77004d", + }, + "pumpkin": { + "backgroundColor": "#efc4ad", + "color": "#712d09", + "iconColor": "#712d09", + "ringColor": "#ca5010", + }, + "purple": { + "backgroundColor": "#c6b1de", + "color": "#341a51", + "iconColor": "#341a51", + "ringColor": "#5c2e91", + }, + "red": { + "backgroundColor": "#f1bbbc", + "color": "#751d1f", + "iconColor": "#751d1f", + "ringColor": "#d13438", + }, + "ringColor": "#00000000", + "royalBlue": { + "backgroundColor": "#9abfdc", + "color": "#002c4e", + "iconColor": "#002c4e", + "ringColor": "#004e8c", + }, + "seafoam": { + "backgroundColor": "#a8f0cd", + "color": "#00723b", + "iconColor": "#00723b", + "ringColor": "#00cc6a", + }, + "steel": { + "backgroundColor": "#94c8d4", + "color": "#00333f", + "iconColor": "#00333f", + "ringColor": "#005b70", + }, + "teal": { + "backgroundColor": "#9bd9db", + "color": "#02494c", + "iconColor": "#02494c", + "ringColor": "#038387", + }, +} +`; diff --git a/packages/components/Badge/src/BadgeColorTokens.win32.ts b/packages/components/Badge/src/BadgeColorTokens.macos.ts similarity index 85% rename from packages/components/Badge/src/BadgeColorTokens.win32.ts rename to packages/components/Badge/src/BadgeColorTokens.macos.ts index 7f0570a0626..41eb4672ba7 100644 --- a/packages/components/Badge/src/BadgeColorTokens.win32.ts +++ b/packages/components/Badge/src/BadgeColorTokens.macos.ts @@ -1,7 +1,11 @@ import type { Theme, TokenSettings } from '@fluentui-react-native/framework'; import { colorDarkOrangePrimary, + colorDarkOrangeShade10, + colorDarkOrangeShade40, colorDarkOrangeTint30, + colorDarkOrangeTint40, + colorDarkOrangeTint50, colorDarkOrangeTint60, colorGreenPrimary, colorGreenShade30, @@ -12,10 +16,6 @@ import { colorGrey14, colorGrey16, colorGrey68, - colorOfficeShade10, - colorOfficeShade40, - colorOfficeTint40, - colorOfficeTint50, colorOrangeShade40, colorRedPrimary, colorRedShade30, @@ -31,7 +31,7 @@ import { } from '@fluentui-react-native/design/tokens/global'; import type { BadgeTokens } from './Badge.types'; -import { getFilledColorProps, getOutlineColorProps, getTintColorProps, getGhostColorProps, getWin32Props } from './colorHelper'; +import { getFilledColorProps, getOutlineColorProps, getTintColorProps, getGhostColorProps } from './colorHelper'; export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => ({ @@ -55,11 +55,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: t.colors.brandBackgroundStatic, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.brandForeground1 }, t, getWin32Props), + ...getOutlineColorProps({ color: t.colors.brandForeground1 }, t), }, tint: { ...getTintColorProps( @@ -69,7 +68,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.brandStroke2, }, t, - getWin32Props, ), }, ghost: { @@ -78,7 +76,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.brandForeground1, }, t, - getWin32Props, ), }, }, @@ -89,11 +86,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorRedPrimary, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorRedPrimary, colorDark: colorRedTint30 }, t, getWin32Props), + ...getOutlineColorProps({ color: colorRedPrimary, colorDark: colorRedTint30 }, t), }, tint: { ...getTintColorProps( @@ -106,7 +102,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorRedShade30, }, t, - getWin32Props, ), }, ghost: { @@ -116,7 +111,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorRedTint30, }, t, - getWin32Props, ), }, }, @@ -127,24 +121,22 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorDarkOrangePrimary, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorDarkOrangePrimary, colorDark: colorDarkOrangeTint30 }, t, getWin32Props), + ...getOutlineColorProps({ color: colorDarkOrangePrimary, colorDark: colorDarkOrangeTint30 }, t), }, tint: { ...getTintColorProps( { backgroundColor: colorDarkOrangeTint60, - color: colorOfficeShade10, - borderColor: colorOfficeTint50, + color: colorDarkOrangeShade10, + borderColor: colorDarkOrangeTint50, backgroundColorDark: colorOrangeShade40, - colorDark: colorOfficeTint40, - borderColorDark: colorOfficeShade40, + colorDark: colorDarkOrangeTint40, + borderColorDark: colorDarkOrangeShade40, }, t, - getWin32Props, ), }, ghost: { @@ -154,7 +146,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorDarkOrangeTint30, }, t, - getWin32Props, ), }, }, @@ -166,11 +157,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: colorGrey14, // It should be neutralForegroundStatic1. It's hardcoded because the token doesn't exist right now }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorYellowShade30, colorDark: colorYellowTint40 }, t, getWin32Props), + ...getOutlineColorProps({ color: colorYellowShade30, colorDark: colorYellowTint40 }, t), }, tint: { ...getTintColorProps( @@ -183,7 +173,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorYellowShade30, }, t, - getWin32Props, ), }, ghost: { @@ -193,7 +182,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorYellowTint40, }, t, - getWin32Props, ), }, }, @@ -204,11 +192,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorGreenPrimary, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorGreenPrimary, colorDark: colorGreenTint40 }, t, getWin32Props), + ...getOutlineColorProps({ color: colorGreenPrimary, colorDark: colorGreenTint40 }, t), }, tint: { ...getTintColorProps( @@ -221,7 +208,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorGreenShade30, }, t, - getWin32Props, ), }, ghost: { @@ -231,7 +217,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorGreenTint40, }, t, - getWin32Props, ), }, }, @@ -243,11 +228,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralBackground1, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStrokeAccessible }, t, getWin32Props), + ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStrokeAccessible }, t), }, tint: { ...getTintColorProps( @@ -260,7 +244,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorGrey68, }, t, - getWin32Props, ), }, ghost: { @@ -269,7 +252,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForeground1, }, t, - getWin32Props, ), }, }, @@ -283,11 +265,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => hcColor: t.colors.brandForeground1, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStroke2 }, t, getWin32Props), + ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStroke2 }, t), }, tint: { ...getTintColorProps( @@ -297,7 +278,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.neutralStroke2, }, t, - getWin32Props, ), }, ghost: { @@ -306,7 +286,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForeground3, }, t, - getWin32Props, ), }, }, @@ -320,11 +299,10 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => hcColor: t.colors.brandForeground1, }, t, - getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForegroundOnBrand }, t, getWin32Props), + ...getOutlineColorProps({ color: t.colors.neutralForegroundOnBrand }, t), }, tint: { ...getTintColorProps( @@ -334,7 +312,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.neutralStroke2, }, t, - getWin32Props, ), }, ghost: { @@ -343,7 +320,6 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForegroundOnBrand, }, t, - getWin32Props, ), }, }, diff --git a/packages/components/Badge/src/BadgeColorTokens.test.windows.ts b/packages/components/Badge/src/BadgeColorTokens.test.windows.ts new file mode 100644 index 00000000000..c32d049d39d --- /dev/null +++ b/packages/components/Badge/src/BadgeColorTokens.test.windows.ts @@ -0,0 +1,19 @@ +import { createColorPinningTheme, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings as badgeStylingSettings } from './Badge.styling'; +import { stylingSettings as counterBadgeStylingSettings } from './CounterBadge/CounterBadge.styling'; +import { stylingSettings as presenceBadgeStylingSettings } from './PresenceBadge/PresenceBadge.styling'; + +const theme = createColorPinningTheme(); + +it('pins Badge color tokens on Windows', () => { + expect(resolveV1ColorTokens(badgeStylingSettings.tokens, theme)).toMatchSnapshot(); +}); + +it('pins CounterBadge color tokens on Windows', () => { + expect(resolveV1ColorTokens(counterBadgeStylingSettings.tokens, theme)).toMatchSnapshot(); +}); + +it('pins PresenceBadge color tokens on Windows', () => { + expect(resolveV1ColorTokens(presenceBadgeStylingSettings.tokens, theme)).toMatchSnapshot(); +}); diff --git a/packages/components/Badge/src/BadgeColorTokens.ts b/packages/components/Badge/src/BadgeColorTokens.ts index 41eb4672ba7..7f0570a0626 100644 --- a/packages/components/Badge/src/BadgeColorTokens.ts +++ b/packages/components/Badge/src/BadgeColorTokens.ts @@ -1,11 +1,7 @@ import type { Theme, TokenSettings } from '@fluentui-react-native/framework'; import { colorDarkOrangePrimary, - colorDarkOrangeShade10, - colorDarkOrangeShade40, colorDarkOrangeTint30, - colorDarkOrangeTint40, - colorDarkOrangeTint50, colorDarkOrangeTint60, colorGreenPrimary, colorGreenShade30, @@ -16,6 +12,10 @@ import { colorGrey14, colorGrey16, colorGrey68, + colorOfficeShade10, + colorOfficeShade40, + colorOfficeTint40, + colorOfficeTint50, colorOrangeShade40, colorRedPrimary, colorRedShade30, @@ -31,7 +31,7 @@ import { } from '@fluentui-react-native/design/tokens/global'; import type { BadgeTokens } from './Badge.types'; -import { getFilledColorProps, getOutlineColorProps, getTintColorProps, getGhostColorProps } from './colorHelper'; +import { getFilledColorProps, getOutlineColorProps, getTintColorProps, getGhostColorProps, getWin32Props } from './colorHelper'; export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => ({ @@ -55,10 +55,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: t.colors.brandBackgroundStatic, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.brandForeground1 }, t), + ...getOutlineColorProps({ color: t.colors.brandForeground1 }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -68,6 +69,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.brandStroke2, }, t, + getWin32Props, ), }, ghost: { @@ -76,6 +78,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.brandForeground1, }, t, + getWin32Props, ), }, }, @@ -86,10 +89,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorRedPrimary, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorRedPrimary, colorDark: colorRedTint30 }, t), + ...getOutlineColorProps({ color: colorRedPrimary, colorDark: colorRedTint30 }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -102,6 +106,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorRedShade30, }, t, + getWin32Props, ), }, ghost: { @@ -111,6 +116,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorRedTint30, }, t, + getWin32Props, ), }, }, @@ -121,22 +127,24 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorDarkOrangePrimary, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorDarkOrangePrimary, colorDark: colorDarkOrangeTint30 }, t), + ...getOutlineColorProps({ color: colorDarkOrangePrimary, colorDark: colorDarkOrangeTint30 }, t, getWin32Props), }, tint: { ...getTintColorProps( { backgroundColor: colorDarkOrangeTint60, - color: colorDarkOrangeShade10, - borderColor: colorDarkOrangeTint50, + color: colorOfficeShade10, + borderColor: colorOfficeTint50, backgroundColorDark: colorOrangeShade40, - colorDark: colorDarkOrangeTint40, - borderColorDark: colorDarkOrangeShade40, + colorDark: colorOfficeTint40, + borderColorDark: colorOfficeShade40, }, t, + getWin32Props, ), }, ghost: { @@ -146,6 +154,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorDarkOrangeTint30, }, t, + getWin32Props, ), }, }, @@ -157,10 +166,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: colorGrey14, // It should be neutralForegroundStatic1. It's hardcoded because the token doesn't exist right now }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorYellowShade30, colorDark: colorYellowTint40 }, t), + ...getOutlineColorProps({ color: colorYellowShade30, colorDark: colorYellowTint40 }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -173,6 +183,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorYellowShade30, }, t, + getWin32Props, ), }, ghost: { @@ -182,6 +193,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorYellowTint40, }, t, + getWin32Props, ), }, }, @@ -192,10 +204,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => backgroundColor: colorGreenPrimary, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: colorGreenPrimary, colorDark: colorGreenTint40 }, t), + ...getOutlineColorProps({ color: colorGreenPrimary, colorDark: colorGreenTint40 }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -208,6 +221,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorGreenShade30, }, t, + getWin32Props, ), }, ghost: { @@ -217,6 +231,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => colorDark: colorGreenTint40, }, t, + getWin32Props, ), }, }, @@ -228,10 +243,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralBackground1, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStrokeAccessible }, t), + ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStrokeAccessible }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -244,6 +260,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColorDark: colorGrey68, }, t, + getWin32Props, ), }, ghost: { @@ -252,6 +269,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForeground1, }, t, + getWin32Props, ), }, }, @@ -265,10 +283,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => hcColor: t.colors.brandForeground1, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStroke2 }, t), + ...getOutlineColorProps({ color: t.colors.neutralForeground3, borderColor: t.colors.neutralStroke2 }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -278,6 +297,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.neutralStroke2, }, t, + getWin32Props, ), }, ghost: { @@ -286,6 +306,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForeground3, }, t, + getWin32Props, ), }, }, @@ -299,10 +320,11 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => hcColor: t.colors.brandForeground1, }, t, + getWin32Props, ), }, outline: { - ...getOutlineColorProps({ color: t.colors.neutralForegroundOnBrand }, t), + ...getOutlineColorProps({ color: t.colors.neutralForegroundOnBrand }, t, getWin32Props), }, tint: { ...getTintColorProps( @@ -312,6 +334,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => borderColor: t.colors.neutralStroke2, }, t, + getWin32Props, ), }, ghost: { @@ -320,6 +343,7 @@ export const defaultBadgeColorTokens: TokenSettings = (t: Theme) => color: t.colors.neutralForegroundOnBrand, }, t, + getWin32Props, ), }, }, diff --git a/packages/components/Badge/src/BadgeFontTokens.win32.ts b/packages/components/Badge/src/BadgeFontTokens.macos.ts similarity index 52% rename from packages/components/Badge/src/BadgeFontTokens.win32.ts rename to packages/components/Badge/src/BadgeFontTokens.macos.ts index 9419cc5722d..dd6f2c95d96 100644 --- a/packages/components/Badge/src/BadgeFontTokens.win32.ts +++ b/packages/components/Badge/src/BadgeFontTokens.macos.ts @@ -1,18 +1,15 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { fontSize100, fontSize200, fontWeightRegular } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { BadgeTokens } from './Badge.types'; -export const badgeFontTokens: TokenSettings = (t: Theme) => +export const badgeFontTokens: TokenSettings = () => ({ - fontFamily: t.typography.families.primary, - fontSize: fontSize100, - fontWeight: fontWeightRegular, + variant: 'captionStandard', large: { - fontSize: fontSize200, + variant: 'secondaryStandard', }, extraLarge: { - fontSize: fontSize200, + variant: 'secondaryStandard', }, }) as BadgeTokens; diff --git a/packages/components/Badge/src/BadgeFontTokens.ts b/packages/components/Badge/src/BadgeFontTokens.ts index dd6f2c95d96..9419cc5722d 100644 --- a/packages/components/Badge/src/BadgeFontTokens.ts +++ b/packages/components/Badge/src/BadgeFontTokens.ts @@ -1,15 +1,18 @@ import type { Theme } from '@fluentui-react-native/framework'; +import { fontSize100, fontSize200, fontWeightRegular } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { BadgeTokens } from './Badge.types'; -export const badgeFontTokens: TokenSettings = () => +export const badgeFontTokens: TokenSettings = (t: Theme) => ({ - variant: 'captionStandard', + fontFamily: t.typography.families.primary, + fontSize: fontSize100, + fontWeight: fontWeightRegular, large: { - variant: 'secondaryStandard', + fontSize: fontSize200, }, extraLarge: { - variant: 'secondaryStandard', + fontSize: fontSize200, }, }) as BadgeTokens; diff --git a/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.ts b/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.ts index 74419becd22..f9d35709d10 100644 --- a/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.ts +++ b/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.ts @@ -10,6 +10,7 @@ import { sizeNone, } from '@fluentui-react-native/design/tokens/global'; import { isHighContrast } from '@fluentui-react-native/design/theming'; +import { getBadgeColor } from './PresenceBadge.helpers'; import type { PresenceBadgeTokens } from './PresenceBadge.types'; @@ -21,8 +22,8 @@ export const defaultPresenceBadgeTokens: TokenSettings = (t right: -1, paddingHorizontal: sizeNone, backgroundColor: t.colors.neutralBackground1, - ...getBadgeColor(colorLightGreenPrimary, t), position: 'relative', + ...getBadgeColor(colorLightGreenPrimary, t), tiny: { width: 6, height: 6, @@ -40,16 +41,16 @@ export const defaultPresenceBadgeTokens: TokenSettings = (t height: 16, }, large: { - borderWidth: 2, width: 20, height: 20, + borderWidth: 2, bottom: -size20, right: -size20, }, extraLarge: { - borderWidth: 2, width: 28, height: 28, + borderWidth: 2, bottom: -size20, right: -size20, }, @@ -58,18 +59,9 @@ export const defaultPresenceBadgeTokens: TokenSettings = (t busy: getBadgeColor(colorRedPrimary, t), blocked: getBadgeColor(colorRedPrimary, t), unknown: getBadgeColor(colorRedPrimary, t), + doNotDisturb: getBadgeColor(colorRedPrimary, t), offline: { iconColor: isHighContrast(t) ? t.colors.neutralForeground3 : colorGrey38, }, outOfOffice: getBadgeColor(colorBerryPrimary, t), }) as PresenceBadgeTokens; - -function getBadgeColor(nonHcColor: string, t: Theme, oofColor?: string): PresenceBadgeTokens { - oofColor ??= nonHcColor; - return { - iconColor: isHighContrast(t) ? t.colors.neutralForeground3 : nonHcColor, - outOfOffice: { - iconColor: isHighContrast(t) ? t.colors.neutralForeground3 : oofColor, - }, - }; -} diff --git a/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.win32.ts b/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.win32.ts deleted file mode 100644 index f9d35709d10..00000000000 --- a/packages/components/Badge/src/PresenceBadge/PresenceBadgeTokens.win32.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { TokenSettings, Theme } from '@fluentui-react-native/framework'; -import { - colorBerryPrimary, - colorGrey38, - colorLightGreenPrimary, - colorMarigoldPrimary, - colorRedPrimary, - colorWhite, - size20, - sizeNone, -} from '@fluentui-react-native/design/tokens/global'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import { getBadgeColor } from './PresenceBadge.helpers'; - -import type { PresenceBadgeTokens } from './PresenceBadge.types'; - -export const defaultPresenceBadgeTokens: TokenSettings = (t: Theme): PresenceBadgeTokens => - ({ - borderWidth: 1, - borderColor: isHighContrast(t) ? 'transparent' : colorWhite, - bottom: -1, - right: -1, - paddingHorizontal: sizeNone, - backgroundColor: t.colors.neutralBackground1, - position: 'relative', - ...getBadgeColor(colorLightGreenPrimary, t), - tiny: { - width: 6, - height: 6, - }, - extraSmall: { - width: 10, - height: 10, - }, - small: { - width: 12, - height: 12, - }, - medium: { - width: 16, - height: 16, - }, - large: { - width: 20, - height: 20, - borderWidth: 2, - bottom: -size20, - right: -size20, - }, - extraLarge: { - width: 28, - height: 28, - borderWidth: 2, - bottom: -size20, - right: -size20, - }, - available: getBadgeColor(colorLightGreenPrimary, t), - away: getBadgeColor(colorMarigoldPrimary, t, colorBerryPrimary), - busy: getBadgeColor(colorRedPrimary, t), - blocked: getBadgeColor(colorRedPrimary, t), - unknown: getBadgeColor(colorRedPrimary, t), - doNotDisturb: getBadgeColor(colorRedPrimary, t), - offline: { - iconColor: isHighContrast(t) ? t.colors.neutralForeground3 : colorGrey38, - }, - outOfOffice: getBadgeColor(colorBerryPrimary, t), - }) as PresenceBadgeTokens; diff --git a/packages/components/Badge/src/__snapshots__/BadgeColorTokens.test.windows.ts.snap b/packages/components/Badge/src/__snapshots__/BadgeColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..9a9d93cb485 --- /dev/null +++ b/packages/components/Badge/src/__snapshots__/BadgeColorTokens.test.windows.ts.snap @@ -0,0 +1,442 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`pins Badge color tokens on Windows 1`] = ` +{ + "backgroundColor": "#185abd", + "borderColor": "#00000000", + "brand": { + "filled": { + "backgroundColor": "#185abd", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#aec6eb", + "iconColor": "#aec6eb", + }, + "outline": { + "borderColor": "#aec6eb", + "color": "#aec6eb", + "iconColor": "#aec6eb", + }, + "tint": { + "backgroundColor": "#d2e0f4", + "borderColor": "#d2e0f4", + "color": "#d2e0f4", + "iconColor": "#d2e0f4", + }, + }, + "color": "#FFFFFF", + "danger": { + "filled": { + "backgroundColor": "#d13438", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#d13438", + "iconColor": "#d13438", + }, + "outline": { + "borderColor": "#d13438", + "color": "#d13438", + "iconColor": "#d13438", + }, + "tint": { + "backgroundColor": "#fdf6f6", + "borderColor": "#f1bbbc", + "color": "#d13438", + "iconColor": "#d13438", + }, + }, + "filled": { + "borderColor": "#00000000", + }, + "ghost": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + }, + "important": { + "filled": { + "backgroundColor": "#262626", + "color": "antiquewhite", + "iconColor": "antiquewhite", + }, + "ghost": { + "color": "#262626", + "iconColor": "#262626", + }, + "outline": { + "borderColor": "#969696", + "color": "#616161", + "iconColor": "#616161", + }, + "tint": { + "backgroundColor": "#616161", + "borderColor": "#969696", + "color": "antiquewhite", + "iconColor": "antiquewhite", + }, + }, + "informative": { + "filled": { + "backgroundColor": "#ebebeb", + "color": "#616161", + "iconColor": "#616161", + }, + "ghost": { + "color": "#616161", + "iconColor": "#616161", + }, + "outline": { + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + "tint": { + "backgroundColor": "#f0f0f0", + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + }, + "outline": { + "backgroundColor": "#00000000", + }, + "severe": { + "filled": { + "backgroundColor": "#da3b01", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#da3b01", + "iconColor": "#da3b01", + }, + "outline": { + "borderColor": "#da3b01", + "color": "#da3b01", + "iconColor": "#da3b01", + }, + "tint": { + "backgroundColor": "#fdf6f3", + "borderColor": "#f4beaa", + "color": "#c33400", + "iconColor": "#c33400", + }, + }, + "subtle": { + "filled": { + "backgroundColor": "antiquewhite", + "color": "#262626", + "iconColor": "#262626", + }, + "ghost": { + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "outline": { + "borderColor": "#FFFFFF", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "tint": { + "backgroundColor": "antiquewhite", + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + }, + "success": { + "filled": { + "backgroundColor": "#107c10", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#107c10", + "iconColor": "#107c10", + }, + "outline": { + "borderColor": "#107c10", + "color": "#107c10", + "iconColor": "#107c10", + }, + "tint": { + "backgroundColor": "#f1faf1", + "borderColor": "#9fd89f", + "color": "#107c10", + "iconColor": "#107c10", + }, + }, + "warning": { + "filled": { + "backgroundColor": "#fde300", + "color": "#242424", + "iconColor": "#242424", + }, + "ghost": { + "color": "#817400", + "iconColor": "#817400", + }, + "outline": { + "borderColor": "#817400", + "color": "#817400", + "iconColor": "#817400", + }, + "tint": { + "backgroundColor": "#fffef5", + "borderColor": "#fef7b2", + "color": "#817400", + "iconColor": "#817400", + }, + }, +} +`; + +exports[`pins CounterBadge color tokens on Windows 1`] = ` +{ + "backgroundColor": "#185abd", + "borderColor": "#00000000", + "brand": { + "filled": { + "backgroundColor": "#185abd", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#aec6eb", + "iconColor": "#aec6eb", + }, + "outline": { + "borderColor": "#aec6eb", + "color": "#aec6eb", + "iconColor": "#aec6eb", + }, + "tint": { + "backgroundColor": "#d2e0f4", + "borderColor": "#d2e0f4", + "color": "#d2e0f4", + "iconColor": "#d2e0f4", + }, + }, + "color": "#FFFFFF", + "danger": { + "filled": { + "backgroundColor": "#d13438", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#d13438", + "iconColor": "#d13438", + }, + "outline": { + "borderColor": "#d13438", + "color": "#d13438", + "iconColor": "#d13438", + }, + "tint": { + "backgroundColor": "#fdf6f6", + "borderColor": "#f1bbbc", + "color": "#d13438", + "iconColor": "#d13438", + }, + }, + "filled": { + "borderColor": "#00000000", + }, + "ghost": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + }, + "important": { + "filled": { + "backgroundColor": "#262626", + "color": "antiquewhite", + "iconColor": "antiquewhite", + }, + "ghost": { + "color": "#262626", + "iconColor": "#262626", + }, + "outline": { + "borderColor": "#969696", + "color": "#616161", + "iconColor": "#616161", + }, + "tint": { + "backgroundColor": "#616161", + "borderColor": "#969696", + "color": "antiquewhite", + "iconColor": "antiquewhite", + }, + }, + "informative": { + "filled": { + "backgroundColor": "#ebebeb", + "color": "#616161", + "iconColor": "#616161", + }, + "ghost": { + "color": "#616161", + "iconColor": "#616161", + }, + "outline": { + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + "tint": { + "backgroundColor": "#f0f0f0", + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + }, + "outline": { + "backgroundColor": "#00000000", + }, + "severe": { + "filled": { + "backgroundColor": "#da3b01", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#da3b01", + "iconColor": "#da3b01", + }, + "outline": { + "borderColor": "#da3b01", + "color": "#da3b01", + "iconColor": "#da3b01", + }, + "tint": { + "backgroundColor": "#fdf6f3", + "borderColor": "#f4beaa", + "color": "#c33400", + "iconColor": "#c33400", + }, + }, + "subtle": { + "filled": { + "backgroundColor": "antiquewhite", + "color": "#262626", + "iconColor": "#262626", + }, + "ghost": { + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "outline": { + "borderColor": "#FFFFFF", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "tint": { + "backgroundColor": "antiquewhite", + "borderColor": "#262626", + "color": "#616161", + "iconColor": "#616161", + }, + }, + "success": { + "filled": { + "backgroundColor": "#107c10", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "ghost": { + "color": "#107c10", + "iconColor": "#107c10", + }, + "outline": { + "borderColor": "#107c10", + "color": "#107c10", + "iconColor": "#107c10", + }, + "tint": { + "backgroundColor": "#f1faf1", + "borderColor": "#9fd89f", + "color": "#107c10", + "iconColor": "#107c10", + }, + }, + "warning": { + "filled": { + "backgroundColor": "#fde300", + "color": "#242424", + "iconColor": "#242424", + }, + "ghost": { + "color": "#817400", + "iconColor": "#817400", + }, + "outline": { + "borderColor": "#817400", + "color": "#817400", + "iconColor": "#817400", + }, + "tint": { + "backgroundColor": "#fffef5", + "borderColor": "#fef7b2", + "color": "#817400", + "iconColor": "#817400", + }, + }, +} +`; + +exports[`pins PresenceBadge color tokens on Windows 1`] = ` +{ + "available": { + "iconColor": "#13a10e", + "outOfOffice": { + "iconColor": "#13a10e", + }, + }, + "away": { + "iconColor": "#eaa300", + "outOfOffice": { + "iconColor": "#c239b3", + }, + }, + "backgroundColor": "antiquewhite", + "blocked": { + "iconColor": "#d13438", + "outOfOffice": { + "iconColor": "#d13438", + }, + }, + "borderColor": "#ffffff", + "busy": { + "iconColor": "#d13438", + "outOfOffice": { + "iconColor": "#d13438", + }, + }, + "doNotDisturb": { + "iconColor": "#d13438", + "outOfOffice": { + "iconColor": "#d13438", + }, + }, + "iconColor": "#13a10e", + "offline": { + "iconColor": "#616161", + }, + "outOfOffice": { + "iconColor": "#c239b3", + "outOfOffice": { + "iconColor": "#c239b3", + }, + }, + "unknown": { + "iconColor": "#d13438", + "outOfOffice": { + "iconColor": "#d13438", + }, + }, +} +`; diff --git a/packages/components/Button/src/ButtonColorTokens.ios.ts b/packages/components/Button/src/ButtonColorTokens.ios.ts new file mode 100644 index 00000000000..76a767f07eb --- /dev/null +++ b/packages/components/Button/src/ButtonColorTokens.ios.ts @@ -0,0 +1,88 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { ButtonTokens } from './Button.types'; + +export const defaultButtonColorTokens: TokenSettings = (t: Theme) => + ({ + backgroundColor: t.colors.buttonBackground, + color: t.colors.buttonText, + borderColor: t.colors.buttonBorder, + iconColor: t.colors.buttonIcon, + disabled: { + backgroundColor: t.colors.defaultDisabledBackground, + color: t.colors.defaultDisabledContent, + borderColor: t.colors.defaultDisabledBorder, + iconColor: t.colors.defaultDisabledIcon, + }, + hovered: { + backgroundColor: t.colors.defaultHoveredBackground, + color: t.colors.defaultHoveredContent, + borderColor: t.colors.defaultHoveredBorder, + iconColor: t.colors.defaultHoveredIcon, + }, + pressed: { + backgroundColor: t.colors.defaultPressedBackground, + color: t.colors.defaultPressedContent, + borderColor: t.colors.defaultPressedBorder, + iconColor: t.colors.defaultPressedIcon, + }, + focused: { + backgroundColor: t.colors.defaultFocusedBackground, + color: t.colors.defaultFocusedContent, + borderColor: t.colors.defaultFocusedBorder, + icon: t.colors.defaultFocusedIcon, + }, + primary: { + backgroundColor: t.colors.brandBackground, + color: t.colors.neutralForegroundOnColor, + borderColor: t.colors.brandStroke1, + iconColor: t.colors.neutralForegroundOnColor, + disabled: { + backgroundColor: t.colors.brandBackgroundDisabled, + color: t.colors.neutralForegroundDisabled1, + iconColor: t.colors.neutralForegroundDisabled1, + }, + pressed: { + backgroundColor: t.colors.brandBackgroundPressed, + color: t.colors.neutralForegroundOnColor, + iconColor: t.colors.neutralForegroundOnColor, + }, + focused: { + backgroundColor: t.colors.brandBackground, + color: t.colors.neutralForegroundOnColor, + borderColor: t.colors.strokeFocus2, + iconColor: t.colors.neutralForegroundOnColor, + }, + }, + subtle: { + backgroundColor: t.colors.ghostBackground, + color: t.colors.ghostContent, + borderColor: t.colors.ghostBorder, + iconColor: t.colors.ghostIcon, + disabled: { + color: t.colors.ghostDisabledContent, + borderColor: t.colors.ghostDisabledBorder, + backgroundColor: t.colors.ghostDisabledBackground, + iconColor: t.colors.ghostDisabledIcon, + }, + hovered: { + backgroundColor: t.colors.ghostHoveredBackground, + color: t.colors.ghostHoveredContent, + borderColor: t.colors.ghostHoveredBorder, + iconColor: t.colors.ghostHoveredIcon, + }, + pressed: { + backgroundColor: t.colors.ghostPressedBackground, + borderColor: t.colors.ghostPressedBorder, + color: t.colors.ghostPressedContent, + icon: t.colors.ghostPressedIcon, + }, + focused: { + borderColor: t.colors.ghostFocusedBorder, + backgroundColor: t.colors.ghostFocusedBackground, + color: t.colors.ghostFocusedContent, + icon: t.colors.ghostFocusedIcon, + }, + }, + }) as ButtonTokens; diff --git a/packages/components/Button/src/ButtonColorTokens.ts b/packages/components/Button/src/ButtonColorTokens.ts index 76a767f07eb..3bd71cdedbf 100644 --- a/packages/components/Button/src/ButtonColorTokens.ts +++ b/packages/components/Button/src/ButtonColorTokens.ts @@ -1,88 +1,133 @@ +import { PlatformColor } from 'react-native'; + import type { Theme } from '@fluentui-react-native/framework'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { ButtonTokens } from './Button.types'; -export const defaultButtonColorTokens: TokenSettings = (t: Theme) => - ({ - backgroundColor: t.colors.buttonBackground, - color: t.colors.buttonText, - borderColor: t.colors.buttonBorder, - iconColor: t.colors.buttonIcon, +export const defaultButtonColorTokens: TokenSettings = (t: Theme) => { + if (isHighContrast(t)) { + return highContrastColors; + } + + return { + backgroundColor: t.colors.neutralBackground1, + color: t.colors.neutralForeground1, + borderColor: t.colors.neutralStroke1, + iconColor: t.colors.neutralForeground1, disabled: { - backgroundColor: t.colors.defaultDisabledBackground, - color: t.colors.defaultDisabledContent, - borderColor: t.colors.defaultDisabledBorder, - iconColor: t.colors.defaultDisabledIcon, + backgroundColor: t.colors.neutralBackgroundDisabled, + color: t.colors.neutralForegroundDisabled, + borderColor: t.colors.neutralStrokeDisabled, + iconColor: t.colors.neutralForegroundDisabled, }, hovered: { - backgroundColor: t.colors.defaultHoveredBackground, - color: t.colors.defaultHoveredContent, - borderColor: t.colors.defaultHoveredBorder, - iconColor: t.colors.defaultHoveredIcon, + backgroundColor: t.colors.neutralBackground1Hover, + color: t.colors.neutralForeground1Hover, + borderColor: t.colors.neutralStroke1, + iconColor: t.colors.neutralForeground1Hover, }, pressed: { - backgroundColor: t.colors.defaultPressedBackground, - color: t.colors.defaultPressedContent, - borderColor: t.colors.defaultPressedBorder, - iconColor: t.colors.defaultPressedIcon, + backgroundColor: t.colors.neutralBackground1Pressed, + color: t.colors.neutralForeground1Pressed, + borderColor: t.colors.neutralStroke1, + iconColor: t.colors.neutralForeground1Pressed, }, focused: { - backgroundColor: t.colors.defaultFocusedBackground, - color: t.colors.defaultFocusedContent, - borderColor: t.colors.defaultFocusedBorder, - icon: t.colors.defaultFocusedIcon, + backgroundColor: t.colors.neutralBackground1Hover, + color: t.colors.neutralForeground1Hover, + borderColor: t.colors.transparentStroke, + iconColor: t.colors.neutralForeground1Hover, }, primary: { backgroundColor: t.colors.brandBackground, - color: t.colors.neutralForegroundOnColor, + color: t.colors.neutralForegroundOnBrand, borderColor: t.colors.brandStroke1, - iconColor: t.colors.neutralForegroundOnColor, + iconColor: t.colors.neutralForegroundOnBrand, disabled: { - backgroundColor: t.colors.brandBackgroundDisabled, - color: t.colors.neutralForegroundDisabled1, - iconColor: t.colors.neutralForegroundDisabled1, + backgroundColor: t.colors.neutralBackgroundDisabled, + color: t.colors.neutralForegroundDisabled, + borderColor: t.colors.neutralStrokeDisabled, + iconColor: t.colors.neutralForegroundDisabled, + }, + hovered: { + backgroundColor: t.colors.brandBackgroundHover, + color: t.colors.neutralForegroundOnBrandHover, + borderColor: t.colors.brandBackgroundHover, + iconColor: t.colors.neutralForegroundOnBrandHover, }, pressed: { backgroundColor: t.colors.brandBackgroundPressed, - color: t.colors.neutralForegroundOnColor, - iconColor: t.colors.neutralForegroundOnColor, + color: t.colors.neutralForegroundOnBrandPressed, + borderColor: t.colors.brandBackgroundPressed, + iconColor: t.colors.neutralForegroundOnBrandPressed, }, focused: { - backgroundColor: t.colors.brandBackground, - color: t.colors.neutralForegroundOnColor, + backgroundColor: t.colors.brandBackgroundHover, + color: t.colors.neutralForegroundOnBrandHover, borderColor: t.colors.strokeFocus2, - iconColor: t.colors.neutralForegroundOnColor, + borderInnerColor: t.colors.strokeFocus1, + iconColor: t.colors.neutralForegroundOnBrandHover, }, }, subtle: { - backgroundColor: t.colors.ghostBackground, - color: t.colors.ghostContent, - borderColor: t.colors.ghostBorder, - iconColor: t.colors.ghostIcon, + backgroundColor: t.colors.subtleBackground, + color: t.colors.neutralForeground1, + borderColor: t.colors.transparentStroke, + iconColor: t.colors.neutralForeground1, disabled: { - color: t.colors.ghostDisabledContent, - borderColor: t.colors.ghostDisabledBorder, - backgroundColor: t.colors.ghostDisabledBackground, - iconColor: t.colors.ghostDisabledIcon, + backgroundColor: t.colors.subtleBackground, + color: t.colors.neutralForegroundDisabled, + borderColor: t.colors.transparentStroke, + iconColor: t.colors.neutralForegroundDisabled, }, hovered: { - backgroundColor: t.colors.ghostHoveredBackground, - color: t.colors.ghostHoveredContent, - borderColor: t.colors.ghostHoveredBorder, - iconColor: t.colors.ghostHoveredIcon, + backgroundColor: t.colors.subtleBackgroundHover, + color: t.colors.neutralForeground1Hover, + borderColor: t.colors.subtleBackgroundHover, + iconColor: t.colors.neutralForeground1Hover, }, pressed: { - backgroundColor: t.colors.ghostPressedBackground, - borderColor: t.colors.ghostPressedBorder, - color: t.colors.ghostPressedContent, - icon: t.colors.ghostPressedIcon, + backgroundColor: t.colors.subtleBackgroundPressed, + color: t.colors.neutralForeground1Pressed, + borderColor: t.colors.subtleBackgroundPressed, + iconColor: t.colors.neutralForeground1Pressed, }, focused: { - borderColor: t.colors.ghostFocusedBorder, - backgroundColor: t.colors.ghostFocusedBackground, - color: t.colors.ghostFocusedContent, - icon: t.colors.ghostFocusedIcon, + backgroundColor: t.colors.subtleBackgroundHover, + color: t.colors.neutralForeground1Hover, + borderColor: t.colors.transparentStroke, + iconColor: t.colors.neutralForeground1Hover, }, }, - }) as ButtonTokens; + } as ButtonTokens; +}; + +const highContrastColors = { + backgroundColor: PlatformColor('ButtonFace'), + borderColor: PlatformColor('ButtonText'), + color: PlatformColor('ButtonText'), + iconColor: PlatformColor('ButtonText'), + disabled: { + backgroundColor: PlatformColor('ButtonFace'), + borderColor: PlatformColor('GrayText'), + color: PlatformColor('GrayText'), + iconColor: PlatformColor('GrayText'), + }, + hovered: { + backgroundColor: PlatformColor('Highlight'), + color: PlatformColor('HighlightText'), + iconColor: PlatformColor('HighlightText'), + }, + pressed: { + backgroundColor: PlatformColor('Highlight'), + color: PlatformColor('HighlightText'), + iconColor: PlatformColor('HighlightText'), + }, + focused: { + backgroundColor: PlatformColor('Highlight'), + color: PlatformColor('HighlightText'), + iconColor: PlatformColor('HighlightText'), + }, +}; diff --git a/packages/components/Button/src/ButtonColorTokens.win32.ts b/packages/components/Button/src/ButtonColorTokens.win32.ts deleted file mode 100644 index 3bd71cdedbf..00000000000 --- a/packages/components/Button/src/ButtonColorTokens.win32.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ButtonTokens } from './Button.types'; - -export const defaultButtonColorTokens: TokenSettings = (t: Theme) => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - backgroundColor: t.colors.neutralBackground1, - color: t.colors.neutralForeground1, - borderColor: t.colors.neutralStroke1, - iconColor: t.colors.neutralForeground1, - disabled: { - backgroundColor: t.colors.neutralBackgroundDisabled, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.neutralStrokeDisabled, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.neutralStroke1, - iconColor: t.colors.neutralForeground1Hover, - }, - pressed: { - backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground1Pressed, - borderColor: t.colors.neutralStroke1, - iconColor: t.colors.neutralForeground1Pressed, - }, - focused: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForeground1Hover, - }, - primary: { - backgroundColor: t.colors.brandBackground, - color: t.colors.neutralForegroundOnBrand, - borderColor: t.colors.brandStroke1, - iconColor: t.colors.neutralForegroundOnBrand, - disabled: { - backgroundColor: t.colors.neutralBackgroundDisabled, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.neutralStrokeDisabled, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.brandBackgroundHover, - color: t.colors.neutralForegroundOnBrandHover, - borderColor: t.colors.brandBackgroundHover, - iconColor: t.colors.neutralForegroundOnBrandHover, - }, - pressed: { - backgroundColor: t.colors.brandBackgroundPressed, - color: t.colors.neutralForegroundOnBrandPressed, - borderColor: t.colors.brandBackgroundPressed, - iconColor: t.colors.neutralForegroundOnBrandPressed, - }, - focused: { - backgroundColor: t.colors.brandBackgroundHover, - color: t.colors.neutralForegroundOnBrandHover, - borderColor: t.colors.strokeFocus2, - borderInnerColor: t.colors.strokeFocus1, - iconColor: t.colors.neutralForegroundOnBrandHover, - }, - }, - subtle: { - backgroundColor: t.colors.subtleBackground, - color: t.colors.neutralForeground1, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForeground1, - disabled: { - backgroundColor: t.colors.subtleBackground, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.subtleBackgroundHover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.subtleBackgroundHover, - iconColor: t.colors.neutralForeground1Hover, - }, - pressed: { - backgroundColor: t.colors.subtleBackgroundPressed, - color: t.colors.neutralForeground1Pressed, - borderColor: t.colors.subtleBackgroundPressed, - iconColor: t.colors.neutralForeground1Pressed, - }, - focused: { - backgroundColor: t.colors.subtleBackgroundHover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForeground1Hover, - }, - }, - } as ButtonTokens; -}; - -const highContrastColors = { - backgroundColor: PlatformColor('ButtonFace'), - borderColor: PlatformColor('ButtonText'), - color: PlatformColor('ButtonText'), - iconColor: PlatformColor('ButtonText'), - disabled: { - backgroundColor: PlatformColor('ButtonFace'), - borderColor: PlatformColor('GrayText'), - color: PlatformColor('GrayText'), - iconColor: PlatformColor('GrayText'), - }, - hovered: { - backgroundColor: PlatformColor('Highlight'), - color: PlatformColor('HighlightText'), - iconColor: PlatformColor('HighlightText'), - }, - pressed: { - backgroundColor: PlatformColor('Highlight'), - color: PlatformColor('HighlightText'), - iconColor: PlatformColor('HighlightText'), - }, - focused: { - backgroundColor: PlatformColor('Highlight'), - color: PlatformColor('HighlightText'), - iconColor: PlatformColor('HighlightText'), - }, -}; diff --git a/packages/components/Button/src/ButtonColorTokens.windows.ts b/packages/components/Button/src/ButtonColorTokens.windows.ts deleted file mode 100644 index 5c602420982..00000000000 --- a/packages/components/Button/src/ButtonColorTokens.windows.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ButtonTokens } from './Button.types'; - -export const defaultButtonColorTokens: TokenSettings = (t: Theme) => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - backgroundColor: t.colors.neutralBackground1, - color: t.colors.neutralForeground1, - borderColor: t.colors.neutralStroke1, - iconColor: t.colors.neutralForeground1, - disabled: { - backgroundColor: t.colors.neutralBackgroundDisabled, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.neutralStrokeDisabled, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.neutralStroke1Hover, - iconColor: t.colors.neutralForeground1Hover, - }, - pressed: { - backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground1Pressed, - borderColor: t.colors.neutralStroke1Pressed, - iconColor: t.colors.neutralForeground1Pressed, - }, - focused: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.transparentStroke, - icon: t.colors.neutralForeground1Hover, - }, - primary: { - backgroundColor: t.colors.brandBackground, - color: t.colors.neutralForegroundOnBrand, - borderColor: t.colors.brandStroke1, - iconColor: t.colors.neutralForegroundOnBrand, - disabled: { - backgroundColor: t.colors.neutralBackgroundDisabled, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.neutralStrokeDisabled, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.brandBackgroundHover, - color: t.colors.neutralForegroundOnBrandHover, - borderColor: t.colors.brandBackgroundHover, - iconColor: t.colors.neutralForegroundOnBrandHover, - }, - pressed: { - backgroundColor: t.colors.brandBackgroundPressed, - color: t.colors.neutralForegroundOnBrandPressed, - borderColor: t.colors.brandBackgroundPressed, - iconColor: t.colors.neutralForegroundOnBrandPressed, - }, - focused: { - backgroundColor: t.colors.brandBackgroundHover, - color: t.colors.neutralForegroundOnBrandHover, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForegroundOnBrandHover, - }, - }, - subtle: { - backgroundColor: t.colors.subtleBackground, - color: t.colors.neutralForeground1, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForeground2, - disabled: { - backgroundColor: t.colors.subtleBackground, - color: t.colors.neutralForegroundDisabled, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - backgroundColor: t.colors.subtleBackgroundHover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.subtleBackgroundHover, - iconColor: t.colors.neutralForeground2BrandHover, - }, - pressed: { - backgroundColor: t.colors.subtleBackgroundPressed, - color: t.colors.neutralForeground1Pressed, - borderColor: t.colors.subtleBackgroundPressed, - iconColor: t.colors.neutralForeground2BrandPressed, - }, - focused: { - backgroundColor: t.colors.subtleBackgroundHover, - color: t.colors.neutralForeground1Hover, - borderColor: t.colors.transparentStroke, - iconColor: t.colors.neutralForeground1Hover, - }, - }, - } as ButtonTokens; -}; - -const highContrastColors = { - backgroundColor: PlatformColor('SystemColorButtonFaceColor'), - borderColor: PlatformColor('SystemColorButtonTextColor'), - color: PlatformColor('SystemColorButtonTextColor'), - iconColor: PlatformColor('SystemColorButtonTextColor'), - disabled: { - backgroundColor: PlatformColor('SystemColorButtonFaceColor'), - borderColor: PlatformColor('SystemColorGrayTextColor'), - color: PlatformColor('SystemColorGrayTextColor'), - iconColor: PlatformColor('SystemColorGrayTextColor'), - }, - hovered: { - backgroundColor: PlatformColor('SystemColorHighlightColor'), - borderColor: PlatformColor('SystemColorHighlightColor'), - color: PlatformColor('SystemColorHighlightTextColor'), - iconColor: PlatformColor('SystemColorHighlightTextColor'), - }, - pressed: { - backgroundColor: PlatformColor('SystemColorHighlightColor'), - borderColor: PlatformColor('SystemColorHighlightColor'), - color: PlatformColor('SystemColorHighlightTextColor'), - iconColor: PlatformColor('SystemColorHighlightTextColor'), - }, - focused: { - backgroundColor: PlatformColor('SystemColorHighlightColor'), - borderColor: PlatformColor('SystemColorHighlightColor'), - color: PlatformColor('SystemColorHighlightTextColor'), - iconColor: PlatformColor('SystemColorHighlightTextColor'), - }, -}; diff --git a/packages/components/Button/src/ButtonFontTokens.ts b/packages/components/Button/src/ButtonFontTokens.ts index 2a3bf9fafa0..9dc6a6d02b2 100644 --- a/packages/components/Button/src/ButtonFontTokens.ts +++ b/packages/components/Button/src/ButtonFontTokens.ts @@ -1,21 +1,30 @@ import type { Theme } from '@fluentui-react-native/framework'; +import { fontSize200, fontSize300, fontSize400, fontWeightRegular, fontWeightSemibold } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { ButtonTokens } from './Button.types'; -export const defaultButtonFontTokens: TokenSettings = (_t: Theme) => +export const defaultButtonFontTokens: TokenSettings = (t: Theme) => ({ medium: { hasContent: { - variant: 'bodySemibold', + fontFamily: t.typography.families.secondary, + fontSize: fontSize300, + fontWeight: fontWeightSemibold, }, }, small: { hasContent: { - variant: 'secondaryStandard', + fontFamily: t.typography.families.primary, + fontSize: fontSize200, + fontWeight: fontWeightRegular, }, }, large: { - variant: 'subheaderSemibold', + hasContent: { + fontFamily: t.typography.families.secondary, + fontSize: fontSize400, + fontWeight: fontWeightSemibold, + }, }, }) as ButtonTokens; diff --git a/packages/components/Button/src/ButtonFontTokens.win32.ts b/packages/components/Button/src/ButtonFontTokens.win32.ts deleted file mode 100644 index 9dc6a6d02b2..00000000000 --- a/packages/components/Button/src/ButtonFontTokens.win32.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { fontSize200, fontSize300, fontSize400, fontWeightRegular, fontWeightSemibold } from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ButtonTokens } from './Button.types'; - -export const defaultButtonFontTokens: TokenSettings = (t: Theme) => - ({ - medium: { - hasContent: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize300, - fontWeight: fontWeightSemibold, - }, - }, - small: { - hasContent: { - fontFamily: t.typography.families.primary, - fontSize: fontSize200, - fontWeight: fontWeightRegular, - }, - }, - large: { - hasContent: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize400, - fontWeight: fontWeightSemibold, - }, - }, - }) as ButtonTokens; diff --git a/packages/components/Button/src/ButtonTokens.macos.ts b/packages/components/Button/src/ButtonTokens.macos.ts new file mode 100644 index 00000000000..956dce4fb3b --- /dev/null +++ b/packages/components/Button/src/ButtonTokens.macos.ts @@ -0,0 +1,98 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import { + cornerRadius40, + cornerRadiusCircular, + cornerRadiusNone, + size120, + size160, + size40, + size60, + size80, + strokeWidth10, +} from '@fluentui-react-native/design/tokens/global'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { ButtonTokens } from './Button.types'; + +export const defaultButtonTokens: TokenSettings = () => + ({ + block: { + width: '100%', + }, + medium: { + padding: size60 - strokeWidth10, + borderWidth: strokeWidth10, + iconSize: 16, + focused: { + borderWidth: 0, + padding: size60, + }, + hasContent: { + minWidth: 96, + paddingHorizontal: size120 - strokeWidth10, + hasIconAfter: { + spacingIconContentAfter: size60, + }, + hasIconBefore: { + spacingIconContentBefore: size60, + }, + focused: { + paddingHorizontal: size120, + }, + }, + }, + small: { + padding: size40 - strokeWidth10, + borderWidth: strokeWidth10, + iconSize: 16, + focused: { + borderWidth: 0, + padding: size40, + }, + hasContent: { + minWidth: 64, + minHeight: 24, + paddingHorizontal: size80 - strokeWidth10, + hasIconAfter: { + spacingIconContentAfter: size40, + }, + hasIconBefore: { + spacingIconContentBefore: size40, + }, + focused: { + paddingHorizontal: size80, + }, + }, + }, + large: { + padding: size80 - strokeWidth10, + borderWidth: strokeWidth10, + iconSize: 20, + focused: { + borderWidth: 0, + padding: size80, + }, + hasContent: { + minWidth: 96, + paddingHorizontal: size160 - strokeWidth10, + hasIconAfter: { + spacingIconContentAfter: size60, + }, + hasIconBefore: { + spacingIconContentBefore: size60, + }, + focused: { + paddingHorizontal: size160, + }, + }, + }, + rounded: { + borderRadius: cornerRadius40, + }, + circular: { + borderRadius: cornerRadiusCircular, + }, + square: { + borderRadius: cornerRadiusNone, + }, + }) as ButtonTokens; diff --git a/packages/components/Button/src/ButtonTokens.ts b/packages/components/Button/src/ButtonTokens.ts index 956dce4fb3b..17c489862cd 100644 --- a/packages/components/Button/src/ButtonTokens.ts +++ b/packages/components/Button/src/ButtonTokens.ts @@ -3,52 +3,93 @@ import { cornerRadius40, cornerRadiusCircular, cornerRadiusNone, + size100, size120, size160, size40, size60, size80, strokeWidth10, + strokeWidth20, } from '@fluentui-react-native/design/tokens/global'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { ButtonTokens } from './Button.types'; -export const defaultButtonTokens: TokenSettings = () => +export const defaultButtonTokens: TokenSettings = (theme: Theme) => ({ + borderWidth: strokeWidth10, + borderInnerWidth: strokeWidth10, block: { width: '100%', }, medium: { - padding: size60 - strokeWidth10, - borderWidth: strokeWidth10, + padding: size80 - strokeWidth10, iconSize: 16, focused: { borderWidth: 0, - padding: size60, + padding: size80, + }, + primary: !isHighContrast(theme) && { + focused: { + borderWidth: strokeWidth20, + padding: size80 - strokeWidth20, + }, + square: { + focused: { + borderWidth: strokeWidth10, + padding: size80 - strokeWidth10, + }, + }, }, hasContent: { minWidth: 96, + padding: size60 - strokeWidth10, paddingHorizontal: size120 - strokeWidth10, hasIconAfter: { - spacingIconContentAfter: size60, + spacingIconContentAfter: size80, }, hasIconBefore: { - spacingIconContentBefore: size60, + spacingIconContentBefore: size80, }, focused: { + padding: size60, paddingHorizontal: size120, }, + primary: !isHighContrast(theme) && { + focused: { + padding: size60 - strokeWidth20, + paddingHorizontal: size120 - strokeWidth20, + }, + square: { + focused: { + padding: size60 - strokeWidth10, + paddingHorizontal: size120 - strokeWidth10, + }, + }, + }, }, }, small: { padding: size40 - strokeWidth10, - borderWidth: strokeWidth10, iconSize: 16, focused: { borderWidth: 0, padding: size40, }, + primary: !isHighContrast(theme) && { + focused: { + borderWidth: strokeWidth20, + padding: size40 - strokeWidth20, + }, + square: { + focused: { + borderWidth: strokeWidth10, + padding: size40 - strokeWidth10, + }, + }, + }, hasContent: { minWidth: 64, minHeight: 24, @@ -62,18 +103,41 @@ export const defaultButtonTokens: TokenSettings = () => focused: { paddingHorizontal: size80, }, + primary: !isHighContrast(theme) && { + focused: { + paddingHorizontal: size80 - strokeWidth20, + }, + square: { + focused: { + paddingHorizontal: size80 - strokeWidth10, + }, + }, + }, }, }, large: { - padding: size80 - strokeWidth10, - borderWidth: strokeWidth10, + padding: size100 - strokeWidth10, iconSize: 20, focused: { borderWidth: 0, - padding: size80, + padding: size100, + }, + primary: !isHighContrast(theme) && { + focused: { + borderWidth: strokeWidth20, + padding: size100 - strokeWidth20, + }, + square: { + focused: { + borderWidth: strokeWidth10, + padding: size100 - strokeWidth10, + }, + }, }, hasContent: { minWidth: 96, + minHeight: 40, + padding: size80 - strokeWidth10, paddingHorizontal: size160 - strokeWidth10, hasIconAfter: { spacingIconContentAfter: size60, @@ -82,17 +146,33 @@ export const defaultButtonTokens: TokenSettings = () => spacingIconContentBefore: size60, }, focused: { + padding: size80, paddingHorizontal: size160, }, + primary: !isHighContrast(theme) && { + focused: { + padding: size80 - strokeWidth20, + paddingHorizontal: size160 - strokeWidth20, + }, + square: { + focused: { + padding: size80 - strokeWidth10, + paddingHorizontal: size160 - strokeWidth10, + }, + }, + }, }, }, rounded: { borderRadius: cornerRadius40, + borderInnerRadius: cornerRadius40 - 1, // reduce the rounding so that the curvature matches }, circular: { borderRadius: cornerRadiusCircular, + borderInnerRadius: cornerRadiusCircular - 1, // reduce the rounding so that the curvature matches }, square: { borderRadius: cornerRadiusNone, + borderInnerRadius: cornerRadiusNone, }, }) as ButtonTokens; diff --git a/packages/components/Button/src/ButtonTokens.win32.ts b/packages/components/Button/src/ButtonTokens.win32.ts deleted file mode 100644 index 17c489862cd..00000000000 --- a/packages/components/Button/src/ButtonTokens.win32.ts +++ /dev/null @@ -1,178 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { - cornerRadius40, - cornerRadiusCircular, - cornerRadiusNone, - size100, - size120, - size160, - size40, - size60, - size80, - strokeWidth10, - strokeWidth20, -} from '@fluentui-react-native/design/tokens/global'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ButtonTokens } from './Button.types'; - -export const defaultButtonTokens: TokenSettings = (theme: Theme) => - ({ - borderWidth: strokeWidth10, - borderInnerWidth: strokeWidth10, - block: { - width: '100%', - }, - medium: { - padding: size80 - strokeWidth10, - iconSize: 16, - focused: { - borderWidth: 0, - padding: size80, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size80 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size80 - strokeWidth10, - }, - }, - }, - hasContent: { - minWidth: 96, - padding: size60 - strokeWidth10, - paddingHorizontal: size120 - strokeWidth10, - hasIconAfter: { - spacingIconContentAfter: size80, - }, - hasIconBefore: { - spacingIconContentBefore: size80, - }, - focused: { - padding: size60, - paddingHorizontal: size120, - }, - primary: !isHighContrast(theme) && { - focused: { - padding: size60 - strokeWidth20, - paddingHorizontal: size120 - strokeWidth20, - }, - square: { - focused: { - padding: size60 - strokeWidth10, - paddingHorizontal: size120 - strokeWidth10, - }, - }, - }, - }, - }, - small: { - padding: size40 - strokeWidth10, - iconSize: 16, - focused: { - borderWidth: 0, - padding: size40, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size40 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size40 - strokeWidth10, - }, - }, - }, - hasContent: { - minWidth: 64, - minHeight: 24, - paddingHorizontal: size80 - strokeWidth10, - hasIconAfter: { - spacingIconContentAfter: size40, - }, - hasIconBefore: { - spacingIconContentBefore: size40, - }, - focused: { - paddingHorizontal: size80, - }, - primary: !isHighContrast(theme) && { - focused: { - paddingHorizontal: size80 - strokeWidth20, - }, - square: { - focused: { - paddingHorizontal: size80 - strokeWidth10, - }, - }, - }, - }, - }, - large: { - padding: size100 - strokeWidth10, - iconSize: 20, - focused: { - borderWidth: 0, - padding: size100, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size100 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size100 - strokeWidth10, - }, - }, - }, - hasContent: { - minWidth: 96, - minHeight: 40, - padding: size80 - strokeWidth10, - paddingHorizontal: size160 - strokeWidth10, - hasIconAfter: { - spacingIconContentAfter: size60, - }, - hasIconBefore: { - spacingIconContentBefore: size60, - }, - focused: { - padding: size80, - paddingHorizontal: size160, - }, - primary: !isHighContrast(theme) && { - focused: { - padding: size80 - strokeWidth20, - paddingHorizontal: size160 - strokeWidth20, - }, - square: { - focused: { - padding: size80 - strokeWidth10, - paddingHorizontal: size160 - strokeWidth10, - }, - }, - }, - }, - }, - rounded: { - borderRadius: cornerRadius40, - borderInnerRadius: cornerRadius40 - 1, // reduce the rounding so that the curvature matches - }, - circular: { - borderRadius: cornerRadiusCircular, - borderInnerRadius: cornerRadiusCircular - 1, // reduce the rounding so that the curvature matches - }, - square: { - borderRadius: cornerRadiusNone, - borderInnerRadius: cornerRadiusNone, - }, - }) as ButtonTokens; diff --git a/packages/components/Button/src/ColorTokens.test.windows.ts b/packages/components/Button/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..a1007b1fa6c --- /dev/null +++ b/packages/components/Button/src/ColorTokens.test.windows.ts @@ -0,0 +1,41 @@ +import { createColorPinningTheme, resolveV0ColorTokens, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings as buttonStylingSettings } from './Button.styling'; +import { stylingSettings as compoundButtonStylingSettings } from './CompoundButton/CompoundButton.styling'; +import { stylingSettings as fabStylingSettings } from './FAB/FAB.styling'; +import { stylingSettings as toggleButtonStylingSettings } from './ToggleButton/ToggleButton.styling'; +import { settings as buttonSettings } from './deprecated/Button.settings'; +import { settings as primaryButtonSettings } from './deprecated/PrimaryButton/PrimaryButton.settings'; +import { settings as stealthButtonSettings } from './deprecated/StealthButton/StealthButton.settings'; + +const theme = createColorPinningTheme(); + +describe('Button color tokens', () => { + it('pins v0 Button color tokens', () => { + expect(resolveV0ColorTokens(buttonSettings, theme)).toMatchSnapshot(); + }); + + it('pins v0 PrimaryButton color tokens', () => { + expect(resolveV0ColorTokens(primaryButtonSettings, theme)).toMatchSnapshot(); + }); + + it('pins v0 StealthButton color tokens', () => { + expect(resolveV0ColorTokens(stealthButtonSettings, theme)).toMatchSnapshot(); + }); + + it('pins v1 Button color tokens', () => { + expect(resolveV1ColorTokens(buttonStylingSettings.tokens, theme)).toMatchSnapshot(); + }); + + it('pins v1 CompoundButton color tokens', () => { + expect(resolveV1ColorTokens(compoundButtonStylingSettings.tokens, theme)).toMatchSnapshot(); + }); + + it('pins v1 FAB color tokens', () => { + expect(resolveV1ColorTokens(fabStylingSettings.tokens, theme)).toMatchSnapshot(); + }); + + it('pins v1 ToggleButton color tokens', () => { + expect(resolveV1ColorTokens(toggleButtonStylingSettings.tokens, theme)).toMatchSnapshot(); + }); +}); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.macos.ts b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.macos.ts new file mode 100644 index 00000000000..6e739edfee6 --- /dev/null +++ b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.macos.ts @@ -0,0 +1,41 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { CompoundButtonTokens } from './CompoundButton.types'; + +export const defaultCompoundButtonColorTokens: TokenSettings = (t: Theme): CompoundButtonTokens => ({ + secondaryContentColor: t.colors.defaultSecondaryContent, + hovered: { + secondaryContentColor: t.colors.defaultHoveredSecondaryContent, + }, + focused: { + secondaryContentColor: t.colors.defaultFocusedSecondaryContent, + }, + pressed: { + secondaryContentColor: t.colors.defaultPressedSecondaryContent, + }, + primary: { + secondaryContentColor: t.colors.brandedSecondaryContent, + hovered: { + secondaryContentColor: t.colors.brandedHoveredSecondaryContent, + }, + focused: { + secondaryContentColor: t.colors.brandedFocusedSecondaryContent, + }, + pressed: { + secondaryContentColor: t.colors.brandedPressedSecondaryContent, + }, + }, + subtle: { + secondaryContentColor: t.colors.ghostSecondaryContent, + hovered: { + secondaryContentColor: t.colors.ghostHoveredSecondaryContent, + }, + focused: { + secondaryContentColor: t.colors.ghostFocusedSecondaryContent, + }, + pressed: { + secondaryContentColor: t.colors.ghostPressedSecondaryContent, + }, + }, +}); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.ts b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.ts index 6e739edfee6..51b5e580421 100644 --- a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.ts +++ b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.ts @@ -1,41 +1,69 @@ +import { PlatformColor } from 'react-native'; + import type { Theme } from '@fluentui-react-native/framework'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { CompoundButtonTokens } from './CompoundButton.types'; -export const defaultCompoundButtonColorTokens: TokenSettings = (t: Theme): CompoundButtonTokens => ({ - secondaryContentColor: t.colors.defaultSecondaryContent, - hovered: { - secondaryContentColor: t.colors.defaultHoveredSecondaryContent, - }, - focused: { - secondaryContentColor: t.colors.defaultFocusedSecondaryContent, - }, - pressed: { - secondaryContentColor: t.colors.defaultPressedSecondaryContent, - }, - primary: { - secondaryContentColor: t.colors.brandedSecondaryContent, +export const defaultCompoundButtonColorTokens: TokenSettings = (t: Theme): CompoundButtonTokens => { + if (isHighContrast(t)) { + return highContrastColors; + } + + return { + secondaryContentColor: t.colors.neutralForeground2, + disabled: { + secondaryContentColor: t.colors.neutralForegroundDisabled, + }, hovered: { - secondaryContentColor: t.colors.brandedHoveredSecondaryContent, + secondaryContentColor: t.colors.neutralForeground2Hover, }, focused: { - secondaryContentColor: t.colors.brandedFocusedSecondaryContent, + secondaryContentColor: t.colors.neutralForeground2Hover, }, pressed: { - secondaryContentColor: t.colors.brandedPressedSecondaryContent, + secondaryContentColor: t.colors.neutralForeground2Pressed, }, - }, - subtle: { - secondaryContentColor: t.colors.ghostSecondaryContent, - hovered: { - secondaryContentColor: t.colors.ghostHoveredSecondaryContent, + primary: { + secondaryContentColor: t.colors.neutralForegroundOnBrand, + hovered: { + secondaryContentColor: t.colors.neutralForegroundOnBrandHover, + }, + focused: { + secondaryContentColor: t.colors.neutralForegroundOnBrandHover, + }, + pressed: { + secondaryContentColor: t.colors.neutralForegroundOnBrandPressed, + }, }, - focused: { - secondaryContentColor: t.colors.ghostFocusedSecondaryContent, - }, - pressed: { - secondaryContentColor: t.colors.ghostPressedSecondaryContent, + subtle: { + secondaryContentColor: t.colors.neutralForeground2, + hovered: { + secondaryContentColor: t.colors.neutralForeground2Hover, + }, + focused: { + secondaryContentColor: t.colors.neutralForeground2Hover, + }, + pressed: { + secondaryContentColor: t.colors.neutralForeground2Pressed, + }, }, + }; +}; + +const highContrastColors = { + secondaryContentColor: PlatformColor('ButtonText'), + disabled: { + secondaryContentColor: PlatformColor('GrayText'), + }, + hovered: { + secondaryContentColor: PlatformColor('HighlightText'), + }, + focused: { + secondaryContentColor: PlatformColor('HighlightText'), + }, + pressed: { + secondaryContentColor: PlatformColor('HighlightText'), }, -}); +}; diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.win32.ts b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.win32.ts deleted file mode 100644 index 51b5e580421..00000000000 --- a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.win32.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { CompoundButtonTokens } from './CompoundButton.types'; - -export const defaultCompoundButtonColorTokens: TokenSettings = (t: Theme): CompoundButtonTokens => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - secondaryContentColor: t.colors.neutralForeground2, - disabled: { - secondaryContentColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - focused: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForeground2Pressed, - }, - primary: { - secondaryContentColor: t.colors.neutralForegroundOnBrand, - hovered: { - secondaryContentColor: t.colors.neutralForegroundOnBrandHover, - }, - focused: { - secondaryContentColor: t.colors.neutralForegroundOnBrandHover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForegroundOnBrandPressed, - }, - }, - subtle: { - secondaryContentColor: t.colors.neutralForeground2, - hovered: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - focused: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForeground2Pressed, - }, - }, - }; -}; - -const highContrastColors = { - secondaryContentColor: PlatformColor('ButtonText'), - disabled: { - secondaryContentColor: PlatformColor('GrayText'), - }, - hovered: { - secondaryContentColor: PlatformColor('HighlightText'), - }, - focused: { - secondaryContentColor: PlatformColor('HighlightText'), - }, - pressed: { - secondaryContentColor: PlatformColor('HighlightText'), - }, -}; diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.windows.ts b/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.windows.ts deleted file mode 100644 index c67494bfc30..00000000000 --- a/packages/components/Button/src/CompoundButton/CompoundButtonColorTokens.windows.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { CompoundButtonTokens } from './CompoundButton.types'; - -export const defaultCompoundButtonColorTokens: TokenSettings = (t: Theme): CompoundButtonTokens => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - secondaryContentColor: t.colors.neutralForeground2, - disabled: { - secondaryContentColor: t.colors.neutralForegroundDisabled, - }, - hovered: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - focused: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForeground2Pressed, - }, - primary: { - secondaryContentColor: t.colors.neutralForegroundOnBrand, - hovered: { - secondaryContentColor: t.colors.neutralForegroundOnBrandHover, - }, - focused: { - secondaryContentColor: t.colors.neutralForegroundOnBrandHover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForegroundOnBrandPressed, - }, - }, - subtle: { - secondaryContentColor: t.colors.neutralForeground2, - hovered: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - focused: { - secondaryContentColor: t.colors.neutralForeground2Hover, - }, - pressed: { - secondaryContentColor: t.colors.neutralForeground2Pressed, - }, - }, - }; -}; - -const highContrastColors = { - secondaryContentColor: PlatformColor('SystemColorButtonTextColor'), - disabled: { - secondaryContentColor: PlatformColor('SystemColorGrayTextColor'), - }, - hovered: { - secondaryContentColor: PlatformColor('SystemColorHighlightTextColor'), - }, - focused: { - secondaryContentColor: PlatformColor('SystemColorHighlightTextColor'), - }, - pressed: { - secondaryContentColor: PlatformColor('SystemColorHighlightTextColor'), - }, -}; diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.macos.ts b/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.macos.ts new file mode 100644 index 00000000000..d278051a826 --- /dev/null +++ b/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.macos.ts @@ -0,0 +1,25 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { CompoundButtonTokens } from './CompoundButton.types'; + +export const defaultCompoundButtonFontTokens: TokenSettings = (_t: Theme): CompoundButtonTokens => ({ + medium: { + hasContent: { + variant: 'bodySemibold', + secondaryContentFont: { variant: 'secondaryStandard' }, + }, + }, + small: { + hasContent: { + variant: 'bodyStandard', + secondaryContentFont: { variant: 'secondaryStandard' }, + }, + }, + large: { + hasContent: { + variant: 'subheaderSemibold', + secondaryContentFont: { variant: 'bodyStandard' }, + }, + }, +}); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.ts b/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.ts index d278051a826..6bc5d88fa1d 100644 --- a/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.ts +++ b/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.ts @@ -1,25 +1,44 @@ -import type { Theme } from '@fluentui-react-native/framework'; +import type { FontWeightValue, Theme } from '@fluentui-react-native/framework'; +import { fontSize100, fontSize200, fontSize400, fontWeightRegular, fontWeightSemibold } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { CompoundButtonTokens } from './CompoundButton.types'; -export const defaultCompoundButtonFontTokens: TokenSettings = (_t: Theme): CompoundButtonTokens => ({ +export const defaultCompoundButtonFontTokens: TokenSettings = (t: Theme): CompoundButtonTokens => ({ medium: { hasContent: { - variant: 'bodySemibold', - secondaryContentFont: { variant: 'secondaryStandard' }, + fontFamily: t.typography.families.secondary, + fontSize: fontSize200, + fontWeight: fontWeightSemibold as FontWeightValue, + secondaryContentFont: { + fontFamily: t.typography.families.secondary, + fontSize: fontSize100, + fontWeight: fontWeightSemibold as FontWeightValue, + }, }, }, small: { hasContent: { - variant: 'bodyStandard', - secondaryContentFont: { variant: 'secondaryStandard' }, + fontFamily: t.typography.families.primary, + fontSize: fontSize200, + fontWeight: fontWeightRegular as FontWeightValue, + secondaryContentFont: { + fontFamily: t.typography.families.secondary, + fontSize: fontSize100, + fontWeight: fontWeightSemibold as FontWeightValue, + }, }, }, large: { hasContent: { - variant: 'subheaderSemibold', - secondaryContentFont: { variant: 'bodyStandard' }, + fontFamily: t.typography.families.secondary, + fontSize: fontSize400, + fontWeight: fontWeightSemibold as FontWeightValue, + secondaryContentFont: { + fontFamily: t.typography.families.primary, + fontSize: fontSize200, + fontWeight: fontWeightRegular as FontWeightValue, + }, }, }, }); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.win32.ts b/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.win32.ts deleted file mode 100644 index 6bc5d88fa1d..00000000000 --- a/packages/components/Button/src/CompoundButton/CompoundButtonFontTokens.win32.ts +++ /dev/null @@ -1,44 +0,0 @@ -import type { FontWeightValue, Theme } from '@fluentui-react-native/framework'; -import { fontSize100, fontSize200, fontSize400, fontWeightRegular, fontWeightSemibold } from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { CompoundButtonTokens } from './CompoundButton.types'; - -export const defaultCompoundButtonFontTokens: TokenSettings = (t: Theme): CompoundButtonTokens => ({ - medium: { - hasContent: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize200, - fontWeight: fontWeightSemibold as FontWeightValue, - secondaryContentFont: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize100, - fontWeight: fontWeightSemibold as FontWeightValue, - }, - }, - }, - small: { - hasContent: { - fontFamily: t.typography.families.primary, - fontSize: fontSize200, - fontWeight: fontWeightRegular as FontWeightValue, - secondaryContentFont: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize100, - fontWeight: fontWeightSemibold as FontWeightValue, - }, - }, - }, - large: { - hasContent: { - fontFamily: t.typography.families.secondary, - fontSize: fontSize400, - fontWeight: fontWeightSemibold as FontWeightValue, - secondaryContentFont: { - fontFamily: t.typography.families.primary, - fontSize: fontSize200, - fontWeight: fontWeightRegular as FontWeightValue, - }, - }, - }, -}); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonTokens.macos.ts b/packages/components/Button/src/CompoundButton/CompoundButtonTokens.macos.ts new file mode 100644 index 00000000000..94b8b87169b --- /dev/null +++ b/packages/components/Button/src/CompoundButton/CompoundButtonTokens.macos.ts @@ -0,0 +1,83 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import { size120, size160, size200, size80, strokeWidth10 } from '@fluentui-react-native/design/tokens/global'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { CompoundButtonTokens } from './CompoundButton.types'; + +export const defaultCompoundButtonTokens: TokenSettings = (): CompoundButtonTokens => ({ + medium: { + padding: size120 - strokeWidth10, + focused: { + padding: size120, + }, + hasContent: { + paddingHorizontal: size120 - strokeWidth10, + minWidth: 96, + focused: { + paddingHorizontal: size120, + }, + hasIconAfter: { + spacingIconContentAfter: size120, + }, + hasIconBefore: { + spacingIconContentBefore: size120, + }, + circular: { + paddingHorizontal: size160 - strokeWidth10, + focused: { + paddingHorizontal: size160, + }, + }, + }, + }, + small: { + padding: size80 - strokeWidth10, + focused: { + padding: size80, + }, + hasContent: { + paddingHorizontal: size80 - strokeWidth10, + minWidth: 64, + focused: { + paddingHorizontal: size80, + }, + hasIconAfter: { + spacingIconContentAfter: size80, + }, + hasIconBefore: { + spacingIconContentBefore: size80, + }, + circular: { + paddingHorizontal: size120 - strokeWidth10, + focused: { + paddingHorizontal: size120, + }, + }, + }, + }, + large: { + padding: size160 - strokeWidth10, + focused: { + padding: size160, + }, + hasContent: { + paddingHorizontal: size160 - strokeWidth10, + minWidth: 96, + focused: { + paddingHorizontal: size160, + }, + hasIconAfter: { + spacingIconContentAfter: size160, + }, + hasIconBefore: { + spacingIconContentBefore: size160, + }, + circular: { + paddingHorizontal: size200 - strokeWidth10, + focused: { + paddingHorizontal: size200, + }, + }, + }, + }, +}); diff --git a/packages/components/Button/src/CompoundButton/CompoundButtonTokens.ts b/packages/components/Button/src/CompoundButton/CompoundButtonTokens.ts index 94b8b87169b..dfc8b3950da 100644 --- a/packages/components/Button/src/CompoundButton/CompoundButtonTokens.ts +++ b/packages/components/Button/src/CompoundButton/CompoundButtonTokens.ts @@ -1,21 +1,49 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { size120, size160, size200, size80, strokeWidth10 } from '@fluentui-react-native/design/tokens/global'; +import { size120, size160, size200, size80, strokeWidth10, strokeWidth20 } from '@fluentui-react-native/design/tokens/global'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { CompoundButtonTokens } from './CompoundButton.types'; -export const defaultCompoundButtonTokens: TokenSettings = (): CompoundButtonTokens => ({ +export const defaultCompoundButtonTokens: TokenSettings = (theme: Theme): CompoundButtonTokens => ({ medium: { padding: size120 - strokeWidth10, focused: { padding: size120, }, + primary: !isHighContrast(theme) && { + focused: { + borderWidth: strokeWidth20, + padding: size120 - strokeWidth20, + }, + square: { + focused: { + borderWidth: strokeWidth10, + padding: size120 - strokeWidth10, + }, + }, + }, hasContent: { paddingHorizontal: size120 - strokeWidth10, minWidth: 96, focused: { paddingHorizontal: size120, }, + primary: !isHighContrast(theme) && { + focused: { + paddingHorizontal: size120 - strokeWidth20, + }, + circular: { + focused: { + paddingHorizontal: size160 - strokeWidth20, + }, + }, + square: { + focused: { + paddingHorizontal: size120 - strokeWidth10, + }, + }, + }, hasIconAfter: { spacingIconContentAfter: size120, }, @@ -33,14 +61,42 @@ export const defaultCompoundButtonTokens: TokenSettings = (theme: Theme): CompoundButtonTokens => ({ - medium: { - padding: size120 - strokeWidth10, - focused: { - padding: size120, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size120 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size120 - strokeWidth10, - }, - }, - }, - hasContent: { - paddingHorizontal: size120 - strokeWidth10, - minWidth: 96, - focused: { - paddingHorizontal: size120, - }, - primary: !isHighContrast(theme) && { - focused: { - paddingHorizontal: size120 - strokeWidth20, - }, - circular: { - focused: { - paddingHorizontal: size160 - strokeWidth20, - }, - }, - square: { - focused: { - paddingHorizontal: size120 - strokeWidth10, - }, - }, - }, - hasIconAfter: { - spacingIconContentAfter: size120, - }, - hasIconBefore: { - spacingIconContentBefore: size120, - }, - circular: { - paddingHorizontal: size160 - strokeWidth10, - focused: { - paddingHorizontal: size160, - }, - }, - }, - }, - small: { - padding: size80 - strokeWidth10, - focused: { - borderWidth: 0, - padding: size80, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size80 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size80 - strokeWidth10, - }, - }, - }, - hasContent: { - paddingHorizontal: size80 - strokeWidth10, - minWidth: 64, - focused: { - paddingHorizontal: size80, - }, - primary: !isHighContrast(theme) && { - focused: { - paddingHorizontal: size80 - strokeWidth20, - }, - circular: { - focused: { - paddingHorizontal: size120 - strokeWidth20, - }, - }, - square: { - focused: { - paddingHorizontal: size80 - strokeWidth10, - }, - }, - }, - hasIconAfter: { - spacingIconContentAfter: size80, - }, - hasIconBefore: { - spacingIconContentBefore: size80, - }, - circular: { - paddingHorizontal: size120 - strokeWidth10, - focused: { - paddingHorizontal: size120, - }, - }, - }, - }, - large: { - padding: size160 - strokeWidth10, - focused: { - padding: size160, - }, - primary: !isHighContrast(theme) && { - focused: { - borderWidth: strokeWidth20, - padding: size160 - strokeWidth20, - }, - square: { - focused: { - borderWidth: strokeWidth10, - padding: size160 - strokeWidth10, - }, - }, - }, - hasContent: { - paddingHorizontal: size160 - strokeWidth10, - minWidth: 96, - focused: { - paddingHorizontal: size160, - }, - primary: !isHighContrast(theme) && { - focused: { - paddingHorizontal: size160 - strokeWidth20, - }, - circular: { - focused: { - paddingHorizontal: size200 - strokeWidth20, - }, - }, - square: { - focused: { - paddingHorizontal: size160 - strokeWidth10, - }, - }, - }, - hasIconAfter: { - spacingIconContentAfter: size160, - }, - hasIconBefore: { - spacingIconContentBefore: size160, - }, - circular: { - paddingHorizontal: size200 - strokeWidth10, - focused: { - paddingHorizontal: size200, - }, - }, - }, - }, -}); diff --git a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.macos.ts b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.macos.ts new file mode 100644 index 00000000000..a1a5670ae9c --- /dev/null +++ b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.macos.ts @@ -0,0 +1,24 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { ToggleButtonTokens } from './ToggleButton.types'; + +export const defaultToggleButtonColorTokens: TokenSettings = (t: Theme): ToggleButtonTokens => ({ + checked: { + color: t.colors.defaultCheckedContent, + backgroundColor: t.colors.defaultCheckedBackground, + hovered: { + color: t.colors.defaultCheckedHoveredContent, + backgroundColor: t.colors.defaultCheckedHoveredBackground, + }, + subtle: { + color: t.colors.ghostCheckedContent, + backgroundColor: t.colors.ghostCheckedBackground, + hovered: { + color: t.colors.ghostCheckedHoveredContent, + backgroundColor: t.colors.ghostCheckedHoveredBackground, + borderColor: t.colors.ghostCheckedHoveredBorder, + }, + }, + }, +}); diff --git a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.ts b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.ts index a1a5670ae9c..979612ffd8b 100644 --- a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.ts +++ b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.ts @@ -1,24 +1,39 @@ +import { PlatformColor } from 'react-native'; + import type { Theme } from '@fluentui-react-native/framework'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { ToggleButtonTokens } from './ToggleButton.types'; -export const defaultToggleButtonColorTokens: TokenSettings = (t: Theme): ToggleButtonTokens => ({ - checked: { - color: t.colors.defaultCheckedContent, - backgroundColor: t.colors.defaultCheckedBackground, - hovered: { - color: t.colors.defaultCheckedHoveredContent, - backgroundColor: t.colors.defaultCheckedHoveredBackground, - }, - subtle: { - color: t.colors.ghostCheckedContent, - backgroundColor: t.colors.ghostCheckedBackground, - hovered: { - color: t.colors.ghostCheckedHoveredContent, - backgroundColor: t.colors.ghostCheckedHoveredBackground, - borderColor: t.colors.ghostCheckedHoveredBorder, +export const defaultToggleButtonColorTokens: TokenSettings = (t: Theme): ToggleButtonTokens => { + if (isHighContrast(t)) { + return highContrastColors; + } + + return { + checked: { + color: t.colors.neutralForeground1Selected, + backgroundColor: t.colors.neutralBackground1Selected, + borderColor: t.colors.neutralStroke1, + primary: { + color: t.colors.neutralForegroundOnBrandSelected, + backgroundColor: t.colors.brandBackgroundSelected, + borderColor: t.colors.brandBackgroundSelected, + }, + subtle: { + color: t.colors.neutralForeground1Selected, + backgroundColor: t.colors.subtleBackgroundSelected, + borderColor: t.colors.subtleBackgroundSelected, }, }, + }; +}; + +const highContrastColors = { + checked: { + backgroundColor: PlatformColor('Highlight'), + color: PlatformColor('HighlightText'), + iconColor: PlatformColor('HighlightText'), }, -}); +}; diff --git a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.win32.ts b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.win32.ts deleted file mode 100644 index 979612ffd8b..00000000000 --- a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.win32.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ToggleButtonTokens } from './ToggleButton.types'; - -export const defaultToggleButtonColorTokens: TokenSettings = (t: Theme): ToggleButtonTokens => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - checked: { - color: t.colors.neutralForeground1Selected, - backgroundColor: t.colors.neutralBackground1Selected, - borderColor: t.colors.neutralStroke1, - primary: { - color: t.colors.neutralForegroundOnBrandSelected, - backgroundColor: t.colors.brandBackgroundSelected, - borderColor: t.colors.brandBackgroundSelected, - }, - subtle: { - color: t.colors.neutralForeground1Selected, - backgroundColor: t.colors.subtleBackgroundSelected, - borderColor: t.colors.subtleBackgroundSelected, - }, - }, - }; -}; - -const highContrastColors = { - checked: { - backgroundColor: PlatformColor('Highlight'), - color: PlatformColor('HighlightText'), - iconColor: PlatformColor('HighlightText'), - }, -}; diff --git a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.windows.ts b/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.windows.ts deleted file mode 100644 index bf00a4391b3..00000000000 --- a/packages/components/Button/src/ToggleButton/ToggleButtonColorTokens.windows.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PlatformColor } from 'react-native'; - -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { ToggleButtonTokens } from './ToggleButton.types'; - -export const defaultToggleButtonColorTokens: TokenSettings = (t: Theme): ToggleButtonTokens => { - if (isHighContrast(t)) { - return highContrastColors; - } - - return { - checked: { - color: t.colors.neutralForeground1Selected, - backgroundColor: t.colors.neutralBackground1Selected, - borderColor: t.colors.neutralStroke1, - primary: { - color: t.colors.neutralForegroundOnBrandSelected, - backgroundColor: t.colors.brandBackgroundSelected, - borderColor: t.colors.brandBackgroundSelected, - }, - subtle: { - color: t.colors.neutralForeground1Selected, - backgroundColor: t.colors.subtleBackgroundSelected, - borderColor: t.colors.subtleBackgroundSelected, - }, - }, - }; -}; - -const highContrastColors = { - checked: { - backgroundColor: PlatformColor('SystemColorHighlightColor'), - borderColor: PlatformColor('SystemColorHighlightColor'), - color: PlatformColor('SystemColorHighlightTextColor'), - iconColor: PlatformColor('SystemColorHighlightTextColor'), - }, -}; diff --git a/packages/components/Button/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/Button/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..ffb840ffd2e --- /dev/null +++ b/packages/components/Button/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,479 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Button color tokens pins v0 Button color tokens 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + }, + }, + "focused": { + "tokens": { + "backgroundColor": "#FFF7F0", + "borderColor": "#FBDFD0", + "color": "#262626", + "wrapperBorderColor": "#FBDFD0", + }, + }, + "hovered": { + "tokens": { + "backgroundColor": "#FFF7F0", + "borderColor": "buttonBorderHovered", + "color": "#262626", + }, + }, + "pressed": { + "tokens": { + "backgroundColor": "#FBDFD0", + "borderColor": "buttonPressedBorder", + "color": "#262626", + }, + }, + }, + "tokens": { + "backgroundColor": "#E6E6E6", + "borderColor": "#969696", + "color": "#262626", + "wrapperBorderColor": "transparent", + }, +} +`; + +exports[`Button color tokens pins v0 PrimaryButton color tokens 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "backgroundColor": "#E6E6E6", + "borderColor": "#E6E6E6", + "color": "#B1B1B1", + }, + }, + "focused": { + "tokens": { + "backgroundColor": "#F29F71", + "borderColor": "#A22C01", + "color": "#FFFFFF", + }, + }, + "hovered": { + "tokens": { + "backgroundColor": "#F29F71", + "borderColor": "primaryButtonBorderHovered", + "color": "#FFFFFF", + }, + }, + "pressed": { + "tokens": { + "backgroundColor": "#A22C01", + "borderColor": "primaryButtonBorderPressed", + "color": "#FFFFFF", + }, + }, + }, + "endIcon": { + "color": "#ffffff", + }, + "startIcon": { + "color": "#ffffff", + }, + "tokens": { + "backgroundColor": "#D83B01", + "borderColor": "#A22C01", + "color": "#FFFFFF", + }, +} +`; + +exports[`Button color tokens pins v0 StealthButton color tokens 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "backgroundColor": "antiquewhite", + "borderColor": "antiquewhite", + "color": "#B1B1B1", + }, + }, + "focused": { + "tokens": { + "backgroundColor": "#D2D2D2", + "borderColor": "#969696", + "color": "#262626", + }, + }, + "hovered": { + "tokens": { + "backgroundColor": "#D2D2D2", + "borderColor": "#D2D2D2", + "color": "#262626", + }, + }, + "pressed": { + "tokens": { + "backgroundColor": "#B1B1B1", + "borderColor": "#B1B1B1", + }, + }, + }, + "tokens": { + "backgroundColor": "antiquewhite", + "borderColor": "antiquewhite", + "color": "#262626", + }, +} +`; + +exports[`Button color tokens pins v1 Button color tokens 1`] = ` +{ + "backgroundColor": "antiquewhite", + "borderColor": "#969696", + "color": "#262626", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + }, + "hovered": { + "backgroundColor": "#D2D2D2", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + }, + "primary": { + "backgroundColor": "#D83B01", + "borderColor": "#D83B01", + "color": "#FFFFFF", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#F29F71", + "borderColor": "#969696", + "borderInnerColor": "#ffffff", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "hovered": { + "backgroundColor": "#F29F71", + "borderColor": "#F29F71", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "iconColor": "#FFFFFF", + "pressed": { + "backgroundColor": "#A22C01", + "borderColor": "#A22C01", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + }, + "subtle": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#262626", + "disabled": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#f5f5f5", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + }, + "hovered": { + "backgroundColor": "#f5f5f5", + "borderColor": "#f5f5f5", + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#e0e0e0", + "borderColor": "#e0e0e0", + "color": "#262626", + "iconColor": "#262626", + }, + }, +} +`; + +exports[`Button color tokens pins v1 CompoundButton color tokens 1`] = ` +{ + "backgroundColor": "antiquewhite", + "borderColor": "#969696", + "color": "#262626", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + "secondaryContentColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#505050", + }, + "hovered": { + "backgroundColor": "#D2D2D2", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#505050", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#666666", + }, + "primary": { + "backgroundColor": "#D83B01", + "borderColor": "#D83B01", + "color": "#FFFFFF", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#F29F71", + "borderColor": "#969696", + "borderInnerColor": "#ffffff", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + "secondaryContentColor": "#FFFFFF", + }, + "hovered": { + "backgroundColor": "#F29F71", + "borderColor": "#F29F71", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + "secondaryContentColor": "#FFFFFF", + }, + "iconColor": "#FFFFFF", + "pressed": { + "backgroundColor": "#A22C01", + "borderColor": "#A22C01", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + "secondaryContentColor": "#FFFFFF", + }, + "secondaryContentColor": "#FFFFFF", + }, + "secondaryContentColor": "#666666", + "subtle": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#262626", + "disabled": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#f5f5f5", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#505050", + }, + "hovered": { + "backgroundColor": "#f5f5f5", + "borderColor": "#f5f5f5", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#505050", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#e0e0e0", + "borderColor": "#e0e0e0", + "color": "#262626", + "iconColor": "#262626", + "secondaryContentColor": "#666666", + }, + "secondaryContentColor": "#666666", + }, +} +`; + +exports[`Button color tokens pins v1 FAB color tokens 1`] = ` +{ + "backgroundColor": "#D83B01", + "disabled": { + "backgroundColor": "#ebebeb", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D83B01", + "borderColor": "#969696", + "borderInnerColor": "#ffffff", + }, + "pressed": { + "backgroundColor": "#A22C01", + }, + "rippleColor": "#D4D4D4", + "subtle": { + "backgroundColor": "#ebebeb", + "color": "#aec6eb", + "disabled": { + "backgroundColor": "#E6E6E6", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#ebebeb", + "borderColor": "#969696", + "borderInnerColor": "#ffffff", + "color": "#aec6eb", + "iconColor": "#aec6eb", + }, + "iconColor": "#aec6eb", + "pressed": { + "backgroundColor": "#B1B1B1", + }, + "rippleColor": "#D4D4D4", + }, +} +`; + +exports[`Button color tokens pins v1 ToggleButton color tokens 1`] = ` +{ + "backgroundColor": "antiquewhite", + "borderColor": "#969696", + "checked": { + "backgroundColor": "#C6C6C6", + "borderColor": "#969696", + "color": "#262626", + "primary": { + "backgroundColor": "#13458f", + "borderColor": "#13458f", + "color": "#ffffff", + }, + "subtle": { + "backgroundColor": "#ebebeb", + "borderColor": "#ebebeb", + "color": "#262626", + }, + }, + "color": "#262626", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + }, + "hovered": { + "backgroundColor": "#D2D2D2", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "borderColor": "#969696", + "color": "#262626", + "iconColor": "#262626", + }, + "primary": { + "backgroundColor": "#D83B01", + "borderColor": "#D83B01", + "color": "#FFFFFF", + "disabled": { + "backgroundColor": "#E6E6E6", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#F29F71", + "borderColor": "#969696", + "borderInnerColor": "#ffffff", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "hovered": { + "backgroundColor": "#F29F71", + "borderColor": "#F29F71", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + "iconColor": "#FFFFFF", + "pressed": { + "backgroundColor": "#A22C01", + "borderColor": "#A22C01", + "color": "#FFFFFF", + "iconColor": "#FFFFFF", + }, + }, + "subtle": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#262626", + "disabled": { + "backgroundColor": "#00000000", + "borderColor": "#00000000", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#f5f5f5", + "borderColor": "#00000000", + "color": "#262626", + "iconColor": "#262626", + }, + "hovered": { + "backgroundColor": "#f5f5f5", + "borderColor": "#f5f5f5", + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#e0e0e0", + "borderColor": "#e0e0e0", + "color": "#262626", + "iconColor": "#262626", + }, + }, +} +`; diff --git a/packages/components/Button/src/deprecated/Button.settings.win32.ts b/packages/components/Button/src/deprecated/Button.settings.macos.ts similarity index 91% rename from packages/components/Button/src/deprecated/Button.settings.win32.ts rename to packages/components/Button/src/deprecated/Button.settings.macos.ts index 271d42ff074..e115b905c21 100644 --- a/packages/components/Button/src/deprecated/Button.settings.win32.ts +++ b/packages/components/Button/src/deprecated/Button.settings.macos.ts @@ -16,7 +16,6 @@ export const settings: IComposeSettings = [ borderColor: 'buttonBorder', borderWidth: 1, borderRadius: 4, - wrapperBorderColor: 'transparent', }, root: { accessible: true, @@ -29,13 +28,6 @@ export const settings: IComposeSettings = [ alignSelf: 'flex-start', }, } as IViewProps, - borderWrapper: { - style: { - display: 'flex', - flexGrow: 1, - borderWidth: 1, - }, - }, endIcon: { style: { marginStart: 2, @@ -93,7 +85,6 @@ export const settings: IComposeSettings = [ borderColor: 'buttonBorderFocused', color: 'buttonTextHovered', backgroundColor: 'buttonBackgroundHovered', - wrapperBorderColor: 'buttonBorderFocused', }, }, }, diff --git a/packages/components/Button/src/deprecated/Button.settings.ts b/packages/components/Button/src/deprecated/Button.settings.ts index e115b905c21..271d42ff074 100644 --- a/packages/components/Button/src/deprecated/Button.settings.ts +++ b/packages/components/Button/src/deprecated/Button.settings.ts @@ -16,6 +16,7 @@ export const settings: IComposeSettings = [ borderColor: 'buttonBorder', borderWidth: 1, borderRadius: 4, + wrapperBorderColor: 'transparent', }, root: { accessible: true, @@ -28,6 +29,13 @@ export const settings: IComposeSettings = [ alignSelf: 'flex-start', }, } as IViewProps, + borderWrapper: { + style: { + display: 'flex', + flexGrow: 1, + borderWidth: 1, + }, + }, endIcon: { style: { marginStart: 2, @@ -85,6 +93,7 @@ export const settings: IComposeSettings = [ borderColor: 'buttonBorderFocused', color: 'buttonTextHovered', backgroundColor: 'buttonBackgroundHovered', + wrapperBorderColor: 'buttonBorderFocused', }, }, }, diff --git a/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.win32.ts b/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.macos.ts similarity index 88% rename from packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.win32.ts rename to packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.macos.ts index 14ff405614d..3e8aadbeb31 100644 --- a/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.win32.ts +++ b/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.macos.ts @@ -9,13 +9,6 @@ export const settings: IComposeSettings = [ color: 'primaryButtonText', borderColor: 'primaryButtonBorder', }, - // TODO - #728: neutralForegroundOnBrand is not working for icon color. - endIcon: { - color: '#ffffff', - }, - startIcon: { - color: '#ffffff', - }, _overrides: { disabled: { tokens: { diff --git a/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.ts b/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.ts index 3e8aadbeb31..14ff405614d 100644 --- a/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.ts +++ b/packages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.settings.ts @@ -9,6 +9,13 @@ export const settings: IComposeSettings = [ color: 'primaryButtonText', borderColor: 'primaryButtonBorder', }, + // TODO - #728: neutralForegroundOnBrand is not working for icon color. + endIcon: { + color: '#ffffff', + }, + startIcon: { + color: '#ffffff', + }, _overrides: { disabled: { tokens: { diff --git a/packages/components/Button/src/deprecated/__snapshots__/Button.test.tsx.snap b/packages/components/Button/src/deprecated/__snapshots__/Button.test.tsx.snap index a5008031fd7..e77d0aed4e3 100644 --- a/packages/components/Button/src/deprecated/__snapshots__/Button.test.tsx.snap +++ b/packages/components/Button/src/deprecated/__snapshots__/Button.test.tsx.snap @@ -34,7 +34,16 @@ exports[`Button default 1`] = ` } } > - + = (t: T checkboxBorderWidth: strokeWidth10, checkboxBorderRadius: cornerRadius20, checkboxSize: 16, - checkmarkSize: 8, - spacingLabelAfter: size120, + checkmarkSize: 12, label: { padding: size80, borderRadius: cornerRadius40, @@ -40,8 +39,7 @@ export const defaultCheckboxTokens: TokenSettings = (t: T checkboxBorderWidth: strokeWidth10, checkboxBorderRadius: cornerRadius20, checkboxSize: 20, - checkmarkSize: 10, - spacingLabelAfter: size120, + checkmarkSize: 16, label: { padding: size80, borderRadius: cornerRadius40, @@ -54,45 +52,29 @@ export const defaultCheckboxTokens: TokenSettings = (t: T padding: size40, variant: 'bodyStandard', }, - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessible, - color: t.colors.neutralForeground3, + checkboxBackgroundColor: t.colors.menuBackground, + checkboxBorderColor: t.colors.menuItemText, + checkmarkColor: t.colors.menuItemTextHovered, checkmarkOpacity: 0, + color: t.colors.menuItemText, disabled: { - checkboxBorderColor: t.colors.neutralStrokeDisabled, - color: t.colors.neutralForegroundDisabled, - checkboxBackgroundColor: t.colors.neutralBackgroundDisabled, + checkboxBorderColor: t.colors.buttonBorderDisabled, + color: t.colors.disabledBodyText, + checkboxBackgroundColor: t.colors.background, + checkmarkColor: t.colors.neutralForegroundDisabled, }, hovered: { - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessibleHover, - color: t.colors.neutralForeground2, - checked: { - checkboxBackgroundColor: t.colors.compoundBrandBackground1Hover, - checkboxBorderColor: t.colors.compoundBrandBackground1Hover, - checkmarkColor: t.colors.neutralForegroundOnBrand, - checkmarkOpacity: 1, - }, + checkboxBackgroundColor: t.colors.menuItemBackgroundHovered, + }, + focused: { + checkboxBackgroundColor: t.colors.menuItemBackgroundHovered, + borderColor: t.colors.focusBorder, }, pressed: { - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessiblePressed, - color: t.colors.neutralForeground1, - checked: { - checkboxBackgroundColor: t.colors.compoundBrandBackground1Pressed, - checkboxBorderColor: t.colors.compoundBrandBackground1Pressed, - checkmarkColor: t.colors.neutralForegroundOnBrand, - checkmarkOpacity: 1, - }, + checkboxBackgroundColor: t.colors.menuItemBackgroundPressed, }, checked: { - checkboxBackgroundColor: t.colors.compoundBrandBackground1, - checkboxBorderColor: t.colors.compoundBrandBackground1, checkmarkOpacity: 1, - checkmarkColor: t.colors.neutralForegroundOnBrand, - disabled: { - checkmarkColor: t.colors.neutralForegroundDisabled, - }, }, circular: { borderRadius: cornerRadiusCircular, diff --git a/packages/components/Checkbox/src/CheckboxTokens.ts b/packages/components/Checkbox/src/CheckboxTokens.ts index eb0b12735cb..901aeedba1f 100644 --- a/packages/components/Checkbox/src/CheckboxTokens.ts +++ b/packages/components/Checkbox/src/CheckboxTokens.ts @@ -3,6 +3,9 @@ import { cornerRadius20, cornerRadius40, cornerRadiusCircular, + fontSize200, + fontSize300, + fontWeightRegular, size120, size40, size80, @@ -24,15 +27,18 @@ export const defaultCheckboxTokens: TokenSettings = (t: T checkmarkSize: 12, label: { padding: size80, + paddingHorizontal: size120, borderRadius: cornerRadius40, - spacingLabelAfter: size120, + spacingLabelAfter: size80, labelIsBefore: { - spacingLabelBefore: size120, + spacingLabelBefore: size80, spacingLabelAfter: 0, }, }, padding: size40, - variant: 'bodyStandard', + fontSize: fontSize200, + fontWeight: fontWeightRegular, + fontFamily: t.typography.families.primary, }, large: { borderRadius: cornerRadius20, @@ -50,31 +56,51 @@ export const defaultCheckboxTokens: TokenSettings = (t: T }, }, padding: size40, - variant: 'bodyStandard', + fontSize: fontSize300, + fontWeight: fontWeightRegular, + fontFamily: t.typography.families.primary, }, - checkboxBackgroundColor: t.colors.menuBackground, - checkboxBorderColor: t.colors.menuItemText, - checkmarkColor: t.colors.menuItemTextHovered, + checkboxBackgroundColor: t.colors.neutralBackground1, + checkboxBorderColor: t.colors.neutralStrokeAccessible, + color: t.colors.neutralForeground1, checkmarkOpacity: 0, - color: t.colors.menuItemText, disabled: { - checkboxBorderColor: t.colors.buttonBorderDisabled, - color: t.colors.disabledBodyText, - checkboxBackgroundColor: t.colors.background, - checkmarkColor: t.colors.neutralForegroundDisabled, + checkboxBorderColor: t.colors.neutralStrokeDisabled, + color: t.colors.neutralForegroundDisabled, + checkboxBackgroundColor: t.colors.neutralBackgroundDisabled, }, hovered: { - checkboxBackgroundColor: t.colors.menuItemBackgroundHovered, - }, - focused: { - checkboxBackgroundColor: t.colors.menuItemBackgroundHovered, - borderColor: t.colors.focusBorder, + checkboxBackgroundColor: t.colors.neutralBackground1, + checkboxBorderColor: t.colors.neutralStrokeAccessibleHover, + checkmarkColor: t.colors.neutralForeground4, + checkmarkOpacity: 1, + color: t.colors.neutralForeground1, + checked: { + checkboxBackgroundColor: t.colors.brandBackgroundHover, + checkboxBorderColor: t.colors.compoundBrandStroke1Hover, + checkmarkColor: t.colors.neutralForegroundOnBrandHover, + }, }, pressed: { - checkboxBackgroundColor: t.colors.menuItemBackgroundPressed, + checkboxBackgroundColor: t.colors.neutralBackground1, + checkboxBorderColor: t.colors.neutralStrokeAccessiblePressed, + checkmarkColor: t.colors.neutralForeground1, + checkmarkOpacity: 1, + color: t.colors.neutralForeground1, + checked: { + checkboxBackgroundColor: t.colors.brandBackgroundPressed, + checkboxBorderColor: t.colors.compoundBrandStroke1Pressed, + checkmarkColor: t.colors.neutralForegroundOnBrandPressed, + }, }, checked: { + checkboxBackgroundColor: t.colors.brandBackground, + checkboxBorderColor: t.colors.compoundBrandStroke1Hover, checkmarkOpacity: 1, + checkmarkColor: t.colors.neutralForegroundOnBrand, + disabled: { + checkmarkColor: t.colors.neutralForegroundDisabled, + }, }, circular: { borderRadius: cornerRadiusCircular, diff --git a/packages/components/Checkbox/src/CheckboxTokens.win32.ts b/packages/components/Checkbox/src/CheckboxTokens.win32.ts deleted file mode 100644 index 901aeedba1f..00000000000 --- a/packages/components/Checkbox/src/CheckboxTokens.win32.ts +++ /dev/null @@ -1,109 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { - cornerRadius20, - cornerRadius40, - cornerRadiusCircular, - fontSize200, - fontSize300, - fontWeightRegular, - size120, - size40, - size80, - strokeWidth10, -} from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { CheckboxTokens } from './Checkbox.types'; - -export const defaultCheckboxTokens: TokenSettings = (t: Theme) => - ({ - requiredColor: t.colors.redForeground1, - requiredPadding: size80, - medium: { - borderRadius: cornerRadius20, - checkboxBorderWidth: strokeWidth10, - checkboxBorderRadius: cornerRadius20, - checkboxSize: 16, - checkmarkSize: 12, - label: { - padding: size80, - paddingHorizontal: size120, - borderRadius: cornerRadius40, - spacingLabelAfter: size80, - labelIsBefore: { - spacingLabelBefore: size80, - spacingLabelAfter: 0, - }, - }, - padding: size40, - fontSize: fontSize200, - fontWeight: fontWeightRegular, - fontFamily: t.typography.families.primary, - }, - large: { - borderRadius: cornerRadius20, - checkboxBorderWidth: strokeWidth10, - checkboxBorderRadius: cornerRadius20, - checkboxSize: 20, - checkmarkSize: 16, - label: { - padding: size80, - borderRadius: cornerRadius40, - spacingLabelAfter: size120, - labelIsBefore: { - spacingLabelBefore: size120, - spacingLabelAfter: 0, - }, - }, - padding: size40, - fontSize: fontSize300, - fontWeight: fontWeightRegular, - fontFamily: t.typography.families.primary, - }, - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessible, - color: t.colors.neutralForeground1, - checkmarkOpacity: 0, - disabled: { - checkboxBorderColor: t.colors.neutralStrokeDisabled, - color: t.colors.neutralForegroundDisabled, - checkboxBackgroundColor: t.colors.neutralBackgroundDisabled, - }, - hovered: { - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessibleHover, - checkmarkColor: t.colors.neutralForeground4, - checkmarkOpacity: 1, - color: t.colors.neutralForeground1, - checked: { - checkboxBackgroundColor: t.colors.brandBackgroundHover, - checkboxBorderColor: t.colors.compoundBrandStroke1Hover, - checkmarkColor: t.colors.neutralForegroundOnBrandHover, - }, - }, - pressed: { - checkboxBackgroundColor: t.colors.neutralBackground1, - checkboxBorderColor: t.colors.neutralStrokeAccessiblePressed, - checkmarkColor: t.colors.neutralForeground1, - checkmarkOpacity: 1, - color: t.colors.neutralForeground1, - checked: { - checkboxBackgroundColor: t.colors.brandBackgroundPressed, - checkboxBorderColor: t.colors.compoundBrandStroke1Pressed, - checkmarkColor: t.colors.neutralForegroundOnBrandPressed, - }, - }, - checked: { - checkboxBackgroundColor: t.colors.brandBackground, - checkboxBorderColor: t.colors.compoundBrandStroke1Hover, - checkmarkOpacity: 1, - checkmarkColor: t.colors.neutralForegroundOnBrand, - disabled: { - checkmarkColor: t.colors.neutralForegroundDisabled, - }, - }, - circular: { - borderRadius: cornerRadiusCircular, - checkboxBorderRadius: cornerRadiusCircular, - }, - }) as CheckboxTokens; diff --git a/packages/components/Checkbox/src/ColorTokens.test.windows.ts b/packages/components/Checkbox/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..e8431402848 --- /dev/null +++ b/packages/components/Checkbox/src/ColorTokens.test.windows.ts @@ -0,0 +1,16 @@ +import { createColorPinningTheme, resolveV0ColorTokens, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings } from './Checkbox.styling'; +import { settings } from './deprecated/Checkbox.settings'; + +const theme = createColorPinningTheme(); + +describe('Checkbox color tokens', () => { + it('pins v0 Checkbox color tokens', () => { + expect(resolveV0ColorTokens(settings, theme)).toMatchSnapshot(); + }); + + it('pins v1 Checkbox color tokens', () => { + expect(resolveV1ColorTokens(stylingSettings.tokens, theme)).toMatchSnapshot(); + }); +}); diff --git a/packages/components/Checkbox/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/Checkbox/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..f9978e77c68 --- /dev/null +++ b/packages/components/Checkbox/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Checkbox color tokens pins v0 Checkbox color tokens 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "backgroundColor": "antiquewhite", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + }, + }, + "focused": { + "tokens": { + "backgroundColor": "#D2D2D2", + "checkmarkColor": "#262626", + "textBorderColor": "#969696", + }, + }, + "hovered": { + "tokens": { + "backgroundColor": "#D2D2D2", + "checkmarkColor": "#262626", + }, + }, + "pressed": { + "tokens": { + "backgroundColor": "#B1B1B1", + }, + }, + }, + "tokens": { + "backgroundColor": "antiquewhite", + "borderColor": "#262626", + "color": "#262626", + "textBorderColor": "transparent", + }, +} +`; + +exports[`Checkbox color tokens pins v1 Checkbox color tokens 1`] = ` +{ + "checkboxBackgroundColor": "antiquewhite", + "checkboxBorderColor": "#969696", + "checked": { + "checkboxBackgroundColor": "#D83B01", + "checkboxBorderColor": "#EA6115", + "checkmarkColor": "#FFFFFF", + "disabled": { + "checkmarkColor": "#B1B1B1", + }, + }, + "color": "#262626", + "disabled": { + "checkboxBackgroundColor": "#E6E6E6", + "checkboxBorderColor": "#D2D2D2", + "color": "#B1B1B1", + }, + "hovered": { + "checkboxBackgroundColor": "antiquewhite", + "checkboxBorderColor": "#B1B1B1", + "checked": { + "checkboxBackgroundColor": "#F29F71", + "checkboxBorderColor": "#EA6115", + "checkmarkColor": "#FFFFFF", + }, + "checkmarkColor": "#666666", + "color": "#262626", + }, + "pressed": { + "checkboxBackgroundColor": "antiquewhite", + "checkboxBorderColor": "#737373", + "checked": { + "checkboxBackgroundColor": "#A22C01", + "checkboxBorderColor": "#A22C01", + "checkmarkColor": "#FFFFFF", + }, + "checkmarkColor": "#262626", + "color": "#262626", + }, +} +`; diff --git a/packages/components/Menu/src/ColorTokens.test.windows.ts b/packages/components/Menu/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..c3cbdbf08ab --- /dev/null +++ b/packages/components/Menu/src/ColorTokens.test.windows.ts @@ -0,0 +1,30 @@ +import { createColorPinningTheme, getColorTokenSnapshot, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings as menuDividerStylingSettings } from './MenuDivider/MenuDivider.styling'; +import { stylingSettings as menuGroupHeaderStylingSettings } from './MenuGroupHeader/MenuGroupHeader.styling'; +import { stylingSettings as menuItemStylingSettings } from './MenuItem/MenuItem.styling'; +import { stylingSettings as menuItemCheckboxStylingSettings } from './MenuItemCheckbox/MenuItemCheckbox.styling'; +import { stylingSettings as menuItemRadioStylingSettings } from './MenuItemRadio/MenuItemRadio.styling'; +import { stylingSettings as menuListStylingSettings } from './MenuList/MenuList.styling'; +import { useMenuPopoverTokens } from './MenuPopover/MenuPopoverTokens'; + +const theme = createColorPinningTheme(); + +describe('Menu color tokens', () => { + it.each([ + ['MenuDivider', menuDividerStylingSettings.tokens], + ['MenuGroupHeader', menuGroupHeaderStylingSettings.tokens], + ['MenuItem', menuItemStylingSettings.tokens], + ['MenuItemCheckbox', menuItemCheckboxStylingSettings.tokens], + ['MenuItemRadio', menuItemRadioStylingSettings.tokens], + ['MenuList', menuListStylingSettings.tokens], + ])('pins %s colors', (_name, tokenSettings) => { + expect(resolveV1ColorTokens(tokenSettings, theme)).toMatchSnapshot(); + }); + + it('pins MenuPopover colors', () => { + const [tokens] = useMenuPopoverTokens(theme); + + expect(getColorTokenSnapshot(tokens, theme)).toMatchSnapshot(); + }); +}); diff --git a/packages/components/Menu/src/MenuDivider/MenuDividerTokens.ts b/packages/components/Menu/src/MenuDivider/MenuDividerTokens.ts index 0bdba66e0d5..d341a44d4af 100644 --- a/packages/components/Menu/src/MenuDivider/MenuDividerTokens.ts +++ b/packages/components/Menu/src/MenuDivider/MenuDividerTokens.ts @@ -1,11 +1,11 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { size40, strokeWidth10 } from '@fluentui-react-native/design/tokens/global'; +import { size20, strokeWidth10 } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { MenuDividerTokens } from './MenuDivider.types'; export const defaultMenuDividerTokens: TokenSettings = (t: Theme): MenuDividerTokens => ({ - backgroundColor: t.colors.neutralStroke2, + backgroundColor: t.colors.neutralStroke1, height: strokeWidth10, - marginVertical: size40, + margin: size20, }); diff --git a/packages/components/Menu/src/MenuDivider/MenuDividerTokens.win32.ts b/packages/components/Menu/src/MenuDivider/MenuDividerTokens.win32.ts deleted file mode 100644 index d341a44d4af..00000000000 --- a/packages/components/Menu/src/MenuDivider/MenuDividerTokens.win32.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { size20, strokeWidth10 } from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { MenuDividerTokens } from './MenuDivider.types'; - -export const defaultMenuDividerTokens: TokenSettings = (t: Theme): MenuDividerTokens => ({ - backgroundColor: t.colors.neutralStroke1, - height: strokeWidth10, - margin: size20, -}); diff --git a/packages/components/Menu/src/MenuItem/MenuItemTokens.ts b/packages/components/Menu/src/MenuItem/MenuItemTokens.ts index cff1f973db3..628dc97442e 100644 --- a/packages/components/Menu/src/MenuItem/MenuItemTokens.ts +++ b/packages/components/Menu/src/MenuItem/MenuItemTokens.ts @@ -1,38 +1,33 @@ import type { FontWeightValue, Theme } from '@fluentui-react-native/framework'; -import { cornerRadius40, fontSize300, fontWeightRegular, size40, size60, sizeNone } from '@fluentui-react-native/design/tokens/global'; +import { cornerRadiusNone, fontSize200, fontWeightRegular, size20, size40, size80 } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { MenuItemTokens } from './MenuItem.types'; export const defaultMenuItemTokens: TokenSettings = (t: Theme): MenuItemTokens => ({ backgroundColor: t.colors.neutralBackground1, - borderRadius: cornerRadius40, + borderRadius: cornerRadiusNone, checkmarkSize: 16, - color: t.colors.neutralForeground2, + color: t.colors.neutralForeground1, fontFamily: t.typography.families.primary, - fontSize: fontSize300, + fontSize: fontSize200, fontWeight: fontWeightRegular as FontWeightValue, gap: size40, - iconColor: t.colors.neutralForeground2, + iconColor: t.colors.neutralForeground1, iconSize: 16, - minHeight: 32, + minHeight: 24, minWidth: 128, maxWidth: 300, - padding: size60, - submenuIndicatorColor: t.colors.neutralForeground2, - submenuIndicatorPadding: sizeNone, + padding: size40, + paddingHorizontal: size80, + submenuIndicatorColor: t.colors.neutralForeground1, + submenuIndicatorPadding: size20, submenuIndicatorSize: 16, - hovered: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground2Hover, - iconColor: t.colors.neutralForeground2Hover, - submenuIndicatorColor: t.colors.neutralForeground2Hover, - }, pressed: { backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground2Pressed, - iconColor: t.colors.neutralForeground2Pressed, - submenuIndicatorColor: t.colors.neutralForeground2Pressed, + color: t.colors.neutralForeground1Pressed, + iconColor: t.colors.neutralForeground1Pressed, + submenuIndicatorColor: t.colors.neutralForeground1Pressed, }, disabled: { backgroundColor: t.colors.neutralBackground1, @@ -40,4 +35,10 @@ export const defaultMenuItemTokens: TokenSettings = (t: T iconColor: t.colors.neutralForegroundDisabled, submenuIndicatorColor: t.colors.neutralForegroundDisabled, }, + focused: { + backgroundColor: t.colors.neutralBackground1Hover, + color: t.colors.neutralForeground1Hover, + iconColor: t.colors.neutralForeground1Hover, + submenuIndicatorColor: t.colors.neutralForeground1Hover, + }, }); diff --git a/packages/components/Menu/src/MenuItem/MenuItemTokens.win32.ts b/packages/components/Menu/src/MenuItem/MenuItemTokens.win32.ts deleted file mode 100644 index 628dc97442e..00000000000 --- a/packages/components/Menu/src/MenuItem/MenuItemTokens.win32.ts +++ /dev/null @@ -1,44 +0,0 @@ -import type { FontWeightValue, Theme } from '@fluentui-react-native/framework'; -import { cornerRadiusNone, fontSize200, fontWeightRegular, size20, size40, size80 } from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { MenuItemTokens } from './MenuItem.types'; - -export const defaultMenuItemTokens: TokenSettings = (t: Theme): MenuItemTokens => ({ - backgroundColor: t.colors.neutralBackground1, - borderRadius: cornerRadiusNone, - checkmarkSize: 16, - color: t.colors.neutralForeground1, - fontFamily: t.typography.families.primary, - fontSize: fontSize200, - fontWeight: fontWeightRegular as FontWeightValue, - gap: size40, - iconColor: t.colors.neutralForeground1, - iconSize: 16, - minHeight: 24, - minWidth: 128, - maxWidth: 300, - padding: size40, - paddingHorizontal: size80, - submenuIndicatorColor: t.colors.neutralForeground1, - submenuIndicatorPadding: size20, - submenuIndicatorSize: 16, - pressed: { - backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground1Pressed, - iconColor: t.colors.neutralForeground1Pressed, - submenuIndicatorColor: t.colors.neutralForeground1Pressed, - }, - disabled: { - backgroundColor: t.colors.neutralBackground1, - color: t.colors.neutralForegroundDisabled, - iconColor: t.colors.neutralForegroundDisabled, - submenuIndicatorColor: t.colors.neutralForegroundDisabled, - }, - focused: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - iconColor: t.colors.neutralForeground1Hover, - submenuIndicatorColor: t.colors.neutralForeground1Hover, - }, -}); diff --git a/packages/components/Menu/src/MenuItemCheckbox/MenuItemCheckboxTokens.ts b/packages/components/Menu/src/MenuItemCheckbox/MenuItemCheckboxTokens.ts index 0bfc5ec5537..25a3b74eed2 100644 --- a/packages/components/Menu/src/MenuItemCheckbox/MenuItemCheckboxTokens.ts +++ b/packages/components/Menu/src/MenuItemCheckbox/MenuItemCheckboxTokens.ts @@ -1,41 +1,33 @@ import type { FontWeightValue, Theme } from '@fluentui-react-native/framework'; -import { cornerRadius40, fontSize300, fontWeightRegular, size40, size60, sizeNone } from '@fluentui-react-native/design/tokens/global'; +import { cornerRadiusNone, fontSize200, fontWeightRegular, size20, size40, size80 } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { MenuItemCheckboxTokens } from './MenuItemCheckbox.types'; export const defaultMenuItemCheckboxTokens: TokenSettings = (t: Theme): MenuItemCheckboxTokens => ({ backgroundColor: t.colors.neutralBackground1, - borderRadius: cornerRadius40, - checkmarkPadding: sizeNone, + borderRadius: cornerRadiusNone, + checkmarkPadding: size20, checkmarkSize: 16, checkmarkVisibility: 0, - color: t.colors.neutralForeground2, + color: t.colors.neutralForeground1, fontFamily: t.typography.families.primary, - fontSize: fontSize300, + fontSize: fontSize200, fontWeight: fontWeightRegular as FontWeightValue, gap: size40, - iconColor: t.colors.neutralForeground2, + iconColor: t.colors.neutralForeground1, iconSize: 16, - minHeight: 32, + minHeight: 24, minWidth: 160, maxWidth: 300, - padding: size60, - hovered: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground2Hover, - iconColor: t.colors.neutralForeground2Hover, - checked: { - checkmarkColor: t.colors.neutralForeground2Hover, - checkmarkVisibility: 1, - }, - }, + padding: size40, + paddingHorizontal: size80, pressed: { backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground2Pressed, - iconColor: t.colors.neutralForeground2Pressed, + color: t.colors.neutralForeground1Pressed, + iconColor: t.colors.neutralForeground1Pressed, checked: { - checkmarkColor: t.colors.neutralForeground2Pressed, + checkmarkColor: t.colors.neutralForeground1Pressed, checkmarkVisibility: 1, }, }, @@ -48,8 +40,17 @@ export const defaultMenuItemCheckboxTokens: TokenSettings = (t: Theme): MenuItemCheckboxTokens => ({ - backgroundColor: t.colors.neutralBackground1, - borderRadius: cornerRadiusNone, - checkmarkPadding: size20, - checkmarkSize: 16, - checkmarkVisibility: 0, - color: t.colors.neutralForeground1, - fontFamily: t.typography.families.primary, - fontSize: fontSize200, - fontWeight: fontWeightRegular as FontWeightValue, - gap: size40, - iconColor: t.colors.neutralForeground1, - iconSize: 16, - minHeight: 24, - minWidth: 160, - maxWidth: 300, - padding: size40, - paddingHorizontal: size80, - pressed: { - backgroundColor: t.colors.neutralBackground1Pressed, - color: t.colors.neutralForeground1Pressed, - iconColor: t.colors.neutralForeground1Pressed, - checked: { - checkmarkColor: t.colors.neutralForeground1Pressed, - checkmarkVisibility: 1, - }, - }, - disabled: { - backgroundColor: t.colors.neutralBackground1, - color: t.colors.neutralForegroundDisabled, - iconColor: t.colors.neutralForegroundDisabled, - checked: { - checkmarkColor: t.colors.neutralForegroundDisabled, - checkmarkVisibility: 1, - }, - }, - focused: { - backgroundColor: t.colors.neutralBackground1Hover, - color: t.colors.neutralForeground1Hover, - iconColor: t.colors.neutralForeground1Hover, - checked: { - checkmarkColor: t.colors.neutralForeground1Hover, - checkmarkVisibility: 1, - }, - }, - checked: { - checkmarkColor: t.colors.neutralForeground1, - checkmarkVisibility: 1, - }, -}); diff --git a/packages/components/Menu/src/MenuList/MenuListTokens.ts b/packages/components/Menu/src/MenuList/MenuListTokens.ts index 5d420aba591..1988afa3641 100644 --- a/packages/components/Menu/src/MenuList/MenuListTokens.ts +++ b/packages/components/Menu/src/MenuList/MenuListTokens.ts @@ -1,13 +1,16 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { size20, size40 } from '@fluentui-react-native/design/tokens/global'; +import { size40 } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { MenuListTokens } from './MenuList.types'; export const defaultMenuListTokens: TokenSettings = (t: Theme): MenuListTokens => ({ - padding: size40, + paddingVertical: size40, minWidth: 128, maxWidth: 300, backgroundColor: t.colors.neutralBackground1, - gap: size20, + /* To account for the width of the vertical scrollView. With the default minWidth, some content may be cut off */ + hasMaxHeight: { + minWidth: 140, + }, }); diff --git a/packages/components/Menu/src/MenuList/MenuListTokens.win32.ts b/packages/components/Menu/src/MenuList/MenuListTokens.win32.ts deleted file mode 100644 index 1988afa3641..00000000000 --- a/packages/components/Menu/src/MenuList/MenuListTokens.win32.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { size40 } from '@fluentui-react-native/design/tokens/global'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { MenuListTokens } from './MenuList.types'; - -export const defaultMenuListTokens: TokenSettings = (t: Theme): MenuListTokens => ({ - paddingVertical: size40, - minWidth: 128, - maxWidth: 300, - backgroundColor: t.colors.neutralBackground1, - /* To account for the width of the vertical scrollView. With the default minWidth, some content may be cut off */ - hasMaxHeight: { - minWidth: 140, - }, -}); diff --git a/packages/components/Menu/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/Menu/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..4b454dc4a60 --- /dev/null +++ b/packages/components/Menu/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,122 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Menu color tokens pins MenuDivider colors 1`] = ` +{ + "backgroundColor": "#969696", +} +`; + +exports[`Menu color tokens pins MenuGroupHeader colors 1`] = ` +{ + "color": "#666666", +} +`; + +exports[`Menu color tokens pins MenuItem colors 1`] = ` +{ + "backgroundColor": "antiquewhite", + "color": "#262626", + "disabled": { + "backgroundColor": "antiquewhite", + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + "submenuIndicatorColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "color": "#262626", + "iconColor": "#262626", + "submenuIndicatorColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "color": "#262626", + "iconColor": "#262626", + "submenuIndicatorColor": "#262626", + }, + "submenuIndicatorColor": "#262626", +} +`; + +exports[`Menu color tokens pins MenuItemCheckbox colors 1`] = ` +{ + "backgroundColor": "antiquewhite", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "disabled": { + "backgroundColor": "antiquewhite", + "checked": { + "checkmarkColor": "#B1B1B1", + }, + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "iconColor": "#262626", + }, +} +`; + +exports[`Menu color tokens pins MenuItemRadio colors 1`] = ` +{ + "backgroundColor": "antiquewhite", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "disabled": { + "backgroundColor": "antiquewhite", + "checked": { + "checkmarkColor": "#B1B1B1", + }, + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + }, + "focused": { + "backgroundColor": "#D2D2D2", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "iconColor": "#262626", + }, + "iconColor": "#262626", + "pressed": { + "backgroundColor": "#B1B1B1", + "checked": { + "checkmarkColor": "#262626", + }, + "color": "#262626", + "iconColor": "#262626", + }, +} +`; + +exports[`Menu color tokens pins MenuList colors 1`] = ` +{ + "backgroundColor": "antiquewhite", +} +`; + +exports[`Menu color tokens pins MenuPopover colors 1`] = ` +{ + "borderColor": "#969696", +} +`; diff --git a/packages/components/RadioGroup/src/Radio/RadioTokens.win32.ts b/packages/components/RadioGroup/src/Radio/RadioTokens.macos.ts similarity index 63% rename from packages/components/RadioGroup/src/Radio/RadioTokens.win32.ts rename to packages/components/RadioGroup/src/Radio/RadioTokens.macos.ts index 22f4a949909..0dc5ffff7e5 100644 --- a/packages/components/RadioGroup/src/Radio/RadioTokens.win32.ts +++ b/packages/components/RadioGroup/src/Radio/RadioTokens.macos.ts @@ -1,14 +1,13 @@ import type { Theme } from '@fluentui-react-native/framework'; import { cornerRadius40, - size160, + size100, size20, + size200, size40, size60, - size80, sizeNone, strokeWidth10, - strokeWidth20, } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; @@ -19,25 +18,24 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) rootHorizontalPadding: size40, borderColor: t.colors.transparentStroke, borderStyle: 'solid', - borderWidth: strokeWidth20, + borderWidth: strokeWidth10, borderRadius: cornerRadius40, radioBorderWidth: strokeWidth10, radioVisibility: 0, - variant: 'body1', + variant: 'subheaderStandard', radioBorderStyle: 'solid', radioBorder: t.colors.neutralStrokeAccessible, - color: t.colors.neutralForeground1, - radioOuterCircleSize: size160, - radioInnerCircleSize: size80, - radioOuterCircleBackground: t.colors.neutralBackground1, + color: t.colors.neutralForeground3, + radioOuterCircleSize: size200, + radioInnerCircleSize: size100, labelMarginVertical: size40, - labelMarginRight: sizeNone, + labelMarginRight: size20, labelMarginLeft: sizeNone, subtextVariant: 'caption1', subtextMarginTop: sizeNone, subtextMarginBottom: size40 + 1, marginTop: size60, - marginRight: sizeNone, + marginRight: size60, marginBottom: size60, marginLeft: size40, flexDirection: 'row', @@ -48,58 +46,46 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) flexDirection: 'column', alignItems: 'center', labelAlignItems: 'center', - labelMarginRight: sizeNone, - labelMarginVertical: size20, - labelPadding: size20, + labelMarginLeft: size20, marginLeft: size60, - marginRight: size60, - marginBottom: sizeNone, }, disabled: { // Unchecked, Disabled - radioOuterCircleBackground: t.colors.neutralBackgroundDisabled, - radioBorder: t.colors.neutralStrokeDisabled, + radioBorder: t.colors.neutralForegroundDisabled, color: t.colors.neutralForegroundDisabled, radioVisibility: 0, }, hovered: { // Unchecked, Hover - radioOuterCircleBackground: t.colors.neutralBackground1, radioBorder: t.colors.neutralStrokeAccessibleHover, - color: t.colors.neutralForeground1, + color: t.colors.neutralForeground2, selected: { // Checked, Hover - radioOuterCircleBackground: t.colors.brandBackgroundHover, radioBorder: t.colors.compoundBrandStroke1Hover, - radioFill: t.colors.neutralForegroundOnBrand, - color: t.colors.neutralForeground1, + radioFill: t.colors.compoundBrandBackground1Hover, + color: t.colors.neutralForeground2, radioVisibility: 1, - radioInnerCircleSize: 10, }, }, pressed: { // Unchecked, Pressed - radioOuterCircleBackground: t.colors.neutralBackground1, radioBorder: t.colors.neutralStrokeAccessiblePressed, color: t.colors.neutralForeground1, selected: { // Checked, Pressed - radioOuterCircleBackground: t.colors.brandBackgroundPressed, radioBorder: t.colors.compoundBrandStroke1Pressed, - radioFill: t.colors.neutralForegroundOnBrand, + radioFill: t.colors.compoundBrandBackground1Pressed, color: t.colors.neutralForeground1, radioVisibility: 1, - radioInnerCircleSize: 6, }, }, focused: { - borderColor: t.colors.strokeFocus2, selected: { // Checked, Focused radioVisibility: 1, @@ -108,10 +94,9 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) selected: { // Checked, Rest - radioOuterCircleBackground: t.colors.brandBackground, radioBorder: t.colors.compoundBrandStroke1, - radioFill: t.colors.neutralForegroundOnBrand, - color: t.colors.neutralForeground1, + radioFill: t.colors.compoundBrandStroke1, + color: t.colors.neutralForeground3, radioVisibility: 1, disabled: { diff --git a/packages/components/RadioGroup/src/Radio/RadioTokens.ts b/packages/components/RadioGroup/src/Radio/RadioTokens.ts index 0dc5ffff7e5..22f4a949909 100644 --- a/packages/components/RadioGroup/src/Radio/RadioTokens.ts +++ b/packages/components/RadioGroup/src/Radio/RadioTokens.ts @@ -1,13 +1,14 @@ import type { Theme } from '@fluentui-react-native/framework'; import { cornerRadius40, - size100, + size160, size20, - size200, size40, size60, + size80, sizeNone, strokeWidth10, + strokeWidth20, } from '@fluentui-react-native/design/tokens/global'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; @@ -18,24 +19,25 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) rootHorizontalPadding: size40, borderColor: t.colors.transparentStroke, borderStyle: 'solid', - borderWidth: strokeWidth10, + borderWidth: strokeWidth20, borderRadius: cornerRadius40, radioBorderWidth: strokeWidth10, radioVisibility: 0, - variant: 'subheaderStandard', + variant: 'body1', radioBorderStyle: 'solid', radioBorder: t.colors.neutralStrokeAccessible, - color: t.colors.neutralForeground3, - radioOuterCircleSize: size200, - radioInnerCircleSize: size100, + color: t.colors.neutralForeground1, + radioOuterCircleSize: size160, + radioInnerCircleSize: size80, + radioOuterCircleBackground: t.colors.neutralBackground1, labelMarginVertical: size40, - labelMarginRight: size20, + labelMarginRight: sizeNone, labelMarginLeft: sizeNone, subtextVariant: 'caption1', subtextMarginTop: sizeNone, subtextMarginBottom: size40 + 1, marginTop: size60, - marginRight: size60, + marginRight: sizeNone, marginBottom: size60, marginLeft: size40, flexDirection: 'row', @@ -46,46 +48,58 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) flexDirection: 'column', alignItems: 'center', labelAlignItems: 'center', - labelMarginLeft: size20, + labelMarginRight: sizeNone, + labelMarginVertical: size20, + labelPadding: size20, marginLeft: size60, + marginRight: size60, + marginBottom: sizeNone, }, disabled: { // Unchecked, Disabled - radioBorder: t.colors.neutralForegroundDisabled, + radioOuterCircleBackground: t.colors.neutralBackgroundDisabled, + radioBorder: t.colors.neutralStrokeDisabled, color: t.colors.neutralForegroundDisabled, radioVisibility: 0, }, hovered: { // Unchecked, Hover + radioOuterCircleBackground: t.colors.neutralBackground1, radioBorder: t.colors.neutralStrokeAccessibleHover, - color: t.colors.neutralForeground2, + color: t.colors.neutralForeground1, selected: { // Checked, Hover + radioOuterCircleBackground: t.colors.brandBackgroundHover, radioBorder: t.colors.compoundBrandStroke1Hover, - radioFill: t.colors.compoundBrandBackground1Hover, - color: t.colors.neutralForeground2, + radioFill: t.colors.neutralForegroundOnBrand, + color: t.colors.neutralForeground1, radioVisibility: 1, + radioInnerCircleSize: 10, }, }, pressed: { // Unchecked, Pressed + radioOuterCircleBackground: t.colors.neutralBackground1, radioBorder: t.colors.neutralStrokeAccessiblePressed, color: t.colors.neutralForeground1, selected: { // Checked, Pressed + radioOuterCircleBackground: t.colors.brandBackgroundPressed, radioBorder: t.colors.compoundBrandStroke1Pressed, - radioFill: t.colors.compoundBrandBackground1Pressed, + radioFill: t.colors.neutralForegroundOnBrand, color: t.colors.neutralForeground1, radioVisibility: 1, + radioInnerCircleSize: 6, }, }, focused: { + borderColor: t.colors.strokeFocus2, selected: { // Checked, Focused radioVisibility: 1, @@ -94,9 +108,10 @@ export const defaultRadioTokens: TokenSettings = (t: Theme) selected: { // Checked, Rest + radioOuterCircleBackground: t.colors.brandBackground, radioBorder: t.colors.compoundBrandStroke1, - radioFill: t.colors.compoundBrandStroke1, - color: t.colors.neutralForeground3, + radioFill: t.colors.neutralForegroundOnBrand, + color: t.colors.neutralForeground1, radioVisibility: 1, disabled: { diff --git a/packages/components/RadioGroup/src/__tests__/ColorTokens.test.windows.ts b/packages/components/RadioGroup/src/__tests__/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..0239e79acea --- /dev/null +++ b/packages/components/RadioGroup/src/__tests__/ColorTokens.test.windows.ts @@ -0,0 +1,26 @@ +import { createColorPinningTheme, resolveV0ColorTokens, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings as radioStylingSettings } from '../Radio/Radio.styling'; +import { stylingSettings as radioGroupStylingSettings } from '../RadioGroup/RadioGroup.styling'; +import { settings as radioButtonSettings } from '../legacy/RadioButton.settings'; +import { settings as radioGroupSettings } from '../legacy/RadioGroup.settings'; + +const theme = createColorPinningTheme(); + +describe('RadioGroup color tokens', () => { + it('pins RadioButton v0 colors', () => { + expect(resolveV0ColorTokens(radioButtonSettings, theme)).toMatchSnapshot('RadioButton v0'); + }); + + it('pins RadioGroup v0 colors', () => { + expect(resolveV0ColorTokens(radioGroupSettings, theme)).toMatchSnapshot('RadioGroup v0'); + }); + + it('pins Radio v1 colors', () => { + expect(resolveV1ColorTokens(radioStylingSettings.tokens, theme)).toMatchSnapshot('Radio v1'); + }); + + it('pins RadioGroup v1 colors', () => { + expect(resolveV1ColorTokens(radioGroupStylingSettings.tokens, theme)).toMatchSnapshot('RadioGroup v1'); + }); +}); diff --git a/packages/components/RadioGroup/src/__tests__/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/RadioGroup/src/__tests__/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..e4f3fc0cb8b --- /dev/null +++ b/packages/components/RadioGroup/src/__tests__/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RadioGroup color tokens pins Radio v1 colors: Radio v1 1`] = ` +{ + "borderColor": "#00000000", + "color": "#262626", + "disabled": { + "color": "#B1B1B1", + "radioOuterCircleBackground": "#E6E6E6", + }, + "focused": { + "borderColor": "#969696", + }, + "hovered": { + "color": "#262626", + "radioOuterCircleBackground": "antiquewhite", + "selected": { + "color": "#262626", + "radioFill": "#FFFFFF", + "radioOuterCircleBackground": "#F29F71", + }, + }, + "pressed": { + "color": "#262626", + "radioOuterCircleBackground": "antiquewhite", + "selected": { + "color": "#262626", + "radioFill": "#FFFFFF", + "radioOuterCircleBackground": "#A22C01", + }, + }, + "radioOuterCircleBackground": "antiquewhite", + "selected": { + "color": "#262626", + "disabled": { + "radioFill": "#B1B1B1", + }, + "radioFill": "#FFFFFF", + "radioOuterCircleBackground": "#D83B01", + }, +} +`; + +exports[`RadioGroup color tokens pins RadioButton v0 colors: RadioButton v0 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "backgroundColor": "antiquewhite", + "borderColor": "#D2D2D2", + "color": "#B1B1B1", + }, + }, + "focused": { + "tokens": { + "textBorderColor": "#969696", + }, + }, + }, + "button": { + "style": { + "backgroundColor": "transparent", + }, + }, + "tokens": { + "backgroundColor": "#262626", + "borderColor": "#262626", + "color": "#262626", + "textBorderColor": "transparent", + }, +} +`; + +exports[`RadioGroup color tokens pins RadioGroup v0 colors: RadioGroup v0 1`] = ` +{ + "tokens": { + "color": "#262626", + }, +} +`; + +exports[`RadioGroup color tokens pins RadioGroup v1 colors: RadioGroup v1 1`] = ` +{ + "color": "#262626", + "disabled": { + "color": "#B1B1B1", + }, +} +`; diff --git a/packages/components/Switch/src/SwitchColorTokens.test.windows.ts b/packages/components/Switch/src/SwitchColorTokens.test.windows.ts new file mode 100644 index 00000000000..edf1d5a4c13 --- /dev/null +++ b/packages/components/Switch/src/SwitchColorTokens.test.windows.ts @@ -0,0 +1,9 @@ +import { createColorPinningTheme, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings } from './Switch.styling'; + +it('pins Switch color tokens on Windows', () => { + const theme = createColorPinningTheme(); + + expect(resolveV1ColorTokens(stylingSettings.tokens, theme)).toMatchSnapshot(); +}); diff --git a/packages/components/Switch/src/SwitchTokens.win32.ts b/packages/components/Switch/src/SwitchTokens.macos.ts similarity index 53% rename from packages/components/Switch/src/SwitchTokens.win32.ts rename to packages/components/Switch/src/SwitchTokens.macos.ts index 8acf956fa25..9dd28ddc139 100644 --- a/packages/components/Switch/src/SwitchTokens.win32.ts +++ b/packages/components/Switch/src/SwitchTokens.macos.ts @@ -1,5 +1,4 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { SwitchTokens } from './Switch.types'; @@ -49,43 +48,43 @@ export const defaultSwitchTokens: TokenSettings = (t: Theme toggleOn: { trackColor: t.colors.compoundBrandBackground1, - thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralForegroundInverted, + thumbColor: t.colors.neutralForegroundInverted, borderColor: t.colors.compoundBrandBackground1, justifyContent: 'flex-end', hovered: { - trackColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.compoundBrandBackground1Hover, - thumbColor: isHighContrast(t) ? t.colors.compoundBrandBackground1Hover : t.colors.neutralForegroundInvertedLink, + trackColor: t.colors.compoundBrandBackground1Hover, + thumbColor: t.colors.neutralForegroundInvertedLink, borderColor: t.colors.compoundBrandBackground1Hover, }, pressed: { trackColor: t.colors.compoundBrandBackground1Pressed, - thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralForegroundInvertedLink, + thumbColor: t.colors.neutralForegroundInvertedLink, borderColor: t.colors.compoundBrandBackground1Pressed, }, disabled: { - trackColor: isHighContrast(t) ? t.colors.neutralForegroundDisabled : t.colors.neutralBackgroundDisabled, - thumbColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralStrokeDisabled, + trackColor: t.colors.neutralBackgroundDisabled, + thumbColor: t.colors.neutralStrokeDisabled, borderColor: t.colors.neutralForegroundDisabled, }, }, toggleOff: { - trackColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralForegroundInvertedLink, - thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrand : t.colors.neutralStrokeAccessible, - borderColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrand : t.colors.neutralStrokeAccessible, + trackColor: t.colors.neutralForegroundInvertedLink, + thumbColor: t.colors.neutralStrokeAccessible, + borderColor: t.colors.neutralStrokeAccessible, justifyContent: 'flex-start', hovered: { - trackColor: isHighContrast(t) ? t.colors.brandBackgroundHover : t.colors.neutralForegroundInvertedLinkHover, - thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralStrokeAccessibleHover, - borderColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralStrokeAccessibleHover, + trackColor: t.colors.neutralForegroundInvertedLinkHover, + thumbColor: t.colors.neutralStrokeAccessibleHover, + borderColor: t.colors.neutralStrokeAccessibleHover, }, pressed: { - trackColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandPressed : t.colors.neutralForegroundInvertedLinkPressed, + trackColor: t.colors.neutralForegroundInvertedLinkPressed, thumbColor: t.colors.neutralStrokeAccessiblePressed, borderColor: t.colors.neutralStrokeAccessiblePressed, }, disabled: { - trackColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralBackgroundDisabled, + trackColor: t.colors.neutralBackgroundDisabled, thumbColor: t.colors.neutralStrokeDisabled, borderColor: t.colors.neutralStrokeDisabled, }, diff --git a/packages/components/Switch/src/SwitchTokens.ts b/packages/components/Switch/src/SwitchTokens.ts index 9dd28ddc139..8acf956fa25 100644 --- a/packages/components/Switch/src/SwitchTokens.ts +++ b/packages/components/Switch/src/SwitchTokens.ts @@ -1,4 +1,5 @@ import type { Theme } from '@fluentui-react-native/framework'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { SwitchTokens } from './Switch.types'; @@ -48,43 +49,43 @@ export const defaultSwitchTokens: TokenSettings = (t: Theme toggleOn: { trackColor: t.colors.compoundBrandBackground1, - thumbColor: t.colors.neutralForegroundInverted, + thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralForegroundInverted, borderColor: t.colors.compoundBrandBackground1, justifyContent: 'flex-end', hovered: { - trackColor: t.colors.compoundBrandBackground1Hover, - thumbColor: t.colors.neutralForegroundInvertedLink, + trackColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.compoundBrandBackground1Hover, + thumbColor: isHighContrast(t) ? t.colors.compoundBrandBackground1Hover : t.colors.neutralForegroundInvertedLink, borderColor: t.colors.compoundBrandBackground1Hover, }, pressed: { trackColor: t.colors.compoundBrandBackground1Pressed, - thumbColor: t.colors.neutralForegroundInvertedLink, + thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralForegroundInvertedLink, borderColor: t.colors.compoundBrandBackground1Pressed, }, disabled: { - trackColor: t.colors.neutralBackgroundDisabled, - thumbColor: t.colors.neutralStrokeDisabled, + trackColor: isHighContrast(t) ? t.colors.neutralForegroundDisabled : t.colors.neutralBackgroundDisabled, + thumbColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralStrokeDisabled, borderColor: t.colors.neutralForegroundDisabled, }, }, toggleOff: { - trackColor: t.colors.neutralForegroundInvertedLink, - thumbColor: t.colors.neutralStrokeAccessible, - borderColor: t.colors.neutralStrokeAccessible, + trackColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralForegroundInvertedLink, + thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrand : t.colors.neutralStrokeAccessible, + borderColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrand : t.colors.neutralStrokeAccessible, justifyContent: 'flex-start', hovered: { - trackColor: t.colors.neutralForegroundInvertedLinkHover, - thumbColor: t.colors.neutralStrokeAccessibleHover, - borderColor: t.colors.neutralStrokeAccessibleHover, + trackColor: isHighContrast(t) ? t.colors.brandBackgroundHover : t.colors.neutralForegroundInvertedLinkHover, + thumbColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralStrokeAccessibleHover, + borderColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandHover : t.colors.neutralStrokeAccessibleHover, }, pressed: { - trackColor: t.colors.neutralForegroundInvertedLinkPressed, + trackColor: isHighContrast(t) ? t.colors.neutralForegroundOnBrandPressed : t.colors.neutralForegroundInvertedLinkPressed, thumbColor: t.colors.neutralStrokeAccessiblePressed, borderColor: t.colors.neutralStrokeAccessiblePressed, }, disabled: { - trackColor: t.colors.neutralBackgroundDisabled, + trackColor: isHighContrast(t) ? t.colors.brandBackground : t.colors.neutralBackgroundDisabled, thumbColor: t.colors.neutralStrokeDisabled, borderColor: t.colors.neutralStrokeDisabled, }, diff --git a/packages/components/Switch/src/__snapshots__/SwitchColorTokens.test.windows.ts.snap b/packages/components/Switch/src/__snapshots__/SwitchColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..c3529dbd7b8 --- /dev/null +++ b/packages/components/Switch/src/__snapshots__/SwitchColorTokens.test.windows.ts.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`pins Switch color tokens on Windows 1`] = ` +{ + "color": "#666666", + "focusStrokeColor": "#00000000", + "focused": { + "focusStrokeColor": "#969696", + }, + "toggleOff": { + "borderColor": "#969696", + "disabled": { + "borderColor": "#D2D2D2", + "thumbColor": "#D2D2D2", + "trackColor": "#E6E6E6", + }, + "hovered": { + "borderColor": "#B1B1B1", + "thumbColor": "#B1B1B1", + "trackColor": "#D2D2D2", + }, + "pressed": { + "borderColor": "#737373", + "thumbColor": "#737373", + "trackColor": "#B1B1B1", + }, + "thumbColor": "#969696", + "trackColor": "#FFFFFF", + }, + "toggleOn": { + "borderColor": "#D83B01", + "disabled": { + "borderColor": "#B1B1B1", + "thumbColor": "#D2D2D2", + "trackColor": "#E6E6E6", + }, + "hovered": { + "borderColor": "#EA6115", + "thumbColor": "#FFFFFF", + "trackColor": "#EA6115", + }, + "pressed": { + "borderColor": "#A22C01", + "thumbColor": "#FFFFFF", + "trackColor": "#A22C01", + }, + "thumbColor": "#ffffff", + "trackColor": "#D83B01", + }, +} +`; diff --git a/packages/components/TabList/src/ColorTokens.test.windows.ts b/packages/components/TabList/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..4425f3426cd --- /dev/null +++ b/packages/components/TabList/src/ColorTokens.test.windows.ts @@ -0,0 +1,13 @@ +import { createColorPinningTheme, getColorTokenSnapshot } from '@fluentui-react-native/test-tools'; + +import { useTabTokens } from './Tab/TabTokens'; + +const theme = createColorPinningTheme(); + +describe('TabList color tokens', () => { + it('pins Tab colors', () => { + const [tokens] = useTabTokens(theme); + + expect(getColorTokenSnapshot(tokens, theme)).toMatchSnapshot(); + }); +}); diff --git a/packages/components/TabList/src/Tab/TabColorTokens.macos.ts b/packages/components/TabList/src/Tab/TabColorTokens.macos.ts new file mode 100644 index 00000000000..bf5438c47dc --- /dev/null +++ b/packages/components/TabList/src/Tab/TabColorTokens.macos.ts @@ -0,0 +1,89 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { TabTokens } from '..'; + +export const tabStates: (keyof TabTokens)[] = [ + 'small', + 'medium', + 'large', + 'vertical', + 'hovered', + 'disabled', + 'selected', + 'focused', + 'pressed', + 'transparent', + 'subtle', + 'hasIcon', +]; + +export const defaultTabColorTokens: TokenSettings = (t: Theme) => + ({ + borderColor: t.colors.transparentBackground, + color: t.colors.neutralForeground2, + iconColor: t.colors.neutralForeground2, + indicatorColor: t.colors.transparentBackground, + transparent: { + backgroundColor: t.colors.transparentBackground, + }, + subtle: { + backgroundColor: t.colors.subtleBackground, + }, + selected: { + color: t.colors.neutralForeground1, + iconColor: t.colors.compoundBrandForeground1, + indicatorColor: t.colors.compoundBrandStroke1, + pressed: { + color: t.colors.neutralForeground1Pressed, + iconColor: t.colors.compoundBrandForeground1Pressed, + indicatorColor: t.colors.compoundBrandStroke1Pressed, + }, + }, + disabled: { + color: t.colors.neutralForegroundDisabled, + iconColor: t.colors.neutralForegroundDisabled, + selected: { + color: t.colors.neutralForegroundDisabled, + iconColor: t.colors.neutralForegroundDisabled, + indicatorColor: t.colors.neutralForegroundDisabled, + }, + }, + hovered: { + color: t.colors.neutralForeground2Hover, + iconColor: t.colors.neutralForeground2Hover, + indicatorColor: t.colors.neutralStroke1Hover, + selected: { + color: t.colors.neutralForeground1Hover, + iconColor: t.colors.compoundBrandForeground1Hover, + indicatorColor: t.colors.compoundBrandStroke1Hover, + subtle: { + indicatorColor: t.colors.compoundBrandStroke1Hover, + }, + }, + disabled: { + indicatorColor: t.colors.transparentBackground, + }, + transparent: { + backgroundColor: t.colors.transparentBackgroundHover, + }, + subtle: { + backgroundColor: t.colors.subtleBackgroundHover, + indicatorColor: t.colors.neutralStroke1Hover, + }, + }, + pressed: { + color: t.colors.neutralForeground2Pressed, + iconColor: t.colors.neutralForeground2Pressed, + indicatorColor: t.colors.neutralStroke1Pressed, + transparent: { + backgroundColor: t.colors.transparentBackgroundPressed, + }, + subtle: { + backgroundColor: t.colors.subtleBackgroundPressed, + }, + }, + focused: { + borderColor: t.colors.neutralForeground1, + }, + }) as TabTokens; diff --git a/packages/components/TabList/src/Tab/TabColorTokens.ts b/packages/components/TabList/src/Tab/TabColorTokens.ts index bf5438c47dc..58a9fb18219 100644 --- a/packages/components/TabList/src/Tab/TabColorTokens.ts +++ b/packages/components/TabList/src/Tab/TabColorTokens.ts @@ -1,4 +1,5 @@ import type { Theme } from '@fluentui-react-native/framework'; +import { isHighContrast } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import type { TabTokens } from '..'; @@ -35,30 +36,30 @@ export const defaultTabColorTokens: TokenSettings = (t: Theme) iconColor: t.colors.compoundBrandForeground1, indicatorColor: t.colors.compoundBrandStroke1, pressed: { - color: t.colors.neutralForeground1Pressed, - iconColor: t.colors.compoundBrandForeground1Pressed, + color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground1Pressed, + iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.compoundBrandForeground1Pressed, indicatorColor: t.colors.compoundBrandStroke1Pressed, }, }, disabled: { - color: t.colors.neutralForegroundDisabled, - iconColor: t.colors.neutralForegroundDisabled, + color: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, + iconColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, selected: { - color: t.colors.neutralForegroundDisabled, - iconColor: t.colors.neutralForegroundDisabled, - indicatorColor: t.colors.neutralForegroundDisabled, + color: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, + iconColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, + indicatorColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, }, }, hovered: { - color: t.colors.neutralForeground2Hover, - iconColor: t.colors.neutralForeground2Hover, - indicatorColor: t.colors.neutralStroke1Hover, + color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Hover, + iconColor: isHighContrast(t) ? t.colors.compoundBrandForeground1Hover : t.colors.neutralForeground2Hover, + indicatorColor: isHighContrast(t) ? t.colors.compoundBrandStroke1Hover : t.colors.neutralStroke1Hover, selected: { - color: t.colors.neutralForeground1Hover, - iconColor: t.colors.compoundBrandForeground1Hover, + color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground1Hover, + iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.compoundBrandForeground1Hover, indicatorColor: t.colors.compoundBrandStroke1Hover, subtle: { - indicatorColor: t.colors.compoundBrandStroke1Hover, + indicatorColor: isHighContrast(t) ? t.colors.neutralStroke1 : t.colors.compoundBrandStroke1Hover, }, }, disabled: { @@ -69,13 +70,13 @@ export const defaultTabColorTokens: TokenSettings = (t: Theme) }, subtle: { backgroundColor: t.colors.subtleBackgroundHover, - indicatorColor: t.colors.neutralStroke1Hover, + indicatorColor: isHighContrast(t) ? t.colors.neutralStroke1 : t.colors.neutralStroke1Hover, }, }, pressed: { - color: t.colors.neutralForeground2Pressed, - iconColor: t.colors.neutralForeground2Pressed, - indicatorColor: t.colors.neutralStroke1Pressed, + color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Pressed, + iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Pressed, + indicatorColor: isHighContrast(t) ? t.colors.compoundBrandBackground1Pressed : t.colors.neutralStroke1Pressed, transparent: { backgroundColor: t.colors.transparentBackgroundPressed, }, @@ -84,6 +85,6 @@ export const defaultTabColorTokens: TokenSettings = (t: Theme) }, }, focused: { - borderColor: t.colors.neutralForeground1, + borderColor: isHighContrast(t) ? t.colors.compoundBrandStroke1 : t.colors.neutralForeground1, }, }) as TabTokens; diff --git a/packages/components/TabList/src/Tab/TabColorTokens.win32.ts b/packages/components/TabList/src/Tab/TabColorTokens.win32.ts deleted file mode 100644 index 58a9fb18219..00000000000 --- a/packages/components/TabList/src/Tab/TabColorTokens.win32.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { Theme } from '@fluentui-react-native/framework'; -import { isHighContrast } from '@fluentui-react-native/design/theming'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { TabTokens } from '..'; - -export const tabStates: (keyof TabTokens)[] = [ - 'small', - 'medium', - 'large', - 'vertical', - 'hovered', - 'disabled', - 'selected', - 'focused', - 'pressed', - 'transparent', - 'subtle', - 'hasIcon', -]; - -export const defaultTabColorTokens: TokenSettings = (t: Theme) => - ({ - borderColor: t.colors.transparentBackground, - color: t.colors.neutralForeground2, - iconColor: t.colors.neutralForeground2, - indicatorColor: t.colors.transparentBackground, - transparent: { - backgroundColor: t.colors.transparentBackground, - }, - subtle: { - backgroundColor: t.colors.subtleBackground, - }, - selected: { - color: t.colors.neutralForeground1, - iconColor: t.colors.compoundBrandForeground1, - indicatorColor: t.colors.compoundBrandStroke1, - pressed: { - color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground1Pressed, - iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.compoundBrandForeground1Pressed, - indicatorColor: t.colors.compoundBrandStroke1Pressed, - }, - }, - disabled: { - color: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, - iconColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, - selected: { - color: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, - iconColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, - indicatorColor: isHighContrast(t) ? t.colors.neutralStrokeDisabled : t.colors.neutralForegroundDisabled, - }, - }, - hovered: { - color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Hover, - iconColor: isHighContrast(t) ? t.colors.compoundBrandForeground1Hover : t.colors.neutralForeground2Hover, - indicatorColor: isHighContrast(t) ? t.colors.compoundBrandStroke1Hover : t.colors.neutralStroke1Hover, - selected: { - color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground1Hover, - iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.compoundBrandForeground1Hover, - indicatorColor: t.colors.compoundBrandStroke1Hover, - subtle: { - indicatorColor: isHighContrast(t) ? t.colors.neutralStroke1 : t.colors.compoundBrandStroke1Hover, - }, - }, - disabled: { - indicatorColor: t.colors.transparentBackground, - }, - transparent: { - backgroundColor: t.colors.transparentBackgroundHover, - }, - subtle: { - backgroundColor: t.colors.subtleBackgroundHover, - indicatorColor: isHighContrast(t) ? t.colors.neutralStroke1 : t.colors.neutralStroke1Hover, - }, - }, - pressed: { - color: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Pressed, - iconColor: isHighContrast(t) ? t.colors.neutralForeground2 : t.colors.neutralForeground2Pressed, - indicatorColor: isHighContrast(t) ? t.colors.compoundBrandBackground1Pressed : t.colors.neutralStroke1Pressed, - transparent: { - backgroundColor: t.colors.transparentBackgroundPressed, - }, - subtle: { - backgroundColor: t.colors.subtleBackgroundPressed, - }, - }, - focused: { - borderColor: isHighContrast(t) ? t.colors.compoundBrandStroke1 : t.colors.neutralForeground1, - }, - }) as TabTokens; diff --git a/packages/components/TabList/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/TabList/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..4d3d010ea5c --- /dev/null +++ b/packages/components/TabList/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TabList color tokens pins Tab colors 1`] = ` +{ + "borderColor": "#00000000", + "color": "#666666", + "disabled": { + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + "selected": { + "color": "#B1B1B1", + "iconColor": "#B1B1B1", + "indicatorColor": "#B1B1B1", + }, + }, + "focused": { + "borderColor": "#262626", + }, + "hovered": { + "color": "#505050", + "disabled": { + "indicatorColor": "#00000000", + }, + "iconColor": "#505050", + "indicatorColor": "#969696", + "selected": { + "color": "#262626", + "iconColor": "#EA6115", + "indicatorColor": "#EA6115", + "subtle": { + "indicatorColor": "#EA6115", + }, + }, + "subtle": { + "backgroundColor": "#f5f5f5", + "indicatorColor": "#969696", + }, + "transparent": { + "backgroundColor": "#00000000", + }, + }, + "iconColor": "#666666", + "indicatorColor": "#00000000", + "pressed": { + "color": "#666666", + "iconColor": "#666666", + "indicatorColor": "#00000000", + "subtle": { + "backgroundColor": "#e0e0e0", + }, + "transparent": { + "backgroundColor": "#00000000", + }, + }, + "selected": { + "color": "#262626", + "iconColor": "#D83B01", + "indicatorColor": "#D83B01", + "pressed": { + "color": "#262626", + "iconColor": "#A22C01", + "indicatorColor": "#A22C01", + }, + }, + "subtle": { + "backgroundColor": "#00000000", + }, + "transparent": { + "backgroundColor": "#00000000", + }, +} +`; diff --git a/packages/components/Text/src/ColorTokens.test.windows.ts b/packages/components/Text/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..22eef2a9029 --- /dev/null +++ b/packages/components/Text/src/ColorTokens.test.windows.ts @@ -0,0 +1,17 @@ +import { createColorPinningTheme, getColorTokenSnapshot, resolveV0ColorTokens } from '@fluentui-react-native/test-tools'; + +import { useTextTokens } from './TextTokens'; +import { settings } from './deprecated/Text.settings'; + +const theme = createColorPinningTheme(); + +describe('Text color tokens', () => { + it('pins v0 Text color tokens', () => { + expect(resolveV0ColorTokens(settings, theme)).toMatchSnapshot(); + }); + + it('pins v1 Text color tokens', () => { + const [tokens] = useTextTokens(theme); + expect(getColorTokenSnapshot(tokens, theme)).toMatchSnapshot(); + }); +}); diff --git a/packages/components/Text/src/Variants.macos.ts b/packages/components/Text/src/Variants.macos.ts new file mode 100644 index 00000000000..975544810e1 --- /dev/null +++ b/packages/components/Text/src/Variants.macos.ts @@ -0,0 +1,20 @@ +import { Text } from './Text'; + +// stubbed out for other platforms for which variant alias tokens aren't defined +export const Caption1 = Text; +export const Caption1Strong = Text; +export const Caption2 = Text; +export const Body1 = Text; +export const Body1Strong = Text; +export const Body2 = Text; +export const Body2Strong = Text; +export const Subtitle1 = Text; +export const Subtitle1Strong = Text; +export const Subtitle2 = Text; +export const Subtitle2Strong = Text; +export const Title1 = Text; +export const Title1Strong = Text; +export const Title2 = Text; +export const Title3 = Text; +export const LargeTitle = Text; +export const Display = Text; diff --git a/packages/components/Text/src/Variants.ts b/packages/components/Text/src/Variants.ts index 975544810e1..1b5eb8a031e 100644 --- a/packages/components/Text/src/Variants.ts +++ b/packages/components/Text/src/Variants.ts @@ -1,20 +1,45 @@ import { Text } from './Text'; -// stubbed out for other platforms for which variant alias tokens aren't defined -export const Caption1 = Text; -export const Caption1Strong = Text; -export const Caption2 = Text; -export const Body1 = Text; -export const Body1Strong = Text; -export const Body2 = Text; -export const Body2Strong = Text; -export const Subtitle1 = Text; -export const Subtitle1Strong = Text; -export const Subtitle2 = Text; -export const Subtitle2Strong = Text; -export const Title1 = Text; -export const Title1Strong = Text; -export const Title2 = Text; -export const Title3 = Text; -export const LargeTitle = Text; -export const Display = Text; +export const Caption1 = Text.customize({ + variant: 'caption1', +}); +export const Caption1Strong = null; // Not supported on Win32 +export const Caption2 = null; // Not supported on Win32 +export const Body1 = Text.customize({ + variant: 'body1', +}); +export const Body1Strong = Text.customize({ + variant: 'body1Strong', +}); +export const Body2 = Text.customize({ + variant: 'body2', +}); +export const Body2Strong = Text.customize({ + variant: 'body2Strong', +}); +export const Subtitle1 = Text.customize({ + variant: 'subtitle1', +}); +export const Subtitle1Strong = Text.customize({ + variant: 'subtitle1Strong', +}); +export const Subtitle2 = Text.customize({ + variant: 'subtitle2', +}); +export const Subtitle2Strong = Text.customize({ + variant: 'subtitle2Strong', +}); +export const Title1 = Text.customize({ + variant: 'title1', +}); +export const Title1Strong = Text.customize({ + variant: 'title1Strong', +}); +export const Title2 = null; // Not supported on Win32 +export const Title3 = null; // Not supported on Win32 +export const LargeTitle = Text.customize({ + variant: 'largeTitle', +}); +export const Display = Text.customize({ + variant: 'display', +}); diff --git a/packages/components/Text/src/Variants.win32.ts b/packages/components/Text/src/Variants.win32.ts deleted file mode 100644 index 1b5eb8a031e..00000000000 --- a/packages/components/Text/src/Variants.win32.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Text } from './Text'; - -export const Caption1 = Text.customize({ - variant: 'caption1', -}); -export const Caption1Strong = null; // Not supported on Win32 -export const Caption2 = null; // Not supported on Win32 -export const Body1 = Text.customize({ - variant: 'body1', -}); -export const Body1Strong = Text.customize({ - variant: 'body1Strong', -}); -export const Body2 = Text.customize({ - variant: 'body2', -}); -export const Body2Strong = Text.customize({ - variant: 'body2Strong', -}); -export const Subtitle1 = Text.customize({ - variant: 'subtitle1', -}); -export const Subtitle1Strong = Text.customize({ - variant: 'subtitle1Strong', -}); -export const Subtitle2 = Text.customize({ - variant: 'subtitle2', -}); -export const Subtitle2Strong = Text.customize({ - variant: 'subtitle2Strong', -}); -export const Title1 = Text.customize({ - variant: 'title1', -}); -export const Title1Strong = Text.customize({ - variant: 'title1Strong', -}); -export const Title2 = null; // Not supported on Win32 -export const Title3 = null; // Not supported on Win32 -export const LargeTitle = Text.customize({ - variant: 'largeTitle', -}); -export const Display = Text.customize({ - variant: 'display', -}); diff --git a/packages/components/Text/src/Variants.windows.ts b/packages/components/Text/src/Variants.windows.ts deleted file mode 100644 index b42ae7a860f..00000000000 --- a/packages/components/Text/src/Variants.windows.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Text } from './Text'; - -export const Caption1 = Text.customize({ - variant: 'caption1', -}); -export const Caption1Strong = null; // Not supported on windows -export const Caption2 = null; // Not supported on windows -export const Body1 = Text.customize({ - variant: 'body1', -}); -export const Body1Strong = Text.customize({ - variant: 'body1Strong', -}); -export const Body2 = Text.customize({ - variant: 'body2', -}); -export const Body2Strong = Text.customize({ - variant: 'body2Strong', -}); -export const Subtitle1 = Text.customize({ - variant: 'subtitle1', -}); -export const Subtitle1Strong = Text.customize({ - variant: 'subtitle1Strong', -}); -export const Subtitle2 = Text.customize({ - variant: 'subtitle2', -}); -export const Subtitle2Strong = Text.customize({ - variant: 'subtitle2Strong', -}); -export const Title1 = Text.customize({ - variant: 'title1', -}); -export const Title1Strong = Text.customize({ - variant: 'title1Strong', -}); -export const Title2 = null; // Not supported on windows -export const Title3 = null; // Not supported on windows -export const LargeTitle = Text.customize({ - variant: 'largeTitle', -}); -export const Display = Text.customize({ - variant: 'display', -}); diff --git a/packages/components/Text/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/components/Text/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..97d736b4b0e --- /dev/null +++ b/packages/components/Text/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Text color tokens pins v0 Text color tokens 1`] = ` +{ + "_overrides": { + "disabled": { + "tokens": { + "color": "#B1B1B1", + }, + }, + }, + "tokens": { + "color": "#262626", + }, +} +`; + +exports[`Text color tokens pins v1 Text color tokens 1`] = ` +{ + "color": "#262626", +} +`; diff --git a/packages/experimental/Shimmer/src/ColorTokens.test.windows.ts b/packages/experimental/Shimmer/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..9b1bf522cfc --- /dev/null +++ b/packages/experimental/Shimmer/src/ColorTokens.test.windows.ts @@ -0,0 +1,9 @@ +import { createColorPinningTheme, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings } from './Shimmer.styling'; + +it('pins Shimmer color tokens on Windows', () => { + const theme = createColorPinningTheme(); + + expect(resolveV1ColorTokens(stylingSettings.tokens, theme)).toMatchSnapshot(); +}); diff --git a/packages/experimental/Shimmer/src/Shimmer.styling.win32.ts b/packages/experimental/Shimmer/src/Shimmer.styling.win32.ts index fc2dd705f61..249a6f6aa35 100644 --- a/packages/experimental/Shimmer/src/Shimmer.styling.win32.ts +++ b/packages/experimental/Shimmer/src/Shimmer.styling.win32.ts @@ -4,7 +4,7 @@ import { buildProps } from '@fluentui-react-native/framework'; import type { ShimmerProps, ShimmerTokens } from './Shimmer.types'; import { shimmerName } from './Shimmer.types'; import type { ShimmerSlotProps } from './Shimmer.types.win32'; -import { defaultShimmerTokens } from './ShimmerTokens.win32'; +import { defaultShimmerTokens } from './ShimmerTokens'; /** * tell the styling hook how to build up the tokens diff --git a/packages/experimental/Shimmer/src/ShimmerTokens.win32.ts b/packages/experimental/Shimmer/src/ShimmerTokens.macos.ts similarity index 61% rename from packages/experimental/Shimmer/src/ShimmerTokens.win32.ts rename to packages/experimental/Shimmer/src/ShimmerTokens.macos.ts index 04b5c250e23..c2c8d903b9a 100644 --- a/packages/experimental/Shimmer/src/ShimmerTokens.win32.ts +++ b/packages/experimental/Shimmer/src/ShimmerTokens.macos.ts @@ -1,4 +1,5 @@ import type { Theme } from '@fluentui-react-native/framework'; +import { getCurrentAppearance } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import { shimmerDefaultAngle, shimmerDefaultDelay, shimmerDefaultDuration } from './consts'; @@ -7,12 +8,11 @@ import type { ShimmerTokens } from './Shimmer.types'; export const defaultShimmerTokens: TokenSettings = (theme: Theme) => ({ angle: shimmerDefaultAngle, - backgroundColor: theme.colors.background, + backgroundColor: theme.colors.transparentBackground, delay: shimmerDefaultDelay, duration: shimmerDefaultDuration, - shimmerColor: theme.colors.bodyFrameDivider, + shimmerColor: getCurrentAppearance(theme.host.appearance, 'light') === 'light' ? '#E1E1E1' : '#404040', shimmerColorOpacity: 1, - shimmerWaveColor: '#E1E1E1', + shimmerWaveColor: getCurrentAppearance(theme.host.appearance, 'light') === 'light' ? 'white' : 'black', shimmerWaveColorOpacity: 1, - shimmerWaveWidth: '100%', }) as ShimmerTokens; diff --git a/packages/experimental/Shimmer/src/ShimmerTokens.ts b/packages/experimental/Shimmer/src/ShimmerTokens.ts index c2c8d903b9a..04b5c250e23 100644 --- a/packages/experimental/Shimmer/src/ShimmerTokens.ts +++ b/packages/experimental/Shimmer/src/ShimmerTokens.ts @@ -1,5 +1,4 @@ import type { Theme } from '@fluentui-react-native/framework'; -import { getCurrentAppearance } from '@fluentui-react-native/design/theming'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; import { shimmerDefaultAngle, shimmerDefaultDelay, shimmerDefaultDuration } from './consts'; @@ -8,11 +7,12 @@ import type { ShimmerTokens } from './Shimmer.types'; export const defaultShimmerTokens: TokenSettings = (theme: Theme) => ({ angle: shimmerDefaultAngle, - backgroundColor: theme.colors.transparentBackground, + backgroundColor: theme.colors.background, delay: shimmerDefaultDelay, duration: shimmerDefaultDuration, - shimmerColor: getCurrentAppearance(theme.host.appearance, 'light') === 'light' ? '#E1E1E1' : '#404040', + shimmerColor: theme.colors.bodyFrameDivider, shimmerColorOpacity: 1, - shimmerWaveColor: getCurrentAppearance(theme.host.appearance, 'light') === 'light' ? 'white' : 'black', + shimmerWaveColor: '#E1E1E1', shimmerWaveColorOpacity: 1, + shimmerWaveWidth: '100%', }) as ShimmerTokens; diff --git a/packages/experimental/Shimmer/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/experimental/Shimmer/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..e999c94a7de --- /dev/null +++ b/packages/experimental/Shimmer/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`pins Shimmer color tokens on Windows 1`] = ` +{ + "backgroundColor": "antiquewhite", + "shimmerColor": "#E6E6E6", + "shimmerWaveColor": "#E1E1E1", +} +`; diff --git a/packages/experimental/Spinner/src/ColorTokens.test.windows.ts b/packages/experimental/Spinner/src/ColorTokens.test.windows.ts new file mode 100644 index 00000000000..32017736014 --- /dev/null +++ b/packages/experimental/Spinner/src/ColorTokens.test.windows.ts @@ -0,0 +1,9 @@ +import { createColorPinningTheme, resolveV1ColorTokens } from '@fluentui-react-native/test-tools'; + +import { stylingSettings } from './Spinner.styling'; + +it('pins Spinner color tokens on Windows', () => { + const theme = createColorPinningTheme(); + + expect(resolveV1ColorTokens(stylingSettings.tokens, theme)).toMatchSnapshot(); +}); diff --git a/packages/experimental/Spinner/src/Spinner.android.tsx b/packages/experimental/Spinner/src/Spinner.android.tsx index 15e4bfe3d20..7fb455c9a5c 100644 --- a/packages/experimental/Spinner/src/Spinner.android.tsx +++ b/packages/experimental/Spinner/src/Spinner.android.tsx @@ -12,7 +12,7 @@ import type { SvgProps } from 'react-native-svg'; import { stylingSettings } from './Spinner.styling'; import type { SpinnerProps, SpinnerType } from './Spinner.types'; import { spinnerName } from './Spinner.types'; -import { diameterSizeMap, lineThicknessSizeMap } from './SpinnerTokens.win32'; +import { diameterSizeMap, lineThicknessSizeMap } from './SpinnerSizeMaps'; import { useSpinner } from './useSpinner'; const getSpinnerPath = (diameter: number, width: number, color: ColorValue) => { diff --git a/packages/experimental/Spinner/src/Spinner.win32.tsx b/packages/experimental/Spinner/src/Spinner.win32.tsx index d82a34b2aa8..c6f7ad86d28 100644 --- a/packages/experimental/Spinner/src/Spinner.win32.tsx +++ b/packages/experimental/Spinner/src/Spinner.win32.tsx @@ -18,7 +18,7 @@ import type { SvgProps } from 'react-native-svg'; import { stylingSettings } from './Spinner.styling.win32'; import { spinnerName } from './Spinner.types'; import type { SpinnerProps, SpinnerType, SpinnerSvgProps } from './Spinner.types.win32'; -import { diameterSizeMap, lineThicknessSizeMap, getDefaultSize } from './SpinnerTokens.win32'; +import { diameterSizeMap, lineThicknessSizeMap, getDefaultSize } from './SpinnerTokens'; import { useSpinner } from './useSpinner'; import RCTNativeAnimatedContainer from './Win32NativeAnimatedContainerNativeComponent'; diff --git a/packages/experimental/Spinner/src/SpinnerSizeMaps.ts b/packages/experimental/Spinner/src/SpinnerSizeMaps.ts new file mode 100644 index 00000000000..0848557d3ec --- /dev/null +++ b/packages/experimental/Spinner/src/SpinnerSizeMaps.ts @@ -0,0 +1,19 @@ +export const diameterSizeMap: { [key: string]: number } = { + tiny: 20, + 'x-small': 24, + small: 28, + medium: 32, + large: 36, + 'x-large': 40, + huge: 44, +}; + +export const lineThicknessSizeMap: { [key: string]: number } = { + tiny: 2, + 'x-small': 2, + small: 2, + medium: 3, + large: 3, + 'x-large': 3, + huge: 4, +}; diff --git a/packages/experimental/Spinner/src/SpinnerTokens.ios.ts b/packages/experimental/Spinner/src/SpinnerTokens.ios.ts new file mode 100644 index 00000000000..07244780935 --- /dev/null +++ b/packages/experimental/Spinner/src/SpinnerTokens.ios.ts @@ -0,0 +1 @@ +export { defaultSpinnerTokens, diameterSizeMap, lineThicknessSizeMap } from './SpinnerTokens.mobile'; diff --git a/packages/experimental/Spinner/src/SpinnerTokens.macos.ts b/packages/experimental/Spinner/src/SpinnerTokens.macos.ts new file mode 100644 index 00000000000..07244780935 --- /dev/null +++ b/packages/experimental/Spinner/src/SpinnerTokens.macos.ts @@ -0,0 +1 @@ +export { defaultSpinnerTokens, diameterSizeMap, lineThicknessSizeMap } from './SpinnerTokens.mobile'; diff --git a/packages/experimental/Spinner/src/SpinnerTokens.mobile.ts b/packages/experimental/Spinner/src/SpinnerTokens.mobile.ts new file mode 100644 index 00000000000..fab39ffc5c6 --- /dev/null +++ b/packages/experimental/Spinner/src/SpinnerTokens.mobile.ts @@ -0,0 +1,50 @@ +import type { Theme } from '@fluentui-react-native/framework'; +import type { TokenSettings } from '@fluentui-react-native/use-styling'; + +import type { SpinnerTokens } from './Spinner.types'; + +export const diameterSizeMap: { [key: string]: number } = { + 'xx-small': 12, + 'x-small': 16, + medium: 24, + large: 32, + 'x-large': 40, +}; + +export const lineThicknessSizeMap: { [key: string]: number } = { + 'xx-small': 1, + 'x-small': 1, + medium: 2, + large: 3, + 'x-large': 4, +}; + +export const defaultSpinnerTokens: TokenSettings = (t: Theme) => + ({ + xxSmall: { + size: 'xx-small', + width: diameterSizeMap['xx-small'], + height: diameterSizeMap['xx-small'], + }, + small: { + size: 'x-small', + width: diameterSizeMap['x-small'], + height: diameterSizeMap['x-small'], + }, + medium: { + size: 'medium', + width: diameterSizeMap['medium'], + height: diameterSizeMap['medium'], + }, + large: { + size: 'large', + width: diameterSizeMap['large'], + height: diameterSizeMap['large'], + }, + xlarge: { + size: 'x-large', + width: diameterSizeMap['x-large'], + height: diameterSizeMap['x-large'], + }, + trackColor: t.colors.brandStroke2, + }) as SpinnerTokens; diff --git a/packages/experimental/Spinner/src/SpinnerTokens.ts b/packages/experimental/Spinner/src/SpinnerTokens.ts index 24a8334aa47..4be4783e910 100644 --- a/packages/experimental/Spinner/src/SpinnerTokens.ts +++ b/packages/experimental/Spinner/src/SpinnerTokens.ts @@ -1,36 +1,42 @@ -import type { Theme } from '@fluentui-react-native/framework'; +import type { Theme, Variant } from '@fluentui-react-native/framework'; import type { TokenSettings } from '@fluentui-react-native/use-styling'; -import type { SpinnerTokens } from './Spinner.types'; +import type { SpinnerSize, SpinnerTokens } from './Spinner.types'; +import { diameterSizeMap, lineThicknessSizeMap } from './SpinnerSizeMaps'; -/* Mobile sizes */ -export const diameterSizeMap: { [key: string]: number } = { - 'xx-small': 12, - 'x-small': 16, - medium: 24, - large: 32, - 'x-large': 40, +export { diameterSizeMap, lineThicknessSizeMap }; + +export const textStyleMap: { [key: string]: Variant } = { + tiny: 'body1', + 'x-small': 'body1', + small: 'body1', + medium: 'subtitle2', + large: 'subtitle2', + 'x-large': 'subtitle2', + huge: 'subtitle1', }; -export const lineThicknessSizeMap: { [key: string]: number } = { - 'xx-small': 1, - 'x-small': 1, - medium: 2, - large: 3, - 'x-large': 4, + +export const getDefaultSize = (): SpinnerSize => { + return 'medium'; }; export const defaultSpinnerTokens: TokenSettings = (t: Theme) => ({ - xxSmall: { - size: 'xx-small', - width: diameterSizeMap['xx-small'], - height: diameterSizeMap['xx-small'], + tiny: { + size: 'tiny', + width: diameterSizeMap['tiny'], + height: diameterSizeMap['tiny'], }, - small: { + 'x-small': { size: 'x-small', width: diameterSizeMap['x-small'], height: diameterSizeMap['x-small'], }, + small: { + size: 'small', + width: diameterSizeMap['small'], + height: diameterSizeMap['small'], + }, medium: { size: 'medium', width: diameterSizeMap['medium'], @@ -41,10 +47,20 @@ export const defaultSpinnerTokens: TokenSettings = (t: The width: diameterSizeMap['large'], height: diameterSizeMap['large'], }, - xlarge: { + 'x-large': { size: 'x-large', width: diameterSizeMap['x-large'], height: diameterSizeMap['x-large'], }, + huge: { + size: 'huge', + width: diameterSizeMap['huge'], + height: diameterSizeMap['huge'], + }, + tailColor: t.colors.brandStroke1, trackColor: t.colors.brandStroke2, + inverted: { + tailColor: t.colors.neutralStroke2, + trackColor: t.colors.neutralBackgroundInverted, + }, }) as SpinnerTokens; diff --git a/packages/experimental/Spinner/src/SpinnerTokens.win32.ts b/packages/experimental/Spinner/src/SpinnerTokens.win32.ts deleted file mode 100644 index 154e5fb0bf1..00000000000 --- a/packages/experimental/Spinner/src/SpinnerTokens.win32.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { Theme, Variant } from '@fluentui-react-native/framework'; -import type { TokenSettings } from '@fluentui-react-native/use-styling'; - -import type { SpinnerSize, SpinnerTokens } from './Spinner.types.win32'; - -export const diameterSizeMap: { [key: string]: number } = { - tiny: 20, - 'x-small': 24, - small: 28, - medium: 32, - large: 36, - 'x-large': 40, - huge: 44, -}; -export const lineThicknessSizeMap: { [key: string]: number } = { - tiny: 2, - 'x-small': 2, - small: 2, - medium: 3, - large: 3, - 'x-large': 3, - huge: 4, -}; - -export const textStyleMap: { [key: string]: Variant } = { - tiny: 'body1', - 'x-small': 'body1', - small: 'body1', - medium: 'subtitle2', - large: 'subtitle2', - 'x-large': 'subtitle2', - huge: 'subtitle1', -}; - -export const getDefaultSize = (): SpinnerSize => { - return 'medium'; -}; - -export const defaultSpinnerTokens: TokenSettings = (t: Theme) => - ({ - tiny: { - size: 'tiny', - width: diameterSizeMap['tiny'], - height: diameterSizeMap['tiny'], - }, - 'x-small': { - size: 'x-small', - width: diameterSizeMap['x-small'], - height: diameterSizeMap['x-small'], - }, - small: { - size: 'small', - width: diameterSizeMap['small'], - height: diameterSizeMap['small'], - }, - medium: { - size: 'medium', - width: diameterSizeMap['medium'], - height: diameterSizeMap['medium'], - }, - large: { - size: 'large', - width: diameterSizeMap['large'], - height: diameterSizeMap['large'], - }, - 'x-large': { - size: 'x-large', - width: diameterSizeMap['x-large'], - height: diameterSizeMap['x-large'], - }, - huge: { - size: 'huge', - width: diameterSizeMap['huge'], - height: diameterSizeMap['huge'], - }, - tailColor: t.colors.brandStroke1, - trackColor: t.colors.brandStroke2, - inverted: { - tailColor: t.colors.neutralStroke2, - trackColor: t.colors.neutralBackgroundInverted, - }, - }) as SpinnerTokens; diff --git a/packages/experimental/Spinner/src/__snapshots__/ColorTokens.test.windows.ts.snap b/packages/experimental/Spinner/src/__snapshots__/ColorTokens.test.windows.ts.snap new file mode 100644 index 00000000000..63e3a0d904b --- /dev/null +++ b/packages/experimental/Spinner/src/__snapshots__/ColorTokens.test.windows.ts.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`pins Spinner color tokens on Windows 1`] = ` +{ + "inverted": { + "tailColor": "#262626", + "trackColor": "#737373", + }, + "tailColor": "#D83B01", + "trackColor": "#d2e0f4", +} +`; diff --git a/packages/utils/test-tools/README.md b/packages/utils/test-tools/README.md index 87326c4a940..cd82ee618f7 100644 --- a/packages/utils/test-tools/README.md +++ b/packages/utils/test-tools/README.md @@ -5,5 +5,6 @@ This is a dev environment only private package designed to aid in testing compon ## Color token pinning `createColorPinningTheme` resolves the platform theme selected by Jest. Pair it with `resolveV0ColorTokens`, -`resolveV1ColorTokens`, or `getColorTokenSnapshot` in `.test.win32.ts` and `.test.macos.ts` files to snapshot only -color-bearing token leaves while preserving nested component states. +`resolveV1ColorTokens`, or `getColorTokenSnapshot` in `.test.windows.ts`, `.test.win32.ts`, and `.test.macos.ts` files to +snapshot only color-bearing token leaves while preserving nested component states. Windows and Win32 intentionally use +the same Office theme to verify their shared styling contract. diff --git a/packages/utils/test-tools/src/colorPinningTheme.test.windows.ts b/packages/utils/test-tools/src/colorPinningTheme.test.windows.ts new file mode 100644 index 00000000000..51c9ecf6fc5 --- /dev/null +++ b/packages/utils/test-tools/src/colorPinningTheme.test.windows.ts @@ -0,0 +1,8 @@ +import { createColorPinningTheme } from './colorPinningTheme'; + +it('creates an Office color pinning theme for Windows', () => { + const theme = createColorPinningTheme(); + + expect(Object.keys(theme.colors).length).toBeGreaterThan(0); + expect(theme.host.appearance).toBe('light'); +}); diff --git a/packages/utils/test-tools/src/colorPinningTheme.windows.ts b/packages/utils/test-tools/src/colorPinningTheme.windows.ts new file mode 100644 index 00000000000..a74efc8161e --- /dev/null +++ b/packages/utils/test-tools/src/colorPinningTheme.windows.ts @@ -0,0 +1,6 @@ +import type { Theme } from '@fluentui-react-native/design/theming'; +import { createOfficeTheme } from '@fluentui-react-native/win32-theme'; + +export function createColorPinningTheme(): Theme { + return createOfficeTheme({ appearance: 'light', paletteName: 'TaskPane' }).theme; +}