@spothero/ui 15.9.4-beta.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spothero/ui",
3
- "version": "15.9.4-beta.0",
3
+ "version": "15.9.5-beta.0",
4
4
  "description": "SpotHero's React component UI library.",
5
5
  "main": "v2/index.js",
6
6
  "repository": "https://github.com/spothero/fe-monorepo",
@@ -164,4 +164,4 @@
164
164
  "react-redux": ">=7.0.0",
165
165
  "redux": ">=4.0.0"
166
166
  }
167
- }
167
+ }
@@ -168,7 +168,7 @@ AutoSuggestSelect.propTypes = {
168
168
  placeholder: PropTypes.string,
169
169
  /** Optional helper text displayed below the select */
170
170
  helperText: PropTypes.string,
171
- /** Error message that would dispplay under the select */
171
+ /** Error message that would display under the select */
172
172
  errorMessage: PropTypes.string,
173
173
  /** Boolean that sets whether the select is valid */
174
174
  isInvalid: PropTypes.bool,
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ import {Skeleton as Component, SkeletonCircle as CircleSkeleton, SkeletonText as TextSkeleton} from './index';
4
+
5
+ export default {
6
+ title: 'v2/Skeleton',
7
+ component: Component,
8
+ parameters: {
9
+ removeBaseHtmlClass: true,
10
+ chakraLink: 'https://chakra-ui.com/docs/components/skeleton/',
11
+ },
12
+ };
13
+
14
+ const SkeletonTemplate = props => (
15
+ <Component {...props}>
16
+ Text
17
+ </Component>
18
+ );
19
+
20
+ const SkeletonCircleTemplate = props => (
21
+ <CircleSkeleton>
22
+ Text
23
+ </CircleSkeleton>
24
+ )
25
+
26
+ const SkeletonTextTemplate = props => (
27
+ <TextSkeleton>
28
+ Text
29
+ </TextSkeleton>
30
+ )
31
+
32
+ export const Skeleton = SkeletonTemplate.bind({});
33
+ export const SkeletonCircle = SkeletonCircleTemplate.bind({})
34
+ export const SkeletonText = SkeletonTextTemplate.bind({})
@@ -0,0 +1,3 @@
1
+ import chakraDefaultTheme from '@chakra-ui/theme';
2
+
3
+ export default chakraDefaultTheme.components.Skeleton;
@@ -0,0 +1 @@
1
+ export {Skeleton, SkeletonCircle, SkeletonText} from '@chakra-ui/react';
@@ -1 +1,39 @@
1
- export {Tabs as default} from '@chakra-ui/react';
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: 'black',
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
  };
@@ -7,6 +7,7 @@ export {
7
7
  } from './Accordion';
8
8
  export * from './Button';
9
9
  export * from './Table';
10
+ export * from './Skeleton';
10
11
  export {TabList, TabPanels, Tab, TabPanel, default as Tabs} from './Tabs';
11
12
  export {default as Select} from './Select';
12
13
  export {default as Switch} from './Switch';
@@ -16,3 +16,4 @@ export {default as Popover} from './Popover/styles';
16
16
  export {default as Input} from './Input/styles';
17
17
  export {default as Modal} from './Modal/styles';
18
18
  export {default as Radio} from './Radio/styles';
19
+ export {default as Skeleton} from './Skeleton/Skeleton.styles';