@spaced-out/ui-design-system 0.0.29 → 0.0.31

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.
@@ -30,6 +30,9 @@ jobs:
30
30
  steps:
31
31
  - name: Checkout
32
32
  uses: actions/checkout@v3
33
+ - uses: actions/setup-node@v3
34
+ with:
35
+ node-version: 16
33
36
  - name: Install and Build 🔧
34
37
  # Install npm packages and build the Storybook files
35
38
  run: |
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.31](https://github.com/spaced-out/ui-design-system/compare/v0.0.30...v0.0.31) (2023-02-22)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * padding overrides for card ([263df80](https://github.com/spaced-out/ui-design-system/commit/263df80accb51477941978a758b707fd677b28e9))
11
+
12
+ ### [0.0.30](https://github.com/spaced-out/ui-design-system/compare/v0.0.29...v0.0.30) (2023-02-21)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * compose menu fixes ([09b116b](https://github.com/spaced-out/ui-design-system/commit/09b116bbb9426f4678c0ccd8db4bfffb107c11fb))
18
+ * pages action node 16 ([#69](https://github.com/spaced-out/ui-design-system/issues/69)) ([2cbe669](https://github.com/spaced-out/ui-design-system/commit/2cbe6699cae1606471f7e1bed240eace8d907af2))
19
+ * tooltip motion duration ([#67](https://github.com/spaced-out/ui-design-system/issues/67)) ([653dc72](https://github.com/spaced-out/ui-design-system/commit/653dc72d68a4098b577620c2ba8538f2943d08e3))
20
+
5
21
  ### [0.0.29](https://github.com/spaced-out/ui-design-system/compare/v0.0.28...v0.0.29) (2023-02-21)
6
22
 
7
23
 
@@ -34,14 +34,14 @@ const Card = _ref => {
34
34
  ...props
35
35
  } = _ref;
36
36
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
37
- "data-testid": "Card",
38
- className: (0, _classify.default)(_CardModule.default.cardWrapper, classNames?.wrapper),
39
37
  style: {
40
- paddingTop: getPaddingValue(paddingTop),
41
- paddingRight: getPaddingValue(paddingRight),
42
- paddingBottom: getPaddingValue(paddingBottom),
43
- paddingLeft: getPaddingValue(paddingLeft)
44
- }
38
+ '--card-padding-top': getPaddingValue(paddingTop),
39
+ '--card-padding-right': getPaddingValue(paddingRight),
40
+ '--card-padding-bottom': getPaddingValue(paddingBottom),
41
+ '--card-padding-left': getPaddingValue(paddingLeft)
42
+ },
43
+ "data-testid": "Card",
44
+ className: (0, _classify.default)(_CardModule.default.cardWrapper, classNames?.wrapper)
45
45
  }), children);
46
46
  };
47
47
  exports.Card = Card;
