norma-library 0.6.986 → 0.6.988

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.
@@ -1,6 +1,17 @@
1
1
  import type { Preview } from '@storybook/react';
2
+ import { themes } from '../src/helpers';
3
+ import { NormaProvider } from '../src/providers/NormaProvider';
2
4
 
3
5
  const preview: Preview = {
6
+ decorators: [
7
+ (Story) => {
8
+ return (
9
+ <NormaProvider theme={themes.light}>
10
+ <Story />
11
+ </NormaProvider>
12
+ );
13
+ }
14
+ ],
4
15
  parameters: {
5
16
  docs: {
6
17
  source: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "norma-library",
3
- "version": "0.6.986",
3
+ "version": "0.6.988",
4
4
  "private": false,
5
5
  "description": "Olos/Norma-DS. Design System based on Material UI, developed with TypeScript and Styled Components to create reusable and consistent components in web applications.",
6
6
  "scripts": {
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import { ColorVariant } from '@/types';
2
2
  import { Card as MuiCard } from '@mui/material';
3
- import { CardBaseProps } from '../interfaces';
4
- import { palette } from '../helpers';
3
+ import React from 'react';
5
4
  import styled from 'styled-components';
6
- import { ColorVariant } from '@/types';
5
+ import { palette } from '../helpers';
6
+ import { CardBaseProps } from '../interfaces';
7
7
 
8
8
  const colorMap: Record<ColorVariant, string> = {
9
9
  inherit: palette.inherit,
@@ -1,12 +1,12 @@
1
- import React from 'react';
1
+ import { ChatMessageProps } from '@/interfaces';
2
2
  import { Box, Typography } from '@mui/material';
3
3
  import { styled } from '@mui/material/styles';
4
- import { ChatMessageProps } from '@/interfaces';
4
+ import React from 'react';
5
+ import { olosPalette } from '../helpers';
5
6
 
6
7
  const Item = styled(Box)<{
7
8
  orient?: string;
8
9
  }>(({ orient }) => ({
9
- borderColor: '#ccc',
10
10
  display: 'flex',
11
11
  position: 'relative',
12
12
  width: '100%',
@@ -15,28 +15,32 @@ const Item = styled(Box)<{
15
15
  alignItems: 'center',
16
16
  }));
17
17
 
18
- const ContainerStyled = styled(Box)({
18
+ const ContainerStyled = styled(Box)(({ theme }) => ({
19
19
  display: 'flex',
20
20
  flexDirection: 'column',
21
21
  alignItems: 'center',
22
22
  minWidth: '640px',
23
- backgroundColor: '#F0F0F0',
24
- padding: '10px',
25
- });
23
+ backgroundColor: theme?.palette?.grey?.[100] || '#F0F0F0',
24
+ padding: theme?.spacing?.(1.25) || '10px',
25
+ }));
26
26
 
27
27
  const BoxStyled = styled(Box)<{
28
28
  orient?: string;
29
- }>(({ orient }) => ({
29
+ }>(({ theme, orient }) => ({
30
30
  width: '70%',
31
- backgroundColor: orient === 'replay' ? '#E18B50' : '#FFF',
32
- color: orient === 'replay' ? '#FFF' : '#4D4F5C',
31
+ backgroundColor: orient === 'replay'
32
+ ? theme?.palette?.primary?.main || olosPalette.primary.main
33
+ : theme?.palette?.background?.paper || '#FFF',
34
+ color: orient === 'replay'
35
+ ? theme?.palette?.primary?.contrastText || '#FFF'
36
+ : theme?.palette?.text?.primary || '#4D4F5C',
33
37
  borderTopLeftRadius: 30,
34
38
  borderTopRightRadius: 30,
35
39
  borderBottomLeftRadius: orient === 'me' ? 2 : 30,
36
40
  borderBottomRightRadius: orient === 'me' ? 30 : 2,
37
- marginLeft: orient === 'replay' ? '10px' : 0,
38
- marginRight: orient === 'me' ? '10px' : 0,
39
- padding: 20,
41
+ marginLeft: orient === 'replay' ? theme?.spacing?.(1.25) || '10px' : 0,
42
+ marginRight: orient === 'me' ? theme?.spacing?.(1.25) || '10px' : 0,
43
+ padding: theme?.spacing?.(2.5) || 20,
40
44
  }));
41
45
 
42
46
  export const ChatMessage: React.FC<ChatMessageProps> = ({ data }) => {
@@ -48,31 +52,38 @@ export const ChatMessage: React.FC<ChatMessageProps> = ({ data }) => {
48
52
  <BoxStyled orient={item.send}>
49
53
  <Typography
50
54
  variant="subtitle2"
51
- style={{
55
+ sx={{
52
56
  marginBottom: '5px',
53
- font: 'normal normal 600 16px/20px Source Sans Pro',
57
+ fontWeight: 600,
58
+ fontSize: '16px',
59
+ lineHeight: '20px',
60
+ fontFamily: theme => theme?.typography?.fontFamily || 'Source Sans Pro',
54
61
  }}
55
62
  >
56
63
  {item.name}
57
64
  </Typography>
58
65
  <Typography
59
66
  variant="body1"
60
- style={{
61
- font: 'normal normal normal 16px/20px Source Sans Pro',
67
+ sx={{
68
+ fontSize: '16px',
69
+ lineHeight: '20px',
70
+ fontFamily: theme => theme?.typography?.fontFamily || 'Source Sans Pro',
62
71
  }}
63
72
  >
64
73
  {item.message}
65
74
  </Typography>
66
75
  <Typography
67
76
  variant="caption"
68
- style={{
77
+ sx={{
69
78
  position: 'absolute',
70
79
  bottom: '-18px',
71
80
  left: item.send === 'me' ? 0 : 'auto',
72
81
  right: item.send === 'me' ? 'auto' : 0,
73
- font: 'normal normal normal 11px/13px Source Sans Pro',
82
+ fontSize: '11px',
83
+ lineHeight: '13px',
84
+ fontFamily: theme => theme?.typography?.fontFamily || 'Source Sans Pro',
74
85
  opacity: 0.5,
75
- color: '#4D4F5C',
86
+ color: theme => theme?.palette?.text?.secondary || '#4D4F5C',
76
87
  }}
77
88
  >
78
89
  {item.time}
@@ -17,7 +17,7 @@ export const ChatMessageBalloonRowStyle: any = styled('div')<{ direction: string
17
17
  `;
18
18
 
19
19
  export const ChatMessageBalloonStyle: any = styled('div')<{ direction: string }>`
20
- background-color: ${props => (props.direction === 'I' ? '#FFF' : '#E18B50')};
20
+ background-color: ${props => (props.direction === 'I' ? props.theme.palette.background.paper : props.theme.palette.primary.main)};
21
21
  border: 2px solid transparent;
22
22
  border-radius: ${props => (props.direction === 'I' ? '20px 20px 0px 20px' : '20px 20px 20px 0px')};
23
23
  box-sizing: border-box;
@@ -29,20 +29,20 @@ export const ChatMessageBalloonStyle: any = styled('div')<{ direction: string }>
29
29
  transition: border 0.6s cubic-bezier(0.16, 1, 0.3, 1);
30
30
 
31
31
  &.is-highlight {
32
- border: 2px solid #8a8888;
32
+ border: 2px solid ${props => props.theme.palette.info.light};
33
33
  }
34
34
 
35
35
  &.is-interactive {
36
36
  cursor: pointer;
37
37
 
38
38
  &:hover {
39
- border: 2px solid #8a8888;
39
+ border: 2px solid ${props => props.theme.palette.primary.light};
40
40
  }
41
41
  }
42
42
  `;
43
43
 
44
44
  export const ChatMessageDateStyle: any = styled(Typography)`
45
- color: #43425d;
45
+ color: ${props => props.theme.palette.text.secondary};
46
46
  opacity: 0.5;
47
47
  `;
48
48
 
@@ -1,34 +1,43 @@
1
- import React from 'react';
1
+ import { ButtonVariant, ColorVariant } from '@/types';
2
2
  import { IconButton as MuiIconButton } from '@mui/material';
3
- import { IconButtonBaseProps } from '../interfaces';
4
- import { palette } from '../helpers';
5
3
  import { styled } from '@mui/material/styles';
6
- import { ButtonVariant, ColorVariant } from '@/types';
7
-
8
- const colorMap: Record<ColorVariant, string> = {
9
- inherit: palette.inherit,
10
- primary: palette.primary,
11
- secondary: palette.secondary,
12
- error: palette.error,
13
- warning: palette.warning,
14
- info: palette.info,
15
- success: palette.success,
16
- };
4
+ import React from 'react';
5
+ import { IconButtonBaseProps } from '../interfaces';
17
6
 
18
7
  const IconButtonStyled = styled(MuiIconButton)<{
19
8
  circle: string;
20
9
  color: ColorVariant;
21
10
  variant: ButtonVariant;
22
11
  cursor: string;
23
- }>(({ circle, color, variant, cursor }) => ({
24
- borderRadius: circle === 'true' ? 99 : 5,
25
- border: variant === 'outlined' ? `1px solid ${colorMap[color]}` : 'none',
26
- backgroundColor: variant === 'contained' ? `${colorMap[color]}` : 'none',
27
- cursor: cursor,
28
- }));
12
+ }>(({ theme, circle, color, variant, cursor }) => {
13
+ const colorMap: Record<ColorVariant, string> = {
14
+ inherit: theme.palette.text.primary,
15
+ primary: theme.palette.primary.main,
16
+ secondary: theme.palette.secondary.main,
17
+ error: theme.palette.error.main,
18
+ warning: theme.palette.warning.main,
19
+ info: theme.palette.info.main,
20
+ success: theme.palette.success.main,
21
+ };
22
+
23
+ return {
24
+ borderRadius: circle === 'true' ? 99 : 5,
25
+ border: variant === 'outlined' ? `1px solid ${colorMap[color]}` : 'none',
26
+ backgroundColor: variant === 'contained' ? `${colorMap[color]}` : 'none',
27
+ cursor: cursor,
28
+
29
+ '&:hover': {
30
+ backgroundColor:
31
+ variant === 'contained'
32
+ ? theme.palette.action.hover
33
+ : variant === 'outlined'
34
+ ? theme.palette.action.hover
35
+ : 'none',
36
+ },
37
+ };
38
+ });
29
39
 
30
40
  export const IconButton = ({ circle = false, children, ...props }: IconButtonBaseProps) => {
31
-
32
41
  return (
33
42
  <IconButtonStyled circle={`${circle}`} color="primary" variant="text" cursor="default" {...props}>
34
43
  {children}
@@ -1,10 +1,10 @@
1
- import React, { FunctionComponent } from 'react';
1
+ import styled from '@emotion/styled';
2
2
  import { SvgIconComponent } from '@mui/icons-material';
3
- import { iconsSVG } from './Svgs';
4
- import { IconColors, IconScale } from '../types';
3
+ import { useTheme } from '@mui/material';
4
+ import React, { FunctionComponent } from 'react';
5
5
  import { IconsProps, SvgProps } from '../interfaces/Icons';
6
- import styled from '@emotion/styled';
7
- import { palette } from '../helpers';
6
+ import { IconScale } from '../types';
7
+ import { iconsSVG } from './Svgs';
8
8
 
9
9
  export const Svg = styled.svg<SvgProps>(
10
10
  {
@@ -24,19 +24,6 @@ const scaleSize: Partial<Record<IconScale, number>> = {
24
24
  '3xlarge': 40,
25
25
  };
26
26
 
27
- const colors: Record<IconColors, string> = {
28
- inherit: palette.inherit,
29
- primary: palette.primary,
30
- secondary: palette.secondary,
31
- error: palette.error,
32
- info: palette.info,
33
- success: palette.success,
34
- warning: palette.warning,
35
- white: palette.white,
36
- black: palette.black,
37
- };
38
-
39
-
40
27
  export const Icons: FunctionComponent<IconsProps> = ({
41
28
  icon,
42
29
  scale,
@@ -44,6 +31,22 @@ export const Icons: FunctionComponent<IconsProps> = ({
44
31
  color = 'inherit',
45
32
  ...props
46
33
  }: IconsProps) => {
34
+
35
+ const theme = useTheme()
36
+
37
+ const colors: Record<string, string> = {
38
+ primary: theme.palette.primary.main,
39
+ secondary: theme.palette.secondary.main,
40
+ error: theme.palette.error.main,
41
+ info: theme.palette.info.main,
42
+ success: theme.palette.success.main,
43
+ warning: theme.palette.warning.main,
44
+ action: theme.palette.action.disabled,
45
+ inherit: theme.palette.text.primary,
46
+ white: '#ffffff',
47
+ black: '#000000',
48
+ };
49
+
47
50
  let width = 24;
48
51
  let height = 24;
49
52
  if (scale) {
@@ -83,4 +86,4 @@ export const Icons: FunctionComponent<IconsProps> = ({
83
86
  )}
84
87
  </Svg>
85
88
  );
86
- };
89
+ };
@@ -10,16 +10,14 @@ export const ChatMessageBalloonRowStyle: any = styled('div')<{ direction: string
10
10
  display: flex;
11
11
  margin-bottom: 8px;
12
12
  flex-direction: ${props => (props.direction === 'I' ? 'row-reverse' : 'row')};
13
- justify-content: flex-start;
14
- align-items: flex-start;
15
- vertical-align: middle;
13
+
16
14
  &:last-child {
17
15
  margin-bottom: 0px;
18
16
  }
19
17
  `;
20
18
 
21
19
  export const ChatMessageBalloonStyle: any = styled('div')<{ direction: string }>`
22
- background-color: ${props => (props.direction === 'I' ? '#FFF' : '#E18B50')};
20
+ background-color: ${props => (props.direction === 'I' ? props.theme.palette.background.paper : props.theme.palette.primary.main)};
23
21
  border: 2px solid transparent;
24
22
  border-radius: ${props => (props.direction === 'I' ? '20px 20px 0px 20px' : '20px 20px 20px 0px')};
25
23
  box-sizing: border-box;
@@ -31,22 +29,21 @@ export const ChatMessageBalloonStyle: any = styled('div')<{ direction: string }>
31
29
  transition: border 0.6s cubic-bezier(0.16, 1, 0.3, 1);
32
30
 
33
31
  &.is-highlight {
34
- border: 2px solid #8a8888;
32
+ border: 2px solid ${props => props.theme.palette.info.light};
35
33
  }
36
34
 
37
35
  &.is-interactive {
38
36
  cursor: pointer;
39
37
 
40
38
  &:hover {
41
- border: 2px solid #8a8888;
39
+ border: 2px solid ${props => props.theme.palette.primary.light};
42
40
  }
43
41
  }
44
42
  `;
45
43
 
46
44
  export const ChatMessageDateStyle: any = styled(Typography)`
47
- color: #43425d;
45
+ color: ${props => props.theme.palette.text.secondary};
48
46
  opacity: 0.5;
49
- margin-top: 7px;
50
47
  `;
51
48
 
52
49
  export const ChatMessageChildrenStyle: any = styled('div')<{ direction: string }>`
@@ -56,4 +53,4 @@ export const ChatMessageChildrenStyle: any = styled('div')<{ direction: string }
56
53
  flex: 1;
57
54
  justify-content: ${props => (props.direction === 'I' ? 'end' : 'start')};
58
55
  padding: 8px;
59
- `;
56
+ `;
@@ -16,7 +16,7 @@ const sizes: TextFieldSizeVariant[] = ['small', 'medium'];
16
16
 
17
17
  export const RadioGroup = ({ ...props }: RadioBaseProps) => {
18
18
  const { onChange } = props;
19
-
19
+
20
20
  return (
21
21
  <FormControl disabled={props.disabled}>
22
22
  <FormLabel id={props.id}>{props.label}</FormLabel>
@@ -1,23 +1,11 @@
1
1
  import React from 'react';
2
2
  import { Box, Slider as MuiSlider, Typography } from '@mui/material';
3
- import { palette } from '../helpers';
4
3
  import { styled } from '@mui/material/styles';
5
- import { ColorVariant } from '@/types';
6
4
  import { RangerSliderBaseProps } from '@/interfaces/RangerSlider';
7
5
 
8
- const colorMap: Record<ColorVariant, string> = {
9
- inherit: palette.inherit,
10
- primary: palette.primary,
11
- secondary: palette.secondary,
12
- error: palette.error,
13
- warning: palette.warning,
14
- info: palette.info,
15
- success: palette.success,
16
- };
17
-
18
- const RangerSliderStyled = styled(MuiSlider)(() => ({
6
+ const RangerSliderStyled = styled(MuiSlider)(({ theme }) => ({
19
7
  height: 8,
20
- color: colorMap['primary'],
8
+ color: theme.palette.primary.main,
21
9
  '& .MuiSlider-track': {
22
10
  border: 'none',
23
11
  },
@@ -25,7 +13,7 @@ const RangerSliderStyled = styled(MuiSlider)(() => ({
25
13
  height: 18,
26
14
  width: 18,
27
15
  backgroundColor: '#FFF',
28
- border: `2px solid ${colorMap['primary']}`,
16
+ border: `2px solid ${theme.palette.primary.main}`,
29
17
  '&:focus, &:hover, &.Mui-active, &.Mui-focusVisible': {
30
18
  boxShadow: 'inherit',
31
19
  },
@@ -34,7 +22,7 @@ const RangerSliderStyled = styled(MuiSlider)(() => ({
34
22
  height: '8px',
35
23
  position: 'absolute',
36
24
  display: 'block',
37
- background: colorMap['primary'],
25
+ background: theme.palette.primary.main,
38
26
  },
39
27
  },
40
28
  '& .MuiSlider-valueLabel': {
@@ -43,7 +31,7 @@ const RangerSliderStyled = styled(MuiSlider)(() => ({
43
31
  top: 48,
44
32
  position: 'absolute',
45
33
  transition: 'none',
46
- color: colorMap['primary'],
34
+ color: theme.palette.primary.main,
47
35
  '&:before': {
48
36
  bottom: 'inherit',
49
37
  top: '-8px',
@@ -1,6 +1,6 @@
1
- import styled from "styled-components";
1
+ import { styled } from "@mui/material/styles";
2
2
 
3
- export const Pagination = styled.div`
3
+ export const Pagination = styled('div')`
4
4
  width: 100%;
5
5
  margin: 24px 0 0 0;
6
6
  display: flex;
@@ -9,21 +9,21 @@ export const Pagination = styled.div`
9
9
  display: flex;
10
10
  gap: 8px;
11
11
  .button {
12
- border: 1px solid #E8E9EC;
13
- background: #fff;
12
+ border: 1px solid ${props => props.theme.palette.divider};
13
+ background: ${props => props.theme.palette.background.paper};
14
14
  border-radius: 4px;
15
- color: #4D4F5C;
15
+ color: ${props => props.theme.palette.text.primary};
16
16
  cursor: pointer;
17
17
  &:disabled {
18
18
  opacity: 0.4;
19
19
  }
20
20
  }
21
21
  .button-active {
22
- border: 1px solid #FFDB9F;
23
- background: #FFDB9F;
24
- color: #B74616;
22
+ border: 1px solid ${props => props.theme.palette.primary.light};
23
+ background: ${props => props.theme.palette.primary.main};
24
+ color: ${props => props.theme.palette.primary.contrastText};
25
25
  border-radius: 4px;
26
26
  cursor: pointer;
27
27
  }
28
28
  }
29
- `
29
+ `
@@ -1,29 +1,17 @@
1
- import React from 'react';
2
1
  import { Box, Tabs as MuiTabs, Tab } from '@mui/material';
2
+ import { styled, ThemeOptions, useTheme } from '@mui/material/styles';
3
+ import React from 'react';
3
4
  import { TabPanelProps, TabsBaseProps } from '../interfaces';
4
- import { palette } from '../helpers';
5
- import { styled } from '@mui/material/styles';
6
- import { ColorVariant } from '@/types';
7
-
8
- const colorMap: Record<ColorVariant, string> = {
9
- inherit: palette.inherit,
10
- primary: palette.primary,
11
- secondary: palette.secondary,
12
- error: palette.error,
13
- warning: palette.warning,
14
- info: palette.info,
15
- success: palette.success,
16
- };
17
5
 
18
6
  const TabsStyled = styled(MuiTabs)<{
19
- color: ColorVariant;
20
- }>(({ color }) => ({
7
+ theme: ThemeOptions;
8
+ }>(({ theme }) => ({
21
9
  borderBottom: '1px solid #e8e8e8',
22
10
  '& .Mui-selected': {
23
- color: colorMap[color],
11
+ color: theme.palette.primary.main,
24
12
  },
25
13
  '& .MuiTabs-indicator': {
26
- backgroundColor: colorMap[color],
14
+ backgroundColor: theme.palette.primary.main,
27
15
  },
28
16
  '& .MuiButtonBase-root': {
29
17
  textTransform: 'none',
@@ -32,20 +20,19 @@ const TabsStyled = styled(MuiTabs)<{
32
20
 
33
21
  interface StyledTabProps {
34
22
  label: string;
35
- color: ColorVariant;
36
23
  }
37
24
 
38
- const TabStyled = styled((props: StyledTabProps) => <Tab disableRipple {...props} />)(({ theme, color }) => ({
25
+ const TabStyled = styled((props: StyledTabProps) => <Tab disableRipple {...props} />)(({ theme }) => ({
39
26
  textTransform: 'none',
40
27
  fontWeight: theme.typography.fontWeightRegular,
41
28
  fontSize: theme.typography.pxToRem(15),
42
29
  marginRight: theme.spacing(1),
43
- color: '#666666',
30
+ color: theme.palette.text.secondary,
44
31
  padding: '5px 15px',
45
32
  top: '5px',
46
33
  minWidth: '60px',
47
34
  '&.Mui-selected': {
48
- color: colorMap[color],
35
+ color: theme.palette.primary.main,
49
36
  },
50
37
  '&.Mui-focusVisible': {
51
38
  backgroundColor: 'rgba(100, 95, 228, 0.32)',
@@ -80,6 +67,7 @@ function a11yProps(index: number) {
80
67
  }
81
68
 
82
69
  export const Tabs = ({ data = [], color = 'primary', onChange, ...props }: TabsBaseProps) => {
70
+ const muiTheme = useTheme()
83
71
  const [value, setValue] = React.useState(0);
84
72
 
85
73
  const handleChange = (event: React.SyntheticEvent, newValue: number) => {
@@ -90,8 +78,8 @@ export const Tabs = ({ data = [], color = 'primary', onChange, ...props }: TabsB
90
78
  return (
91
79
  <Box sx={{ width: '100%' }}>
92
80
  <Box>
93
- <TabsStyled value={value} color={color} onChange={handleChange} aria-label="basic tabs example" {...props}>
94
- {data && data.map((item, key) => <TabStyled label={item.label} color={color} {...a11yProps(key)} />)}
81
+ <TabsStyled value={value} onChange={handleChange} aria-label="basic tabs example" {...props} theme={muiTheme}>
82
+ {data && data.map((item, key) => <TabStyled label={item.label} {...a11yProps(key)} />)}
95
83
  </TabsStyled>
96
84
  </Box>
97
85
  {data &&
@@ -1,24 +1,24 @@
1
- import React from 'react';
2
1
  import { Chip as MuiTag } from '@mui/material';
2
+ import { styled, useTheme } from '@mui/material/styles';
3
+ import React from 'react';
3
4
  import { TagBaseProps } from '../interfaces';
4
- import { palette } from '../helpers';
5
- import { styled } from '@mui/material/styles';
6
- import { ColorVariant } from '@/types';
7
5
 
8
- const colorMap: Record<ColorVariant, string> = {
9
- inherit: palette.inherit,
10
- primary: palette.primary,
11
- secondary: palette.secondary,
12
- error: palette.error,
13
- warning: palette.warning,
14
- info: palette.info,
15
- success: palette.success,
16
- };
17
6
 
18
- const TagStyled = styled(MuiTag)({});
7
+ const TagStyled = styled(MuiTag)({
8
+ color: '#FFFF',
9
+ });
19
10
 
20
11
  export const Tag = ({ label, color = 'primary', outlined = false, ...props }: TagBaseProps) => {
21
-
12
+ const theme = useTheme()
13
+
14
+ const colorMap: Record<string, string> = {
15
+ primary: theme.palette.primary.main,
16
+ secondary: theme.palette.secondary.main,
17
+ error: theme.palette.error.main,
18
+ warning: theme.palette.warning.main,
19
+ info: theme.palette.info.main,
20
+ success: theme.palette.success.main,
21
+ };
22
22
  return (
23
23
  <TagStyled
24
24
  label={label}
@@ -1,18 +1,17 @@
1
1
  import React from 'react';
2
2
 
3
- import { Typography } from '@mui/material';
4
3
  import {
5
4
  Timeline,
6
- TimelineItem,
7
- TimelineSeparator,
8
5
  TimelineConnector,
9
6
  TimelineContent,
10
7
  TimelineDot,
8
+ TimelineItem,
11
9
  timelineItemClasses,
10
+ TimelineSeparator,
12
11
  } from '@mui/lab';
12
+ import { Typography } from '@mui/material';
13
13
 
14
- import { palette } from '../../helpers';
15
- import { ColorVariant } from '@/types';
14
+ import { ThemeOptions, useTheme } from '@mui/material/styles';
16
15
  import styled from 'styled-components';
17
16
 
18
17
  export interface TimeLineData {
@@ -23,23 +22,12 @@ export interface TimeLineData {
23
22
 
24
23
  interface TimeLineProps {
25
24
  data: TimeLineData[];
26
- theme?: ColorVariant;
27
- color?: string;
25
+ theme?: ThemeOptions;
28
26
  }
29
27
 
30
- const colorMap: Record<ColorVariant, string> = {
31
- inherit: palette.inherit,
32
- // primary: '#DB6619',
33
- primary: palette.primary,
34
- secondary: palette.secondary,
35
- error: palette.error,
36
- warning: palette.warning,
37
- info: palette.info,
38
- success: palette.success,
39
- };
28
+ export const TimeLine: React.FC<TimeLineProps> = ({ data }) => {
40
29
 
41
- export const TimeLine: React.FC<TimeLineProps> = ({ data, theme = 'primary', color }) => {
42
- const _mainColor = color || colorMap[theme];
30
+ const muiTheme = useTheme();
43
31
 
44
32
  const NormaTimeLine = styled(Timeline)`
45
33
  .${timelineItemClasses.root} {
@@ -56,7 +44,7 @@ export const TimeLine: React.FC<TimeLineProps> = ({ data, theme = 'primary', col
56
44
  content: '';
57
45
  width: 70%;
58
46
  height: 70%;
59
- background: ${_mainColor};
47
+ background: ${muiTheme.palette.primary.main};
60
48
  position: absolute;
61
49
  border-radius: 50%;
62
50
  top: 50%;
@@ -73,7 +61,7 @@ export const TimeLine: React.FC<TimeLineProps> = ({ data, theme = 'primary', col
73
61
  boxShadow: 'none',
74
62
  padding: '6px',
75
63
  margin: '0',
76
- border: `3px solid ${_mainColor}`,
64
+ border: `3px solid ${muiTheme.palette.primary.main}`,
77
65
  };
78
66
 
79
67
  const lastStyle = {
@@ -93,7 +81,7 @@ export const TimeLine: React.FC<TimeLineProps> = ({ data, theme = 'primary', col
93
81
  <TimelineItem key={key} sx={{ minHeight: 'auto' }}>
94
82
  <TimelineSeparator>
95
83
  <TimelineDot sx={_getDotStyle(!last)} />
96
- {last && <TimelineConnector sx={{ bgcolor: _mainColor, width: '5px' }} />}
84
+ {last && <TimelineConnector sx={{ bgcolor: muiTheme.palette.primary.main, width: '5px' }} />}
97
85
  </TimelineSeparator>
98
86
  <TimelineContent sx={{ py: 0, pl: 2, pb: '35px' }}>
99
87
  <Typography sx={{ m: 'auto 0' }} className="TimelineContent__Date" variant="body1">
@@ -1,29 +1,30 @@
1
- import styled from "styled-components";
1
+ import { styled } from "@mui/material/styles";
2
+ import { olosPalette } from "../../../../helpers";
2
3
 
3
- export const Pagination = styled.div`
4
- width: 100%;
5
- margin: 24px 0 0 0;
6
- display: flex;
7
- justify-content: center;
8
- .content {
9
- display: flex;
10
- gap: 8px;
11
- .button {
12
- border: 1px solid #E8E9EC;
13
- background: #fff;
14
- border-radius: 4px;
15
- color: #4D4F5C;
16
- cursor: pointer;
17
- &:disabled {
18
- opacity: 0.4;
19
- }
20
- }
21
- .button-active {
22
- border: 1px solid #FFDB9F;
23
- background: #FFDB9F;
24
- color: #B74616;
25
- border-radius: 4px;
26
- cursor: pointer;
27
- }
28
- }
29
- `
4
+ export const Pagination = styled('div')(({ theme }) => ({
5
+ width: '100%',
6
+ margin: '24px 0 0 0',
7
+ display: 'flex',
8
+ justifyContent: 'center',
9
+ '& .content': {
10
+ display: 'flex',
11
+ gap: '8px',
12
+ '& .button': {
13
+ border: `1px solid ${theme?.palette?.divider || '#E8E9EC'}`,
14
+ background: theme?.palette?.background?.paper || '#fff',
15
+ borderRadius: '4px',
16
+ color: theme?.palette?.text?.secondary || '#4D4F5C',
17
+ cursor: 'pointer',
18
+ '&:disabled': {
19
+ opacity: 0.4,
20
+ },
21
+ },
22
+ '& .button-active': {
23
+ border: `1px solid ${theme?.palette?.primary?.light || olosPalette.primary.main}`,
24
+ background: theme?.palette?.primary?.light || '#FFDB9F',
25
+ color: theme?.palette?.primary?.dark || '#B74616',
26
+ borderRadius: '4px',
27
+ cursor: 'pointer',
28
+ },
29
+ },
30
+ }));
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { Pagination as MuiPagination, PaginationItem } from '@mui/material';
2
+ import React from 'react';
3
3
  import * as S from './pagination.styles';
4
4
 
5
5
  interface PaginationProps {
@@ -1,35 +1,19 @@
1
- import React from 'react';
2
1
  import { styled } from '@mui/material/styles';
3
- import { TabsProps } from '@mui/material/Tabs';
2
+ import React from 'react';
4
3
 
5
4
  import { Tab, Tabs } from '@mui/material';
6
- import { ColorVariant } from '@/types';
7
- import { palette } from '../../helpers';
8
-
9
- const colorMap: Record<ColorVariant, string> = {
10
- inherit: palette.inherit,
11
- primary: palette.primary,
12
- secondary: palette.secondary,
13
- error: palette.error,
14
- warning: palette.warning,
15
- info: palette.info,
16
- success: palette.success,
17
- };
18
5
 
19
6
  interface StyledTabProps {
20
7
  label: string;
21
- color: ColorVariant;
22
8
  }
23
9
 
24
- export const NormaTabs: React.ComponentType<TabsProps & { color: ColorVariant }> = styled(Tabs)<{
25
- color: ColorVariant;
26
- }>(({ color }) => ({
27
- borderBottom: '1px solid #e8e8e8',
10
+ export const NormaTabs = styled(Tabs)(({ theme }) => ({
11
+ borderBottom: `1px solid ${theme.palette.background.paper}`,
28
12
  '& .Mui-selected': {
29
- color: colorMap[color],
13
+ color: theme.palette.primary.main,
30
14
  },
31
15
  '& .MuiTabs-indicator': {
32
- backgroundColor: colorMap[color],
16
+ backgroundColor: theme.palette.primary.main,
33
17
  },
34
18
  '& .MuiButtonBase-root': {
35
19
  textTransform: 'none',
@@ -38,20 +22,20 @@ export const NormaTabs: React.ComponentType<TabsProps & { color: ColorVariant }>
38
22
 
39
23
  export const NormaTab: React.ComponentType<StyledTabProps> = styled((props: StyledTabProps) => (
40
24
  <Tab disableRipple {...props} />
41
- ))(({ theme, color }) => ({
25
+ ))(({ theme }) => ({
42
26
  textTransform: 'none',
43
27
  fontWeight: theme.typography.fontWeightRegular,
44
28
  fontSize: theme.typography.pxToRem(15),
45
29
  marginRight: theme.spacing(1),
46
- color: '#666666',
30
+ color: theme.palette.text.secondary,
47
31
  padding: '5px 15px',
48
32
  top: '5px',
49
33
  minWidth: '60px',
50
34
  '&.Mui-selected': {
51
- color: colorMap[color],
35
+ color: theme.palette.primary.main,
52
36
  },
53
37
  '&.Mui-focusVisible': {
54
- backgroundColor: 'rgba(100, 95, 228, 0.32)',
38
+ backgroundColor: theme.palette.background.default,
55
39
  },
56
40
  }));
57
41
 
@@ -225,6 +225,27 @@ export const newOlosPalette: PaletteOptions = {
225
225
  }
226
226
  };
227
227
 
228
+ export const mockPalette: PaletteOptions = {
229
+ primary: {
230
+ main: '#fc92ee',
231
+ },
232
+ secondary: {
233
+ main: '#43bbf2',
234
+ },
235
+ error: {
236
+ main: '#d63643',
237
+ },
238
+ warning: {
239
+ main: '#ffc300',
240
+ },
241
+ info: {
242
+ main: '#71d5f7',
243
+ },
244
+ success: {
245
+ main: '#6bc235',
246
+ },
247
+ };
248
+
228
249
  export const lightTheme = createTheme({
229
250
  palette: {
230
251
  mode: 'light',
@@ -250,6 +271,13 @@ export const darkTheme = createTheme({
250
271
  },
251
272
  });
252
273
 
274
+ export const mockTheme = createTheme({
275
+ palette: {
276
+ mode: 'light',
277
+ ...mockPalette,
278
+ },
279
+ });
280
+
253
281
  export const themes = {
254
282
  light: lightTheme,
255
283
  dark: darkTheme,
@@ -1,12 +1,22 @@
1
- import React from 'react';
2
- import { ThemeProvider } from '@mui/material';
1
+ import { createTheme, ThemeProvider } from '@mui/material';
3
2
  import { ThemeProviderProps } from "@mui/material/styles/ThemeProvider";
3
+ import React from 'react';
4
+ import { newOlosPalette } from '../helpers';
4
5
 
5
- export const NormaProvider = (props:ThemeProviderProps) => {
6
+ export const NormaProvider = (props: ThemeProviderProps) => {
6
7
  const { theme, children } = props;
7
-
8
+
9
+ const getTheme = () => {
10
+ if (theme) return theme;
11
+ return createTheme({
12
+ palette: newOlosPalette,
13
+ });
14
+ };
15
+
16
+ const appTheme = getTheme();
17
+
8
18
  return (
9
- <ThemeProvider theme={theme}>
19
+ <ThemeProvider theme={appTheme}>
10
20
  {children}
11
21
  </ThemeProvider>
12
22
  );
@@ -1,7 +1,6 @@
1
- import React from 'react'
2
- import { IconButton, Icons } from '../components'
3
1
  import type { Meta, StoryObj } from '@storybook/react'
4
- import { ButtonVariant, SizeVariant, ColorVariant } from '../types'
2
+ import { IconButton, Icons } from '../components'
3
+ import { ButtonVariant, ColorVariant, SizeVariant } from '../types'
5
4
 
6
5
  const sizes: SizeVariant[] = ['small', 'medium', 'large']
7
6
  const variants: ButtonVariant[] = ['text', 'outlined', 'contained']
@@ -39,6 +38,7 @@ export const Playground: Story = {
39
38
  size: 'medium',
40
39
  color: 'primary',
41
40
  variant: 'text',
41
+ circle: true,
42
42
  },
43
43
  }
44
44
 
@@ -1,7 +1,5 @@
1
- import React from 'react'
2
- import { RadioGroup } from '../components/RadioGroup'
3
1
  import type { Meta, StoryObj } from '@storybook/react'
4
- import { SizeVariant } from '../types'
2
+ import { RadioGroup } from '../components/RadioGroup'
5
3
 
6
4
  const meta = {
7
5
  title: 'Form/RadioGroup',
@@ -1,8 +1,7 @@
1
- import React from 'react'
2
1
  import type { Meta, StoryObj } from '@storybook/react'
2
+ import React from 'react'
3
3
  import { RangerSlider } from '../components'
4
4
  import { ColorVariant, TextFieldSizeVariant } from '../types'
5
- import { TextField } from '@mui/material'
6
5
 
7
6
  const colors: ColorVariant[] = [
8
7
  'inherit',
@@ -1,331 +0,0 @@
1
- import { Box, Grid, Stack, Typography } from '@mui/material'
2
- import { createTheme } from '@mui/material/styles'
3
- import type { Meta } from '@storybook/react'
4
- import { Accordion, Button, Card, Paper, ProgressBar, Tag } from '../components'
5
- import { themes } from '../helpers'
6
- import { NormaProvider } from '../providers/NormaProvider'
7
-
8
- const meta = {
9
- title: 'Providers/NormaProvider',
10
- component: NormaProvider,
11
- parameters: {
12
- layout: 'centered',
13
- },
14
- tags: ['autodocs'],
15
- argTypes: {
16
- theme: {
17
- control: 'select',
18
- options: ['light', 'dark', 'newLight'],
19
- },
20
- },
21
- } satisfies Meta<typeof NormaProvider>
22
-
23
- export default meta
24
-
25
- const ComponentShowcase = () => (
26
- <Stack spacing={3} sx={{ width: '100%', maxWidth: 800, padding: 3 }}>
27
- <Typography variant="h4" gutterBottom>
28
- Norma Design System Components
29
- </Typography>
30
-
31
- <Paper elevation={2} sx={{ p: 3 }}>
32
- <Typography variant="h6" gutterBottom>
33
- Buttons
34
- </Typography>
35
- <Stack direction="row" spacing={2} flexWrap="wrap">
36
- <Button variant="contained" color="primary">
37
- Primary
38
- </Button>
39
- <Button variant="contained" color="secondary">
40
- Secondary
41
- </Button>
42
- <Button variant="contained" color="error">
43
- Error
44
- </Button>
45
- <Button variant="contained" color="success">
46
- Success
47
- </Button>
48
- <Button variant="outlined" color="warning">
49
- Warning
50
- </Button>
51
- </Stack>
52
- </Paper>
53
-
54
- <Paper elevation={2} sx={{ p: 3 }}>
55
- <Typography variant="h6" gutterBottom>
56
- Progress Bars
57
- </Typography>
58
- <Stack spacing={2}>
59
- <ProgressBar value={25} />
60
- <ProgressBar value={50} color="secondary" />
61
- <ProgressBar value={75} color="success" />
62
- <ProgressBar value={90} color="warning" />
63
- </Stack>
64
- </Paper>
65
-
66
- <Paper elevation={2} sx={{ p: 3 }}>
67
- <Typography variant="h6" gutterBottom>
68
- Cards & Tags
69
- </Typography>
70
- <Grid container spacing={2}>
71
- <Grid item xs={12} sm={6}>
72
- <Card sx={{ p: 2 }}>
73
- <Typography variant="h6" gutterBottom>
74
- Sample Card
75
- </Typography>
76
- <Typography variant="body2">
77
- Card content goes here with the current theme colors.
78
- </Typography>
79
- </Card>
80
- </Grid>
81
- <Grid item xs={12} sm={6}>
82
- <Stack spacing={2}>
83
- <Tag label="Primary Tag" color="primary" />
84
- <Tag label="Secondary Tag" color="secondary" />
85
- <Tag label="Success Tag" color="success" />
86
- <Tag label="Error Tag" color="error" />
87
- </Stack>
88
- </Grid>
89
- </Grid>
90
- </Paper>
91
-
92
- <Paper elevation={2} sx={{ p: 3 }}>
93
- <Typography variant="h6" gutterBottom>
94
- Accordion
95
- </Typography>
96
- <Accordion
97
- label="Theme Configuration"
98
- data={[
99
- {
100
- label: 'Theme Colors',
101
- id: 'theme-colors',
102
- children: <Typography>These components adapt to the current theme configuration.</Typography>,
103
- },
104
- {
105
- label: 'Customization',
106
- id: 'customization',
107
- children: <Typography>You can customize colors by passing custom theme options to NormaProvider.</Typography>,
108
- },
109
- ]}
110
- />
111
- </Paper>
112
- </Stack>
113
- )
114
-
115
- export const DefaultTheme = () => (
116
- <NormaProvider theme={themes.light}>
117
- <ComponentShowcase />
118
- </NormaProvider>
119
- )
120
-
121
- DefaultTheme.storyName = 'Default Theme'
122
-
123
- export const DarkTheme = () => (
124
- <NormaProvider theme={themes.dark}>
125
- <Box sx={{ backgroundColor: 'background.default', minHeight: '100vh', p: 2 }}>
126
- <ComponentShowcase />
127
- </Box>
128
- </NormaProvider>
129
- )
130
-
131
- DarkTheme.storyName = 'Dark Theme'
132
-
133
- export const CustomBlueTheme = () => {
134
- const customTheme = createTheme({
135
- palette: {
136
- mode: 'light',
137
- primary: {
138
- main: '#1976d2',
139
- light: '#42a5f5',
140
- dark: '#1565c0',
141
- },
142
- secondary: {
143
- main: '#dc004e',
144
- light: '#ff5983',
145
- dark: '#9a0036',
146
- },
147
- success: {
148
- main: '#2e7d32',
149
- },
150
- warning: {
151
- main: '#ed6c02',
152
- },
153
- error: {
154
- main: '#d32f2f',
155
- },
156
- },
157
- })
158
-
159
- return (
160
- <NormaProvider theme={customTheme}>
161
- <ComponentShowcase />
162
- </NormaProvider>
163
- )
164
- }
165
-
166
- CustomBlueTheme.storyName = 'Custom Blue Theme'
167
-
168
- export const CustomGreenTheme = () => {
169
- const customTheme = createTheme({
170
- palette: {
171
- mode: 'light',
172
- primary: {
173
- main: '#388e3c',
174
- light: '#6abf69',
175
- dark: '#00600f',
176
- },
177
- secondary: {
178
- main: '#7b1fa2',
179
- light: '#ae52d4',
180
- dark: '#4a0072',
181
- },
182
- success: {
183
- main: '#4caf50',
184
- },
185
- warning: {
186
- main: '#ff9800',
187
- },
188
- error: {
189
- main: '#f44336',
190
- },
191
- },
192
- })
193
-
194
- return (
195
- <NormaProvider theme={customTheme}>
196
- <ComponentShowcase />
197
- </NormaProvider>
198
- )
199
- }
200
-
201
- CustomGreenTheme.storyName = 'Custom Green Theme'
202
-
203
- export const CustomPurpleDarkTheme = () => {
204
- const customTheme = createTheme({
205
- palette: {
206
- mode: 'dark',
207
- primary: {
208
- main: '#9c27b0',
209
- light: '#d05ce3',
210
- dark: '#6a0080',
211
- },
212
- secondary: {
213
- main: '#ff6f00',
214
- light: '#ffa040',
215
- dark: '#c43e00',
216
- },
217
- background: {
218
- default: '#121212',
219
- paper: '#1e1e1e',
220
- },
221
- success: {
222
- main: '#66bb6a',
223
- },
224
- warning: {
225
- main: '#ffa726',
226
- },
227
- error: {
228
- main: '#ef5350',
229
- },
230
- },
231
- })
232
-
233
- return (
234
- <NormaProvider theme={customTheme}>
235
- <Box sx={{ backgroundColor: 'background.default', minHeight: '100vh', p: 2 }}>
236
- <ComponentShowcase />
237
- </Box>
238
- </NormaProvider>
239
- )
240
- }
241
-
242
- CustomPurpleDarkTheme.storyName = 'Custom Purple Dark Theme'
243
-
244
- export const MinimalExample = () => (
245
- <NormaProvider theme={themes.light}>
246
- <Stack spacing={2} alignItems="center" sx={{ p: 4 }}>
247
- <Typography variant="h5" color="primary">
248
- Welcome to Norma Design System
249
- </Typography>
250
- <Button variant="contained" color="primary">
251
- Get Started
252
- </Button>
253
- <Tag label="v1.0.0" color="secondary" />
254
- </Stack>
255
- </NormaProvider>
256
- )
257
-
258
- MinimalExample.storyName = 'Minimal Example'
259
-
260
- export const ThemeComparison = () => (
261
- <Grid container spacing={4} sx={{ p: 2 }}>
262
- <Grid item xs={12} md={4}>
263
- <Typography variant="h6" gutterBottom align="center">
264
- Default Light Theme
265
- </Typography>
266
- <NormaProvider theme={themes.light}>
267
- <Paper sx={{ p: 2 }}>
268
- <Stack spacing={2}>
269
- <Button variant="contained" color="primary" fullWidth>
270
- Primary Button
271
- </Button>
272
- <Button variant="contained" color="secondary" fullWidth>
273
- Secondary Button
274
- </Button>
275
- <ProgressBar value={60} />
276
- <Tag label="Sample Tag" color="primary" />
277
- </Stack>
278
- </Paper>
279
- </NormaProvider>
280
- </Grid>
281
-
282
- <Grid item xs={12} md={4}>
283
- <Typography variant="h6" gutterBottom align="center">
284
- Dark Theme
285
- </Typography>
286
- <NormaProvider theme={themes.dark}>
287
- <Paper sx={{ p: 2, backgroundColor: 'background.paper' }}>
288
- <Stack spacing={2}>
289
- <Button variant="contained" color="primary" fullWidth>
290
- Primary Button
291
- </Button>
292
- <Button variant="contained" color="secondary" fullWidth>
293
- Secondary Button
294
- </Button>
295
- <ProgressBar value={60} />
296
- <Tag label="Sample Tag" color="primary" />
297
- </Stack>
298
- </Paper>
299
- </NormaProvider>
300
- </Grid>
301
-
302
- <Grid item xs={12} md={4}>
303
- <Typography variant="h6" gutterBottom align="center">
304
- Custom Theme
305
- </Typography>
306
- <NormaProvider
307
- theme={createTheme({
308
- palette: {
309
- primary: { main: '#e91e63' },
310
- secondary: { main: '#00bcd4' },
311
- }
312
- })}
313
- >
314
- <Paper sx={{ p: 2 }}>
315
- <Stack spacing={2}>
316
- <Button variant="contained" color="primary" fullWidth>
317
- Primary Button
318
- </Button>
319
- <Button variant="contained" color="secondary" fullWidth>
320
- Secondary Button
321
- </Button>
322
- <ProgressBar value={60} />
323
- <Tag label="Sample Tag" color="primary" />
324
- </Stack>
325
- </Paper>
326
- </NormaProvider>
327
- </Grid>
328
- </Grid>
329
- )
330
-
331
- ThemeComparison.storyName = 'Theme Comparison'