diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 49a1f52e38f489..72b9156562868a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -174,6 +174,7 @@ packages/react-components/react-progress @microsoft/cxe-red @tomi-msft packages/react-components/react-persona @microsoft/cxe-red @sopranopillow packages/react-components/react-avatar-context @microsoft/teams-prg packages/react-components/react-infobutton @microsoft/cxe-red @sopranopillow +packages/react-migration-v8-v9 @microsoft/cxe-coastal @geoffcoxmsft # <%= NX-CODEOWNER-PLACEHOLDER %> diff --git a/apps/public-docsite-v9/.storybook/main.js b/apps/public-docsite-v9/.storybook/main.js index b1cec15df3610a..a9ba66ecd41ff7 100644 --- a/apps/public-docsite-v9/.storybook/main.js +++ b/apps/public-docsite-v9/.storybook/main.js @@ -8,6 +8,7 @@ module.exports = /** @type {Omit @@ -71,18 +70,3 @@ To migrate a button replace the v8 usage with the corresponding v9 button varian | theme | (use FluentProvider) | | toggle | (use ToggleButton) | | uniqueId | HTML key | - -## Button Shims - -The button shim components accept v8 `IButtonProps` and render v9 buttons. -Shims are useful when you have a large number of usage instances, want to render v9 components, and do not have time -or resources to update every instance. - -Prefer to migrate your code to use v9 buttons if possible rather than take a use shims. -Shim depend on both v8 and v9 so may prevent bundle size optimizations. - -You can find the button shims in the Fluent UI React repository here [apps/public-docsite-v9/src/shims/ButtonShim.tsx](https://github.com/microsoft/fluentui/blob/master/apps/public-docsite-v9/src/shims/ButtonShim.tsx) - - - - diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ActionButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ActionButtonShimExample.tsx deleted file mode 100644 index cecc63c686ab4f..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ActionButtonShimExample.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import * as React from 'react'; -import { ActionButton, IButtonProps, Icon, IIconProps } from '@fluentui/react'; -import { Button, webLightTheme, FluentProvider } from '@fluentui/react-components'; -import { ActionButtonShim } from '../../../../../shims/ButtonShim'; - -const addIcon: IIconProps = { iconName: 'Add' }; - -export const ActionButtonShimExample = (props: IButtonProps) => { - return ( - <> - Action - - Action - - - - - - ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ButtonShimExamples.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ButtonShimExamples.tsx deleted file mode 100644 index a3d691324a7bad..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ButtonShimExamples.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import * as React from 'react'; -import { makeStyles, shorthands } from '@fluentui/react-components'; -import { ActionButtonShimExample } from './ActionButtonShimExample'; -import { CommandButtonShimExample } from './CommandButtonShimExample'; -import { CompoundButtonShimExample } from './CompoundButtonShimExample'; -import { DefaultButtonShimExample } from './DefaultButtonShimExample'; -import { MenuButtonShimExample } from './MenuButtonShimExample'; -import { PrimaryButtonShimExample } from './PrimaryButtonShimExample'; -import { ToggleButtonShimExample } from './ToggleButtonShimExample'; - -const useStyles = makeStyles({ - root: { - display: 'grid', - gridTemplateColumns: 'auto auto auto auto', - gridTemplateRows: 'repeat(7, 1fr)', - width: 'fit-content', - alignContent: 'center', - alignItems: 'center', - justifyItems: 'center', - columnGap: '10px', - rowGap: '10px', - }, - componentName: { - justifySelf: 'end', - ...shorthands.margin(0, '10px', 0, 0), - }, -}); - -export const ButtonShimExamples = () => { - const styles = useStyles(); - - return ( -
-

Component

-

v8

-

shim

-

v9

