Skip to content

Commit

Permalink
docs(react-keytips): add custom doc container and decorator for keytips
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev committed Oct 25, 2024
1 parent 474d865 commit 9289b9e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
5 changes: 1 addition & 4 deletions packages/react-keytips/stories/Default.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';
import {
Keytips,
KeytipsProps,
ExecuteKeytipEventHandler,
useKeytipRef,
} from '@fluentui-contrib/react-keytips';
Expand Down Expand Up @@ -122,7 +120,7 @@ const MenuButtonComponent = () => {
);
};

export const DefaultStory = (props: KeytipsProps) => {
export const DefaultStory = () => {
const classes = useStyles();

const normalButton = useKeytipRef({
Expand All @@ -146,7 +144,6 @@ export const DefaultStory = (props: KeytipsProps) => {

return (
<>
<Keytips {...props} content="Alt Meta" />
<div className={classes.column}>
<div className={classes.row}>
<Button ref={normalButton}>Button</Button>
Expand Down
5 changes: 1 addition & 4 deletions packages/react-keytips/stories/Dynamic.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';
import {
Keytips,
KeytipsProps,
ExecuteKeytipEventHandler,
useKeytipRef,
} from '@fluentui-contrib/react-keytips';
Expand All @@ -21,7 +19,7 @@ const useStyles = makeStyles({
},
});

export const DynamicStory = (props: KeytipsProps) => {
export const DynamicStory = () => {
const classes = useStyles();

const [currentButton, setCurrentButton] = React.useState('Button 1');
Expand Down Expand Up @@ -52,7 +50,6 @@ export const DynamicStory = (props: KeytipsProps) => {

return (
<>
<Keytips {...props} content="Alt Control" />
<div className={classes.column}>
<div className={classes.row}>
<Button
Expand Down
2 changes: 0 additions & 2 deletions packages/react-keytips/stories/OverflowMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import {
Keytips,
ExecuteKeytipEventHandler,
useKeytipRef,
} from '@fluentui-contrib/react-keytips';
Expand Down Expand Up @@ -163,7 +162,6 @@ export const OverflowStory = () => {

return (
<>
<Keytips content="Alt Control" />
<Overflow>
<div className={mergeClasses(styles.container, styles.resizableArea)}>
{itemIds.map((i) => (
Expand Down
5 changes: 1 addition & 4 deletions packages/react-keytips/stories/WithTabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as React from 'react';
import {
ExecuteKeytipEventHandler,
Keytips,
KeytipsProps,
useKeytipRef,
} from '@fluentui-contrib/react-keytips';
import {
Expand Down Expand Up @@ -44,7 +42,7 @@ const btnExecute: ExecuteKeytipEventHandler = (_, el) => {
el.targetElement?.click();
};

export const WithTabsStory = (props: KeytipsProps) => {
export const WithTabsStory = () => {
const classes = useStyles();

const [selectedValue, setSelectedValue] = React.useState<TabValue>('1');
Expand Down Expand Up @@ -103,7 +101,6 @@ export const WithTabsStory = (props: KeytipsProps) => {

return (
<>
<Keytips {...props} content="Alt Control" />
<TabList onTabSelect={onTabSelect}>
<Tab id="1" ref={refFirstTab} value="1">
First Tab
Expand Down
13 changes: 0 additions & 13 deletions packages/react-keytips/stories/index.stories.ts

This file was deleted.

51 changes: 51 additions & 0 deletions packages/react-keytips/stories/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as React from 'react';

import { Meta } from '@storybook/react';
import { Keytips } from '@fluentui-contrib/react-keytips';
export { DefaultStory as Default } from './Default.stories';
export { WithTabsStory as WithTabs } from './WithTabs.stories';
export { DynamicStory as Dynamic } from './Dynamic.stories';
export { OverflowStory as Overflow } from './OverflowMenu.stories';
import { DocsContainer, type DocsContextProps } from '@storybook/addon-docs';
import { webLightTheme, FluentProvider } from '@fluentui/react-components';

interface CustomKeytipsContainerProps {
children: React.ReactNode;
context: DocsContextProps;
}

const CustomKeytipsContainer = ({
children,
context,
}: CustomKeytipsContainerProps) => {
return (
<FluentProvider
className="sb-unstyled"
style={{ backgroundColor: 'transparent' }}
theme={webLightTheme}
>
<Keytips />
<DocsContainer context={context}>{children}</DocsContainer>
</FluentProvider>
);
};

const meta = {
title: 'Packages/react-keytips',
component: Keytips,
decorators: [
(Story, { viewMode }) => (
<>
{viewMode === 'story' && <Keytips />}
<Story />
</>
),
],
parameters: {
docs: {
container: CustomKeytipsContainer,
},
},
} satisfies Meta<typeof Keytips>;

export default meta;

0 comments on commit 9289b9e

Please sign in to comment.