Skip to content

Commit aa6fe5b

Browse files
authored
Merge pull request #156 from Dias999/feature/Storybook-Text
feat: add Text storybook and tsDocs
2 parents b83400c + da5951c commit aa6fe5b

File tree

2 files changed

+116
-3
lines changed

2 files changed

+116
-3
lines changed

packages/react-material-ui/src/components/Text/Text.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import React from 'react';
22
import Typography, { TypographyProps } from '@mui/material/Typography';
33

4-
const Text = (props: TypographyProps) => {
5-
const { children, fontWeight = '300' } = props;
4+
/**
5+
* The Text component is a wrapper around the Material-UI Typography component
6+
* with a default fontWeight of 300. It's props extend from [Material UI's Typography](https://mui.com/material-ui/api/Typography/#props)
7+
* component props, so every prop is interchangeable between those two.
8+
*
9+
* @see {@link [MUI Typography Component](https://mui.com/material-ui/react-typography/)}
10+
* @see [Storybook - Text](https://storybook.rockets.tools/?path=/docs/text)
11+
*
12+
* @example
13+
* ```tsx
14+
* <Text variant="h6" fontWeight="400" fontSize='18px'>
15+
* Sample Text
16+
* </Text>
17+
* ```
18+
*
19+
* @param typographyProps - MUI {@link [TypographyProps](https://mui.com/material-ui/api/Typography/#props)}
20+
*/
21+
const Text = (typographyProps: TypographyProps) => {
22+
const { children, fontWeight = '300' } = typographyProps;
623

724
return (
8-
<Typography fontWeight={fontWeight} {...props}>
25+
<Typography fontWeight={fontWeight} {...typographyProps}>
926
{children}
1027
</Typography>
1128
);

stories/Text.stories.tsx

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { Text } from '@concepta/react-material-ui';
4+
5+
const meta = {
6+
component: Text,
7+
tags: ['autodocs'],
8+
args: {},
9+
argTypes: {
10+
variant: {
11+
control: 'select',
12+
options: [
13+
'body1',
14+
'body2',
15+
'caption',
16+
'button',
17+
'overline',
18+
'subtitle1',
19+
'subtitle2',
20+
'h1',
21+
'h2',
22+
'h3',
23+
'h4',
24+
'h5',
25+
'h6',
26+
],
27+
},
28+
fontWeight: {
29+
control: 'select',
30+
options: ['100', '200', '300', '400', '500', '600', '700', '800', '900'],
31+
},
32+
align: {
33+
control: 'select',
34+
options: ['inherit', 'left', 'center', 'right', 'justify'],
35+
},
36+
sx: {
37+
control: 'object',
38+
},
39+
},
40+
} satisfies Meta<typeof Text>;
41+
42+
export default meta;
43+
44+
type Story = StoryObj<typeof meta>;
45+
46+
export const Default: Story = {
47+
args: {
48+
children: 'Default Text',
49+
fontWeight: '300',
50+
align: 'left',
51+
sx: {},
52+
variant: 'body1',
53+
},
54+
};
55+
56+
export const CustomFontWeight: Story = {
57+
args: {
58+
children: 'Custom Font Weight',
59+
fontWeight: '700',
60+
},
61+
};
62+
63+
export const CustomFontSize: Story = {
64+
args: {
65+
children: 'Custom Font Size',
66+
fontSize: '2rem',
67+
},
68+
};
69+
70+
export const CustomColor: Story = {
71+
args: {
72+
children: 'Custom Color',
73+
color: 'red',
74+
},
75+
};
76+
77+
export const DifferentVariants: Story = {
78+
args: {
79+
children: 'Heading 1 Text',
80+
variant: 'h1',
81+
},
82+
};
83+
84+
export const TextAlignment: Story = {
85+
args: {
86+
children: 'Center Aligned Text',
87+
align: 'center',
88+
},
89+
};
90+
91+
export const TextWithCustomStyles: Story = {
92+
args: {
93+
children: 'Text with Custom Styles',
94+
sx: { color: 'purple', textTransform: 'uppercase', letterSpacing: '2px' },
95+
},
96+
};

0 commit comments

Comments
 (0)