@campxdev/react-blueprint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +29 -0
- package/.storybook/preview.tsx +28 -0
- package/.vscode/settings.json +3 -0
- package/README.md +100 -0
- package/bitbucket-pipelines.yml +60 -0
- package/exports.ts +1 -0
- package/package.json +74 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App.css +38 -0
- package/src/App.test.tsx +9 -0
- package/src/App.tsx +12 -0
- package/src/assets/fonts/heebo/Heebo-Medium.ttf +0 -0
- package/src/assets/fonts/heebo/Heebo-SemiBold.ttf +0 -0
- package/src/assets/fonts/heebo/index.ts +3 -0
- package/src/assets/fonts/poppins/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/poppins/index.ts +14 -0
- package/src/assets/images/admin.png +0 -0
- package/src/assets/images/campx_logo__full_primary.png +0 -0
- package/src/assets/images/collegex.png +0 -0
- package/src/assets/images/commutex.png +0 -0
- package/src/assets/images/enrollx.png +0 -0
- package/src/assets/images/examx.png +0 -0
- package/src/assets/images/hostelx copy.png +0 -0
- package/src/assets/images/hostelx.png +0 -0
- package/src/assets/images/icons.tsx +193 -0
- package/src/assets/images/index.ts +25 -0
- package/src/assets/images/payx.png +0 -0
- package/src/assets/images/pepolex.png +0 -0
- package/src/assets/images/svg/commutex_small.svg +11 -0
- package/src/assets/images/svg/enroll_logo.svg +9 -0
- package/src/assets/images/svg/exams_small.svg +12 -0
- package/src/assets/images/svg/help-icon.svg +8 -0
- package/src/assets/images/svg/hostel_small.svg +13 -0
- package/src/assets/images/svg/index.ts +19 -0
- package/src/assets/images/svg/payx_small.svg +16 -0
- package/src/assets/images/svg/people_small.svg +9 -0
- package/src/assets/images/svg/squareSmall.svg +9 -0
- package/src/assets/images/svg/square_small.svg +9 -0
- package/src/components/DropDownMenu/DropDownButton.tsx +30 -0
- package/src/components/DropDownMenu/DropDownIcon.tsx +31 -0
- package/src/components/DropDownMenu/DropDownMenu.stories.tsx +139 -0
- package/src/components/DropDownMenu/DropDownMenu.tsx +65 -0
- package/src/components/DropDownMenu/MenuItemButton.tsx +29 -0
- package/src/components/DropDownMenu/styles.tsx +31 -0
- package/src/components/Input/Button/Button.stories.tsx +62 -0
- package/src/components/Input/Button/Button.tsx +11 -0
- package/src/components/Input/Label/Label.tsx +11 -0
- package/src/components/Input/SingleSelect/SingleSelect.stories.tsx +55 -0
- package/src/components/Input/SingleSelect/SingleSelect.tsx +4 -0
- package/src/components/Input/Switch/Switch.stories.tsx +62 -0
- package/src/components/Input/Switch/Switch.tsx +11 -0
- package/src/components/Input/TextField/TextField.stories.tsx +135 -0
- package/src/components/Input/TextField/TextField.tsx +35 -0
- package/src/components/Layout/ComponentBackground/ComponentBackground.tsx +82 -0
- package/src/components/Layout/ComponentBackground/DefaultBackground.tsx +12 -0
- package/src/components/Layout/ComponentBackground/PaperBackground.tsx +12 -0
- package/src/components/Layout/Header/AppHeader.stories.tsx +209 -0
- package/src/components/Layout/Header/AppHeader.tsx +70 -0
- package/src/components/Layout/Header/AppLogo.tsx +53 -0
- package/src/components/Layout/Header/AppsMenu.tsx +162 -0
- package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +30 -0
- package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +63 -0
- package/src/components/Layout/Header/HeaderActions/UserBox.tsx +117 -0
- package/src/components/Layout/Header/styles/styles.tsx +69 -0
- package/src/components/Typography/Typography.stories.tsx +95 -0
- package/src/components/Typography/Typography.tsx +12 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/Providers.tsx +6 -0
- package/src/index.css +13 -0
- package/src/index.tsx +19 -0
- package/src/logo.svg +1 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/src/stories/Button.stories.ts +52 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +5 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +15 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +3 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +12 -0
- package/src/stories/assets/youtube.svg +4 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/themes/MuiThemeProvider.tsx +18 -0
- package/src/themes/colorTokens.stories.tsx +71 -0
- package/src/themes/colorTokens.ts +77 -0
- package/src/themes/commonTheme.ts +443 -0
- package/src/themes/customCssBaseline.ts +39 -0
- package/src/themes/darkTheme.ts +24 -0
- package/src/themes/index.ts +4 -0
- package/src/themes/lightTheme.ts +22 -0
- package/src/themes/typography.stories.tsx +79 -0
- package/src/utils/applications.ts +140 -0
- package/src/utils/constants.ts +6 -0
- package/src/utils/imageMap.ts +22 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Avatar, Box, styled } from "@mui/material";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
export const StyledContainer = styled(Box)(({ theme }) => ({
|
|
5
|
+
backgroundColor: theme.palette.background.paper,
|
|
6
|
+
display: "flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "space-between",
|
|
9
|
+
height: "60px",
|
|
10
|
+
margin: "auto",
|
|
11
|
+
"@media (min-width: 768px)": {
|
|
12
|
+
width: "770px",
|
|
13
|
+
},
|
|
14
|
+
"@media (min-width: 1024px)": {
|
|
15
|
+
width: "1025px",
|
|
16
|
+
},
|
|
17
|
+
"@media (min-width: 1200px)": {
|
|
18
|
+
width: "1280px",
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
export const StyledHeader = styled("header")(({ theme }) => ({
|
|
23
|
+
width: "100%",
|
|
24
|
+
position: "fixed",
|
|
25
|
+
top: 0,
|
|
26
|
+
left: 0,
|
|
27
|
+
backgroundColor: theme.palette.background.paper,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export const StyledActionBox = styled(Box)(({ theme }) => ({
|
|
31
|
+
marginRight: "20px",
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
gap: "14px",
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
export const StyledRouterLink = styled(Link)(() => ({
|
|
38
|
+
textDecoration: "none",
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
export const StyledLogosWrapper = styled(Box)(() => ({
|
|
42
|
+
display: "flex",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
gap: "10px",
|
|
45
|
+
padding: "10px",
|
|
46
|
+
transition: "background ease 0.3s",
|
|
47
|
+
borderRadius: "5px",
|
|
48
|
+
"&:hover": {
|
|
49
|
+
background: "rgba(0, 0, 0, 0.05)",
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
export const StyledImageWrapper = styled(Box)(() => ({
|
|
54
|
+
width: "auto",
|
|
55
|
+
height: "22px",
|
|
56
|
+
display: "flex",
|
|
57
|
+
img: {
|
|
58
|
+
width: "100%",
|
|
59
|
+
height: "25px",
|
|
60
|
+
objectFit: "contain",
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
export const StyledAvatar = styled(Avatar)(({ theme }) => ({
|
|
65
|
+
// background: theme.palette.secondary.main,
|
|
66
|
+
// cursor: "pointer",
|
|
67
|
+
// height: "45px",
|
|
68
|
+
// width: "45px",
|
|
69
|
+
}));
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Import React and other necessary elements
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
// Make sure your childrenField import is correct
|
|
5
|
+
|
|
6
|
+
import Typography, { TypographyProps } from "./Typography";
|
|
7
|
+
|
|
8
|
+
// Define the default export with Meta type including the component type
|
|
9
|
+
export default {
|
|
10
|
+
title: "Typography",
|
|
11
|
+
component: Typography,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
variant: {
|
|
15
|
+
control: "select",
|
|
16
|
+
options: ["h1", "h2", "h3", "h4", "fieldLabel"],
|
|
17
|
+
description: "The Typography Variant to use",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} as Meta<typeof Typography>;
|
|
21
|
+
|
|
22
|
+
// Define stories directly as objects with render function
|
|
23
|
+
export const H6 = {
|
|
24
|
+
render: (args: TypographyProps) => (
|
|
25
|
+
<Typography {...args}>{args.children}</Typography>
|
|
26
|
+
),
|
|
27
|
+
args: {
|
|
28
|
+
variant: "h6",
|
|
29
|
+
children: "Heading 6",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Subtitle1 = {
|
|
34
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
35
|
+
args: {
|
|
36
|
+
variant: "subtitle1",
|
|
37
|
+
children: "Subtitle 1",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Subtitle2 = {
|
|
42
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
43
|
+
args: {
|
|
44
|
+
variant: "subtitle2",
|
|
45
|
+
children: "Subtitle 2",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Subtitle3 = {
|
|
50
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
51
|
+
args: {
|
|
52
|
+
variant: "subtitle3",
|
|
53
|
+
children: "Subtitle 3",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Body1 = {
|
|
58
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
59
|
+
args: {
|
|
60
|
+
variant: "body1",
|
|
61
|
+
children: "Body 1",
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const Body2 = {
|
|
66
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
67
|
+
args: {
|
|
68
|
+
variant: "body2",
|
|
69
|
+
children: "Body 2",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Caption = {
|
|
74
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
75
|
+
args: {
|
|
76
|
+
variant: "caption",
|
|
77
|
+
children: "Caption",
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Label1 = {
|
|
82
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
83
|
+
args: {
|
|
84
|
+
variant: "label1",
|
|
85
|
+
children: "Label 1",
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Label2 = {
|
|
90
|
+
render: (args: TypographyProps) => <Typography {...args} />,
|
|
91
|
+
args: {
|
|
92
|
+
variant: "label2",
|
|
93
|
+
children: "Label 2",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Typography as MuiTypography,
|
|
3
|
+
TypographyProps as MuiTypographyProps,
|
|
4
|
+
} from "@mui/material";
|
|
5
|
+
|
|
6
|
+
export type TypographyProps = {} & MuiTypographyProps;
|
|
7
|
+
|
|
8
|
+
const Typography = ({ variant, children }: TypographyProps) => {
|
|
9
|
+
return <MuiTypography variant={variant}>{children}</MuiTypography>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default Typography;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ActionButton } from "./Input/Button/Button";
|
package/src/index.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
code {
|
|
11
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
+
monospace;
|
|
13
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import App from './App';
|
|
5
|
+
import reportWebVitals from './reportWebVitals';
|
|
6
|
+
|
|
7
|
+
const root = ReactDOM.createRoot(
|
|
8
|
+
document.getElementById('root') as HTMLElement
|
|
9
|
+
);
|
|
10
|
+
root.render(
|
|
11
|
+
<React.StrictMode>
|
|
12
|
+
<App />
|
|
13
|
+
</React.StrictMode>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// If you want to start measuring performance in your app, pass a function
|
|
17
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
18
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
19
|
+
reportWebVitals();
|
package/src/logo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReportHandler } from 'web-vitals';
|
|
2
|
+
|
|
3
|
+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
+
getCLS(onPerfEntry);
|
|
7
|
+
getFID(onPerfEntry);
|
|
8
|
+
getFCP(onPerfEntry);
|
|
9
|
+
getLCP(onPerfEntry);
|
|
10
|
+
getTTFB(onPerfEntry);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default reportWebVitals;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Example/Button',
|
|
8
|
+
component: Button,
|
|
9
|
+
parameters: {
|
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
16
|
+
argTypes: {
|
|
17
|
+
backgroundColor: { control: 'color' },
|
|
18
|
+
},
|
|
19
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
20
|
+
args: { onClick: fn() },
|
|
21
|
+
} satisfies Meta<typeof Button>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
27
|
+
export const Primary: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
primary: true,
|
|
30
|
+
label: 'Button',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Secondary: Story = {
|
|
35
|
+
args: {
|
|
36
|
+
label: 'Button',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Large: Story = {
|
|
41
|
+
args: {
|
|
42
|
+
size: 'large',
|
|
43
|
+
label: 'Button',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Small: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
size: 'small',
|
|
50
|
+
label: 'Button',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './button.css';
|
|
3
|
+
|
|
4
|
+
interface ButtonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Is this the principal call to action on the page?
|
|
7
|
+
*/
|
|
8
|
+
primary?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* What background color to use
|
|
11
|
+
*/
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
/**
|
|
14
|
+
* How large should the button be?
|
|
15
|
+
*/
|
|
16
|
+
size?: 'small' | 'medium' | 'large';
|
|
17
|
+
/**
|
|
18
|
+
* Button contents
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional click handler
|
|
23
|
+
*/
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Primary UI component for user interaction
|
|
29
|
+
*/
|
|
30
|
+
export const Button = ({
|
|
31
|
+
primary = false,
|
|
32
|
+
size = 'medium',
|
|
33
|
+
backgroundColor,
|
|
34
|
+
label,
|
|
35
|
+
...props
|
|
36
|
+
}: ButtonProps) => {
|
|
37
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
38
|
+
return (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
42
|
+
style={{ backgroundColor }}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
);
|
|
48
|
+
};
|