@spothero/ui 15.9.4 → 15.9.5-beta.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.
- package/package.json +1 -1
- package/styles/v2/components/Tabs/Tabs.jsx +39 -1
- package/styles/v2/components/Tabs/Tabs.stories.js +11 -3
- package/styles/v2/components/Tabs/combineSizeWithVariant.js +29 -0
- package/styles/v2/components/Tabs/styles/index.js +4 -1
- package/v2/index.js +1 -1
- package/v2/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {Tabs as ChakraTabs, forwardRef} from '@chakra-ui/react';
|
|
4
|
+
import combineSizeWithVariant from "./combineSizeWithVariant";
|
|
5
|
+
|
|
6
|
+
export const SIZE_SMALL = 'small';
|
|
7
|
+
export const SIZE_BODY = 'body';
|
|
8
|
+
export const SIZE_HEADING = 'heading';
|
|
9
|
+
|
|
10
|
+
const sizeMapping = {
|
|
11
|
+
[SIZE_SMALL]: 'sm',
|
|
12
|
+
[SIZE_BODY]: 'md',
|
|
13
|
+
[SIZE_HEADING]: 'lg'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Tabs = forwardRef(({size, ...props}, ref) => {
|
|
17
|
+
return (
|
|
18
|
+
<ChakraTabs
|
|
19
|
+
size={sizeMapping[size]}
|
|
20
|
+
{...props}
|
|
21
|
+
{...combineSizeWithVariant({size})}
|
|
22
|
+
ref={ref}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Tabs.defaultProps = {
|
|
28
|
+
size: SIZE_BODY,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Tabs.propTypes = {
|
|
32
|
+
/** The React node that will render inside the element */
|
|
33
|
+
children: PropTypes.node,
|
|
34
|
+
/** Controls the size of Tabs */
|
|
35
|
+
size: PropTypes.oneOf([SIZE_SMALL, SIZE_BODY, SIZE_HEADING]),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default Tabs;
|
|
39
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import Component from './Tabs';
|
|
3
|
+
import Component, {SIZE_BODY, SIZE_HEADING, SIZE_SMALL} from './Tabs';
|
|
4
4
|
import {TabList, TabPanels, Tab, TabPanel} from './index';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -8,11 +8,19 @@ export default {
|
|
|
8
8
|
parameters: {
|
|
9
9
|
removeBaseHtmlClass: true,
|
|
10
10
|
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
size: {
|
|
13
|
+
control: {
|
|
14
|
+
type: 'select',
|
|
15
|
+
options: [SIZE_SMALL, SIZE_BODY, SIZE_HEADING],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
11
19
|
};
|
|
12
20
|
|
|
13
|
-
const TabsTemplate =
|
|
21
|
+
const TabsTemplate = props => {
|
|
14
22
|
return (
|
|
15
|
-
<Component variant="line">
|
|
23
|
+
<Component variant="line" {...props}>
|
|
16
24
|
<TabList>
|
|
17
25
|
<Tab>One</Tab>
|
|
18
26
|
<Tab>Two</Tab>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styles from './styles/index';
|
|
2
|
+
import {fontSizes} from 'v2/theme/base/typography';
|
|
3
|
+
import {SIZE_BODY, SIZE_HEADING, SIZE_SMALL} from "./Tabs";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ### `combineSizeWithVariant`
|
|
7
|
+
* A function that takes in the `size` value, and the
|
|
8
|
+
* `variant` value. The default-like styling for the `size` prop is merged with the styling from the
|
|
9
|
+
* `variant` and a combined styleProp object is returned.
|
|
10
|
+
*
|
|
11
|
+
* @function combineSizeWithVariant
|
|
12
|
+
* @param {string} args.size - The size of Tabs component
|
|
13
|
+
* @param {string} args.variant - The style variant for the Text component
|
|
14
|
+
* @returns {Object} An object containing the merged styleProps from the `variant` and the `size` props
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const combineSizeWithVariant = ({size, variant = 'line'}) => {
|
|
18
|
+
const fontSizeMapping = {
|
|
19
|
+
[SIZE_SMALL]: fontSizes.xs,
|
|
20
|
+
[SIZE_BODY]: fontSizes.base,
|
|
21
|
+
[SIZE_HEADING]: fontSizes.lg
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const styleProps = styles.variants[`${variant}`];
|
|
25
|
+
styleProps.tab.fontSize = fontSizeMapping[size];
|
|
26
|
+
return styleProps;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default combineSizeWithVariant;
|
|
@@ -13,7 +13,7 @@ const variants = {
|
|
|
13
13
|
borderColor: 'transparent',
|
|
14
14
|
marginBottom: '-2px',
|
|
15
15
|
_selected: {
|
|
16
|
-
color: '
|
|
16
|
+
color: 'primary.default',
|
|
17
17
|
borderColor: 'primary.default',
|
|
18
18
|
fontWeight: 'semibold',
|
|
19
19
|
},
|
|
@@ -28,6 +28,9 @@ const variants = {
|
|
|
28
28
|
opacity: 0.4,
|
|
29
29
|
cursor: 'not-allowed',
|
|
30
30
|
},
|
|
31
|
+
_hover: {
|
|
32
|
+
color: 'black'
|
|
33
|
+
}
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
};
|