norma-library 0.4.2 → 0.4.3
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/components/button/button.d.ts +3 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/types.d.ts +18 -0
- package/dist/components/card/card-header.d.ts +3 -0
- package/dist/components/card/card.d.ts +3 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/styles.d.ts +811 -0
- package/dist/components/card/types.d.ts +12 -0
- package/dist/components/checkbox/checkbox.d.ts +3 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/types.d.ts +23 -0
- package/dist/components/icon/default.d.ts +210 -0
- package/dist/components/icon/defaultIcon.d.ts +5 -0
- package/dist/components/icon/icons-ia.d.ts +71 -0
- package/dist/components/icon/index.d.ts +234 -0
- package/dist/components/icon/norma.d.ts +30 -0
- package/dist/components/icon/normaIcon.d.ts +13 -0
- package/dist/components/icon/styles.d.ts +481 -0
- package/dist/components/icon/svg.d.ts +6 -0
- package/dist/components/icon/types.d.ts +12 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/modal/modal.d.ts +3 -0
- package/dist/components/modal/modalFooter.d.ts +3 -0
- package/dist/components/modal/modalHeader.d.ts +3 -0
- package/dist/components/modal/styles.d.ts +540 -0
- package/dist/components/modal/types.d.ts +27 -0
- package/dist/components/progress-bar/index.d.ts +1 -0
- package/dist/components/progress-bar/progress-bar.d.ts +7 -0
- package/dist/components/progress-bar/styles.d.ts +272 -0
- package/dist/components/progress-bar/types.d.ts +22 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/radio.d.ts +3 -0
- package/dist/components/radio/types.d.ts +16 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/tag.d.ts +3 -0
- package/dist/components/tag/types.d.ts +25 -0
- package/dist/components/textfield/index.d.ts +1 -0
- package/dist/components/textfield/textfield.d.ts +3 -0
- package/dist/components/textfield/types.d.ts +42 -0
- package/dist/helpers/clients.d.ts +5 -0
- package/dist/helpers/colors.d.ts +174 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/sizes.d.ts +6 -0
- package/dist/helpers/variants.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/norma-library.cjs.development.js +1286 -0
- package/dist/norma-library.cjs.development.js.map +1 -0
- package/dist/norma-library.cjs.production.min.js +2 -0
- package/dist/norma-library.cjs.production.min.js.map +1 -0
- package/dist/norma-library.esm.js +1274 -0
- package/dist/norma-library.esm.js.map +1 -0
- package/package.json +1 -1
- package/src/components/button/button.stories.tsx +44 -0
- package/src/components/button/button.tsx +18 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button/types.ts +48 -0
- package/src/components/card/card-header.tsx +8 -0
- package/src/components/card/card.stories.tsx +28 -0
- package/src/components/card/card.tsx +13 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/card/styles.tsx +29 -0
- package/src/components/card/types.ts +14 -0
- package/src/components/checkbox/checkbox.stories.tsx +66 -0
- package/src/components/checkbox/checkbox.tsx +13 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/types.ts +30 -0
- package/src/components/icon/default.tsx +1459 -0
- package/src/components/icon/defaultIcon.tsx +82 -0
- package/src/components/icon/icon.stories.tsx +44 -0
- package/src/components/icon/icons-ia.tsx +107 -0
- package/src/components/icon/index.ts +11 -0
- package/src/components/icon/norma.tsx +523 -0
- package/src/components/icon/normaIcon.tsx +94 -0
- package/src/components/icon/styles.ts +11 -0
- package/src/components/icon/svg.tsx +24 -0
- package/src/components/icon/types.ts +14 -0
- package/src/components/index.ts +8 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/modal/modal.stories.tsx +55 -0
- package/src/components/modal/modal.tsx +42 -0
- package/src/components/modal/modalFooter.tsx +32 -0
- package/src/components/modal/modalHeader.tsx +46 -0
- package/src/components/modal/styles.tsx +13 -0
- package/src/components/modal/types.ts +47 -0
- package/src/components/progress-bar/index.ts +1 -0
- package/src/components/progress-bar/progress-bar.stories.tsx +68 -0
- package/src/components/progress-bar/progress-bar.tsx +38 -0
- package/src/components/progress-bar/styles.tsx +27 -0
- package/src/components/progress-bar/types.ts +35 -0
- package/src/components/radio/index.ts +1 -0
- package/src/components/radio/radio.stories.tsx +150 -0
- package/src/components/radio/radio.tsx +13 -0
- package/src/components/radio/types.ts +27 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/tag.stories.tsx +80 -0
- package/src/components/tag/tag.tsx +13 -0
- package/src/components/tag/types.ts +47 -0
- package/src/components/textfield/index.ts +1 -0
- package/src/components/textfield/textfield.stories.tsx +376 -0
- package/src/components/textfield/textfield.tsx +23 -0
- package/src/components/textfield/types.ts +93 -0
- package/src/helpers/clients.ts +6 -0
- package/src/helpers/colors.ts +209 -0
- package/src/helpers/index.ts +3 -0
- package/src/helpers/sizes.ts +26 -0
- package/src/helpers/variants.ts +3 -0
- package/src/index.tsx +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { StoryDefault, Story } from '@ladle/react'
|
|
3
|
+
import { Modal } from './modal'
|
|
4
|
+
import { Button } from '../button'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
import { StyledModalBody } from './styles'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Layout / Modal',
|
|
10
|
+
meta: {
|
|
11
|
+
key: 'modal',
|
|
12
|
+
},
|
|
13
|
+
} satisfies StoryDefault
|
|
14
|
+
|
|
15
|
+
export const ModalSimple: Story = () => {
|
|
16
|
+
const [open, setOpen] = useState(false)
|
|
17
|
+
const handleOpen = () => setOpen(true)
|
|
18
|
+
const handleClose = () => setOpen(false)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
22
|
+
<Button variant="text" label="Open modal" onClick={handleOpen} />
|
|
23
|
+
<Modal
|
|
24
|
+
open={open}
|
|
25
|
+
onClose={handleClose}
|
|
26
|
+
aria-labelledby="modal-modal-title"
|
|
27
|
+
aria-describedby="modal-modal-description"
|
|
28
|
+
>
|
|
29
|
+
<div
|
|
30
|
+
style={{
|
|
31
|
+
background: '#FFFFFF 0% 0% no-repeat padding-box',
|
|
32
|
+
border: '1px solid #00000033',
|
|
33
|
+
opacity: 1,
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
top: '50%',
|
|
36
|
+
left: '50%',
|
|
37
|
+
transform: 'translate(-50%, -50%)',
|
|
38
|
+
width: 400,
|
|
39
|
+
height: 298,
|
|
40
|
+
borderRadius: 4,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<StyledModalBody>
|
|
44
|
+
<h2>Text in a modal</h2>
|
|
45
|
+
<p id="modal-modal-description" style={{ marginTop: 2 }}>
|
|
46
|
+
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
|
|
47
|
+
</p>
|
|
48
|
+
</StyledModalBody>
|
|
49
|
+
</div>
|
|
50
|
+
</Modal>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ModalSimple.storyName = 'Modal Simple'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModalBaseProps } from './types';
|
|
3
|
+
import { Modal as MuiModal } from '@mui/material';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
5
|
+
import { ModalHeader } from './modalHeader';
|
|
6
|
+
import { ModalFooter } from './modalFooter';
|
|
7
|
+
import { StyledModalBody } from './styles';
|
|
8
|
+
|
|
9
|
+
const style = {
|
|
10
|
+
background: '#FFFFFF 0% 0% no-repeat padding-box',
|
|
11
|
+
border: '1px solid #00000033',
|
|
12
|
+
opacity: 1,
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
top: '50%',
|
|
15
|
+
left: '50%',
|
|
16
|
+
transform: 'translate(-50%, -50%)',
|
|
17
|
+
width: 400,
|
|
18
|
+
bgcolor: 'background.paper',
|
|
19
|
+
borderRadius: 1,
|
|
20
|
+
boxShadow: 48,
|
|
21
|
+
p: 0,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Modal: React.FC<ModalBaseProps> = ({
|
|
25
|
+
title,
|
|
26
|
+
open = false,
|
|
27
|
+
onConfirm,
|
|
28
|
+
children,
|
|
29
|
+
onClose,
|
|
30
|
+
onCancel,
|
|
31
|
+
...props
|
|
32
|
+
}) => {
|
|
33
|
+
return (
|
|
34
|
+
<MuiModal {...props} open={open}>
|
|
35
|
+
<Box sx={style}>
|
|
36
|
+
<ModalHeader onClose={onClose} title={title} />
|
|
37
|
+
<StyledModalBody>{children}</StyledModalBody>
|
|
38
|
+
{onConfirm && <ModalFooter onCancel={onCancel} onConfirm={onConfirm} />}
|
|
39
|
+
</Box>
|
|
40
|
+
</MuiModal>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Button } from '../button/button';
|
|
4
|
+
import { ModalFooterProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const ModalFooter: React.FC<ModalFooterProps> = ({
|
|
7
|
+
onCancel,
|
|
8
|
+
onConfirm,
|
|
9
|
+
}) => {
|
|
10
|
+
const StyledModalFooter = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: flex-end;
|
|
13
|
+
padding: 16px;
|
|
14
|
+
align-items: center;
|
|
15
|
+
height: 50px;
|
|
16
|
+
padding-top: 10px;
|
|
17
|
+
margin-top: 10px;
|
|
18
|
+
border-top: 1px solid #e9ecef;
|
|
19
|
+
`;
|
|
20
|
+
return (
|
|
21
|
+
<StyledModalFooter>
|
|
22
|
+
<Button
|
|
23
|
+
onClick={onCancel}
|
|
24
|
+
label="Cancel"
|
|
25
|
+
variant="outlined"
|
|
26
|
+
color="primary"
|
|
27
|
+
style={{ marginRight: '10px' }}
|
|
28
|
+
/>
|
|
29
|
+
<Button onClick={onConfirm} label="Confirm" color="primary" />
|
|
30
|
+
</StyledModalFooter>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { ModalHeaderProps } from './types';
|
|
4
|
+
import { IconButton } from '@mui/material';
|
|
5
|
+
import { Icons } from '../icon/defaultIcon';
|
|
6
|
+
import { StyledBoxIcon } from './styles';
|
|
7
|
+
|
|
8
|
+
export const ModalHeader: React.FC<ModalHeaderProps> = ({ title }) => {
|
|
9
|
+
const StyledModalHeader = styled.div`
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
align-items: center;
|
|
13
|
+
text-align: left;
|
|
14
|
+
font: normal normal 600 16px/24px Source Sans Pro;
|
|
15
|
+
letter-spacing: 0px;
|
|
16
|
+
color: #292929;
|
|
17
|
+
opacity: 1;
|
|
18
|
+
height: 25px;
|
|
19
|
+
padding-bottom: 10px;
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
border-bottom: ${title ? '1px solid #e9ecef' : '0'};
|
|
22
|
+
padding: 10px;
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
return (
|
|
26
|
+
<StyledModalHeader>
|
|
27
|
+
{title && <h3>{title}</h3>}
|
|
28
|
+
<IconButton
|
|
29
|
+
aria-label="close"
|
|
30
|
+
sx={{
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
right: 8,
|
|
33
|
+
top: 10,
|
|
34
|
+
padding: 2,
|
|
35
|
+
width: 16,
|
|
36
|
+
height: 16,
|
|
37
|
+
color: theme => theme.palette.grey[500],
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<StyledBoxIcon>
|
|
41
|
+
<Icons icon={'closeAlt'} scale={'small'} />
|
|
42
|
+
</StyledBoxIcon>
|
|
43
|
+
</IconButton>
|
|
44
|
+
</StyledModalHeader>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Modal, ModalProps as MuiModalProps, SxProps } from '@mui/material';
|
|
2
|
+
import { Theme } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
type RenderProps<E extends HTMLElement = HTMLElement> = {
|
|
5
|
+
focusRef?: React.MutableRefObject<E | null>;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type MuiModalBaseProps = Pick<MuiModalProps, 'sx' | 'children' | 'onClose'>;
|
|
10
|
+
|
|
11
|
+
export interface ModalBaseProps extends MuiModalBaseProps {
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
13
|
+
title?: string;
|
|
14
|
+
open: boolean;
|
|
15
|
+
children: React.ReactElement;
|
|
16
|
+
onConfirm?: (
|
|
17
|
+
event?: React.MouseEvent | React.KeyboardEvent | React.TouchEvent,
|
|
18
|
+
contextId?: string
|
|
19
|
+
) => void;
|
|
20
|
+
onClose?: {
|
|
21
|
+
bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown'): void;
|
|
22
|
+
}['bivarianceHack'];
|
|
23
|
+
onCancel?: (
|
|
24
|
+
event?: React.MouseEvent | React.KeyboardEvent | React.TouchEvent,
|
|
25
|
+
contextId?: string
|
|
26
|
+
) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ModalHeaderProps {
|
|
30
|
+
title?: string;
|
|
31
|
+
onClose?: {
|
|
32
|
+
bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown'): void;
|
|
33
|
+
}['bivarianceHack'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ModalFooterProps {
|
|
37
|
+
onCancel?: (
|
|
38
|
+
event?: React.MouseEvent | React.KeyboardEvent | React.TouchEvent,
|
|
39
|
+
contextId?: string
|
|
40
|
+
) => void;
|
|
41
|
+
onConfirm: (
|
|
42
|
+
event?: React.MouseEvent | React.KeyboardEvent | React.TouchEvent,
|
|
43
|
+
contextId?: string
|
|
44
|
+
) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ModalType = keyof typeof Modal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progress-bar';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { StoryDefault, Story } from '@ladle/react'
|
|
3
|
+
import { ProgressBar } from './progress-bar'
|
|
4
|
+
import { Fragment } from 'react'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Data / ProgressBar',
|
|
8
|
+
meta: {
|
|
9
|
+
key: 'button',
|
|
10
|
+
},
|
|
11
|
+
} satisfies StoryDefault
|
|
12
|
+
|
|
13
|
+
export const ProgressBarVariant: Story = () => (
|
|
14
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
15
|
+
<div style={{ position: 'relative', width: '100%' }}>
|
|
16
|
+
<ProgressBar value={10} usage={23} total={100} />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
ProgressBarVariant.storyName = 'Progressbar Simple'
|
|
22
|
+
|
|
23
|
+
export const ProgressBarTitle: Story = () => (
|
|
24
|
+
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
25
|
+
<div style={{ position: 'relative', width: '100%' }}>
|
|
26
|
+
<ProgressBar value={10} label="Progress" usage={23} total={100} />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
ProgressBarTitle.storyName = 'Progressbar Title'
|
|
32
|
+
|
|
33
|
+
export const ProgressBarColors: Story = () => (
|
|
34
|
+
<Fragment>
|
|
35
|
+
<div style={{ display: 'flex', gap: '1rem', marginBottom: 15 }}>
|
|
36
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
37
|
+
<ProgressBar value={60} usage={23} total={100} color="inherit" label="Progress Inherit" />
|
|
38
|
+
</div>
|
|
39
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
40
|
+
<ProgressBar
|
|
41
|
+
value={60}
|
|
42
|
+
usage={23}
|
|
43
|
+
total={100}
|
|
44
|
+
color="secondary"
|
|
45
|
+
label="Progress secondary"
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div style={{ display: 'flex', gap: '1rem', marginBottom: 15 }}>
|
|
50
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
51
|
+
<ProgressBar value={60} usage={23} total={100} color="error" label="Progress error" />
|
|
52
|
+
</div>
|
|
53
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
54
|
+
<ProgressBar value={60} usage={23} total={100} color="info" label="Progress info" />
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div style={{ display: 'flex', gap: '1rem', marginBottom: 15 }}>
|
|
58
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
59
|
+
<ProgressBar value={60} usage={23} total={100} color="success" label="Progress success" />
|
|
60
|
+
</div>
|
|
61
|
+
<div style={{ position: 'relative', flex: 1, width: '100%' }}>
|
|
62
|
+
<ProgressBar value={60} usage={23} total={100} color="warning" label="Progress warning" />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</Fragment>
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
ProgressBarColors.storyName = 'Progressbar Colors'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ThemeProvider } from '@emotion/react';
|
|
2
|
+
import { themes } from '../../helpers/colors';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ProgressBarBaseProps } from './types';
|
|
5
|
+
import { StyledProgressBarLabel, StyledProgressBar } from './styles';
|
|
6
|
+
|
|
7
|
+
export const ProgressBar: React.FC<ProgressBarBaseProps & {
|
|
8
|
+
usage?: number;
|
|
9
|
+
total?: number;
|
|
10
|
+
colorCustom?: string;
|
|
11
|
+
}> = ({
|
|
12
|
+
value = 0,
|
|
13
|
+
label,
|
|
14
|
+
variant = 'determinate',
|
|
15
|
+
usage,
|
|
16
|
+
total,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const percentage = usage && total ? (usage / total) * 100 : 0;
|
|
20
|
+
return (
|
|
21
|
+
<ThemeProvider theme={themes.light}>
|
|
22
|
+
{label && (
|
|
23
|
+
<StyledProgressBarLabel>
|
|
24
|
+
{label}
|
|
25
|
+
<span style={{ right: 0 }}>
|
|
26
|
+
{total} ({percentage.toFixed(2)}%)
|
|
27
|
+
</span>
|
|
28
|
+
</StyledProgressBarLabel>
|
|
29
|
+
)}
|
|
30
|
+
<StyledProgressBar
|
|
31
|
+
value={value}
|
|
32
|
+
variant={variant}
|
|
33
|
+
sx={{ height: 10 }}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LinearProgress as MuiProgressBar,
|
|
3
|
+
linearProgressClasses,
|
|
4
|
+
} from '@mui/material';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { StyledProgressBarProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const StyledProgressBar = styled(MuiProgressBar)<StyledProgressBarProps>`
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 5px;
|
|
11
|
+
border-radius: 10px;
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
&.${linearProgressClasses.determinate} {
|
|
15
|
+
background-color: #e0e0e0;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const StyledProgressBarLabel = styled.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
align-items: center;
|
|
23
|
+
margin-bottom: 8px;
|
|
24
|
+
position: relative;
|
|
25
|
+
text-align: left;
|
|
26
|
+
font: normal normal normal 16px/20px Source Sans Pro;
|
|
27
|
+
`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SxProps, LinearProgressProps } from '@mui/material';
|
|
2
|
+
import { Theme } from '@emotion/react';
|
|
3
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
4
|
+
import { ProgressBar } from './progress-bar';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
7
|
+
export interface LinearProgressPropsColorOverrides {}
|
|
8
|
+
|
|
9
|
+
type MuiProgressBarBaseProps = Pick<LinearProgressProps, 'sx'>;
|
|
10
|
+
|
|
11
|
+
export interface ProgressBarBaseProps extends MuiProgressBarBaseProps {
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
13
|
+
usage?: number;
|
|
14
|
+
value?: number;
|
|
15
|
+
total?: number;
|
|
16
|
+
label?: string;
|
|
17
|
+
colorCustom?: string;
|
|
18
|
+
variant?: 'determinate' | 'indeterminate' | 'buffer' | 'query';
|
|
19
|
+
color?: OverridableStringUnion<
|
|
20
|
+
| 'primary'
|
|
21
|
+
| 'secondary'
|
|
22
|
+
| 'error'
|
|
23
|
+
| 'info'
|
|
24
|
+
| 'success'
|
|
25
|
+
| 'warning'
|
|
26
|
+
| 'inherit',
|
|
27
|
+
LinearProgressPropsColorOverrides
|
|
28
|
+
>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type StyledProgressBarProps = {
|
|
32
|
+
colorCustom?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ProgressBarType = keyof typeof ProgressBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './radio';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StoryDefault, Story } from '@ladle/react'
|
|
3
|
+
import { Radiobox } from './radio'
|
|
4
|
+
import { FormControl, FormControlLabel, FormLabel, RadioGroup } from '@mui/material'
|
|
5
|
+
import { pink } from '@mui/material/colors'
|
|
6
|
+
import { ChangeEvent, useState } from 'react'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Form / Radiobox',
|
|
10
|
+
meta: {
|
|
11
|
+
key: 'radiobox',
|
|
12
|
+
},
|
|
13
|
+
} satisfies StoryDefault
|
|
14
|
+
|
|
15
|
+
export const RadioboxBasic: Story = () => {
|
|
16
|
+
const [selectedValue, setSelectedValue] = useState('b')
|
|
17
|
+
|
|
18
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
19
|
+
setSelectedValue(event.target.value)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 16 }}>
|
|
24
|
+
<Radiobox
|
|
25
|
+
checked={selectedValue === 'a'}
|
|
26
|
+
onChange={handleChange}
|
|
27
|
+
value="a"
|
|
28
|
+
name="radio-buttons"
|
|
29
|
+
inputProps={{ 'aria-label': 'A' }}
|
|
30
|
+
/>
|
|
31
|
+
<Radiobox
|
|
32
|
+
checked={selectedValue === 'b'}
|
|
33
|
+
onChange={handleChange}
|
|
34
|
+
value="b"
|
|
35
|
+
name="radio-buttons"
|
|
36
|
+
inputProps={{ 'aria-label': 'B' }}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
RadioboxBasic.storyName = 'Radiobox Basic'
|
|
43
|
+
|
|
44
|
+
export const RadioboxGroup: Story = () => (
|
|
45
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 16 }}>
|
|
46
|
+
<FormControl>
|
|
47
|
+
<FormLabel id="demo-radio-buttons-group-label">Gender</FormLabel>
|
|
48
|
+
<RadioGroup
|
|
49
|
+
aria-labelledby="demo-radio-buttons-group-label"
|
|
50
|
+
defaultValue="female"
|
|
51
|
+
name="radio-buttons-group"
|
|
52
|
+
>
|
|
53
|
+
<FormControlLabel value="female" control={<Radiobox />} label="Female" />
|
|
54
|
+
<FormControlLabel value="male" control={<Radiobox />} label="Male" />
|
|
55
|
+
<FormControlLabel value="other" control={<Radiobox />} label="Other" />
|
|
56
|
+
</RadioGroup>
|
|
57
|
+
</FormControl>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
RadioboxGroup.storyName = 'Radiobox Group'
|
|
61
|
+
|
|
62
|
+
export const RadioboxDirection: Story = () => (
|
|
63
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 16 }}>
|
|
64
|
+
<FormControl>
|
|
65
|
+
<FormLabel id="demo-row-radio-buttons-group-label">Gender</FormLabel>
|
|
66
|
+
<RadioGroup
|
|
67
|
+
row
|
|
68
|
+
aria-labelledby="demo-row-radio-buttons-group-label"
|
|
69
|
+
name="row-radio-buttons-group"
|
|
70
|
+
>
|
|
71
|
+
<FormControlLabel value="female" control={<Radiobox />} label="Female" />
|
|
72
|
+
<FormControlLabel value="male" control={<Radiobox />} label="Male" />
|
|
73
|
+
<FormControlLabel value="other" control={<Radiobox />} label="Other" />
|
|
74
|
+
<FormControlLabel value="disabled" disabled control={<Radiobox />} label="other" />
|
|
75
|
+
</RadioGroup>
|
|
76
|
+
</FormControl>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
RadioboxDirection.storyName = 'Radiobox Direction'
|
|
80
|
+
|
|
81
|
+
export const RadioboxSize: Story = () => {
|
|
82
|
+
const [selectedValue, setSelectedValue] = useState('a')
|
|
83
|
+
|
|
84
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
85
|
+
setSelectedValue(event.target.value)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const controlProps = (item: string) => ({
|
|
89
|
+
checked: selectedValue === item,
|
|
90
|
+
onChange: handleChange,
|
|
91
|
+
value: item,
|
|
92
|
+
name: 'size-radio-button-demo',
|
|
93
|
+
inputProps: { 'aria-label': item },
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 16 }}>
|
|
98
|
+
<Radiobox {...controlProps('a')} size="small" />
|
|
99
|
+
<Radiobox {...controlProps('b')} />
|
|
100
|
+
<Radiobox
|
|
101
|
+
{...controlProps('c')}
|
|
102
|
+
sx={{
|
|
103
|
+
'& .MuiSvgIcon-root': {
|
|
104
|
+
fontSize: 28,
|
|
105
|
+
},
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
RadioboxSize.storyName = 'Radiobox Size'
|
|
113
|
+
|
|
114
|
+
export const RadioboxColors: Story = () => (
|
|
115
|
+
<div style={{ display: 'flex', gap: '1rem', margin: 16 }}>
|
|
116
|
+
<FormControl>
|
|
117
|
+
<FormLabel id="demo-row-radio-buttons-group-label">Colors</FormLabel>
|
|
118
|
+
<RadioGroup
|
|
119
|
+
row
|
|
120
|
+
aria-labelledby="demo-row-radio-buttons-group-label"
|
|
121
|
+
name="row-radio-buttons-group"
|
|
122
|
+
>
|
|
123
|
+
<FormControlLabel value="Primary" control={<Radiobox />} label="Primary" />
|
|
124
|
+
<FormControlLabel
|
|
125
|
+
value="secondary"
|
|
126
|
+
control={<Radiobox color="secondary" />}
|
|
127
|
+
label="Secondary"
|
|
128
|
+
/>
|
|
129
|
+
<FormControlLabel value="success" control={<Radiobox color="success" />} label="Success" />
|
|
130
|
+
<FormControlLabel value="default" control={<Radiobox color="default" />} label="Default" />
|
|
131
|
+
<FormControlLabel
|
|
132
|
+
value="pink"
|
|
133
|
+
label="Pink"
|
|
134
|
+
control={
|
|
135
|
+
<Radiobox
|
|
136
|
+
sx={{
|
|
137
|
+
color: pink[800],
|
|
138
|
+
'&.Mui-checked': {
|
|
139
|
+
color: pink[600],
|
|
140
|
+
},
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
}
|
|
144
|
+
/>
|
|
145
|
+
</RadioGroup>
|
|
146
|
+
</FormControl>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
RadioboxColors.storyName = 'Radiobox Colors'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ThemeProvider } from '@emotion/react';
|
|
2
|
+
import { themes } from '../../helpers/colors';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { RadioBaseProps } from './types';
|
|
5
|
+
import { Radio as MuiRadio } from '@mui/material';
|
|
6
|
+
|
|
7
|
+
export const Radiobox: React.FC<RadioBaseProps> = ({ ...rest }) => {
|
|
8
|
+
return (
|
|
9
|
+
<ThemeProvider theme={themes.light}>
|
|
10
|
+
<MuiRadio {...rest} />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { OverridableStringUnion } from '@mui/types'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Radio,
|
|
6
|
+
ButtonBaseProps as MuiButtonBaseProps,
|
|
7
|
+
RadioPropsColorOverrides,
|
|
8
|
+
RadioPropsSizeOverrides,
|
|
9
|
+
} from '@mui/material'
|
|
10
|
+
|
|
11
|
+
type MuiRadioBaseProps = Pick<MuiButtonBaseProps, 'sx'>
|
|
12
|
+
|
|
13
|
+
export interface RadioBaseProps extends MuiRadioBaseProps {
|
|
14
|
+
name?: string
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
required?: boolean
|
|
17
|
+
tabIndex?: number
|
|
18
|
+
value?: unknown
|
|
19
|
+
size?: OverridableStringUnion<'small' | 'medium', RadioPropsSizeOverrides>
|
|
20
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>
|
|
21
|
+
color?: OverridableStringUnion<
|
|
22
|
+
'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'default',
|
|
23
|
+
RadioPropsColorOverrides
|
|
24
|
+
>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type RadioType = keyof typeof Radio
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tag';
|