@beydesign/storybook 0.0.47 → 0.0.48
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/dist/stories/Form/TextArea.js +2 -2
- package/dist/stories/Form/TextArea.stories.d.ts +9 -0
- package/dist/stories/Form/TextArea.stories.js +7 -0
- package/dist/stories/Form/TextInput.js +2 -2
- package/dist/stories/Form/TextInput.stories.d.ts +9 -0
- package/dist/stories/Form/TextInput.stories.js +7 -0
- package/dist/stories/Form/types.d.ts +4 -0
- package/dist/stories/Typography/Typography.js +25 -17
- package/dist/stories/Typography/Typography.stories.js +10 -0
- package/dist/stories/Typography/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ import { useState } from 'react';
|
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
5
5
|
import { HintBubble, HintBubbleSize } from '../UI';
|
|
6
|
-
export const TextArea = ({ label, value, onChange, placeholder, hintText, errorText, disabled, maxLength = 256, showMaxLengthIndicator = false, numberOfRows = 5, style, hintBubbleProps, hintBubbleText, required, }) => {
|
|
6
|
+
export const TextArea = ({ label, value, onChange, placeholder, hintText, errorText, disabled, maxLength = 256, showMaxLengthIndicator = false, numberOfRows = 5, style, hintBubbleProps, hintBubbleText, required, labelTrailingElement, }) => {
|
|
7
7
|
const [focused, setFocused] = useState(false);
|
|
8
|
-
return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: `1px solid ${errorText
|
|
8
|
+
return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required, trailingElement: labelTrailingElement })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: `1px solid ${errorText
|
|
9
9
|
? 'var(--colors-light-border-border-error)'
|
|
10
10
|
: focused
|
|
11
11
|
? 'var(--colors-light-border-border-component-active)'
|
|
@@ -104,6 +104,13 @@ const meta = {
|
|
|
104
104
|
type: { summary: 'object' },
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
|
+
labelTrailingElement: {
|
|
108
|
+
control: 'object',
|
|
109
|
+
description: 'The trailing element of the label',
|
|
110
|
+
table: {
|
|
111
|
+
type: { summary: 'ReactNode' },
|
|
112
|
+
},
|
|
113
|
+
},
|
|
107
114
|
},
|
|
108
115
|
};
|
|
109
116
|
export default meta;
|
|
@@ -3,9 +3,9 @@ import { useState } from 'react';
|
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
5
5
|
import { HintBubble, HintBubbleSize } from '../UI';
|
|
6
|
-
export const TextInput = ({ label, value, onChange, placeholder, hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, }) => {
|
|
6
|
+
export const TextInput = ({ label, value, onChange, placeholder, hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, }) => {
|
|
7
7
|
const [focused, setFocused] = useState(false);
|
|
8
|
-
return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: errorText
|
|
8
|
+
return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required, trailingElement: labelTrailingElement })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: errorText
|
|
9
9
|
? 'none'
|
|
10
10
|
: '1px solid var(--colors-light-border-border-component)', overflow: 'hidden', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [_jsx(Box, { display: 'flex', flexDirection: 'row', padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', width: '100%', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs) 0 0 var(--spacing-tokens-size-in-px-spacing-spacing-xs)', border: `${errorText
|
|
11
11
|
? '1px solid var(--colors-light-border-border-error)'
|
|
@@ -90,6 +90,13 @@ const meta = {
|
|
|
90
90
|
type: { summary: 'object' },
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
|
+
labelTrailingElement: {
|
|
94
|
+
control: 'object',
|
|
95
|
+
description: 'The trailing element of the label',
|
|
96
|
+
table: {
|
|
97
|
+
type: { summary: 'ReactNode' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
93
100
|
},
|
|
94
101
|
};
|
|
95
102
|
export default meta;
|
|
@@ -32,6 +32,8 @@ export type TextAreaProps = {
|
|
|
32
32
|
style?: SxProps<Theme>;
|
|
33
33
|
/** Whether the text area is required */
|
|
34
34
|
required?: boolean;
|
|
35
|
+
/** Text area label trailing element */
|
|
36
|
+
labelTrailingElement?: React.ReactNode;
|
|
35
37
|
};
|
|
36
38
|
/**
|
|
37
39
|
* Text input component props
|
|
@@ -61,6 +63,8 @@ export type TextInputProps = {
|
|
|
61
63
|
style?: SxProps<Theme>;
|
|
62
64
|
/** Whether the text input is required */
|
|
63
65
|
required?: boolean;
|
|
66
|
+
/** Text input label trailing element */
|
|
67
|
+
labelTrailingElement?: React.ReactNode;
|
|
64
68
|
};
|
|
65
69
|
/**
|
|
66
70
|
* Toggle position variants
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TypographySize, TypographyWeight } from './types';
|
|
3
|
-
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
export const Typography = ({ text, color, size = TypographySize.HeadingL, weight = TypographyWeight.Bold, className, required = false, style, trailingElement = null, }) => {
|
|
4
5
|
const getTypographySizeToken = () => {
|
|
5
6
|
let sizeLc = size?.toLowerCase() || '';
|
|
6
7
|
if (sizeLc.includes('heading')) {
|
|
@@ -29,26 +30,33 @@ export const Typography = ({ text, color, size = TypographySize.HeadingL, weight
|
|
|
29
30
|
const paragraphIndent = `var(--global-${sizeToken}-${weightToken}-paragraph-indent)`;
|
|
30
31
|
const paragraphSpacing = `var(--global-${sizeToken}-${weightToken}-paragraph-spacing)`;
|
|
31
32
|
const textDecoration = `var(--global-${sizeToken}-${weightToken}-text-decoration)`;
|
|
33
|
+
const requiredColor = 'var(--colors-light-text-text-error)';
|
|
32
34
|
const getTextTransform = () => {
|
|
33
35
|
const computedValue = getComputedStyle(document.documentElement)
|
|
34
36
|
.getPropertyValue(`--global-${sizeToken}-${weightToken}-text-case`)
|
|
35
37
|
.trim();
|
|
36
38
|
return (computedValue === 'uppercase' ? 'uppercase' : 'none');
|
|
37
39
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
const Label = () => {
|
|
41
|
+
return (_jsxs("span", { className: className, style: {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
45
|
+
fontSize: fontSize,
|
|
46
|
+
fontWeight: fontWeight,
|
|
47
|
+
fontFamily: fontFamily + ', sans-serif',
|
|
48
|
+
lineHeight: lineHeight + 'px',
|
|
49
|
+
letterSpacing: letterSpacing,
|
|
50
|
+
textIndent: paragraphIndent,
|
|
51
|
+
marginBottom: paragraphSpacing,
|
|
52
|
+
textTransform: getTextTransform(),
|
|
53
|
+
textDecoration: textDecoration,
|
|
54
|
+
color: color || 'var(--global-text-text-title)',
|
|
55
|
+
...style,
|
|
56
|
+
}, children: [text, required && _jsx("span", { style: { color: requiredColor }, children: "*" })] }));
|
|
57
|
+
};
|
|
58
|
+
if (!trailingElement) {
|
|
59
|
+
return _jsx(Label, {});
|
|
60
|
+
}
|
|
61
|
+
return (_jsxs(Box, { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "flex-start", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)", children: [_jsx(Label, {}), trailingElement] }));
|
|
54
62
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { Typography } from './Typography';
|
|
2
3
|
import { TypographySize, TypographyWeight } from './types';
|
|
4
|
+
import { Info } from '@phosphor-icons/react';
|
|
3
5
|
const meta = {
|
|
4
6
|
title: 'Design System/Components/Typography/Typography',
|
|
5
7
|
component: Typography,
|
|
@@ -65,6 +67,12 @@ const meta = {
|
|
|
65
67
|
type: { summary: 'string' },
|
|
66
68
|
},
|
|
67
69
|
},
|
|
70
|
+
trailingElement: {
|
|
71
|
+
description: 'Trailing element of the typography',
|
|
72
|
+
table: {
|
|
73
|
+
type: { summary: 'ReactNode' },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
68
76
|
},
|
|
69
77
|
};
|
|
70
78
|
export default meta;
|
|
@@ -73,6 +81,8 @@ export const HeadingXLBold = {
|
|
|
73
81
|
text: 'Typography',
|
|
74
82
|
size: TypographySize.HeadingXL,
|
|
75
83
|
weight: TypographyWeight.Bold,
|
|
84
|
+
trailingElement: _jsx(Info, { size: 24 }),
|
|
85
|
+
required: true,
|
|
76
86
|
},
|
|
77
87
|
};
|
|
78
88
|
export const HeadingXLSemiBold = {
|