-
ActionButton
- -
DefaultButton
- -
CommandButton
- -
CompoundButton
- -
MenuButton
- -
PrimaryButton
- -
ToggleButton
- -
- ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CommandButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CommandButtonShimExample.tsx deleted file mode 100644 index dc1aa9c086a280..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CommandButtonShimExample.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import * as React from 'react'; -import { CommandButton, IButtonProps, Icon, IIconProps } from '@fluentui/react'; -import { Button, webLightTheme, FluentProvider } from '@fluentui/react-components'; -import { CommandButtonShim } from '../../../../../shims/ButtonShim'; - -const addIcon: IIconProps = { iconName: 'Add' }; - -export const CommandButtonShimExample = (props: IButtonProps) => { - return ( - <> - Command - - Command - - - - - - ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CompoundButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CompoundButtonShimExample.tsx deleted file mode 100644 index cd734bd378ab09..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/CompoundButtonShimExample.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import { CompoundButton as CompoundButtonV8, IButtonProps } from '@fluentui/react'; -import { CompoundButton as CompoundButtonV9, webLightTheme, FluentProvider } from '@fluentui/react-components'; -import { CompoundButtonShim } from '../../../../../shims/ButtonShim'; - -export const CompoundButtonShimExample = (props: IButtonProps) => { - return ( - <> - Compound - - Compound - - - Compound - - - ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/DefaultButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/DefaultButtonShimExample.tsx deleted file mode 100644 index 80e0557367a6b7..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/DefaultButtonShimExample.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import { DefaultButton, IButtonProps } from '@fluentui/react'; -import { Button, webLightTheme, FluentProvider } from '@fluentui/react-components'; -import { DefaultButtonShim } from '../../../../../shims/ButtonShim'; - -export const DefaultButtonShimExample = (props: IButtonProps) => { - return ( - <> - Default - - Default - - - - - - ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/PrimaryButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/PrimaryButtonShimExample.tsx deleted file mode 100644 index 372bc892a59d9d..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/PrimaryButtonShimExample.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import { PrimaryButton, IButtonProps } from '@fluentui/react'; -import { Button, webLightTheme, FluentProvider } from '@fluentui/react-components'; -import { PrimaryButtonShim } from '../../../../../shims/ButtonShim'; - -export const PrimaryButtonShimExample = (props: IButtonProps) => { - return ( - <> - Primary - - Primary - - - - - - ); -}; diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ToggleButtonShimExample.tsx b/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ToggleButtonShimExample.tsx deleted file mode 100644 index 3f6f02eb2b35e3..00000000000000 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/ToggleButtonShimExample.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/* eslint-disable react/jsx-no-bind */ -import * as React from 'react'; -import { DefaultButton, IButtonProps, Icon, IIconProps, initializeIcons } from '@fluentui/react'; -import { webLightTheme, FluentProvider, ToggleButton } from '@fluentui/react-components'; -import { ToggleButtonShim } from '../../../../../shims/ButtonShim'; - -initializeIcons(); - -const volume0Icon: IIconProps = { iconName: 'Volume0' }; -const volume3Icon: IIconProps = { iconName: 'Volume3' }; - -export const ToggleButtonShimExample = (props: IButtonProps) => { - const [muted1, setMuted1] = React.useState(false); - const [muted2, setMuted2] = React.useState(false); - const [muted3, setMuted3] = React.useState(false); - - return ( - <> - setMuted1(!muted1)} - /> - - setMuted2(!muted2)} - /> - - - : } - onClick={() => setMuted3(!muted3)} - > - Toggle - - - - ); -}; diff --git a/apps/public-docsite-v9/src/shims/ButtonShim.tsx b/apps/public-docsite-v9/src/shims/ButtonShim.tsx deleted file mode 100644 index 6f3f011c42098a..00000000000000 --- a/apps/public-docsite-v9/src/shims/ButtonShim.tsx +++ /dev/null @@ -1,174 +0,0 @@ -import * as React from 'react'; - -import { IBaseButtonProps, IButtonProps, Icon } from '@fluentui/react'; - -import { - Button, - ButtonProps, - CompoundButton, - CompoundButtonProps, - Menu, - MenuButton, - MenuButtonProps, - MenuList, - MenuPopover, - MenuTrigger, - ToggleButton, - ToggleButtonProps, -} from '@fluentui/react-components'; -import { MenuItemShim, shimMenuProps } from './MenuShim'; - -const shimButtonProps = (props: IBaseButtonProps & React.RefAttributes): ButtonProps => { - //TODO: Icon shim. This still renders the v8 icon. - const icon = props.onRenderIcon ? ( - props.onRenderIcon(props) - ) : props.iconProps ? ( - - ) : undefined; - - const variantClassName = props.variantClassName ?? props.primary ? 'ms-Button--primary' : 'ms-Button--default'; - const className = [props.baseClassName, variantClassName, props.className].filter(Boolean).join(' '); - - return { - // spread incoming props to propagate HTML properties not part of IBaseButtonProps - ...props, - appearance: props.primary ? 'primary' : undefined, - className: className, - disabled: props.disabled, - disabledFocusable: props.allowDisabledFocus, - 'aria-hidden': props.ariaHidden, - 'aria-label': props.ariaLabel, - icon, - key: props.key || props.uniqueId, - children: props.onRenderChildren - ? props.onRenderChildren(props) - : props.onRenderText - ? props.onRenderText(props) - : props.text || props.children, - } as ButtonProps; -}; - -export const ButtonShim: React.ForwardRefExoticComponent< - IBaseButtonProps & React.RefAttributes -> = React.forwardRef((props, _ref) => { - const shimProps = shimButtonProps(props); - - if (props.toggle) { - return {props.children}; - } - if (props.secondaryText || props.onRenderDescription?.(props)) { - return ; - } - - return + + + ); +}; + +export default { + title: 'Migration Shims/Button/ActionButtonShim', + component: ActionButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/CommandButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/CommandButtonShim/Description.md new file mode 100644 index 00000000000000..85f4f38aca9b33 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/CommandButtonShim/Description.md @@ -0,0 +1 @@ +The DefaultButtonShim component accepts the same props as a v8 DefaultButton and renders a v9 Button. diff --git a/packages/react-migration-v8-v9/src/stories/CommandButtonShim/index.stories.tsx b/packages/react-migration-v8-v9/src/stories/CommandButtonShim/index.stories.tsx new file mode 100644 index 00000000000000..f38b6e67bf2047 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/CommandButtonShim/index.stories.tsx @@ -0,0 +1,61 @@ +import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { CommandButton, Icon } from '@fluentui/react'; +import type { IIconProps } from '@fluentui/react'; +import { FluentProvider, Button, webLightTheme, makeStyles, shorthands } from '@fluentui/react-components'; +import { CommandButtonShim } from '../../components/Button/index'; + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); + +const addIcon: IIconProps = { iconName: 'Add' }; + +export const Default = () => { + const styles = useStyles(); + + return ( +
+

v8

+

shim

+

v9

+ Command + + Command + + + + +
+ ); +}; + +export default { + title: 'Migration Shims/Button/CommandButtonShim', + component: CommandButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/Description.md new file mode 100644 index 00000000000000..2e29a7a34226fd --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/Description.md @@ -0,0 +1 @@ +The CompoundButtonShim component accepts the same props as a v8 CompoundButton and renders a v9 CompoundButton. diff --git a/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/index.stories.tsx b/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/index.stories.tsx new file mode 100644 index 00000000000000..25ae5c922b00b8 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/CompoundButtonShim/index.stories.tsx @@ -0,0 +1,62 @@ +import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { CompoundButton as CompoundButtonV8 } from '@fluentui/react'; +import { + CompoundButton as CompoundButtonV9, + webLightTheme, + FluentProvider, + makeStyles, + shorthands, +} from '@fluentui/react-components'; +import { CompoundButtonShim } from '../../components/Button/index'; + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); + +export const Default = () => { + const styles = useStyles(); + + return ( +
+

v8

+

shim

+

v9

+ Compound + + Compound + + + Compound + +
+ ); +}; + +export default { + title: 'Migration Shims/Button/CompoundButtonShim', + component: CompoundButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/Description.md new file mode 100644 index 00000000000000..85f4f38aca9b33 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/Description.md @@ -0,0 +1 @@ +The DefaultButtonShim component accepts the same props as a v8 DefaultButton and renders a v9 Button. diff --git a/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/index.tsx b/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/index.tsx new file mode 100644 index 00000000000000..8844dbf68e32f4 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/DefaultButtonShim/index.tsx @@ -0,0 +1,56 @@ +import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { DefaultButton } from '@fluentui/react'; +import { FluentProvider, Button, webLightTheme, makeStyles, shorthands } from '@fluentui/react-components'; +import { DefaultButtonShim } from '../../components/Button/index'; + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); + +export const Default = () => { + const styles = useStyles(); + + return ( +
+

v8

+

DefaultButtonShim

+

v9

+ Default + + Default + + + + +
+ ); +}; + +export default { + title: 'Migration Shims/Button/DefaultButtonShim', + component: DefaultButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/MenuButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/MenuButtonShim/Description.md new file mode 100644 index 00000000000000..4aceb0bb481836 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/MenuButtonShim/Description.md @@ -0,0 +1 @@ +The MenuButtonShim component accepts the same props as a v8 DefaultButton with menuProps and renders a v9 MenuButton. diff --git a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/MenuButtonShimExample.tsx b/packages/react-migration-v8-v9/src/stories/MenuButtonShim/index.stories.tsx similarity index 78% rename from apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/MenuButtonShimExample.tsx rename to packages/react-migration-v8-v9/src/stories/MenuButtonShim/index.stories.tsx index b871e67af5a023..64f0b16160d230 100644 --- a/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Button/MenuButtonShimExample.tsx +++ b/packages/react-migration-v8-v9/src/stories/MenuButtonShim/index.stories.tsx @@ -1,33 +1,53 @@ -/* eslint-disable no-alert */ import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { ContextualMenuItemType, DefaultButton, Icon, initializeIcons } from '@fluentui/react'; +import type { IContextualMenuItem, IContextualMenuProps, IIconProps } from '@fluentui/react'; import { - ContextualMenuItemType, - DefaultButton, - Icon, - IContextualMenuItem, - IContextualMenuProps, - IIconProps, -} from '@fluentui/react'; -import { - webLightTheme, FluentProvider, + webLightTheme, + makeStyles, + shorthands, Menu, - MenuTrigger, MenuButton, - MenuPopover, - MenuList, - MenuItem, MenuDivider, + MenuItem, MenuItemCheckbox, + MenuList, + MenuPopover, + MenuTrigger, } from '@fluentui/react-components'; -import { MenuButtonShim } from '../../../../../shims/ButtonShim'; +import { MenuButtonShim } from '../../components/Button/index'; + +initializeIcons(); + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); const addIcon: IIconProps = { iconName: 'Add' }; const mailIcon: IIconProps = { iconName: 'Mail' }; const calendarIcon: IIconProps = { iconName: 'Calendar' }; const shareIcon: IIconProps = { iconName: 'Share', style: { color: 'salmon' } }; -export const MenuButtonShimExample = () => { +export const Default = () => { + const styles = useStyles(); + const [selection, setSelection] = React.useState<{ [key: string]: boolean }>({}); const onToggleSelect = React.useCallback( @@ -116,7 +136,10 @@ export const MenuButtonShimExample = () => { }; return ( - <> +
+

v8

+

shim

+

v9

@@ -153,6 +176,18 @@ export const MenuButtonShimExample = () => { - +
); }; + +export default { + title: 'Migration Shims/Button/MenuButtonShim', + component: MenuButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/Description.md new file mode 100644 index 00000000000000..1dbebd59b5ad2d --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/Description.md @@ -0,0 +1 @@ +The PrimaryButtonShim component accepts the same props as a v8 PrimaryButton and renders a v9 Button. diff --git a/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/index.stories.tsx b/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/index.stories.tsx new file mode 100644 index 00000000000000..5900bb6a9bb42e --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/PrimaryButtonShim/index.stories.tsx @@ -0,0 +1,56 @@ +import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { PrimaryButton } from '@fluentui/react'; +import { FluentProvider, Button, webLightTheme, makeStyles, shorthands } from '@fluentui/react-components'; +import { PrimaryButtonShim } from '../../components/Button/index'; + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); + +export const Default = () => { + const styles = useStyles(); + + return ( +
+

v8

+

shim

+

v9

+ Primary + + Primary + + + + +
+ ); +}; + +export default { + title: 'Migration Shims/Button/PrimaryButtonShim', + component: PrimaryButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/Stack/Description.md b/packages/react-migration-v8-v9/src/stories/Stack/Description.md new file mode 100644 index 00000000000000..a721f4a26ba38f --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/Stack/Description.md @@ -0,0 +1,3 @@ +The StackShim and StackItemShim accept the same props a v8 Stack and StackItem and render equivalent HTML and stylings to provide layout using CSS flexbox. + +The Stack and StackItem components are not included in v9. Providing components that expose equivalent layout properties as CSS flexbox required learning another set of props without adding signficant value. diff --git a/apps/public-docsite-v9/src/stories/StackShim.stories.tsx b/packages/react-migration-v8-v9/src/stories/Stack/index.stories.tsx similarity index 91% rename from apps/public-docsite-v9/src/stories/StackShim.stories.tsx rename to packages/react-migration-v8-v9/src/stories/Stack/index.stories.tsx index ecc37b3a5e8df3..429a348ae3e8e1 100644 --- a/apps/public-docsite-v9/src/stories/StackShim.stories.tsx +++ b/packages/react-migration-v8-v9/src/stories/Stack/index.stories.tsx @@ -1,8 +1,10 @@ import * as React from 'react'; -import { Meta } from '@storybook/react'; -import { Button, makeStyles } from '@fluentui/react-components'; -import { Checkbox, Dropdown, IDropdownOption, DropdownMenuItemType, Stack, TextField } from '@fluentui/react'; -import { StackShim, StackItemShim } from '../shims/StackShim/index'; +import { makeStyles } from '@fluentui/react-components'; +import { Checkbox, Dropdown, DropdownMenuItemType, Stack, TextField } from '@fluentui/react'; +import type { IDropdownOption } from '@fluentui/react'; +import { StackShim, StackItemShim } from '../../components/Stack/index'; + +import descriptionMd from './Description.md'; const horizontalAlignOptions: IDropdownOption[] = [ { @@ -53,7 +55,7 @@ const useCustomStyles = makeStyles({ }, }); -export const StackShimStory = () => { +export const Playground = () => { const [state, setState] = React.useState({ verticalFill: false, horizontal: false, @@ -68,7 +70,7 @@ export const StackShimStory = () => { const [childrenGapToken, setChildrenGapToken] = React.useState('10'); const [paddingToken, setPaddingToken] = React.useState('10px'); - const onCheckboxChange = (ev: React.ChangeEvent, checked?: boolean) => { + const onCheckboxChange = (ev?: React.FormEvent, checked?: boolean) => { const { name } = ev.target; setState({ ...state, [name]: checked }); @@ -209,13 +211,13 @@ export const StackShimStory = () => { }; export default { - title: 'Concepts/Migration/from v8/Shims/Stack', - component: Button, - decorators: [ - Story => ( -
- -
- ), - ], -} as Meta; + title: 'Migration Shims/StackShim', + component: StackShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/Description.md b/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/Description.md new file mode 100644 index 00000000000000..596353ef214b90 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/Description.md @@ -0,0 +1 @@ +The ToggleButtonShim component accepts the same props as a v8 DefaultButton with the toggle prop set and renders a v9 ToggleButton. diff --git a/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/index.stories.tsx b/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/index.stories.tsx new file mode 100644 index 00000000000000..d03b566ef080b0 --- /dev/null +++ b/packages/react-migration-v8-v9/src/stories/ToggleButtonShim/index.stories.tsx @@ -0,0 +1,84 @@ +import * as React from 'react'; + +import descriptionMd from './Description.md'; + +import { DefaultButton, Icon, initializeIcons } from '@fluentui/react'; +import type { IIconProps } from '@fluentui/react'; +import { FluentProvider, webLightTheme, makeStyles, shorthands, ToggleButton } from '@fluentui/react-components'; +import { ToggleButtonShim } from '../../components/Button/index'; + +initializeIcons(); + +const useStyles = makeStyles({ + root: { + display: 'grid', + gridTemplateColumns: 'auto auto auto', + gridTemplateRows: '1fr', + width: 'fit-content', + alignContent: 'center', + alignItems: 'center', + justifyItems: 'center', + columnGap: '10px', + rowGap: '10px', + }, + componentName: { + justifySelf: 'end', + ...shorthands.margin(0, '10px', 0, 0), + }, +}); + +const volume0Icon: IIconProps = { iconName: 'Volume0' }; +const volume3Icon: IIconProps = { iconName: 'Volume3' }; + +export const Default = () => { + const styles = useStyles(); + + const [muted1, setMuted1] = React.useState(false); + const [muted2, setMuted2] = React.useState(false); + const [muted3, setMuted3] = React.useState(false); + + return ( +
+

v8

+

shim

+

v9

+ setMuted1(!muted1)} + /> + + setMuted2(!muted2)} + /> + + + : } + onClick={() => setMuted3(!muted3)} + > + Toggle + + +
+ ); +}; + +export default { + title: 'Migration Shims/Button/ToggleButtonShim', + component: ToggleButtonShim, + parameters: { + docs: { + description: { + component: [descriptionMd].join('\n'), + }, + }, + }, +}; diff --git a/packages/react-migration-v8-v9/tsconfig.json b/packages/react-migration-v8-v9/tsconfig.json new file mode 100644 index 00000000000000..affceae1828ae1 --- /dev/null +++ b/packages/react-migration-v8-v9/tsconfig.json @@ -0,0 +1,25 @@ +{ + "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" + }, + { + "path": "./.storybook/tsconfig.json" + } + ] +} diff --git a/packages/react-migration-v8-v9/tsconfig.lib.json b/packages/react-migration-v8-v9/tsconfig.lib.json new file mode 100644 index 00000000000000..978cb985cd5e4a --- /dev/null +++ b/packages/react-migration-v8-v9/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/common/**", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.stories.ts", + "**/*.stories.tsx" + ], + "include": ["./src/**/*.ts", "./src/**/*.tsx"] +} diff --git a/packages/react-migration-v8-v9/tsconfig.spec.json b/packages/react-migration-v8-v9/tsconfig.spec.json new file mode 100644 index 00000000000000..469fcba4d7ba75 --- /dev/null +++ b/packages/react-migration-v8-v9/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist", + "types": ["jest", "node"] + }, + "include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index ea392c8e0eb006..fc516cd2d6cdd9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -43,6 +43,7 @@ "@fluentui/react-label": ["packages/react-components/react-label/src/index.ts"], "@fluentui/react-link": ["packages/react-components/react-link/src/index.ts"], "@fluentui/react-menu": ["packages/react-components/react-menu/src/index.ts"], + "@fluentui/react-migration-v8-v9": ["packages/react-migration-v8-v9/src/index.ts"], "@fluentui/react-overflow": ["packages/react-components/react-overflow/src/index.ts"], "@fluentui/react-persona": ["packages/react-components/react-persona/src/index.ts"], "@fluentui/react-popover": ["packages/react-components/react-popover/src/index.ts"], diff --git a/workspace.json b/workspace.json index 18214f4fd8f52d..fc529b32feab69 100644 --- a/workspace.json +++ b/workspace.json @@ -533,6 +533,12 @@ "tags": ["vNext", "platform:web"], "implicitDependencies": [] }, + "@fluentui/react-migration-v8-v9": { + "root": "packages/react-migration-v8-v9", + "projectType": "library", + "implicitDependencies": [], + "sourceRoot": "packages/react-migration-v8-v9/src" + }, "@fluentui/react-monaco-editor": { "root": "packages/react-monaco-editor", "projectType": "library",