@@ -51,14 +51,14 @@ export const Card = ({
51
51
  }: CardProps): React.Node => (
52
52
  <div
53
53
  {...props}
54
- data-testid="Card"
55
- className={classify(css.cardWrapper, classNames?.wrapper)}
56
54
  style={{
57
- paddingTop: getPaddingValue(paddingTop),
58
- paddingRight: getPaddingValue(paddingRight),
59
- paddingBottom: getPaddingValue(paddingBottom),
60
- paddingLeft: getPaddingValue(paddingLeft),
55
+ '--card-padding-top': getPaddingValue(paddingTop),
56
+ '--card-padding-right': getPaddingValue(paddingRight),
57
+ '--card-padding-bottom': getPaddingValue(paddingBottom),
58
+ '--card-padding-left': getPaddingValue(paddingLeft),
61
59
  }}
60
+ data-testid="Card"
61
+ className={classify(css.cardWrapper, classNames?.wrapper)}
62
62
  >
63
63
  {children}
64
64
  </div>
@@ -1,11 +1,20 @@
1
1
  @value (colorBackgroundTertiary, colorFillPrimary, colorBorderSecondary, colorFocusPrimary) from '../../styles/variables/_color.css';
2
2
  @value (borderRadiusMedium, borderWidthNone, borderWidthTertiary) from '../../styles/variables/_border.css';
3
+ @value (spaceSmall, spaceMedium, spaceLarge) from '../../styles/variables/_space.css';
3
4
 
4
5
  .cardWrapper {
6
+ --card-padding-top: spaceMedium;
7
+ --card-padding-right: spaceMedium;
8
+ --card-padding-bottom: spaceMedium;
9
+ --card-padding-left: spaceMedium;
5
10
  display: flex;
6
11
  composes: borderPrimary from '../../styles/border.module.css';
7
12
  background-color: colorBackgroundTertiary;
8
13
  border-radius: borderRadiusMedium;
14
+ padding-top: var(--card-padding-top);
15
+ padding-right: var(--card-padding-right);
16
+ padding-bottom: var(--card-padding-bottom);
17
+ padding-left: var(--card-padding-left);
9
18
  }
10
19
 
11
20
  .clickableCard {
@@ -47,11 +47,11 @@ const Menu = props => {
47
47
  isFluid = true
48
48
  } = props;
49
49
  return /*#__PURE__*/React.createElement("div", {
50
- className: (0, _classify.classify)(_MenuModule.default.menuCard, classNames?.wrapper, {
50
+ className: (0, _classify.classify)(_MenuModule.default.menuCard, {
51
51
  [_MenuModule.default.fluid]: isFluid,
52
52
  [_MenuModule.default.medium]: size === 'medium',
53
53
  [_MenuModule.default.small]: size === 'small'
54
- }),
54
+ }, classNames?.wrapper),
55
55
  style: {
56
56
  width
57
57
  }
@@ -20,6 +20,7 @@ export type MenuOption = {
20
20
  iconRight?: string,
21
21
  iconRightType?: IconType,
22
22
  disabled?: boolean,
23
+ optionSize?: MenuSizeTypes,
23
24
  };
24
25
 
25
26
  // Render first available option set
@@ -28,13 +29,15 @@ export type MenuProps = {
28
29
  onSelect?: (option: MenuOption) => mixed,
29
30
  selectedOption?: MenuOption,
30
31
  classNames?: ClassNames,
31
- size?: 'medium' | 'small',
32
+ size?: MenuSizeTypes,
32
33
  width?: string,
33
34
  menuDisabled?: boolean,
34
35
  isFluid?: boolean,
35
36
  ...MenuOptionTypes,
36
37
  };
37
38
 
39
+ export type MenuSizeTypes = 'medium' | 'small';
40
+
38
41
  export type MenuOptionTypes = {
39
42
  options?: Array<MenuOption>,
40
43
  composeOptions?: Array<Array<MenuOption>>,
@@ -83,11 +86,15 @@ export const Menu = (props: MenuProps): React.Node => {
83
86
 
84
87
  return (
85
88
  <div
86
- className={classify(css.menuCard, classNames?.wrapper, {
87
- [css.fluid]: isFluid,
88
- [css.medium]: size === 'medium',
89
- [css.small]: size === 'small',
90
- })}
89
+ className={classify(
90
+ css.menuCard,
91
+ {
92
+ [css.fluid]: isFluid,
93
+ [css.medium]: size === 'medium',
94
+ [css.small]: size === 'small',
95
+ },
96
+ classNames?.wrapper,
97
+ )}
91
98
  style={{width}}
92
99
  >
93
100
  <RenderOption {...props} />
@@ -33,7 +33,8 @@
33
33
  spaceNone,
34
34
  spaceSmall,
35
35
  spaceXSmall,
36
- spaceXXSmall
36
+ spaceXXSmall,
37
+ spaceNone
37
38
  ) from '../../styles/variables/_space.css';
38
39
 
39
40
  @value (
@@ -161,11 +162,21 @@
161
162
  color: colorTextDisabled;
162
163
  }
163
164
 
165
+ .menuDivider {
166
+ padding-top: spaceXSmall;
167
+ padding-bottom: spaceXSmall;
168
+ }
169
+
164
170
  .menuDivider:not(:first-of-type) {
165
171
  border-top: borderWidthPrimary solid colorBorderPrimary;
166
- padding: spaceXSmall;
172
+ padding-top: spaceXSmall;
173
+ padding-bottom: spaceXSmall;
167
174
  }
168
175
 
169
- .menuDivider {
170
- padding: spaceXSmall;
176
+ .menuDivider:first-child {
177
+ padding-top: spaceNone;
178
+ }
179
+
180
+ .menuDivider:last-child {
181
+ padding-bottom: spaceNone;
171
182
  }
@@ -30,13 +30,18 @@ const MenuOptionButton = props => {
30
30
  iconLeftType,
31
31
  iconRight,
32
32
  iconRightType,
33
- disabled
33
+ disabled,
34
+ optionSize
34
35
  } = option;
36
+ const [buttonSize, setButtonSize] = React.useState(optionSize || size);
37
+ React.useEffect(() => {
38
+ setButtonSize(optionSize || size);
39
+ }, [optionSize, size]);
35
40
  return /*#__PURE__*/React.createElement(_Button.UnstyledButton, {
36
41
  className: (0, _classify.classify)(_MenuModule.default.option, {
37
42
  [_MenuModule.default.selected]: key === selectedOption?.key,
38
- [_MenuModule.default.optionSmall]: size === 'small',
39
- [_MenuModule.default.optionMedium]: size === 'medium',
43
+ [_MenuModule.default.optionSmall]: buttonSize === 'small',
44
+ [_MenuModule.default.optionMedium]: buttonSize === 'medium',
40
45
  [_MenuModule.default.disabled]: menuDisabled || disabled,
41
46
  [_MenuModule.default.withIconLeft]: !!iconLeft,
42
47
  [_MenuModule.default.withIconRight]: !!iconRight
@@ -35,13 +35,20 @@ export const MenuOptionButton = (props: MenuOptionProps): React.Node => {
35
35
  iconRight,
36
36
  iconRightType,
37
37
  disabled,
38
+ optionSize,
38
39
  } = option;
40
+ const [buttonSize, setButtonSize] = React.useState(optionSize || size);
41
+
42
+ React.useEffect(() => {
43
+ setButtonSize(optionSize || size);
44
+ }, [optionSize, size]);
45
+
39
46
  return (
40
47
  <UnstyledButton
41
48
  className={classify(css.option, {
42
49
  [css.selected]: key === selectedOption?.key,
43
- [css.optionSmall]: size === 'small',
44
- [css.optionMedium]: size === 'medium',
50
+ [css.optionSmall]: buttonSize === 'small',
51
+ [css.optionMedium]: buttonSize === 'medium',
45
52
  [css.disabled]: menuDisabled || disabled,
46
53
  [css.withIconLeft]: !!iconLeft,
47
54
  [css.withIconRight]: !!iconRight,
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Tooltip = void 0;
6
+ exports.Tooltip = exports.DELAY_MOTION_DURATION_TYPES = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
9
+ var MOTION = _interopRequireWildcard(require("../../styles/variables/_motion"));
9
10
  var _space = require("../../styles/variables/_space");
10
11
  var _classify = require("../../utils/classify");
11
12
  var _mergeRefs = require("../../utils/merge-refs");
13
+ var _string = require("../../utils/string");
12
14
  var _Text = require("../Text");
13
15
  var _Truncate = require("../Truncate");
14
16
  var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
@@ -16,6 +18,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
20
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
+ const DELAY_MOTION_DURATION_TYPES = Object.freeze({
22
+ none: 'none',
23
+ fast: 'fast',
24
+ normal: 'normal',
25
+ slow: 'slow',
26
+ slower: 'slower',
27
+ slowest: 'slowest'
28
+ });
29
+ exports.DELAY_MOTION_DURATION_TYPES = DELAY_MOTION_DURATION_TYPES;
19
30
  const Tooltip = _ref => {
20
31
  let {
21
32
  classNames,
@@ -24,7 +35,8 @@ const Tooltip = _ref => {
24
35
  body,
25
36
  placement = 'top',
26
37
  bodyMaxLines = 2,
27
- titleMaxLines = 1
38
+ titleMaxLines = 1,
39
+ delayMotionDuration = 'none'
28
40
  } = _ref;
29
41
  const [open, setOpen] = React.useState(false);
30
42
  const {
@@ -41,10 +53,17 @@ const Tooltip = _ref => {
41
53
  middleware: [(0, _reactDomInteractions.offset)(parseInt(_space.spaceXXSmall)), (0, _reactDomInteractions.flip)(), (0, _reactDomInteractions.shift)()],
42
54
  whileElementsMounted: _reactDomInteractions.autoUpdate
43
55
  });
56
+ const motionDurationToken = 'motionDuration' + (0, _string.capitalize)(delayMotionDuration);
57
+ const hoverDelay = parseInt(MOTION[motionDurationToken]) === NaN ? 0 : parseInt(MOTION[motionDurationToken]);
44
58
  const {
45
59
  getReferenceProps,
46
60
  getFloatingProps
47
- } = (0, _reactDomInteractions.useInteractions)([(0, _reactDomInteractions.useHover)(context), (0, _reactDomInteractions.useFocus)(context), (0, _reactDomInteractions.useRole)(context, {
61
+ } = (0, _reactDomInteractions.useInteractions)([(0, _reactDomInteractions.useHover)(context, {
62
+ delay: {
63
+ open: hoverDelay,
64
+ close: 0
65
+ }
66
+ }), (0, _reactDomInteractions.useFocus)(context), (0, _reactDomInteractions.useRole)(context, {
48
67
  role: 'tooltip'
49
68
  }), (0, _reactDomInteractions.useDismiss)(context)]);
50
69
 
@@ -24,9 +24,11 @@ import {
24
24
  useRole,
25
25
  } from '@floating-ui/react-dom-interactions';
26
26
 
27
+ import * as MOTION from '../../styles/variables/_motion';
27
28
  import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
28
29
  import {classify} from '../../utils/classify';
29
30
  import {mergeRefs} from '../../utils/merge-refs';
31
+ import {capitalize} from '../../utils/string';
30
32
  import {BodyMedium, SubTitleExtraSmall} from '../Text';
31
33
  import {Truncate} from '../Truncate';
32
34
 
@@ -35,6 +37,19 @@ import css from './Tooltip.module.css';
35
37
 
36
38
  type ClassNames = $ReadOnly<{tooltip?: string}>;
37
39
 
40
+ export const DELAY_MOTION_DURATION_TYPES = Object.freeze({
41
+ none: 'none',
42
+ fast: 'fast',
43
+ normal: 'normal',
44
+ slow: 'slow',
45
+ slower: 'slower',
46
+ slowest: 'slowest',
47
+ });
48
+
49
+ export type DelayMotionDurationType = $Values<
50
+ typeof DELAY_MOTION_DURATION_TYPES,
51
+ >;
52
+
38
53
  export type PlacementType =
39
54
  | 'top'
40
55
  | 'top-start'
@@ -52,6 +67,7 @@ export type TooltipProps = {
52
67
  placement?: PlacementType,
53
68
  bodyMaxLines?: number,
54
69
  titleMaxLines?: number,
70
+ delayMotionDuration?: DelayMotionDurationType,
55
71
  // TODO(Nishant): Decide on a type to use
56
72
  // $FlowFixMe
57
73
  children: any,
@@ -65,9 +81,9 @@ export const Tooltip = ({
65
81
  placement = 'top',
66
82
  bodyMaxLines = 2,
67
83
  titleMaxLines = 1,
84
+ delayMotionDuration = 'none',
68
85
  }: TooltipProps): React.Node => {
69
86
  const [open, setOpen] = React.useState(false);
70
-
71
87
  const {x, y, reference, floating, strategy, context} = useFloating({
72
88
  placement,
73
89
  open,
@@ -76,8 +92,20 @@ export const Tooltip = ({
76
92
  whileElementsMounted: autoUpdate,
77
93
  });
78
94
 
95
+ const motionDurationToken =
96
+ 'motionDuration' + capitalize(delayMotionDuration);
97
+ const hoverDelay =
98
+ parseInt(MOTION[motionDurationToken]) === NaN
99
+ ? 0
100
+ : parseInt(MOTION[motionDurationToken]);
101
+
79
102
  const {getReferenceProps, getFloatingProps} = useInteractions([
80
- useHover(context),
103
+ useHover(context, {
104
+ delay: {
105
+ open: hoverDelay,
106
+ close: 0,
107
+ },
108
+ }),
81
109
  useFocus(context),
82
110
  useRole(context, {role: 'tooltip'}),
83
111
  useDismiss(context),
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Tooltip", {
7
- enumerable: true,
8
- get: function () {
9
- return _Tooltip.Tooltip;
10
- }
11
- });
12
- var _Tooltip = require("./Tooltip");
6
+ var _Tooltip = require("./Tooltip");
7
+ Object.keys(_Tooltip).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Tooltip[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Tooltip[key];
14
+ }
15
+ });
16
+ });
@@ -1,4 +1,3 @@
1
1
  // @flow strict
2
2
 
3
- export type {PlacementType, TooltipProps} from './Tooltip';
4
- export {Tooltip} from './Tooltip';
3
+ export * from './Tooltip';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {