norma-library 0.6.987 → 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.987",
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,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,19 +1,46 @@
1
+ import { ButtonVariant, ColorVariant } from '@/types';
1
2
  import { IconButton as MuiIconButton } from '@mui/material';
2
- import { styled, ThemeOptions, useTheme } from '@mui/material/styles';
3
+ import { styled } from '@mui/material/styles';
3
4
  import React from 'react';
4
5
  import { IconButtonBaseProps } from '../interfaces';
5
6
 
6
7
  const IconButtonStyled = styled(MuiIconButton)<{
7
- theme: ThemeOptions;
8
+ circle: string;
9
+ color: ColorVariant;
10
+ variant: ButtonVariant;
8
11
  cursor: string;
9
- }>(({ theme, cursor }) => ({
10
- borderRadius: '50%',
11
- border: `1px solid ${theme.palette.primary.main}`,
12
- backgroundColor: theme.palette.primary.main,
13
- cursor: cursor,
14
- }));
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
+ };
15
22
 
16
- export const IconButton = ({ children, cursor = 'pointer', ...props }: IconButtonBaseProps) => {
17
- const muiTheme = useTheme();
18
- return <IconButtonStyled theme={muiTheme} cursor={cursor} {...props}>{children}</IconButtonStyled>;
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
+ });
39
+
40
+ export const IconButton = ({ circle = false, children, ...props }: IconButtonBaseProps) => {
41
+ return (
42
+ <IconButtonStyled circle={`${circle}`} color="primary" variant="text" cursor="default" {...props}>
43
+ {children}
44
+ </IconButtonStyled>
45
+ );
19
46
  };
@@ -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,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
+ `
@@ -27,7 +27,7 @@ const TabStyled = styled((props: StyledTabProps) => <Tab disableRipple {...props
27
27
  fontWeight: theme.typography.fontWeightRegular,
28
28
  fontSize: theme.typography.pxToRem(15),
29
29
  marginRight: theme.spacing(1),
30
- color: '#666666',
30
+ color: theme.palette.text.secondary,
31
31
  padding: '5px 15px',
32
32
  top: '5px',
33
33
  minWidth: '60px',
@@ -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) => {
12
+ const theme = useTheme()
21
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,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 {
@@ -27,7 +27,7 @@ export const NormaTab: React.ComponentType<StyledTabProps> = styled((props: Styl
27
27
  fontWeight: theme.typography.fontWeightRegular,
28
28
  fontSize: theme.typography.pxToRem(15),
29
29
  marginRight: theme.spacing(1),
30
- color: '#666666',
30
+ color: theme.palette.text.secondary,
31
31
  padding: '5px 15px',
32
32
  top: '5px',
33
33
  minWidth: '60px',
@@ -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,
@@ -6,12 +6,17 @@ import { newOlosPalette } from '../helpers';
6
6
  export const NormaProvider = (props: ThemeProviderProps) => {
7
7
  const { theme, children } = props;
8
8
 
9
- const newOlosTheme = createTheme({
10
- palette: newOlosPalette,
11
- })
9
+ const getTheme = () => {
10
+ if (theme) return theme;
11
+ return createTheme({
12
+ palette: newOlosPalette,
13
+ });
14
+ };
15
+
16
+ const appTheme = getTheme();
12
17
 
13
18
  return (
14
- <ThemeProvider theme={theme ? theme : newOlosTheme}>
19
+ <ThemeProvider theme={appTheme}>
15
20
  {children}
16
21
  </ThemeProvider>
17
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',