diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9288891ec7e324..57f8579394b223 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -331,6 +331,8 @@ packages/react-components/component-selector-preview/library @microsoft/teams-pr packages/react-components/component-selector-preview/stories @microsoft/teams-prg packages/react-components/react-menu-grid-preview/library @microsoft/teams-prg packages/react-components/react-menu-grid-preview/stories @microsoft/teams-prg +packages/react-components/visual-refresh-preview/library @microsoft/teams-prg +packages/react-components/visual-refresh-preview/stories @microsoft/teams-prg # <%= NX-CODEOWNER-PLACEHOLDER %> # Deprecated v9 packages - exposed as part of `/unstable` api diff --git a/packages/react-components/react-button/library/src/components/Button/useButtonStyles.styles.ts b/packages/react-components/react-button/library/src/components/Button/useButtonStyles.styles.ts index 186d0f7a86d58e..f95dfb754f2f55 100644 --- a/packages/react-components/react-button/library/src/components/Button/useButtonStyles.styles.ts +++ b/packages/react-components/react-button/library/src/components/Button/useButtonStyles.styles.ts @@ -4,8 +4,10 @@ import { iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster'; import { tokens } from '@fluentui/react-theme'; import { shorthands, makeStyles, makeResetStyles, mergeClasses } from '@griffel/react'; +import type { GriffelStyle } from '@griffel/react'; +import { semanticTokenVar, useIsVisualRefreshEnabled } from '@fluentui/visual-refresh-preview'; import type { SlotClassNames } from '@fluentui/react-utilities'; -import type { ButtonSlots, ButtonState } from './Button.types'; +import type { ButtonProps, ButtonSlots, ButtonState } from './Button.types'; export const buttonClassNames: SlotClassNames = { root: 'fui-Button', @@ -550,9 +552,153 @@ const useIconStyles = makeStyles({ }, }); +export type VisualRefreshAppearanceName = 'base' | NonNullable; + +type VisualRefreshAppearanceVariant = VisualRefreshAppearanceName | 'base' | 'neutral' | 'brand'; + +const visualRefreshAppearanceAlias: Record< + VisualRefreshAppearanceVariant, + 'neutral' | 'brand' | 'outline' | 'subtle' | 'transparent' +> = { + base: 'neutral', + neutral: 'neutral', + secondary: 'neutral', + brand: 'brand', + primary: 'brand', + outline: 'outline', + subtle: 'subtle', + transparent: 'transparent', +}; + +type SemanticTokenName = Parameters[0]; + +const getSemanticTokenValue = (token: string) => semanticTokenVar(token as SemanticTokenName); +const createVisualRefreshAppearanceStyles = (appearance: VisualRefreshAppearanceVariant): GriffelStyle => { + const tokenGroup = visualRefreshAppearanceAlias[appearance] ?? 'neutral'; + const foregroundTokenBase = `foreground/ctrl/${tokenGroup}`; + const backgroundTokenBase = `background/ctrl/${tokenGroup}`; + const borderTokenBase = `borderColor/ctrl/${tokenGroup}`; + const iconColorTokenBase = `iconColor/ctrl/${tokenGroup}`; + + return { + color: getSemanticTokenValue(`${foregroundTokenBase}/rest`), + backgroundColor: getSemanticTokenValue(`${backgroundTokenBase}/rest`), + ...shorthands.borderColor(getSemanticTokenValue(`${borderTokenBase}/rest`)), + [`& .${buttonClassNames.icon}`]: { + color: getSemanticTokenValue(`${iconColorTokenBase}/rest`), + }, + + ':hover': { + color: getSemanticTokenValue(`${foregroundTokenBase}/hover`), + backgroundColor: getSemanticTokenValue(`${backgroundTokenBase}/hover`), + ...shorthands.borderColor(getSemanticTokenValue(`${borderTokenBase}/hover`)), + [`& .${iconFilledClassName}`]: { + display: 'inline', + }, + [`& .${iconRegularClassName}`]: { + display: 'none', + }, + [`& .${buttonClassNames.icon}`]: { + color: getSemanticTokenValue(`${iconColorTokenBase}/hover`), + }, + }, + + ':hover:active': { + color: getSemanticTokenValue(`${foregroundTokenBase}/pressed`), + backgroundColor: getSemanticTokenValue(`${backgroundTokenBase}/pressed`), + ...shorthands.borderColor(getSemanticTokenValue(`${borderTokenBase}/pressed`)), + [`& .${buttonClassNames.icon}`]: { + color: getSemanticTokenValue(`${iconColorTokenBase}/pressed`), + }, + }, + + ':disabled': { + pointerEvents: 'none', + color: getSemanticTokenValue(`${foregroundTokenBase}/disabled`), + backgroundColor: getSemanticTokenValue(`${backgroundTokenBase}/disabled`), + ...shorthands.borderColor(getSemanticTokenValue(`${borderTokenBase}/disabled`)), + [`& .${buttonClassNames.icon}`]: { + color: getSemanticTokenValue(`${iconColorTokenBase}/disabled`), + }, + }, + }; +}; + +const useVisualRefreshStyles = makeStyles({ + base: createVisualRefreshAppearanceStyles('base'), + + // Appearance variations + outline: createVisualRefreshAppearanceStyles('outline'), + primary: createVisualRefreshAppearanceStyles('primary'), + secondary: { + // same as base + }, + subtle: createVisualRefreshAppearanceStyles('subtle'), + transparent: createVisualRefreshAppearanceStyles('transparent'), + + small: { + minHeight: semanticTokenVar('size/ctrl/sm'), + height: semanticTokenVar('size/ctrl/sm'), + + padding: `${semanticTokenVar('padding/ctrl/vertical/sm')} ${semanticTokenVar('padding/ctrl/horizontal/sm')}`, + borderRadius: semanticTokenVar('corner/ctrl/sm'), + + fontSize: semanticTokenVar('fontSize/ctrl/sm'), + fontWeight: semanticTokenVar('fontWeight/ctrl/sm'), + lineHeight: semanticTokenVar('lineHeight/ctrl/sm'), + }, + medium: { + minHeight: semanticTokenVar('size/ctrl/md'), + height: semanticTokenVar('size/ctrl/md'), + + padding: `${semanticTokenVar('padding/ctrl/vertical/md')} ${semanticTokenVar('padding/ctrl/horizontal/md')}`, + borderRadius: semanticTokenVar('corner/ctrl/md'), + + fontSize: semanticTokenVar('fontSize/ctrl/md'), + fontWeight: semanticTokenVar('fontWeight/ctrl/md'), + lineHeight: semanticTokenVar('lineHeight/ctrl/md'), + }, + large: { + minHeight: semanticTokenVar('size/ctrl/lg'), + height: semanticTokenVar('size/ctrl/lg'), + + padding: `${semanticTokenVar('padding/ctrl/vertical/lg')} ${semanticTokenVar('padding/ctrl/horizontal/lg')}`, + borderRadius: semanticTokenVar('corner/ctrl/lg'), + + fontSize: semanticTokenVar('fontSize/ctrl/lg'), + fontWeight: semanticTokenVar('fontWeight/ctrl/lg'), + lineHeight: semanticTokenVar('lineHeight/ctrl/lg'), + }, +}); + +const useVisualRefreshIconStyles = makeStyles({ + small: { + fontSize: '12px', + height: '12px', + width: '12px', + + [iconSpacingVar]: tokens.spacingHorizontalXS, + }, + medium: { + fontSize: '16px', + height: '16px', + width: '16px', + }, + large: { + fontSize: '16px', + height: '16px', + width: '16px', + + [iconSpacingVar]: tokens.spacingHorizontalSNudge, + }, +}); + export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { 'use no memo'; + const isVisualRefreshEnabled = useIsVisualRefreshEnabled(); + const visualRefreshStyles = useVisualRefreshStyles(); + const rootBaseClassName = useRootBaseClassName(); const iconBaseClassName = useIconBaseClassName(); @@ -561,9 +707,16 @@ export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { const rootFocusStyles = useRootFocusStyles(); const rootIconOnlyStyles = useRootIconOnlyStyles(); const iconStyles = useIconStyles(); + const iconVisualRefreshStyles = useVisualRefreshIconStyles(); const { appearance, disabled, disabledFocusable, icon, iconOnly, iconPosition, shape, size } = state; + const visualRefreshStylesRecord = visualRefreshStyles as unknown as Record; + const visualRefreshSlots: Array = ['root', appearance, shape, size]; + const visualRefreshOverrides = isVisualRefreshEnabled + ? mergeClasses(...visualRefreshSlots.map(slot => (slot ? visualRefreshStylesRecord[slot] : undefined))) + : undefined; + state.root.className = mergeClasses( buttonClassNames.root, rootBaseClassName, @@ -581,15 +734,18 @@ export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { appearance && (disabled || disabledFocusable) && rootDisabledStyles[appearance], // Focus styles - appearance === 'primary' && rootFocusStyles.primary, - rootFocusStyles[size], - rootFocusStyles[shape], + !isVisualRefreshEnabled && appearance === 'primary' && rootFocusStyles.primary, + !isVisualRefreshEnabled && rootFocusStyles[size], + !isVisualRefreshEnabled && rootFocusStyles[shape], // Icon-only styles iconOnly && rootIconOnlyStyles[size], // User provided class name state.root.className, + + isVisualRefreshEnabled && visualRefreshOverrides, + isVisualRefreshEnabled && visualRefreshStyles[size], ); if (state.icon) { @@ -598,9 +754,70 @@ export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { iconBaseClassName, !!state.root.children && iconStyles[iconPosition], iconStyles[size], + isVisualRefreshEnabled && iconVisualRefreshStyles[size], state.icon.className, ); } - return state; }; + +/** + * Visual Refresh Storybook utils + * */ +type VisualRefreshInteractionState = 'rest' | 'hover' | 'pressed' | 'disabled'; +type VisualRefreshIconVariant = 'regular' | 'filled'; + +const filledIconStates = new Set(['hover', 'pressed']); + +const visualRefreshInteractionStates: readonly VisualRefreshInteractionState[] = [ + 'rest', + 'hover', + 'pressed', + 'disabled', +]; + +const createInteractionStateTokens = (tokenBase: string): Record => + Object.fromEntries( + visualRefreshInteractionStates.map(state => [state, getSemanticTokenValue(`${tokenBase}/${state}`)]), + ) as Record; + +const createIconVariantTokens = (): Record => + Object.fromEntries( + visualRefreshInteractionStates.map(state => [state, filledIconStates.has(state) ? 'filled' : 'regular']), + ) as Record; + +export type VisualRefreshAppearanceStateTokens = { + foreground: Record; + background: Record; + border: Record; + icon: { + color: Record; + variant: Record; + }; +}; + +const resolveVisualRefreshAppearanceVariant = ( + appearance?: VisualRefreshAppearanceName, +): VisualRefreshAppearanceVariant => { + if (!appearance) { + return 'secondary'; + } + return appearance; +}; + +export const getVisualRefreshAppearanceStateTokens = ( + appearance?: VisualRefreshAppearanceName, +): VisualRefreshAppearanceStateTokens => { + const variant = resolveVisualRefreshAppearanceVariant(appearance); + const tokenGroup = visualRefreshAppearanceAlias[variant] ?? 'neutral'; + + const foreground = createInteractionStateTokens(`foreground/ctrl/${tokenGroup}`); + const background = createInteractionStateTokens(`background/ctrl/${tokenGroup}`); + const border = createInteractionStateTokens(`borderColor/ctrl/${tokenGroup}`); + const icon = { + color: createInteractionStateTokens(`iconColor/ctrl/${tokenGroup}`), + variant: createIconVariantTokens(), + }; + + return { foreground, background, border, icon }; +}; diff --git a/packages/react-components/visual-refresh-preview/library/.babelrc.json b/packages/react-components/visual-refresh-preview/library/.babelrc.json new file mode 100644 index 00000000000000..630deaf765c49f --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/.babelrc.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../../.babelrc-v9.json", + "plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"] +} diff --git a/packages/react-components/visual-refresh-preview/library/.eslintrc.json b/packages/react-components/visual-refresh-preview/library/.eslintrc.json new file mode 100644 index 00000000000000..ceea884c70dccc --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["plugin:@fluentui/eslint-plugin/react"], + "root": true +} diff --git a/packages/react-components/visual-refresh-preview/library/.swcrc b/packages/react-components/visual-refresh-preview/library/.swcrc new file mode 100644 index 00000000000000..b4ffa86dee3067 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/.swcrc @@ -0,0 +1,30 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "exclude": [ + "/testing", + "/**/*.cy.ts", + "/**/*.cy.tsx", + "/**/*.spec.ts", + "/**/*.spec.tsx", + "/**/*.test.ts", + "/**/*.test.tsx" + ], + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true, + "decorators": false, + "dynamicImport": false + }, + "externalHelpers": true, + "transform": { + "react": { + "runtime": "classic", + "useSpread": true + } + }, + "target": "es2019" + }, + "minify": false, + "sourceMaps": true +} diff --git a/packages/react-components/visual-refresh-preview/library/LICENSE b/packages/react-components/visual-refresh-preview/library/LICENSE new file mode 100644 index 00000000000000..19c1105d93e9fb --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/LICENSE @@ -0,0 +1,15 @@ +@fluentui/visual-refresh-preview + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license diff --git a/packages/react-components/visual-refresh-preview/library/README.md b/packages/react-components/visual-refresh-preview/library/README.md new file mode 100644 index 00000000000000..7108e5f3b67a46 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/README.md @@ -0,0 +1,5 @@ +# @fluentui/visual-refresh-preview + +**Visual Refresh components for [Fluent UI React](https://react.fluentui.dev/)** + +These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release. diff --git a/packages/react-components/visual-refresh-preview/library/config/api-extractor.json b/packages/react-components/visual-refresh-preview/library/config/api-extractor.json new file mode 100644 index 00000000000000..8d482156d10d53 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/config/api-extractor.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "extends": "@fluentui/scripts-api-extractor/api-extractor.common.v-next.json", + "mainEntryPointFilePath": "/../../../../../../dist/out-tsc/types/packages/react-components//library/src/index.d.ts" +} diff --git a/packages/react-components/visual-refresh-preview/library/config/tests.js b/packages/react-components/visual-refresh-preview/library/config/tests.js new file mode 100644 index 00000000000000..2e211ae9e21420 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/config/tests.js @@ -0,0 +1 @@ +/** Jest test setup file. */ diff --git a/packages/react-components/visual-refresh-preview/library/docs/Spec.md b/packages/react-components/visual-refresh-preview/library/docs/Spec.md new file mode 100644 index 00000000000000..2f87c2d6b8de3d --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/docs/Spec.md @@ -0,0 +1,63 @@ +# @fluentui/visual-refresh-preview Spec + +## Background + +_Description and use cases of this component_ + +## Prior Art + +_Include background research done for this component_ + +- _Link to Open UI research_ +- _Link to comparison of v7 and v0_ +- _Link to GitHub epic issue for the converged component_ + +## Sample Code + +_Provide some representative example code that uses the proposed API for the component_ + +## Variants + +_Describe visual or functional variants of this control, if applicable. For example, a slider could have a 2D variant._ + +## API + +_List the **Props** and **Slots** proposed for the component. Ideally this would just be a link to the component's `.types.ts` file_ + +## Structure + +- _**Public**_ +- _**Internal**_ +- _**DOM** - how the component will be rendered as HTML elements_ + +## Migration + +_Describe what will need to be done to upgrade from the existing implementations:_ + +- _Migration from v8_ +- _Migration from v0_ + +## Behaviors + +_Explain how the component will behave in use, including:_ + +- _Component States_ +- _Interaction_ + - _Keyboard_ + - _Cursor_ + - _Touch_ + - _Screen readers_ + +## Accessibility + +Base accessibility information is included in the design document. After the spec is filled and review, outcomes from it need to be communicated to design and incorporated in the design document. + +- Decide whether to use **native element** or folow **ARIA** and provide reasons +- Identify the **[ARIA](https://www.w3.org/TR/wai-aria-practices-1.2/) pattern** and, if the component is listed there, follow its specification as possible. +- Identify accessibility **variants**, the `role` ([ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#role_definitions)) of the component, its `slots` and `aria-*` props. +- Describe the **keyboard navigation**: Tab Oder and Arrow Key Navigation. Describe any other keyboard **shortcuts** used +- Specify texts for **state change announcements** - [ARIA live regions + ](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) (number of available items in dropdown, error messages, confirmations, ...) +- Identify UI parts that appear on **hover or focus** and specify keyboard and screen reader interaction with them +- List cases when **focus** needs to be **trapped** in sections of the UI (for dialogs and popups or for hierarchical navigation) +- List cases when **focus** needs to be **moved programatically** (if parts of the UI are appearing/disappearing or other cases) diff --git a/packages/react-components/visual-refresh-preview/library/etc/visual-refresh-preview.api.md b/packages/react-components/visual-refresh-preview/library/etc/visual-refresh-preview.api.md new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/packages/react-components/visual-refresh-preview/library/jest.config.js b/packages/react-components/visual-refresh-preview/library/jest.config.js new file mode 100644 index 00000000000000..2ce82741b48f77 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/jest.config.js @@ -0,0 +1,34 @@ +// @ts-check +/* eslint-disable */ + +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); + +// Reading the SWC compilation config and remove the "exclude" +// for the test files to be compiled by SWC +const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(join(__dirname, '.swcrc'), 'utf-8')); + +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" +if (swcJestConfig.swcrc === undefined) { + swcJestConfig.swcrc = false; +} + +// Uncomment if using global setup/teardown files being transformed via swc +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries +// jest needs EsModule Interop to find the default exported setup/teardown functions +// swcJestConfig.module.noInterop = false; + +/** + * @type {import('@jest/types').Config.InitialOptions} + */ +module.exports = { + displayName: 'visual-refresh-preview', + preset: '../../../../jest.preset.js', + transform: { + '^.+\\.tsx?$': ['@swc/jest', swcJestConfig], + }, + coverageDirectory: './coverage', + setupFilesAfterEnv: ['./config/tests.js'], + snapshotSerializers: ['@griffel/jest-serializer'], +}; diff --git a/packages/react-components/visual-refresh-preview/library/package.json b/packages/react-components/visual-refresh-preview/library/package.json new file mode 100644 index 00000000000000..fbb0c07eca8584 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/package.json @@ -0,0 +1,56 @@ +{ + "name": "@fluentui/visual-refresh-preview", + "version": "0.0.0", + "private": true, + "description": "New fluentui react package", + "main": "lib-commonjs/index.js", + "module": "lib/index.js", + "typings": "./dist/index.d.ts", + "sideEffects": false, + "files": [ + "*.md", + "dist/*.d.ts", + "lib", + "lib-commonjs" + ], + "repository": { + "type": "git", + "url": "https://github.com/microsoft/fluentui" + }, + "license": "MIT", + "devDependencies": { + "@fluentui/eslint-plugin": "*", + "@fluentui/react-conformance": "*", + "@fluentui/react-conformance-griffel": "*", + "@fluentui/scripts-api-extractor": "*" + }, + "dependencies": { + "@fluentui/react-jsx-runtime": "^9.2.2", + "@fluentui/react-shared-contexts": "^9.25.2", + "@fluentui/react-theme": "^9.2.0", + "@fluentui/react-utilities": "^9.25.1", + "@griffel/react": "^1.5.22", + "@swc/helpers": "^0.5.1" + }, + "peerDependencies": { + "@types/react": ">=16.14.0 <19.0.0", + "@types/react-dom": ">=16.9.0 <19.0.0", + "react": ">=16.14.0 <19.0.0", + "react-dom": ">=16.14.0 <19.0.0" + }, + "exports": { + ".": { + "types": "./dist/index.d.ts", + "node": "./lib-commonjs/index.js", + "import": "./lib/index.js", + "require": "./lib-commonjs/index.js" + }, + "./package.json": "./package.json" + }, + "beachball": { + "disallowedChangeTypes": [ + "major", + "prerelease" + ] + } +} diff --git a/packages/react-components/visual-refresh-preview/library/project.json b/packages/react-components/visual-refresh-preview/library/project.json new file mode 100644 index 00000000000000..c6fc76d313d139 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/project.json @@ -0,0 +1,8 @@ +{ + "name": "visual-refresh-preview", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "packages/react-components/visual-refresh-preview/library/src", + "tags": ["platform:web", "vNext"], + "implicitDependencies": [] +} diff --git a/packages/react-components/visual-refresh-preview/library/src/index.ts b/packages/react-components/visual-refresh-preview/library/src/index.ts new file mode 100644 index 00000000000000..e11facd888f189 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/src/index.ts @@ -0,0 +1,392 @@ +import * as React from 'react'; +import { tokens } from '@fluentui/react-theme'; + +export const VisualRefreshContext = React.createContext(false); + +export function useIsVisualRefreshEnabled() { + return React.useContext(VisualRefreshContext); +} + +export const MAI_SEMANTIC_TOKENS = { + 'stv1_size/ctrl/default': '', + 'stv1_size/ctrl/sm': '', + 'stv1_size/ctrl/lg': '', + // Padding + 'stv1_padding/ctrl/textTop': '', + 'stv1_padding/ctrl/textBottom': '', + 'stv1_padding/ctrl/textSide': '', + 'stv1_padding/ctrl/horizontal-default': '', + 'stv1_padding/ctrl/horizontal-iconOnly': '', + // Gap + 'stv1_gap/inside/ctrl/default': '', + 'stv1_gap/inside/ctrl/toSecondaryIcon': '', + // Corner + 'stv1_corner/ctrl/default': '', + 'stv1_corner/ctrl/sm': '', + 'stv1_corner/ctrl/lg': '', + // Background + 'stv1_background/ctrl/neutral/rest': '', + 'stv1_background/ctrl/neutral/hover': '', + 'stv1_background/ctrl/neutral/pressed': '', + 'stv1_background/ctrl/neutral/disabled': '', + 'stv1_background/ctrl/neutral/selected/rest': '', + 'stv1_background/ctrl/neutral/selected/hover': '', + 'stv1_background/ctrl/neutral/selected/pressed': '', + 'stv1_background/ctrl/neutral/selected/disabled': '', + 'stv1_background/ctrl/brand/rest': '', + 'stv1_background/ctrl/brand/hover': '', + 'stv1_background/ctrl/brand/pressed': '', + 'stv1_background/ctrl/brand/disabled': '', + 'stv1_background/ctrl/brand/selected/rest': '', + 'stv1_background/ctrl/brand/selected/hover': '', + 'stv1_background/ctrl/brand/selected/pressed': '', + 'stv1_background/ctrl/brand/selected/disabled': '', + 'stv1_background/ctrl/outline/rest': '', + 'stv1_background/ctrl/outline/hover': '', + 'stv1_background/ctrl/outline/pressed': '', + 'stv1_background/ctrl/outline/disabled': '', + 'stv1_background/ctrl/outline/selected/rest': '', + 'stv1_background/ctrl/outline/selected/hover': '', + 'stv1_background/ctrl/outline/selected/pressed': '', + 'stv1_background/ctrl/outline/selected/disabled': '', + 'stv1_background/ctrl/subtle/rest': '', + 'stv1_background/ctrl/subtle/hover': '', + 'stv1_background/ctrl/subtle/pressed': '', + 'stv1_background/ctrl/subtle/disabled': '', + 'stv1_background/ctrl/subtle/selected/rest': '', + 'stv1_background/ctrl/subtle/selected/hover': '', + 'stv1_background/ctrl/subtle/selected/pressed': '', + 'stv1_background/ctrl/subtle/selected/disabled': '', + 'stv1_background/ctrl/transparent/rest': '', + 'stv1_background/ctrl/transparent/hover': '', + 'stv1_background/ctrl/transparent/pressed': '', + 'stv1_background/ctrl/transparent/disabled': '', + 'stv1_background/ctrl/transparent/selected/rest': '', + 'stv1_background/ctrl/transparent/selected/hover': '', + 'stv1_background/ctrl/transparent/selected/pressed': '', + 'stv1_background/ctrl/transparent/selected/disabled': '', + // Foreground" + 'stv1_foreground/ctrl/neutral/rest': '', + 'stv1_foreground/ctrl/neutral/hover': '', + 'stv1_foreground/ctrl/neutral/pressed': '', + 'stv1_foreground/ctrl/neutral/disabled': '', + 'stv1_foreground/ctrl/neutral/selected/rest': '', + 'stv1_foreground/ctrl/neutral/selected/hover': '', + 'stv1_foreground/ctrl/neutral/selected/pressed': '', + 'stv1_foreground/ctrl/neutral/selected/disabled': '', + 'stv1_foreground/ctrl/brand/rest': '', + 'stv1_foreground/ctrl/brand/hover': '', + 'stv1_foreground/ctrl/brand/pressed': '', + 'stv1_foreground/ctrl/brand/disabled': '', + 'stv1_foreground/ctrl/brand/selected/rest': '', + 'stv1_foreground/ctrl/brand/selected/hover': '', + 'stv1_foreground/ctrl/brand/selected/pressed': '', + 'stv1_foreground/ctrl/brand/selected/disabled': '', + 'stv1_foreground/ctrl/outline/rest': '', + 'stv1_foreground/ctrl/outline/hover': '', + 'stv1_foreground/ctrl/outline/pressed': '', + 'stv1_foreground/ctrl/outline/disabled': '', + 'stv1_foreground/ctrl/outline/selected/rest': '', + 'stv1_foreground/ctrl/outline/selected/hover': '', + 'stv1_foreground/ctrl/outline/selected/pressed': '', + 'stv1_foreground/ctrl/outline/selected/disabled': '', + 'stv1_foreground/ctrl/subtle/rest': '', + 'stv1_foreground/ctrl/subtle/hover': '', + 'stv1_foreground/ctrl/subtle/pressed': '', + 'stv1_foreground/ctrl/subtle/disabled': '', + 'stv1_foreground/ctrl/subtle/selected/rest': '', + 'stv1_foreground/ctrl/subtle/selected/hover': '', + 'stv1_foreground/ctrl/subtle/selected/pressed': '', + 'stv1_foreground/ctrl/subtle/selected/disabled': '', + 'stv1_foreground/ctrl/transparent/rest': '', + 'stv1_foreground/ctrl/transparent/hover': '', + 'stv1_foreground/ctrl/transparent/pressed': '', + 'stv1_foreground/ctrl/transparent/disabled': '', + 'stv1_foreground/ctrl/transparent/selected/rest': '', + 'stv1_foreground/ctrl/transparent/selected/hover': '', + 'stv1_foreground/ctrl/transparent/selected/pressed': '', + 'stv1_foreground/ctrl/transparent/selected/disabled': '', + // Stroke" + 'stv1_stroke/ctrl/neutral/rest': '', + 'stv1_stroke/ctrl/neutral/hover': '', + 'stv1_stroke/ctrl/neutral/pressed': '', + 'stv1_stroke/ctrl/neutral/disabled': '', + 'stv1_stroke/ctrl/neutral/selected/rest': '', + 'stv1_stroke/ctrl/neutral/selected/hover': '', + 'stv1_stroke/ctrl/neutral/selected/pressed': '', + 'stv1_stroke/ctrl/neutral/selected/disabled': '', + 'stv1_stroke/ctrl/brand/rest': '', + 'stv1_stroke/ctrl/brand/hover': '', + 'stv1_stroke/ctrl/brand/pressed': '', + 'stv1_stroke/ctrl/brand/disabled': '', + 'stv1_stroke/ctrl/brand/selected/rest': '', + 'stv1_stroke/ctrl/brand/selected/hover': '', + 'stv1_stroke/ctrl/brand/selected/pressed': '', + 'stv1_stroke/ctrl/brand/selected/disabled': '', + 'stv1_stroke/ctrl/outline/rest': '', + 'stv1_stroke/ctrl/outline/hover': '', + 'stv1_stroke/ctrl/outline/pressed': '', + 'stv1_stroke/ctrl/outline/disabled': '', + 'stv1_stroke/ctrl/outline/selected/rest': '', + 'stv1_stroke/ctrl/outline/selected/hover': '', + 'stv1_stroke/ctrl/outline/selected/pressed': '', + 'stv1_stroke/ctrl/outline/selected/disabled': '', + 'stv1_stroke/control/on/outline/rest': '', + 'stv1_stroke/control/on/outline/hover': '', + 'stv1_stroke/control/on/outline/pressed': '', + 'stv1_stroke/control/on/outline/disabled': '', + 'stv1_stroke/control/on/outline/selected/rest': '', + 'stv1_stroke/control/on/outline/selected/hover': '', + 'stv1_stroke/control/on/outline/selected/pressed': '', + 'stv1_stroke/control/on/outline/selected/disabled': '', + // Stroke Width" + 'stv1_strokeWidth/ctrl/outline/rest': '', + 'stv1_strokeWidth/ctrl/outline/hover': '', + 'stv1_strokeWidth/ctrl/outline/pressed': '', + 'stv1_strokeWidth/ctrl/outline/disabled': '', + 'stv1_strokeWidth/ctrl/outline/selected/rest': '', + 'stv1_strokeWidth/ctrl/outline/selected/hover': '', + 'stv1_strokeWidth/ctrl/outline/selected/pressed': '', + 'stv1_strokeWidth/ctrl/outline/selected/disabled': '', + 'stv1_strokeWidth/default': '', + // Shadow" + 'stv1_shadow/ctrl/default/rest': '', + 'stv1_shadow/ctrl/default/hover': '', + 'stv1_shadow/ctrl/default/pressed': '', + 'stv1_shadow/ctrl/default/disabled': '', + 'stv1_shadow/ctrl/default/selected/rest': '', + 'stv1_shadow/ctrl/default/selected/hover': '', + 'stv1_shadow/ctrl/default/selected/pressed': '', + 'stv1_shadow/ctrl/default/selected/disabled': '', + 'stv1_shadow/ctrl/brand/rest': '', + 'stv1_shadow/ctrl/brand/hover': '', + 'stv1_shadow/ctrl/brand/pressed': '', + 'stv1_shadow/ctrl/brand/disabled': '', + 'stv1_shadow/ctrl/brand/selected/rest': '', + 'stv1_shadow/ctrl/brand/selected/hover': '', + 'stv1_shadow/ctrl/brand/selected/pressed': '', + 'stv1_shadow/ctrl/brand/selected/disabled': '', + 'stv1_shadow/ctrl/outline/rest': '', + 'stv1_shadow/ctrl/outline/hover': '', + 'stv1_shadow/ctrl/outline/pressed': '', + 'stv1_shadow/ctrl/outline/disabled': '', + 'stv1_shadow/ctrl/outline/selected/rest': '', + 'stv1_shadow/ctrl/outline/selected/hover': '', + 'stv1_shadow/ctrl/outline/selected/pressed': '', + 'stv1_shadow/ctrl/outline/selected/disabled': '', + // Icon Theme" + 'stv1_iconTheme/ctrl/default/rest': '', + 'stv1_iconTheme/ctrl/default/hover': '', + 'stv1_iconTheme/ctrl/default/pressed': '', + 'stv1_iconTheme/ctrl/default/selected': '', + 'stv1_iconTheme/ctrl/subtle/rest': '', + 'stv1_iconTheme/ctrl/subtle/hover': '', + 'stv1_iconTheme/ctrl/subtle/pressed': '', + 'stv1_iconTheme/ctrl/subtle/selected': '', + 'stv1_iconTheme/ctrl/chevron/default': '', + 'stv1_iconTheme/ctrl/chevron/selected': '', + // Icon Color" + 'stv1_iconColor/ctrl/default/rest': '', + 'stv1_iconColor/ctrl/default/hover': '', + 'stv1_iconColor/ctrl/default/pressed': '', + 'stv1_iconColor/ctrl/default/selected': '', + 'stv1_iconColor/ctrl/chevron/default': '', + 'stv1_iconColor/ctrl/chevron/selected': '', + // Typography" + 'stv1_fontSize/ctrl/default': '', + 'stv1_fontWeight/ctrl/default': '', + 'stv1_fontFamily/ctrl/default': '', + 'stv1_lineHeight/ctrl/default': '', + 'stv1_letterSpacing/ctrl/default': '', + 'stv1_textStyle/ctrl/body': '', + 'stv1_textStyle/ctrl/header': '', +} as const satisfies { + [key: string]: any; +}; + +/** + * Notes + * 1. sm, default, lg -> sm, md, lg. + * 2. padding/ctrl/horizontal-default -> padding/ctrl/horizontal/md + * 3. gap/inside/ctrl/default -> gap/ctrl/md - no gap outside + * 4. fontWeight, lineHeight - ? - no size relation (sm, md, lg) + * 5. @media (forced-colors: active) ? - missed + * 6. background/ctrl/neutral/selected - no "selected" option for the current Button implementation + * 7. background/ctrl/neutral/hover vs iconColor/ctrl/default/rest + * 8. Fluent UI not defines chevron as icon for Button. Intead the call Button with chevron MenuButton + * - MenuButton + icon/ctrl + * - Button + primaryIcon/ctrl + secondaryIcon/ctrl + * 9. if border="transparent" it makes button height 2px size less depends on variant + * 10. size/ctrl/lg - what should we do with icon size? 12px/16px/16px + * 11. Theme support? light/dark/HC? + * + * Delta + * ------------------------------------------------------ + * Colors + * '#00595D', // tokens.colorPaletteLightTealForeground2 + * '#00686D', // tokens.colorPaletteLightTealForeground2 + * '#03787c', // tokens.colorPaletteTealForeground2 + * '#00393d', // tokens.colorPaletteSteelForeground2 + * + * ------------------------------------------------------ + * Border Radius (12px) + * Sizes (all) + */ + +export const TEAMS_VISUAL_REFRESH_THEME = { + 'size/ctrl/md': '36px', + 'size/ctrl/sm': '28px', + 'size/ctrl/lg': '40px', + + // Button + // Padding + 'padding/ctrl/horizontal/sm': tokens.spacingHorizontalS, + 'padding/ctrl/horizontal/md': tokens.spacingHorizontalM, + 'padding/ctrl/horizontal/lg': tokens.spacingHorizontalM, + + 'padding/ctrl/vertical/sm': tokens.spacingVerticalXS, + 'padding/ctrl/vertical/md': tokens.spacingVerticalS, + 'padding/ctrl/vertical/lg': tokens.spacingVerticalMNudge, + // Gap + 'gap/ctrl/sm': tokens.spacingHorizontalXS, + 'gap/ctrl/md': tokens.spacingHorizontalSNudge, + 'gap/ctrl/lg': tokens.spacingHorizontalSNudge, + + // Border radius + 'corner/ctrl/sm': '12px', + 'corner/ctrl/md': '12px', + 'corner/ctrl/lg': '12px', + + // Font + 'fontSize/ctrl/sm': tokens.fontSizeBase200, + 'fontSize/ctrl/md': tokens.fontSizeBase300, + 'fontSize/ctrl/lg': tokens.fontSizeBase300, + + 'lineHeight/ctrl/sm': tokens.lineHeightBase200, + 'lineHeight/ctrl/md': tokens.lineHeightBase300, + 'lineHeight/ctrl/lg': tokens.lineHeightBase300, + + 'fontWeight/ctrl/sm': tokens.fontWeightSemibold, + 'fontWeight/ctrl/md': tokens.fontWeightSemibold, + 'fontWeight/ctrl/lg': tokens.fontWeightSemibold, + + 'foreground/ctrl/neutral/rest': tokens.colorNeutralForeground3, + 'foreground/ctrl/neutral/hover': tokens.colorNeutralForeground3Hover, + 'foreground/ctrl/neutral/pressed': tokens.colorNeutralForeground3Pressed, + 'foreground/ctrl/neutral/disabled': tokens.colorNeutralForegroundDisabled, + + 'foreground/ctrl/brand/rest': tokens.colorNeutralForegroundOnBrand, + 'foreground/ctrl/brand/hover': tokens.colorNeutralForegroundOnBrand, + 'foreground/ctrl/brand/pressed': tokens.colorNeutralForegroundOnBrand, + 'foreground/ctrl/brand/disabled': tokens.colorNeutralForegroundDisabled, + + 'foreground/ctrl/outline/rest': tokens.colorNeutralForeground3, + 'foreground/ctrl/outline/hover': tokens.colorNeutralForeground3Hover, + 'foreground/ctrl/outline/pressed': tokens.colorNeutralForeground3Pressed, + 'foreground/ctrl/outline/disabled': tokens.colorNeutralForegroundDisabled, + + 'foreground/ctrl/subtle/rest': tokens.colorNeutralForeground3, + 'foreground/ctrl/subtle/hover': tokens.colorNeutralForeground3Hover, + 'foreground/ctrl/subtle/pressed': tokens.colorNeutralForeground3Pressed, + 'foreground/ctrl/subtle/disabled': tokens.colorNeutralForegroundDisabled, + + 'foreground/ctrl/transparent/rest': tokens.colorNeutralForeground3, + 'foreground/ctrl/transparent/hover': '#00686D', // tokens.colorPaletteLightTealForeground2 + 'foreground/ctrl/transparent/pressed': '#00595D', // tokens.colorPaletteLightTealForeground2 + 'foreground/ctrl/transparent/disabled': tokens.colorNeutralForegroundDisabled, + + // Background + 'background/ctrl/neutral/rest': tokens.colorNeutralBackground2, + 'background/ctrl/neutral/hover': tokens.colorNeutralBackground2Hover, + 'background/ctrl/neutral/pressed': tokens.colorNeutralBackground2Pressed, + 'background/ctrl/neutral/disabled': tokens.colorNeutralBackgroundDisabled, + + 'background/ctrl/brand/rest': '#03787c', // tokens.colorPaletteTealForeground2 + 'background/ctrl/brand/hover': tokens.colorPaletteLightTealForeground2, + 'background/ctrl/brand/pressed': '#00393d', // tokens.colorPaletteSteelForeground2 + 'background/ctrl/brand/disabled': tokens.colorNeutralBackgroundDisabled, + + 'background/ctrl/outline/rest': tokens.colorTransparentBackground, + 'background/ctrl/outline/hover': tokens.colorTransparentBackgroundHover, + 'background/ctrl/outline/pressed': tokens.colorTransparentBackgroundPressed, + 'background/ctrl/outline/disabled': tokens.colorTransparentBackground, + + 'background/ctrl/subtle/rest': tokens.colorTransparentBackground, + 'background/ctrl/subtle/hover': tokens.colorSubtleBackgroundHover, + 'background/ctrl/subtle/pressed': tokens.colorSubtleBackgroundPressed, + 'background/ctrl/subtle/disabled': tokens.colorTransparentBackground, + + 'background/ctrl/transparent/rest': tokens.colorTransparentBackground, + 'background/ctrl/transparent/hover': tokens.colorTransparentBackgroundHover, + 'background/ctrl/transparent/pressed': tokens.colorTransparentBackgroundPressed, + 'background/ctrl/transparent/disabled': tokens.colorTransparentBackground, + + // Border + 'borderColor/ctrl/neutral/rest': tokens.colorNeutralStroke1, + 'borderColor/ctrl/neutral/hover': tokens.colorNeutralStroke1Hover, + 'borderColor/ctrl/neutral/pressed': tokens.colorNeutralStroke1Pressed, + 'borderColor/ctrl/neutral/disabled': tokens.colorNeutralStrokeDisabled, + + 'borderColor/ctrl/brand/rest': tokens.colorTransparentStroke, // Acturally should be the same as background, if not sizes would be different + 'borderColor/ctrl/brand/hover': tokens.colorTransparentStroke, + 'borderColor/ctrl/brand/pressed': tokens.colorTransparentStroke, + 'borderColor/ctrl/brand/disabled': tokens.colorTransparentStroke, + + 'borderColor/ctrl/outline/rest': tokens.colorNeutralStroke1, + 'borderColor/ctrl/outline/hover': tokens.colorNeutralStroke1Hover, + 'borderColor/ctrl/outline/pressed': tokens.colorNeutralStroke1Pressed, + 'borderColor/ctrl/outline/disabled': tokens.colorNeutralStrokeDisabled, + + 'borderColor/ctrl/subtle/rest': tokens.colorTransparentStroke, + 'borderColor/ctrl/subtle/hover': tokens.colorTransparentStroke, + 'borderColor/ctrl/subtle/pressed': tokens.colorTransparentStroke, + 'borderColor/ctrl/subtle/disabled': tokens.colorTransparentStroke, + + 'borderColor/ctrl/transparent/rest': tokens.colorTransparentStroke, + 'borderColor/ctrl/transparent/hover': tokens.colorTransparentStroke, + 'borderColor/ctrl/transparent/pressed': tokens.colorTransparentStroke, + 'borderColor/ctrl/transparent/disabled': tokens.colorTransparentStroke, + + // Icon + 'iconColor/ctrl/neutral/rest': tokens.colorNeutralForeground3, + 'iconColor/ctrl/neutral/hover': tokens.colorNeutralForeground3Hover, + 'iconColor/ctrl/neutral/pressed': '#00595D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/neutral/disabled': tokens.colorNeutralForegroundDisabled, + + 'iconColor/ctrl/brand/rest': tokens.colorNeutralForegroundOnBrand, + 'iconColor/ctrl/brand/hover': tokens.colorNeutralForegroundOnBrand, + 'iconColor/ctrl/brand/pressed': tokens.colorNeutralForegroundOnBrand, + 'iconColor/ctrl/brand/disabled': tokens.colorNeutralForegroundDisabled, + + 'iconColor/ctrl/outline/rest': tokens.colorNeutralForeground3, + 'iconColor/ctrl/outline/hover': tokens.colorNeutralForeground3Hover, + 'iconColor/ctrl/outline/pressed': '#00595D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/outline/disabled': tokens.colorNeutralForegroundDisabled, + + 'iconColor/ctrl/subtle/rest': tokens.colorNeutralForeground3, + 'iconColor/ctrl/subtle/hover': '#00686D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/subtle/pressed': '#00595D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/subtle/disabled': tokens.colorNeutralForegroundDisabled, + + 'iconColor/ctrl/transparent/rest': tokens.colorNeutralForeground3, + 'iconColor/ctrl/transparent/hover': '#00686D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/transparent/pressed': '#00595D', // tokens.colorPaletteLightTealForeground2 + 'iconColor/ctrl/transparent/disabled': tokens.colorNeutralForegroundDisabled, +}; + +export const TEAMS_VISUAL_REFRESH_TOKENS = Object.fromEntries( + Object.entries(TEAMS_VISUAL_REFRESH_THEME).map(([key, value]) => [sanitizeTokenName(key), String(value)]), +) as Record; + +export const EXPECTED_SEMANTIC_V2_TOKENS = { + groupButtonBackground: 'background/ctrl/neutral/rest', // -> colorNeutralBackground1 +}; + +export function sanitizeTokenName(token: string) { + return token.replace(/\//g, '_'); +} + +type TokenName = keyof typeof MAI_SEMANTIC_TOKENS | keyof typeof TEAMS_VISUAL_REFRESH_THEME; +export function semanticTokenVar(token: TokenName) { + return `var(--${sanitizeTokenName(token)})`; +} diff --git a/packages/react-components/visual-refresh-preview/library/src/testing/isConformant.ts b/packages/react-components/visual-refresh-preview/library/src/testing/isConformant.ts new file mode 100644 index 00000000000000..8ed2da0f925135 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/src/testing/isConformant.ts @@ -0,0 +1,15 @@ +import { isConformant as baseIsConformant } from '@fluentui/react-conformance'; +import type { IsConformantOptions, TestObject } from '@fluentui/react-conformance'; +import griffelTests from '@fluentui/react-conformance-griffel'; + +export function isConformant( + testInfo: Omit, 'componentPath'> & { componentPath?: string }, +): void { + const defaultOptions: Partial> = { + tsConfig: { configName: 'tsconfig.spec.json' }, + componentPath: require.main?.filename.replace('.test', ''), + extraTests: griffelTests as TestObject, + }; + + baseIsConformant(defaultOptions, testInfo); +} diff --git a/packages/react-components/visual-refresh-preview/library/tsconfig.json b/packages/react-components/visual-refresh-preview/library/tsconfig.json new file mode 100644 index 00000000000000..32bdbdf1ac26f0 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "target": "ES2019", + "noEmit": true, + "isolatedModules": true, + "importHelpers": true, + "jsx": "react", + "noUnusedLocals": true, + "preserveConstEnums": true + }, + "include": [], + "files": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/react-components/visual-refresh-preview/library/tsconfig.lib.json b/packages/react-components/visual-refresh-preview/library/tsconfig.lib.json new file mode 100644 index 00000000000000..53066fdd11fff0 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/tsconfig.lib.json @@ -0,0 +1,22 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "lib": ["ES2019", "dom"], + "declaration": true, + "declarationDir": "../../../../dist/out-tsc/types", + "outDir": "../../../../dist/out-tsc", + "inlineSources": true, + "types": ["static-assets", "environment"] + }, + "exclude": [ + "./src/testing/**", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.ts", + "**/*.stories.tsx" + ], + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/packages/react-components/visual-refresh-preview/library/tsconfig.spec.json b/packages/react-components/visual-refresh-preview/library/tsconfig.spec.json new file mode 100644 index 00000000000000..911456fe4b4d91 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/library/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.d.ts", + "./src/testing/**/*.ts", + "./src/testing/**/*.tsx" + ] +} diff --git a/packages/react-components/visual-refresh-preview/stories/.eslintrc.json b/packages/react-components/visual-refresh-preview/stories/.eslintrc.json new file mode 100644 index 00000000000000..a41120835dcc92 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "extends": ["plugin:@fluentui/eslint-plugin/react"], + "root": true, + "rules": { + "import/no-extraneous-dependencies": [ + "error", + { + "packageDir": [".", "../../../../"] + } + ] + } +} diff --git a/packages/react-components/visual-refresh-preview/stories/.storybook/main.js b/packages/react-components/visual-refresh-preview/stories/.storybook/main.js new file mode 100644 index 00000000000000..b380cd896aea19 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/.storybook/main.js @@ -0,0 +1,14 @@ +const rootMain = require('../../../../../.storybook/main'); + +module.exports = /** @type {Omit} */ ({ + ...rootMain, + stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/index.stories.@(ts|tsx)'], + addons: [...rootMain.addons], + webpackFinal: (config, options) => { + const localConfig = { ...rootMain.webpackFinal(config, options) }; + + // add your own webpack tweaks if needed + + return localConfig; + }, +}); diff --git a/packages/react-components/visual-refresh-preview/stories/.storybook/preview.js b/packages/react-components/visual-refresh-preview/stories/.storybook/preview.js new file mode 100644 index 00000000000000..94455f782364e4 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/.storybook/preview.js @@ -0,0 +1,7 @@ +import * as rootPreview from '../../../../../.storybook/preview'; + +/** @type {typeof rootPreview.decorators} */ +export const decorators = [...rootPreview.decorators]; + +/** @type {typeof rootPreview.parameters} */ +export const parameters = { ...rootPreview.parameters }; diff --git a/packages/react-components/visual-refresh-preview/stories/.storybook/tsconfig.json b/packages/react-components/visual-refresh-preview/stories/.storybook/tsconfig.json new file mode 100644 index 00000000000000..4cdd1ce9d006f1 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/.storybook/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "", + "allowJs": true, + "checkJs": true, + "types": ["static-assets", "environment"] + }, + "include": ["*.js"] +} diff --git a/packages/react-components/visual-refresh-preview/stories/README.md b/packages/react-components/visual-refresh-preview/stories/README.md new file mode 100644 index 00000000000000..2fda219a947114 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/README.md @@ -0,0 +1,17 @@ +# @fluentui/visual-refresh-preview-stories + +Storybook stories for packages/react-components/visual-refresh-preview + +## Usage + +To include within storybook specify stories globs: + +\`\`\`js +module.exports = { +stories: ['../packages/react-components/visual-refresh-preview/stories/src/**/*.stories.mdx', '../packages/react-components/visual-refresh-preview/stories/src/**/index.stories.@(ts|tsx)'], +} +\`\`\` + +## API + +no public API available diff --git a/packages/react-components/visual-refresh-preview/stories/package.json b/packages/react-components/visual-refresh-preview/stories/package.json new file mode 100644 index 00000000000000..e0fe00f72b8014 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/package.json @@ -0,0 +1,11 @@ +{ + "name": "@fluentui/visual-refresh-preview-stories", + "version": "0.0.0", + "private": true, + "devDependencies": { + "@fluentui/react-storybook-addon": "*", + "@fluentui/react-storybook-addon-export-to-sandbox": "*", + "@fluentui/scripts-storybook": "*", + "@fluentui/eslint-plugin": "*" + } +} diff --git a/packages/react-components/visual-refresh-preview/stories/project.json b/packages/react-components/visual-refresh-preview/stories/project.json new file mode 100644 index 00000000000000..a32425de19419f --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/project.json @@ -0,0 +1,8 @@ +{ + "name": "visual-refresh-preview-stories", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "projectType": "library", + "sourceRoot": "packages/react-components/visual-refresh-preview/stories/src", + "tags": ["vNext", "platform:web", "type:stories"], + "implicitDependencies": [] +} diff --git a/packages/react-components/visual-refresh-preview/stories/src/.gitkeep b/packages/react-components/visual-refresh-preview/stories/src/.gitkeep new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/Button.stories.tsx b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/Button.stories.tsx new file mode 100644 index 00000000000000..813474307c3a81 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/Button.stories.tsx @@ -0,0 +1,324 @@ +import * as React from 'react'; +import type { JSXElement } from '@fluentui/react-components'; +import { Button, Label, Select, Switch, makeStyles, useId } from '@fluentui/react-components'; +import type { ButtonProps, SwitchOnChangeData } from '@fluentui/react-components'; +import { tokens } from '@fluentui/react-theme'; +import { + sanitizeTokenName, + TEAMS_VISUAL_REFRESH_THEME, + TEAMS_VISUAL_REFRESH_TOKENS, + VisualRefreshContext, +} from '@fluentui/visual-refresh-preview'; +import { shorthands } from '@griffel/react'; + +import { + getVisualRefreshAppearanceStateTokens, + type VisualRefreshAppearanceStateTokens, +} from '../../../../react-button/library/src/components/Button/useButtonStyles.styles'; +import { bundleIcon, ChatEmptyFilled, ChatEmptyRegular } from '@fluentui/react-icons'; + +type ComponentState = 'rest' | 'hover' | 'pressed' | 'focus' | 'disabled'; +type AppearanceStateKey = keyof VisualRefreshAppearanceStateTokens['foreground']; + +const buttonStateOrder: ComponentState[] = ['rest', 'hover', 'pressed', 'focus', 'disabled']; +const buttonStateLabels: Record = { + rest: 'Rest', + hover: 'Hover', + pressed: 'Pressed', + focus: 'Focus', + disabled: 'Disabled', +}; +const componentStateToAppearanceStateKey: Record = { + rest: 'rest', + hover: 'hover', + pressed: 'pressed', + focus: 'hover', + disabled: 'disabled', +}; +const buttonVariants: Array<{ label: string; appearance?: ButtonProps['appearance']; content: string }> = [ + { label: 'Primary', appearance: 'primary', content: 'Primary' }, + { label: 'Outline', appearance: 'outline', content: 'Outline' }, + { label: 'Subtle', appearance: 'subtle', content: 'Subtle' }, + { label: 'Transparent', appearance: 'transparent', content: 'Transparent' }, + // { label: 'Tint', appearance: 'secondary', content: 'Tint' }, +]; + +const useStoryStyles = makeStyles({ + container: { + display: 'flex', + flexDirection: 'column', + gap: '1.5rem', + maxWidth: 'max-content', + backgroundColor: 'white', + padding: '24px', + margin: '-48px -24px', + }, + controls: { + display: 'flex', + alignItems: 'center', + gap: '0.75rem', + flexWrap: 'wrap', + }, + select: { + width: '200px', + }, + controlItem: { + display: 'flex', + alignItems: 'center', + gap: '0.5rem', + }, + table: { + borderCollapse: 'collapse', + minWidth: '720px', + pointerEvents: 'none', + }, + previewSection: { + display: 'flex', + flexDirection: 'column', + gap: '0.75rem', + paddingBottom: '1.5rem', + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + }, + previewLabel: { + color: tokens.colorNeutralForeground2, + fontWeight: tokens.fontWeightSemibold, + }, + previewContent: { + display: 'flex', + alignItems: 'center', + gap: '34px', + flexWrap: 'wrap', + }, + headerCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + color: tokens.colorNeutralForeground2, + fontWeight: tokens.fontWeightRegular, + opacity: '0.8', + padding: '0.75rem', + textAlign: 'left', + }, + componentCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + fontWeight: tokens.fontWeightSemibold, + padding: '0.75rem', + verticalAlign: 'top', + width: '160px', + }, + variantCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + padding: '0.75rem', + verticalAlign: 'top', + width: '180px', + }, + stateCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + padding: '0.75rem', + textAlign: 'center', + width: '140px', + }, + stateContent: { + display: 'flex', + justifyContent: 'start', + }, +}); + +const useButtonStateStyles = makeStyles({ + focus: { + ...shorthands.borderColor(tokens.colorStrokeFocus2), + boxShadow: `0 0 0 ${tokens.strokeWidthThin} ${tokens.colorStrokeFocus2} inset`, + outline: `${tokens.strokeWidthThick} solid ${tokens.colorTransparentStroke}`, + outlineOffset: '2px', + }, +}); + +const VisualRefreshProvider = ({ children }: { children: React.ReactNode }) => { + const customProperties: Record = {}; + for (const [key, value] of Object.entries(TEAMS_VISUAL_REFRESH_TOKENS ?? {})) { + customProperties[`--visual-refresh-${key}`] = value; + } + for (const [key, value] of Object.entries(TEAMS_VISUAL_REFRESH_THEME)) { + customProperties[`--${sanitizeTokenName(key)}`] = String(value); + } + return ( + +
{children}
+
+ ); +}; + +const ButtonStateCell = ({ + appearance, + state, + children, + size, + isVisualRefreshEnabled, +}: { + appearance?: ButtonProps['appearance']; + state: ComponentState; + children: React.ReactNode; + size: ButtonProps['size']; + isVisualRefreshEnabled: boolean; +}) => { + const buttonStateClasses = useButtonStateStyles(); + const focusClass = state === 'focus' ? buttonStateClasses.focus : undefined; + const visualRefreshState = React.useMemo(() => { + if (!isVisualRefreshEnabled) { + return { + style: undefined, + iconVariant: undefined, + iconColor: undefined, + }; + } + const tokens = getVisualRefreshAppearanceStateTokens(appearance ?? 'secondary'); + const stateKey = componentStateToAppearanceStateKey[state]; + const style: React.CSSProperties = { + color: tokens.foreground[stateKey], + backgroundColor: tokens.background[stateKey], + borderColor: tokens.border[stateKey], + }; + if (state === 'hover') { + style.cursor = 'pointer'; + } + return { + style, + iconVariant: tokens.icon.variant[stateKey], + iconColor: tokens.icon.color[stateKey], + }; + }, [appearance, isVisualRefreshEnabled, state]); + + const visualRefreshStyle = visualRefreshState.style; + const visualRefreshIconVariant = visualRefreshState.iconVariant; + const visualRefreshIconColor = visualRefreshState.iconColor; + + const ChatEmpty = bundleIcon(ChatEmptyFilled, ChatEmptyRegular); + const chatIconFilled = isVisualRefreshEnabled ? visualRefreshIconVariant === 'filled' : undefined; + const chatIconStyle = + isVisualRefreshEnabled && visualRefreshIconColor ? { color: visualRefreshIconColor } : undefined; + + return ( + + ); +}; + +const ComponentStatesTable = ({ + controlSize, + isVisualRefreshEnabled, +}: { + controlSize: ButtonProps['size']; + isVisualRefreshEnabled: boolean; +}) => { + const styles = useStoryStyles(); + + return ( +
+ + + + + + {buttonVariants.map(variant => ( + + ))} + + + + {buttonStateOrder.map((state, stateIndex) => ( + + + {buttonVariants.map(variant => ( + + ))} + + ))} + +
State + {variant.label} +
{buttonStateLabels[state]} +
+ + {state === 'disabled' ? 'Disabled' : variant.content} + +
+
+
+ ); +}; + +export const ButtonVisualRefresh = (): JSXElement => { + const styles = useStoryStyles(); + const switchId = useId('visual-refresh-toggle'); + const sizeSelectId = useId('visual-refresh-size'); + const [isVisualRefreshEnabled, setIsVisualRefreshEnabled] = React.useState(false); + const [controlSize, setControlSize] = React.useState('medium'); + + const handleThemeChange = (_event: React.ChangeEvent, data: SwitchOnChangeData) => { + setIsVisualRefreshEnabled(Boolean(data.checked)); + }; + + const handleSizeChange = (event: React.ChangeEvent) => { + setControlSize(event.target.value as ButtonProps['size']); + }; + + const ChatEmpty = bundleIcon(ChatEmptyFilled, ChatEmptyRegular); + + const content = ( +
+
+
+ +
+
+ + +
+
+
+ +
+ {buttonVariants.map(variant => ( + + ))} +
+
+ {isVisualRefreshEnabled && ( + + )} +
+ ); + + return isVisualRefreshEnabled ? {content} : content; +}; + +ButtonVisualRefresh.parameters = { + docs: { + description: { + story: 'Compare Button variants across interaction states with and without the visual refresh theme.', + }, + }, +}; diff --git a/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/VisualRefresh.stories.tsx b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/VisualRefresh.stories.tsx new file mode 100644 index 00000000000000..ac1f9dfca48991 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/VisualRefresh.stories.tsx @@ -0,0 +1,380 @@ +import * as React from 'react'; +import type { JSXElement } from '@fluentui/react-components'; +import { Button, Input, Label, Select, Switch, makeStyles, useId } from '@fluentui/react-components'; +import type { ButtonProps, InputProps, SwitchOnChangeData } from '@fluentui/react-components'; +import { tokens } from '@fluentui/react-theme'; +import { + sanitizeTokenName, + TEAMS_VISUAL_REFRESH_THEME, + TEAMS_VISUAL_REFRESH_TOKENS, + VisualRefreshContext, +} from '@fluentui/visual-refresh-preview'; +import { mergeClasses, shorthands } from '@griffel/react'; +import { getVisualRefreshAppearanceStateTokens } from '../../../../react-button/library/src/components/Button/useButtonStyles.styles'; + +type ComponentState = 'rest' | 'hover' | 'focus' | 'disabled'; + +const buttonStateOrder: ComponentState[] = ['rest', 'hover', 'focus', 'disabled']; +const buttonStateLabels: Record = { + rest: 'Rest', + hover: 'Hover', + focus: 'Focus', + disabled: 'Disabled', +}; + +const useStoryStyles = makeStyles({ + container: { + display: 'flex', + flexDirection: 'column', + gap: '1.5rem', + maxWidth: 'max-content', + backgroundColor: 'white', + padding: '24px', + margin: '-48px -24px', + }, + controls: { + display: 'flex', + alignItems: 'center', + gap: '0.75rem', + flexWrap: 'wrap', + }, + select: { + width: '200px', + }, + controlItem: { + display: 'flex', + alignItems: 'center', + gap: '0.5rem', + }, + table: { + borderCollapse: 'collapse', + minWidth: '720px', + }, + headerCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + color: tokens.colorNeutralForeground2, + fontWeight: tokens.fontWeightRegular, + opacity: '0.8', + padding: '0.75rem', + textAlign: 'left', + }, + componentCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + fontWeight: tokens.fontWeightSemibold, + padding: '0.75rem', + verticalAlign: 'top', + width: '160px', + }, + variantCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + padding: '0.75rem', + verticalAlign: 'top', + width: '180px', + }, + stateCell: { + borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, + padding: '0.75rem', + textAlign: 'center', + width: '140px', + }, + stateContent: { + display: 'flex', + justifyContent: 'center', + }, +}); + +const useButtonStateStyles = makeStyles({ + focus: { + ...shorthands.borderColor(tokens.colorStrokeFocus2), + boxShadow: `0 0 0 ${tokens.strokeWidthThin} ${tokens.colorStrokeFocus2} inset`, + outline: `${tokens.strokeWidthThick} solid ${tokens.colorTransparentStroke}`, + outlineOffset: '2px', + }, +}); + +const useInputStateStyles = makeStyles({ + base: { + width: '200px', + pointerEvents: 'none', + }, + hoverOutline: { + borderColor: tokens.colorNeutralStroke1Hover, + borderBottomColor: tokens.colorNeutralStrokeAccessibleHover, + cursor: 'text', + }, + hoverUnderline: { + borderBottomColor: tokens.colorNeutralStrokeAccessibleHover, + cursor: 'text', + }, + focusOutline: { + borderColor: tokens.colorNeutralStroke1Pressed, + borderBottomColor: tokens.colorNeutralStrokeAccessiblePressed, + cursor: 'text', + '::after': { + borderBottomColor: tokens.colorCompoundBrandStroke, + transform: 'scaleX(1)', + }, + }, + focusUnderline: { + borderBottomColor: tokens.colorCompoundBrandStroke, + cursor: 'text', + '::after': { + borderBottomColor: tokens.colorCompoundBrandStroke, + transform: 'scaleX(1)', + }, + }, +}); + +const VisualRefreshProvider = ({ children }: { children: React.ReactNode }) => { + const customProperties: Record = {}; + for (const [key, value] of Object.entries(TEAMS_VISUAL_REFRESH_TOKENS ?? {})) { + customProperties[`--visual-refresh-${key}`] = value; + } + for (const [key, value] of Object.entries(TEAMS_VISUAL_REFRESH_THEME)) { + customProperties[`--${sanitizeTokenName(key)}`] = String(value); + } + return ( + +
{children}
+
+ ); +}; + +const ButtonStateCell = ({ + appearance, + state, + children, + size, + isVisualRefreshEnabled, +}: { + appearance?: ButtonProps['appearance']; + state: ComponentState; + children: React.ReactNode; + size: ButtonProps['size']; + isVisualRefreshEnabled: boolean; +}) => { + const buttonStateClasses = useButtonStateStyles(); + const focusClass = state === 'focus' ? buttonStateClasses.focus : undefined; + const visualRefreshStyle = React.useMemo(() => { + if (!isVisualRefreshEnabled) { + return undefined; + } + const tokens = getVisualRefreshAppearanceStateTokens(appearance ?? 'secondary'); + const stateKey = state === 'hover' ? 'hover' : state === 'disabled' ? 'disabled' : 'rest'; + const style: React.CSSProperties = { + color: tokens.foreground[stateKey], + backgroundColor: tokens.background[stateKey], + borderColor: tokens.border[stateKey], + }; + if (state === 'hover') { + style.cursor = 'pointer'; + } + return style; + }, [appearance, isVisualRefreshEnabled, state]); + + return ( + + ); +}; + +const InputStateCell = ({ + appearance, + state, + defaultValue, + disabledValue, + size, +}: { + appearance: NonNullable; + state: ComponentState; + defaultValue: string; + disabledValue: string; + size: NonNullable; +}) => { + const inputStateClasses = useInputStateStyles(); + const hoverClass = + state === 'hover' + ? appearance === 'underline' + ? inputStateClasses.hoverUnderline + : inputStateClasses.hoverOutline + : undefined; + const focusClass = + state === 'focus' + ? appearance === 'underline' + ? inputStateClasses.focusUnderline + : inputStateClasses.focusOutline + : undefined; + const className = mergeClasses(inputStateClasses.base, hoverClass, focusClass); + + return ( + + ); +}; + +const ComponentStatesTable = ({ + controlSize, + isVisualRefreshEnabled, +}: { + controlSize: ButtonProps['size']; + isVisualRefreshEnabled: boolean; +}) => { + const styles = useStoryStyles(); + + const buttonVariants: Array<{ label: string; appearance?: ButtonProps['appearance']; content: string }> = [ + { label: 'Outline', appearance: 'outline', content: 'Outline' }, + { label: 'Primary', appearance: 'primary', content: 'Primary' }, + { label: 'Secondary', appearance: 'secondary', content: 'Secondary' }, + { label: 'Subtle', appearance: 'subtle', content: 'Subtle' }, + { label: 'Transparent', appearance: 'transparent', content: 'Transparent' }, + { label: 'Tint', appearance: 'secondary', content: 'Tint' }, + ]; + + const inputVariants: Array<{ + label: string; + appearance: NonNullable; + defaultValue: string; + disabledValue: string; + }> = [ + { label: 'Outline', appearance: 'outline', defaultValue: 'Outline input', disabledValue: 'Outline disabled' }, + { + label: 'Underline', + appearance: 'underline', + defaultValue: 'Underline input', + disabledValue: 'Underline disabled', + }, + ]; + + return ( + + + + + + {buttonStateOrder.map(state => ( + + ))} + + + + + {buttonVariants.map((variant, index) => ( + + {index === 0 && ( + + )} + + {buttonStateOrder.map(state => ( + + ))} + + ))} + + + {inputVariants.map((variant, index) => ( + + {index === 0 && ( + + )} + + {buttonStateOrder.map(state => ( + + ))} + + ))} + + +
ComponentVariant + {buttonStateLabels[state]} +
+ Button + {variant.label} +
+ + {state === 'disabled' ? 'Disabled' : variant.content} + +
+
+ Input + {variant.label} +
+ +
+
+ ); +}; + +export const VisualRefresh = (): JSXElement => { + const styles = useStoryStyles(); + const switchId = useId('visual-refresh-toggle'); + const sizeSelectId = useId('visual-refresh-size'); + const [isVisualRefreshEnabled, setIsVisualRefreshEnabled] = React.useState(false); + const [controlSize, setControlSize] = React.useState('medium'); + + const handleThemeChange = (_event: React.ChangeEvent, data: SwitchOnChangeData) => { + setIsVisualRefreshEnabled(Boolean(data.checked)); + }; + + const handleSizeChange = (event: React.ChangeEvent) => { + setControlSize(event.target.value as ButtonProps['size']); + }; + + const content = ( +
+
+
+ +
+
+ + +
+
+ +
+ ); + + return isVisualRefreshEnabled ? {content} : content; +}; + +VisualRefresh.parameters = { + docs: { + description: { + story: 'Compare Button and Input variants across interaction states with and without the visual refresh theme.', + }, + }, +}; diff --git a/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/index.stories.tsx b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/index.stories.tsx new file mode 100644 index 00000000000000..f0647b9011fbb1 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/src/VisualRefresh/index.stories.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import { Meta } from '@storybook/react'; + +export { VisualRefresh } from './VisualRefresh.stories'; +export { ButtonVisualRefresh as Button } from './Button.stories'; + +const Component = () =>
; + +export default { + title: 'Components/VisualRefresh', + component: Component, + parameters: {}, +} as Meta; diff --git a/packages/react-components/visual-refresh-preview/stories/src/index.ts b/packages/react-components/visual-refresh-preview/stories/src/index.ts new file mode 100644 index 00000000000000..cb0ff5c3b541f6 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/react-components/visual-refresh-preview/stories/tsconfig.json b/packages/react-components/visual-refresh-preview/stories/tsconfig.json new file mode 100644 index 00000000000000..efc50169d1df18 --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "target": "ES2019", + "noEmit": true, + "isolatedModules": true, + "importHelpers": true, + "jsx": "react", + "noUnusedLocals": true, + "preserveConstEnums": true + }, + "include": [], + "files": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./.storybook/tsconfig.json" + } + ] +} diff --git a/packages/react-components/visual-refresh-preview/stories/tsconfig.lib.json b/packages/react-components/visual-refresh-preview/stories/tsconfig.lib.json new file mode 100644 index 00000000000000..9486b224643d9f --- /dev/null +++ b/packages/react-components/visual-refresh-preview/stories/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "lib": ["ES2019", "dom"], + "outDir": "../../../../dist/out-tsc", + "inlineSources": true, + "types": ["static-assets", "environment"] + }, + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/tsconfig.base.all.json b/tsconfig.base.all.json index 9b9756df7a1a05..0161cbeac676a0 100644 --- a/tsconfig.base.all.json +++ b/tsconfig.base.all.json @@ -252,9 +252,13 @@ "@fluentui/storybook-llms-extractor": ["tools/storybook-llms-extractor/src/index.ts"], "@fluentui/theme-designer": ["packages/react-components/theme-designer/src/index.ts"], "@fluentui/tokens": ["packages/tokens/src/index.ts"], + "@fluentui/visual-refresh-preview": ["packages/react-components/visual-refresh-preview/library/src/index.ts"], "@fluentui/visual-regression-assert": ["tools/visual-regression-assert/src/index.ts"], "@fluentui/visual-regression-utilities": ["tools/visual-regression-utilities/src/index.ts"], - "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"] + "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"], + "@fluentui/visual-refresh-preview-stories": [ + "packages/react-components/visual-refresh-preview/stories/src/index.ts" + ] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index ded6aaaa1f2528..776ecd04f2076d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -208,6 +208,10 @@ "@fluentui/storybook-llms-extractor": ["tools/storybook-llms-extractor/src/index.ts"], "@fluentui/theme-designer": ["packages/react-components/theme-designer/src/index.ts"], "@fluentui/tokens": ["packages/tokens/src/index.ts"], + "@fluentui/visual-refresh-preview": ["packages/react-components/visual-refresh-preview/library/src/index.ts"], + "@fluentui/visual-refresh-preview-stories": [ + "packages/react-components/visual-refresh-preview/stories/src/index.ts" + ], "@fluentui/visual-regression-assert": ["tools/visual-regression-assert/src/index.ts"], "@fluentui/visual-regression-utilities": ["tools/visual-regression-utilities/src/index.ts"], "@fluentui/workspace-plugin": ["tools/workspace-plugin/src/index.ts"]