Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docsite-v9): move theme picker #25385

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { DocsContainer, DocsContextProps } from '@storybook/addon-docs';
import { FluentStoryContext, THEME_ID, themes } from '@fluentui/react-storybook-addon';
import { FluentDocsHeader } from './FluentDocsHeader.stories';
import { FluentStoryContext } from '@fluentui/react-storybook-addon';
import { webLightTheme, FluentProvider } from '@fluentui/react-components';

interface IFluentDocsContainerProps {
Expand All @@ -12,17 +11,8 @@ interface IFluentDocsContainerProps {
* A container that wraps storybook's native docs container to add extra components to the docs experience
*/
export const FluentDocsContainer: React.FC<IFluentDocsContainerProps> = ({ children, context }) => {
// eslint-disable-next-line deprecation/deprecation
const selectedTheme = themes.find(theme => theme.id === context.globals[THEME_ID]);
return (
<>
<FluentProvider style={{ backgroundColor: 'transparent' }} theme={selectedTheme?.theme ?? webLightTheme}>
<FluentDocsHeader
// eslint-disable-next-line deprecation/deprecation
storybookGlobals={context.globals}
/>
</FluentProvider>

{/** TODO add table of contents */}
<FluentProvider style={{ backgroundColor: 'transparent' }} theme={webLightTheme}>
<DocsContainer context={context}>{children}</DocsContainer>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@storybook/addon-docs';
import { makeStyles, shorthands } from '@griffel/react';
import { Toc, nameToHash } from './Toc.stories';
import { THEME_ID, themes } from '@fluentui/react-storybook-addon';
import { ThemePicker } from './ThemePicker.stories';

const useStyles = makeStyles({
divider: {
Expand Down Expand Up @@ -40,6 +42,8 @@ const useStyles = makeStyles({

export const FluentDocsPage = () => {
const context = React.useContext(DocsContext);
// eslint-disable-next-line deprecation/deprecation
const selectedTheme = themes.find(theme => theme.id === context.globals![THEME_ID]);
const stories = context.componentStories();
const primaryStory = stories[0];
const styles = useStyles();
Expand All @@ -61,6 +65,7 @@ export const FluentDocsPage = () => {

<div className={styles.wrapper}>
<div className={styles.container}>
<ThemePicker selectedThemeId={selectedTheme?.id} />
<Subtitle />
<Description />
<hr className={styles.divider} />
Expand Down