import * as React from 'react'; import { ChoiceGroup, CommandBar, ICommandBarItemProps, Customizer, Dialog, DialogFooter, DialogType, getTheme, IStackComponent, IStackStylesReturnType, IStackTokens, ITheme, Stack, Toggle, Text, } from '@fluentui/react'; import { DefaultButton, PrimaryButton } from '@fluentui/react/lib/Button'; import { getNeutralVariant, getSoftVariant, getStrongVariant } from '@fluentui/scheme-utilities'; import { CollapsibleSectionRecursiveExample } from '@fluentui/react-examples/lib/react-experiments/CollapsibleSection/CollapsibleSection.Recursive.Example'; import { ThemeProvider as DeprecatedThemeProvider } from '@fluentui/foundation-legacy'; // Workaround to prevent errors on usage of ThemeProvider, without disabling all deprecation checks // eslint-disable-next-line deprecation/deprecation const ThemeProvider = DeprecatedThemeProvider; const regionStyles: IStackComponent['styles'] = (props, theme): IStackStylesReturnType => ({ root: { backgroundColor: theme.semanticColors.bodyBackground, color: theme.semanticColors.bodyText, }, }); const defaultTheme: ITheme = getTheme(true); const neutralTheme = getNeutralVariant(defaultTheme); const softTheme = getSoftVariant(defaultTheme); const strongTheme = getStrongVariant(defaultTheme); const schemeThemeVariants: ITheme = { ...defaultTheme, schemes: { default: defaultTheme, neutral: neutralTheme, soft: softTheme, strong: strongTheme, }, }; export interface IThemingExampleState { bodyToggle: boolean; sideToggle: boolean; topToggle: boolean; } export class ThemingSchemesVariantExample extends React.Component<{}, IThemingExampleState> { public state: IThemingExampleState = { bodyToggle: false, sideToggle: false, topToggle: false, }; public render(): JSX.Element { // eslint-disable-next-line deprecation/deprecation return {this._renderSchemedComponents()}; } /** * Render various components only using scheme names (no Customizers.) */ private _renderSchemedComponents(): JSX.Element { const bodyScheme = this.state.bodyToggle ? 'soft' : 'neutral'; const sideScheme = this.state.sideToggle ? 'neutral' : 'strong'; const topScheme = this.state.topToggle ? 'strong' : 'soft'; const bodyCaption = 'Scheme: ' + bodyScheme; const sideCaption = 'Scheme: ' + sideScheme; const topCaption = 'Scheme: ' + topScheme; const stackTokens: IStackTokens = { childrenGap: 10 }; // TODO: Even though this styles function is the same for all regions, it has to be provided whenever the scheme // is changed to apply the new semanticColors. Is this the best way we can do this? return ( {sideCaption} {topCaption} {bodyCaption} ); } private _toggleBody = () => { this.setState((state: IThemingExampleState) => this.setState({ bodyToggle: !state.bodyToggle })); }; private _toggleSide = () => { this.setState((state: IThemingExampleState) => this.setState({ sideToggle: !state.sideToggle })); }; private _toggleTop = () => { this.setState((state: IThemingExampleState) => this.setState({ topToggle: !state.topToggle })); }; } // eslint-disable-next-line deprecation/deprecation const onCommandClick = (ev: any, item?: ICommandBarItemProps) => console.log(item && (item.text || item.name)); const items: ICommandBarItemProps[] = [ { key: 'newItem', name: 'New', iconProps: { iconName: 'Add' }, ariaLabel: 'New. Use left and right arrow keys to navigate', subMenuProps: { items: [ { key: 'emailMessage', name: 'Email message', iconProps: { iconName: 'Mail' } }, { key: 'calendarEvent', name: 'Calendar event', iconProps: { iconName: 'Calendar' } }, ], }, }, { key: 'upload', name: 'Upload', iconProps: { iconName: 'Upload' }, href: 'https://developer.microsoft.com/en-us/fluentui', target: '_blank', }, { key: 'share', name: 'Share', iconProps: { iconName: 'Share' }, onClick: onCommandClick }, { key: 'download', name: 'Download', iconProps: { iconName: 'Download' }, onClick: onCommandClick }, ]; const overflowItems: ICommandBarItemProps[] = [ { key: 'move', name: 'Move to...', iconProps: { iconName: 'MoveToFolder' } }, { key: 'copy', name: 'Copy to...', iconProps: { iconName: 'Copy' } }, { key: 'rename', name: 'Rename...', iconProps: { iconName: 'Edit' } }, ]; const farItems: ICommandBarItemProps[] = [ { key: 'sort', name: 'Sort', ariaLabel: 'Sort', iconProps: { iconName: 'SortLines' }, onClick: onCommandClick }, { key: 'tile', name: 'Grid view', ariaLabel: 'Grid view', iconProps: { iconName: 'Tiles' }, iconOnly: true, onClick: onCommandClick, }, { key: 'info', name: 'Info', ariaLabel: 'Info', iconProps: { iconName: 'Info' }, iconOnly: true, onClick: onCommandClick, }, ]; interface IDialogExampleProps { buttonText: string; } interface IDialogExampleState { hideDialog: boolean; } class DialogExample extends React.Component { public state: IDialogExampleState = { hideDialog: true, }; public render(): JSX.Element { return (

); } private _showDialog = (): void => this.setState({ hideDialog: false }); private _closeDialog = (): void => this.setState({ hideDialog: true }); }