Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Jul 23, 2024
1 parent 3d58924 commit e5257ff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { AriaLiveAnnouncer } from '@fluentui/react-aria';
import * as React from 'react';

import { FluentStoryContext } from '../hooks';
import { isDecoratorDisabled } from '../utils/isDecoratorDisabled';

export const withAriaLive = (Story: () => JSX.Element, context: FluentStoryContext) => {
const shouldDisable = context.parameters.reactStorybookAddon?.disabledDecorators?.includes('AriaLive');

if (shouldDisable) {
if (isDecoratorDisabled(context, 'AriaLive')) {
return Story();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Theme } from '@fluentui/react-theme';
import { themes, defaultTheme, ThemeIds } from '../theme';
import { DIR_ID, THEME_ID } from '../constants';
import { FluentGlobals, FluentStoryContext } from '../hooks';
import { isDecoratorDisabled } from '../utils/isDecoratorDisabled';

const findTheme = (themeId?: ThemeIds) => {
if (!themeId) {
Expand All @@ -24,9 +25,7 @@ export const withFluentProvider = (StoryFn: () => JSX.Element, context: FluentSt
const { globals, parameters } = context;
const { mode } = parameters;

const shouldDisable = parameters.reactStorybookAddon?.disabledDecorators?.includes('FluentProvider');

if (shouldDisable) {
if (isDecoratorDisabled(context, 'FluentProvider')) {
return StoryFn();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import * as React from 'react';

import { STRICT_MODE_ID } from '../constants';
import { FluentStoryContext } from '../hooks';
import { isDecoratorDisabled } from '../utils/isDecoratorDisabled';

export const withReactStrictMode = (StoryFn: () => JSX.Element, context: FluentStoryContext) => {
const shouldDisable = context.parameters.reactStorybookAddon?.disabledDecorators?.includes('ReactStrictMode');

if (shouldDisable) {
if (isDecoratorDisabled(context, 'ReactStrictMode')) {
return StoryFn();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { FluentParameters, FluentStoryContext } from '../hooks';

type DecoratorName = NonNullable<FluentParameters['reactStorybookAddon']>['disabledDecorators'][number];

export function isDecoratorDisabled(context: FluentStoryContext, decoratorName: DecoratorName): boolean {
return context.parameters.reactStorybookAddon?.disabledDecorators?.includes(decoratorName) ?? false;
}

0 comments on commit e5257ff

Please sign in to comment.