@tecsinapse/react-web-kit 1.18.5 → 1.19.0

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/components/atoms/Button/Button.d.ts +2 -0
  3. package/dist/components/atoms/Button/Button.js +18 -2
  4. package/dist/components/atoms/Button/Button.js.map +1 -1
  5. package/dist/components/atoms/Button/hooks/useMouseHover.d.ts +3 -3
  6. package/dist/components/atoms/Button/hooks/useMouseHover.js +13 -3
  7. package/dist/components/atoms/Button/hooks/useMouseHover.js.map +1 -1
  8. package/dist/components/atoms/Button/hooks/useMousePressed.d.ts +5 -0
  9. package/dist/components/atoms/Button/hooks/useMousePressed.js +32 -0
  10. package/dist/components/atoms/Button/hooks/useMousePressed.js.map +1 -0
  11. package/dist/components/atoms/Button/styled.js +9 -4
  12. package/dist/components/atoms/Button/styled.js.map +1 -1
  13. package/dist/components/molecules/Grid/Grid.d.ts +3 -13
  14. package/dist/components/molecules/Grid/Grid.js +4 -2
  15. package/dist/components/molecules/Grid/Grid.js.map +1 -1
  16. package/dist/components/molecules/Grid/Item/Item.d.ts +6 -27
  17. package/dist/components/molecules/Grid/Item/Item.js +41 -19
  18. package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
  19. package/dist/components/molecules/Grid/Item/functions.d.ts +2 -0
  20. package/dist/components/molecules/Grid/Item/functions.js +16 -0
  21. package/dist/components/molecules/Grid/Item/functions.js.map +1 -0
  22. package/dist/components/molecules/Grid/Item/index.d.ts +1 -1
  23. package/dist/components/molecules/Grid/Item/index.js.map +1 -1
  24. package/dist/components/molecules/Grid/index.d.ts +2 -2
  25. package/dist/components/molecules/Grid/index.js.map +1 -1
  26. package/dist/components/molecules/IconTextButton/IconTextButton.d.ts +6 -0
  27. package/dist/components/molecules/IconTextButton/IconTextButton.js +64 -0
  28. package/dist/components/molecules/IconTextButton/IconTextButton.js.map +1 -0
  29. package/dist/components/molecules/IconTextButton/TextComponent.d.ts +12 -0
  30. package/dist/components/molecules/IconTextButton/TextComponent.js +32 -0
  31. package/dist/components/molecules/IconTextButton/TextComponent.js.map +1 -0
  32. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.d.ts +6 -0
  33. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.js +31 -0
  34. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.js.map +1 -0
  35. package/dist/components/molecules/IconTextButton/index.d.ts +1 -0
  36. package/dist/components/molecules/IconTextButton/index.js +24 -0
  37. package/dist/components/molecules/IconTextButton/index.js.map +1 -0
  38. package/dist/components/molecules/IconTextButton/styled.d.ts +1 -0
  39. package/dist/components/molecules/IconTextButton/styled.js +33 -0
  40. package/dist/components/molecules/IconTextButton/styled.js.map +1 -0
  41. package/dist/components/molecules/LabeledSwitch/LabelComponent.d.ts +12 -0
  42. package/dist/components/molecules/LabeledSwitch/LabelComponent.js +38 -0
  43. package/dist/components/molecules/LabeledSwitch/LabelComponent.js.map +1 -0
  44. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.d.ts +7 -0
  45. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +55 -0
  46. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +1 -0
  47. package/dist/components/molecules/LabeledSwitch/index.d.ts +1 -0
  48. package/dist/components/molecules/LabeledSwitch/index.js +24 -0
  49. package/dist/components/molecules/LabeledSwitch/index.js.map +1 -0
  50. package/dist/components/molecules/LabeledSwitch/styled.d.ts +8 -0
  51. package/dist/components/molecules/LabeledSwitch/styled.js +39 -0
  52. package/dist/components/molecules/LabeledSwitch/styled.js.map +1 -0
  53. package/dist/components/organisms/DataGrid/Footer/Footer.js +3 -2
  54. package/dist/components/organisms/DataGrid/Footer/Footer.js.map +1 -1
  55. package/dist/hooks/index.d.ts +2 -0
  56. package/dist/hooks/index.js +16 -0
  57. package/dist/hooks/index.js.map +1 -1
  58. package/dist/hooks/useBreakpoints.d.ts +6 -0
  59. package/dist/hooks/useBreakpoints.js +27 -0
  60. package/dist/hooks/useBreakpoints.js.map +1 -0
  61. package/dist/hooks/useWindowSize.d.ts +6 -0
  62. package/dist/hooks/useWindowSize.js +35 -0
  63. package/dist/hooks/useWindowSize.js.map +1 -0
  64. package/dist/index.d.ts +14 -13
  65. package/dist/index.js +147 -131
  66. package/dist/index.js.map +1 -1
  67. package/package.json +6 -6
  68. package/src/components/atoms/Button/Button.tsx +20 -1
  69. package/src/components/atoms/Button/hooks/useMouseHover.ts +17 -9
  70. package/src/components/atoms/Button/hooks/useMousePressed.ts +29 -0
  71. package/src/components/atoms/Button/styled.ts +23 -6
  72. package/src/components/molecules/Grid/Grid.stories.tsx +198 -0
  73. package/src/components/molecules/Grid/Grid.tsx +7 -25
  74. package/src/components/molecules/Grid/Item/Item.tsx +57 -57
  75. package/src/components/molecules/Grid/Item/functions.ts +13 -0
  76. package/src/components/molecules/Grid/Item/index.ts +1 -1
  77. package/src/components/molecules/Grid/index.ts +2 -2
  78. package/src/components/molecules/IconTextButton/IconTextButton.stories.tsx +51 -0
  79. package/src/components/molecules/IconTextButton/IconTextButton.tsx +65 -0
  80. package/src/components/molecules/IconTextButton/TextComponent.tsx +39 -0
  81. package/src/components/molecules/IconTextButton/hooks/useIconTextButton.ts +31 -0
  82. package/src/components/molecules/IconTextButton/index.ts +4 -0
  83. package/src/components/molecules/IconTextButton/styled.ts +18 -0
  84. package/src/components/molecules/LabeledSwitch/LabelComponent.tsx +46 -0
  85. package/src/components/molecules/LabeledSwitch/LabeledSwitch.stories.tsx +41 -0
  86. package/src/components/molecules/LabeledSwitch/LabeledSwitch.tsx +58 -0
  87. package/src/components/molecules/LabeledSwitch/index.ts +4 -0
  88. package/src/components/molecules/LabeledSwitch/styled.ts +26 -0
  89. package/src/components/organisms/DataGrid/Footer/Footer.tsx +4 -4
  90. package/src/hooks/index.ts +2 -0
  91. package/src/hooks/useBreakpoints.ts +18 -0
  92. package/src/hooks/useWindowSize.ts +25 -0
  93. package/src/index.ts +33 -24
