Skip to content

Commit

Permalink
Migrate all *.stories.mdx to MDX+CSF
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyomair committed Nov 13, 2024
1 parent 5619e67 commit cd4bdc0
Show file tree
Hide file tree
Showing 58 changed files with 1,286 additions and 1,500 deletions.
191 changes: 62 additions & 129 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from "path";

export default {
framework: "@storybook/react-webpack5",
stories: ["../src/**/*.stories.@(mdx|tsx)"],
stories: ["../src/**/*.@(mdx|stories.tsx)"],
features: {
// Workaround for storybook's incompatibility with emotion >= 11
// See: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#emotion11-quasi-compatibility
Expand Down
1 change: 1 addition & 0 deletions storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@comet/eslint-config": "workspace:*",
"@faker-js/faker": "^7.6.0",
"@graphql-mocks/network-msw": "^0.3.0",
"@storybook/blocks": "7.6.20",
"@storybook/react-webpack5": "7.6.20",
"@types/draft-js": "^0.11.10",
"@types/faker": "^5.5.8",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meta, Canvas, Story } from "@storybook/addon-docs";

<Meta title="Docs/Components/AppHeader" />
import * as AppHeaderStories from "./AppHeader.stories";

<Meta of={AppHeaderStories} />

# AppHeader

Expand All @@ -10,7 +12,7 @@ It should contain the controls for the main-menu and other commonly needed actio
_**Note:** When using the component inside `MasterLayout`, the props `position` and `headerHeight` should not be set, they may only be useful, if the component is used on it's own._

<Canvas>
<Story id="stories-components-appheader-appheader--appheader" />
<Story of={AppHeaderStories.Basic} />
</Canvas>

## Components
Expand All @@ -28,7 +30,7 @@ The AppHeader system consists of multiple basic components that can be combined
`AppHeader` gives you a blank header, to which you can add things like a menu-button, a application-specific logo and buttons to the `children`.

<Canvas>
<Story id="stories-components-appheader-empty--appheader-empty" />
<Story of={AppHeaderStories.Empty} />
</Canvas>

### AppHeaderMenuButton
Expand All @@ -37,7 +39,7 @@ The AppHeader system consists of multiple basic components that can be combined
Optionally you can add a custom icon as `children` or add a custom `onClick` if you want it to do something other than toggling the menu in `MasterLayout`.

<Canvas>
<Story id="stories-components-appheader-menubutton--appheader-menubutton" />
<Story of={AppHeaderStories.MenuButton} />
</Canvas>

### AppHeaderFillSpace
Expand All @@ -46,33 +48,33 @@ The `AppHeaderFillSpace` component is used to separate the left and right elemen
Basically everything after `AppHeaderFillSpace` is pushed to the right of the `AppHeader`.

<Canvas>
<Story id="stories-components-appheader-fillspace--appheader-fillspace" />
<Story of={AppHeaderStories.FillSpace} />
</Canvas>

### AppHeaderButton

`AppHeaderButton` should generally be used for buttons on the right side of the `AppHeader`.

<Canvas>
<Story id="stories-components-appheader-button-text--appheader-button-text" />
<Story of={AppHeaderStories.ButtonText} />
</Canvas>

<Canvas>
<Story id="stories-components-appheader-button-text-and-icon--appheader-button-text-and-icon" />
<Story of={AppHeaderStories.ButtonTextAndIcon} />
</Canvas>

<Canvas>
<Story id="stories-components-appheader-button-icon--appheader-button-icon" />
<Story of={AppHeaderStories.ButtonIcon} />
</Canvas>

<Canvas>
<Story id="stories-components-appheader-button-custom--appheader-button-custom" />
<Story of={AppHeaderStories.CustomButton} />
</Canvas>

### AppHeaderDropdown

`AppHeaderDropdown` can be used for dropdown menus or other dropdown content.

<Canvas>
<Story id="stories-components-appheader-dropdown--appheader-dropdown" />
<Story of={AppHeaderStories.Dropdown} />
</Canvas>
217 changes: 217 additions & 0 deletions storybook/src/docs/components/AppHeader/AppHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
import { AppHeader, AppHeaderButton, AppHeaderDropdown, AppHeaderFillSpace, AppHeaderMenuButton, CometLogo } from "@comet/admin";
import { Account, Language, Logout, Preview, Snips, SwitchUser, Wrench } from "@comet/admin-icons";
import { Avatar, Box, Button, Divider, MenuItem, MenuList, Typography } from "@mui/material";
import * as React from "react";

export default {
title: "Docs/Components/AppHeader",
};

export const Basic = {
render: () => {
function AccountHeaderItem() {
return (
<Box display="flex" alignItems="center">
<Avatar style={{ marginRight: 10 }}>
<Account />
</Avatar>
User Name
</Box>
);
}

return (
<AppHeader position="relative" headerHeight={60}>
<AppHeaderMenuButton />
<CometLogo />

<AppHeaderFillSpace />

<AppHeaderButton startIcon={<Preview />}>Preview</AppHeaderButton>

<AppHeaderDropdown buttonChildren="Language" startIcon={<Language />}>
{(closeDropdown: () => void) => {
const onItemClicked = () => {
closeDropdown();
// Change language
};

return (
<MenuList>
<MenuItem onClick={onItemClicked}>DE</MenuItem>
<MenuItem onClick={onItemClicked}>EN</MenuItem>
<MenuItem onClick={onItemClicked}>FR</MenuItem>
<MenuItem onClick={onItemClicked}>ES</MenuItem>
</MenuList>
);
}}
</AppHeaderDropdown>

<AppHeaderDropdown buttonChildren={<AccountHeaderItem />}>
<MenuList>
<MenuItem>Edit Profile</MenuItem>
<MenuItem>Change Password</MenuItem>
</MenuList>

<Divider />

<Box padding={4}>
<Button variant="contained" color="primary" startIcon={<Logout />} fullWidth>
Logout
</Button>
</Box>
</AppHeaderDropdown>
</AppHeader>
);
},
name: "AppHeader",
};

export const Empty = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
{/* AppHeader content should be here */}
</AppHeader>
);
},
name: "AppHeader Empty",
};