@@ -1,17 +1,25 @@
1
1
  import { useCallback, useState } from 'react';
2
2
 
3
- export const useMouseHover = (active: boolean) => {
3
+ export const useMouseHover = (
4
+ active: boolean,
5
+ onMouseOver?: () => void,
6
+ onMouseOut?: () => void
7
+ ) => {
4
8
  const [mouseOver, setMouseOver] = useState<boolean>(false);
5
9
 
6
- const handleMouseOver = useCallback(() => active && setMouseOver(true), [
7
- active,
8
- setMouseOver,
9
- ]);
10
+ const handleMouseOver = useCallback(() => {
11
+ if (active) {
12
+ setMouseOver(true);
13
+ onMouseOver?.();
14
+ }
15
+ }, [active, setMouseOver]);
10
16
 
11
- const handleMouseOut = useCallback(() => active && setMouseOver(false), [
12
- active,
13
- setMouseOver,
14
- ]);
17
+ const handleMouseOut = useCallback(() => {
18
+ if (active) {
19
+ setMouseOver(false);
20
+ onMouseOut?.();
21
+ }
22
+ }, [active, setMouseOver]);
15
23
 
16
24
  return {
17
25
  mouseOver,
@@ -0,0 +1,29 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ export const useMousePressed = (
4
+ active: boolean,
5
+ onPressIn?: () => void,
6
+ onPressOut?: () => void
7
+ ) => {
8
+ const [pressed, setPressed] = useState<boolean>(false);
9
+
10
+ const handlePressIn = useCallback(() => {
11
+ if (active) {
12
+ setPressed(true);
13
+ onPressIn?.();
14
+ }
15
+ }, [active, setPressed]);
16
+
17
+ const handlePressOut = useCallback(() => {
18
+ if (active) {
19
+ setPressed(false);
20
+ onPressOut?.();
21
+ }
22
+ }, [active, setPressed]);
23
+
24
+ return {
25
+ pressed,
26
+ handlePressIn,
27
+ handlePressOut,
28
+ };
29
+ };
@@ -1,5 +1,12 @@
1
1
  import styled, { css } from '@emotion/native';
2
- import { Button, StyleProps } from '@tecsinapse/react-core';
2
+ import {
3
+ borderColorGradationVC,
4
+ borderColorVC,
5
+ Button,
6
+ colorGradationVC,
7
+ colorVC,
8
+ StyleProps,
9
+ } from '@tecsinapse/react-core';
3
10
  import { WebButtonProps } from './Button';
4
11
 
5
12
  const webStyles = () => {
@@ -12,20 +19,30 @@ const webStyles = () => {
12
19
 
13
20
  const hoverStyles = ({
14
21
  mouseOver,
22
+ pressed,
15
23
  theme,
16
- color = 'primary',
24
+ variant = 'filled',
17
25
  disabled,
18
- }: { mouseOver: boolean } & WebButtonProps & Partial<StyleProps>) => {
26
+ }: { mouseOver: boolean; pressed: boolean } & WebButtonProps &
27
+ Partial<StyleProps>) => {
28
+ const variantColor = colorVC[variant];
29
+ const variantColorGradation = colorGradationVC[variant];
30
+ const variantBorderColor = borderColorVC[variant];
31
+ const variantBorderColorGradation = borderColorGradationVC[variant];
19
32
  return (
20
33
  mouseOver &&
21
34
  !disabled &&
35
+ !pressed &&
22
36
  css`
23
- background-color: ${theme?.color[color].dark};
24
- border-color: ${theme?.color[color].dark};
37
+ background-color: ${theme?.color[variantColor][variantColorGradation]};
38
+ border-color: ${theme?.color[variantBorderColor][
39
+ variantBorderColorGradation
40
+ ]};
25
41
  `
26
42
  );
27
43
  };
28
44
 
29
45
  export const StyledWebButton = styled(Button)<
30
- { mouseOver: boolean } & WebButtonProps & Partial<StyleProps>
46
+ { mouseOver: boolean; pressed: boolean } & WebButtonProps &
47
+ Partial<StyleProps>
31
48
  >(webStyles, hoverStyles);
@@ -0,0 +1,198 @@
1
+ import React from 'react';
2
+ import { Story } from '@storybook/react';
3
+ import Grid, { IGridWeb } from './Grid';
4
+ import { GridItem } from './Item';
5
+ import { Text } from '@tecsinapse/react-web-kit';
6
+ import styled from '@emotion/styled';
7
+
8
+ export default {
9
+ title: 'Web/Grid',
10
+ component: Grid,
11
+ subcomponents: { GridItem },
12
+ };
13
+
14
+ const Container = styled('div')`
15
+ background-color: orange;
16
+ padding: 8px;
17
+ border-width: 1px;
18
+ border-color: white;
19
+ border-style: solid;
20
+ border-radius: 8px;
21
+ `;
22
+
23
+ const TemplateGrid: Story<IGridWeb> = args => {
24
+ return (
25
+ <Grid {...args}>
26
+ <GridItem wrapper span={12}>
27
+ <Container>
28
+ <Text>Box</Text>
29
+ </Container>
30
+ </GridItem>
31
+
32
+ <GridItem wrapper span={6}>
33
+ <Container>
34
+ <Text>Box</Text>
35
+ </Container>
36
+ </GridItem>
37
+ <GridItem wrapper span={6}>
38
+ <Container>
39
+ <Text>Box</Text>
40
+ </Container>
41
+ </GridItem>
42
+
43
+ <GridItem wrapper span={4} flexShrink={1}>
44
+ <Container>
45
+ <Text>Box</Text>
46
+ </Container>
47
+ </GridItem>
48
+ <GridItem wrapper span={4} flexGrow={1}>
49
+ <Container>
50
+ <Text>Box</Text>
51
+ </Container>
52
+ </GridItem>
53
+ <GridItem wrapper span={4} flexShrink={1}>
54
+ <Container>
55
+ <Text>Box</Text>
56
+ </Container>
57
+ </GridItem>
58
+
59
+ <GridItem wrapper span={3} flexBasis={'content'} flex={1}>
60
+ {/** Width should consider component padding and grid spacing (8px left + 8px right + 2px grid for nano) */}
61
+ <Container style={{ width: 'calc(100% - 18px)' }}>
62
+ <Text>Box</Text>
63
+ </Container>
64
+ </GridItem>
65
+ <GridItem wrapper span={3} flexBasis={'content'}>
66
+ <Container>
67
+ <Text>Box</Text>
68
+ </Container>
69
+ </GridItem>
70
+ <GridItem wrapper span={3} flexBasis={'content'}>
71
+ <Container>
72
+ <Text>Box</Text>
73
+ </Container>
74
+ </GridItem>
75
+ <GridItem wrapper span={3} flexBasis={'content'}>
76
+ <Container>
77
+ <Text>Box</Text>
78
+ </Container>
79
+ </GridItem>
80
+ </Grid>
81
+ );
82
+ };
83
+
84
+ export const WithGridItem = TemplateGrid.bind({});
85
+
86
+ WithGridItem.args = {
87
+ spacing: 'nano',
88
+ };
89
+
90
+ const TemplateLayout: Story<IGridWeb> = args => {
91
+ return (
92
+ <Grid {...args}>
93
+ <Container>
94
+ <Text>Box</Text>
95
+ </Container>
96
+ <Container>
97
+ <Text>Box</Text>
98
+ </Container>
99
+ <Container>
100
+ <Text>Box</Text>
101
+ </Container>
102
+ <Container>
103
+ <Text>Box</Text>
104
+ </Container>
105
+ <Container>
106
+ <Text>Box</Text>
107
+ </Container>
108
+ <Container>
109
+ <Text>Box</Text>
110
+ </Container>
111
+ <Container>
112
+ <Text>Box</Text>
113
+ </Container>
114
+ <Container>
115
+ <Text>Box</Text>
116
+ </Container>
117
+ <Container>
118
+ <Text>Box</Text>
119
+ </Container>
120
+ <Container>
121
+ <Text>Box</Text>
122
+ </Container>
123
+ </Grid>
124
+ );
125
+ };
126
+
127
+ export const WithLayout = TemplateLayout.bind({});
128
+
129
+ WithLayout.args = {
130
+ layout: [[12], [6, 6], [4, 4, 4], [3, 3, 3, 3]],
131
+ spacing: 'mili',
132
+ };
133
+
134
+ const TemplateResponsive: Story<IGridWeb> = args => {
135
+ return (
136
+ <Grid {...args}>
137
+ <GridItem wrapper span={{ sm: 12 }}>
138
+ <Container>
139
+ <Text>Box</Text>
140
+ </Container>
141
+ </GridItem>
142
+
143
+ <GridItem wrapper span={{ sm: 6, md: 6 }}>
144
+ <Container>
145
+ <Text>Box</Text>
146
+ </Container>
147
+ </GridItem>
148
+ <GridItem wrapper span={{ sm: 6, md: 6 }}>
149
+ <Container>
150
+ <Text>Box</Text>
151
+ </Container>
152
+ </GridItem>
153
+
154
+ <GridItem wrapper span={{ sm: 12, md: 4 }} flexShrink={1}>
155
+ <Container>
156
+ <Text>Box</Text>
157
+ </Container>
158
+ </GridItem>
159
+ <GridItem wrapper span={{ sm: 6, md: 4 }} flexGrow={1}>
160
+ <Container>
161
+ <Text>Box</Text>
162
+ </Container>
163
+ </GridItem>
164
+ <GridItem wrapper span={{ sm: 6, md: 4 }} flexShrink={1}>
165
+ <Container>
166
+ <Text>Box</Text>
167
+ </Container>
168
+ </GridItem>
169
+
170
+ <GridItem wrapper span={{ sm: 12, lg: 3 }}>
171
+ <Container>
172
+ <Text>Box</Text>
173
+ </Container>
174
+ </GridItem>
175
+ <GridItem wrapper span={{ sm: 6, lg: 3 }}>
176
+ <Container>
177
+ <Text>Box</Text>
178
+ </Container>
179
+ </GridItem>
180
+ <GridItem wrapper span={{ sm: 6, lg: 3 }}>
181
+ <Container>
182
+ <Text>Box</Text>
183
+ </Container>
184
+ </GridItem>
185
+ <GridItem wrapper span={{ sm: 12, lg: 3 }}>
186
+ <Container>
187
+ <Text>Box</Text>
188
+ </Container>
189
+ </GridItem>
190
+ </Grid>
191
+ );
192
+ };
193
+
194
+ export const WithGridItemResponsive = TemplateResponsive.bind({});
195
+
196
+ WithGridItemResponsive.args = {
197
+ spacing: 'nano',
198
+ };
@@ -1,29 +1,9 @@
1
1
  import React from 'react';
2
2
  import { GridItem } from './Item';
3
- import { SpacingType } from '@tecsinapse/react-core';
3
+ import { IGrid } from '@tecsinapse/react-core';
4
4
 
5
- export interface IGrid extends React.HTMLAttributes<HTMLDivElement> {
6
- children: JSX.Element[];
7
- /** Layout should represent the multiplier of columns to fill the rows properly.
8
- * Example:
9
- * const layout = [
10
- * [6, 6], // Two elements on row
11
- * [4, 4, 4], // Three elements on row
12
- * [12], // One element on row
13
- * ];
14
- * */
15
- layout?: number[][];
16
- /** Number of grid columns to be considered (not the number of elements per row) */
17
- columns?: number;
18
- spacing?:
19
- | SpacingType
20
- | {
21
- top?: SpacingType;
22
- right?: SpacingType;
23
- bottom?: SpacingType;
24
- left?: SpacingType;
25
- };
26
- }
5
+ export type IGridWeb = IGrid &
6
+ Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
27
7
 
28
8
  const Grid = ({
29
9
  children,
@@ -32,7 +12,7 @@ const Grid = ({
32
12
  style,
33
13
  spacing,
34
14
  ...rest
35
- }: IGrid) => {
15
+ }: IGridWeb): JSX.Element => {
36
16
  if (layout) {
37
17
  const flatLayout = layout.flat();
38
18
  return (
@@ -47,6 +27,7 @@ const Grid = ({
47
27
  >
48
28
  {React.Children.map(children, (child, index) => (
49
29
  <GridItem
30
+ key={`child-${index}`}
50
31
  columns={columns}
51
32
  span={flatLayout[index]}
52
33
  spacing={spacing}
@@ -68,11 +49,12 @@ const Grid = ({
68
49
  }}
69
50
  {...rest}
70
51
  >
71
- {React.Children.map(children, child => {
52
+ {React.Children.map(children, (child, index) => {
72
53
  return React.cloneElement(child, {
73
54
  ...child?.props,
74
55
  columns,
75
56
  spacing: child?.props.spacing ?? spacing,
57
+ key: `child-${index}`,
76
58
  });
77
59
  })}
78
60
  </div>
@@ -1,59 +1,53 @@
1
1
  import React from 'react';
2
2
  import {
3
- extractNumbersFromString,
4
- SpacingType,
3
+ IGridItem,
5
4
  useTheme,
5
+ Breakpoints,
6
+ getGridItemColumSpan,
7
+ getGridItemPadding,
6
8
  } from '@tecsinapse/react-core';
9
+ import { useBreakpoints } from '@tecsinapse/react-web-kit';
10
+ import { getSpan } from './functions';
7
11
 
8
- type FlexPositioning = 'flex-start' | 'flex-end' | 'center';
9
- type FlexAlignBase = FlexPositioning | 'stretch';
10
- type FlexAlignType = FlexAlignBase | 'baseline';
11
- type FlexSpacing = 'space-between' | 'space-around';
12
+ export type Span = Pick<Breakpoints, 'sm'> & Partial<Omit<Breakpoints, 'sm'>>;
12
13
 
13
- type PaddingPosition = 'top' | 'right' | 'bottom' | 'left';
14
-
15
- export interface IGridItem {
16
- children: React.ReactElement;
17
- /** Number of columns to fill */
18
- span: number;
19
- /** You don't have to give this property since is inherited from Grid */
20
- columns?: number;
21
- loading?: boolean;
22
- /** If your GridItem has a loading state, specify the component here (Skeleton) */
23
- loadingComponent?: React.ReactElement;
24
- /** Flex properties below */
25
- alignContent?: FlexAlignBase | FlexSpacing;
26
- alignItems?: FlexAlignType;
27
- alignSelf?: 'auto' | FlexAlignType;
28
- flex?: number;
29
- flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
30
- flexGrow?: number;
31
- flexShrink?: number;
32
- justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';
33
- /** You don't have to give this property since is inherited from Grid */
34
- spacing?:
35
- | SpacingType
36
- | {
37
- top?: SpacingType;
38
- right?: SpacingType;
39
- bottom?: SpacingType;
40
- left?: SpacingType;
41
- };
42
- /** Used to wrap children in a View when its style extrapolates the dimensions*/
43
- wrapper?: boolean;
14
+ export interface IGridItemWeb
15
+ extends Omit<IGridItem, 'span'>,
16
+ Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
17
+ /** At least sm should exist */
18
+ span: number | Span;
19
+ /** Only specify this property if the GridItem will be 'dynamic', adjusting itself to content. Use this with `wrapper` for better result. */
20
+ flexBasis?:
21
+ | string
22
+ | 'content'
23
+ | 'auto'
24
+ | 'max-content'
25
+ | 'min-content'
26
+ | 'fit-content';
44
27
  }
45
28
 
46
29
  const GridItem = ({
47
30
  children,
48
- span,
31
+ span: _span,
49
32
  columns = 12,
50
33
  loadingComponent,
51
34
  loading = false,
52
35
  spacing: _spacing,
53
36
  wrapper = false,
37
+ alignContent,
38
+ alignItems,
39
+ alignSelf,
40
+ flex,
41
+ flexDirection,
42
+ flexGrow,
43
+ flexShrink,
44
+ justifyContent,
45
+ flexBasis,
46
+ style,
54
47
  ...rest
55
- }: IGridItem) => {
48
+ }: IGridItemWeb): JSX.Element => {
56
49
  const { spacing } = useTheme();
50
+ const { sm, md, lg } = useBreakpoints();
57
51
  if (!React.Children.only(children)) {
58
52
  throw new Error('The number of children in GridItem should be one');
59
53
  }
@@ -61,34 +55,40 @@ const GridItem = ({
61
55
  return loadingComponent;
62
56
  }
63
57
 
64
- const getPadding = (pos: PaddingPosition) => {
65
- if (_spacing) {
66
- if (typeof _spacing === 'string')
67
- return extractNumbersFromString(spacing[_spacing]);
68
- else if (typeof _spacing === 'object' && _spacing[pos]) {
69
- return extractNumbersFromString(spacing[_spacing[pos]!]);
70
- } else return undefined;
71
- } else return undefined;
72
- };
58
+ const span = typeof _span === 'number' ? _span : getSpan(_span, sm, md, lg);
73
59
 
74
- const style: React.CSSProperties = {
75
- ...rest,
60
+ const _style: React.CSSProperties = {
61
+ ...style,
62
+ alignContent,
63
+ alignItems,
64
+ alignSelf,
65
+ flexDirection,
66
+ flexGrow,
67
+ flexShrink,
68
+ justifyContent,
69
+ flex,
76
70
  boxSizing: 'border-box',
77
- flexBasis: `${100 / (columns / span)}%`,
78
- paddingTop: getPadding('top'),
79
- paddingBottom: getPadding('bottom'),
80
- paddingRight: getPadding('right'),
81
- paddingLeft: getPadding('left'),
71
+ flexBasis: flexBasis ?? `${getGridItemColumSpan(columns, span)}%`,
72
+ paddingTop: getGridItemPadding('top', _spacing, spacing),
73
+ paddingBottom: getGridItemPadding('bottom', _spacing, spacing),
74
+ paddingRight: getGridItemPadding('right', _spacing, spacing),
75
+ paddingLeft: getGridItemPadding('left', _spacing, spacing),
82
76
  };
83
77
 
84
78
  const clone = React.cloneElement(children, {
85
79
  ...children?.props,
86
80
  style: wrapper
87
81
  ? children?.props.style
88
- : { ...style, ...children?.props.style },
82
+ : { ..._style, ...children?.props.style },
89
83
  });
90
84
 
91
- return wrapper ? <div style={style}>{clone}</div> : clone;
85
+ return wrapper ? (
86
+ <div {...rest} style={_style}>
87
+ {clone}
88
+ </div>
89
+ ) : (
90
+ clone
91
+ );
92
92
  };
93
93
 
94
94
  export default GridItem;
@@ -0,0 +1,13 @@
1
+ import { Span } from './Item';
2
+
3
+ export const getSpan = (
4
+ value: Span,
5
+ sm: boolean,
6
+ md: boolean,
7
+ lg: boolean
8
+ ): number => {
9
+ if (sm) return value.sm;
10
+ if (md) return value.md ?? value.sm;
11
+ if (lg) return value.lg ?? value.md ?? value.sm;
12
+ return 0;
13
+ };
@@ -1,2 +1,2 @@
1
1
  export { default as GridItem } from './Item';
2
- export type { IGridItem } from './Item';
2
+ export type { IGridItemWeb } from './Item';
@@ -1,4 +1,4 @@
1
1
  export { GridItem } from './Item';
2
- export type { IGridItem } from './Item';
2
+ export type { IGridItemWeb } from './Item';
3
3
  export { default as Grid } from './Grid';
4
- export type { IGrid } from './Grid';
4
+ export type { IGridWeb } from './Grid';
@@ -0,0 +1,51 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { Story } from '@storybook/react';
3
+ import React from 'react';
4
+ import IconTextButton, { WebIconTextButtonProps } from './IconTextButton';
5
+
6
+ export default {
7
+ title: 'Web/IconTextButton',
8
+ component: IconTextButton,
9
+ };
10
+
11
+ const TemplateIcon: Story<WebIconTextButtonProps> = args => (
12
+ <IconTextButton {...args} />
13
+ );
14
+
15
+ export const BaseIcon = TemplateIcon.bind({});
16
+
17
+ BaseIcon.args = {
18
+ onPress: e => action('onPress')(e),
19
+ iconProps: {
20
+ name: 'rocket',
21
+ type: 'font-awesome',
22
+ },
23
+ };
24
+
25
+ const TemplateIconText: Story<WebIconTextButtonProps> = args => (
26
+ <IconTextButton {...args} />
27
+ );
28
+
29
+ export const BaseIconText = TemplateIconText.bind({});
30
+
31
+ BaseIconText.args = {
32
+ onPress: e => action('onPress')(e),
33
+ variant: 'outlined',
34
+ iconProps: {
35
+ name: 'rocket',
36
+ type: 'font-awesome',
37
+ },
38
+ label: 'Rocket Icon!',
39
+ };
40
+
41
+ const TemplateText: Story<WebIconTextButtonProps> = args => (
42
+ <IconTextButton {...args} />
43
+ );
44
+
45
+ export const BaseText = TemplateText.bind({});
46
+
47
+ BaseText.args = {
48
+ onPress: e => action('onPress')(e),
49
+ variant: 'text',
50
+ label: 'No rocket icon :(',
51
+ };
@@ -0,0 +1,65 @@
1
+ import { IconComponent, IconTextButtonProps } from '@tecsinapse/react-core';
2
+ import React from 'react';
3
+ import { WebButtonProps } from '../../atoms/Button';
4
+ import useIconTextButton from './hooks/useIconTextButton';
5
+ import { StyledIconTextButton } from './styled';
6
+ import TextComponent from './TextComponent';
7
+
8
+ export type WebIconTextButtonProps = IconTextButtonProps &
9
+ Omit<WebButtonProps, 'ButtonProps'>;
10
+
11
+ const IconTextButton: React.FC<WebIconTextButtonProps> = ({
12
+ iconProps,
13
+ iconPosition = 'left',
14
+ textProps,
15
+ label,
16
+ variant = 'filled',
17
+ size = 'default',
18
+ ...rest
19
+ }): JSX.Element => {
20
+ const { handleHover, handlePressed, defaultFontColor } = useIconTextButton(
21
+ variant
22
+ );
23
+
24
+ return (
25
+ <StyledIconTextButton
26
+ boxed={!label}
27
+ variant={variant}
28
+ size={size}
29
+ onMouseOut={() => handleHover(true)}
30
+ onMouseOver={() => handleHover(false)}
31
+ onPressIn={() => handlePressed(true)}
32
+ onPressOut={() => handlePressed(false)}
33
+ {...rest}
34
+ >
35
+ {iconPosition === 'left' ? (
36
+ <IconComponent
37
+ iconProps={iconProps}
38
+ size={size}
39
+ defaultFontColor={defaultFontColor}
40
+ />
41
+ ) : (
42
+ <></>
43
+ )}
44
+ <TextComponent
45
+ label={label}
46
+ defaultFontColor={defaultFontColor}
47
+ hasIcon={!!iconProps}
48
+ iconPosition={iconPosition}
49
+ textProps={textProps}
50
+ size={size}
51
+ />
52
+ {iconPosition === 'right' ? (
53
+ <IconComponent
54
+ iconProps={iconProps}
55
+ size={size}
56
+ defaultFontColor={defaultFontColor}
57
+ />
58
+ ) : (
59
+ <></>
60
+ )}
61
+ </StyledIconTextButton>
62
+ );
63
+ };
64
+
65
+ export default IconTextButton;