export const MenuButton = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<AppHeaderMenuButton />
</AppHeader>
);
},
name: "AppHeader MenuButton",
};

export const FillSpace = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Left Content</Typography>

<AppHeaderFillSpace />

<Typography style={{ padding: 20 }}>Right Content</Typography>
</AppHeader>
);
},
name: "AppHeader FillSpace",
};

export const ButtonText = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Header button</Typography>
<AppHeaderFillSpace />

<AppHeaderButton>My Button</AppHeaderButton>
</AppHeader>
);
},
name: "AppHeader Button text",
};

export const ButtonTextAndIcon = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Header buttons with icon</Typography>
<AppHeaderFillSpace />

<AppHeaderButton startIcon={<Wrench />}>My Button</AppHeaderButton>

<AppHeaderButton endIcon={<Wrench />}>My Button</AppHeaderButton>
</AppHeader>
);
},
name: "AppHeader Button text and icon",
};

export const ButtonIcon = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Header buttons with icon only</Typography>
<AppHeaderFillSpace />

<AppHeaderButton>
<SwitchUser />
</AppHeaderButton>

<AppHeaderButton>
<Wrench color="primary" />
</AppHeaderButton>
</AppHeader>
);
},
name: "AppHeader Button icon",
};

export const CustomButton = {
render: () => {
return (
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Header button custom content</Typography>
<AppHeaderFillSpace />

<AppHeaderButton>
<Box display="flex" alignItems="center">
<Avatar style={{ marginRight: 10 }}>
<Account />
</Avatar>
User Name
</Box>
</AppHeaderButton>
</AppHeader>
);
},
name: "AppHeader Button custom",
};

export const Dropdown = {
render: () => {
const [open, setOpen] = React.useState<boolean>(false);

return (
<>
<div style={{ marginBottom: "30px" }}>Dropdown Menu state: {open ? "open" : "closed"}</div>
<AppHeader position="relative" headerHeight={60}>
<Typography style={{ padding: 20 }}>Header dropdown</Typography>
<AppHeaderFillSpace />

<AppHeaderDropdown buttonChildren={<Snips />} dropdownArrow={null}>
<Box padding={4} width={200}>
<Typography>
<strong>Dropdown Text</strong>
<br />
<br />
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat
porttitor ligula, eget lacinia odio sem nec elit.
</Typography>
</Box>
</AppHeaderDropdown>

<AppHeaderDropdown buttonChildren="Dropdown Menu" open={open} onOpenChange={setOpen}>
{() => {
return (
<MenuList>
<MenuItem>Item 1</MenuItem>
<MenuItem>Item 2</MenuItem>
<MenuItem>Item 3</MenuItem>
</MenuList>
);
}}
</AppHeaderDropdown>
</AppHeader>
</>
);
},
name: "AppHeader Dropdown",
};

This file was deleted.

Loading

0 comments on commit cd4bdc0

Please sign in to comment.