@spaced-out/ui-design-system 0.1.120 → 0.1.121

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
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.1.121](https://github.com/spaced-out/ui-design-system/compare/v0.1.120...v0.1.121) (2024-08-20)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * 👻 added ghost buttons for range slider instead of clickable buttons ([ddff85a](https://github.com/spaced-out/ui-design-system/commit/ddff85a2202363132a530f8ed288279d182d1d2b))
11
+ * accessibility fixes for range slider ([67d4f94](https://github.com/spaced-out/ui-design-system/commit/67d4f9450e687a46162c1c3a8fa8c6ee7c8e5115))
12
+
5
13
  ### [0.1.120](https://github.com/spaced-out/ui-design-system/compare/v0.1.119...v0.1.120) (2024-08-19)
6
14
 
7
15
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_ACTION_TYPE = void 0;
6
+ exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_SIZE = exports.BUTTON_ACTION_TYPE = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = require("../../utils/classify");
9
9
  var _CircularLoader = require("../CircularLoader");
@@ -38,6 +38,11 @@ const BUTTON_ACTION_TYPE = Object.freeze({
38
38
  reset: 'reset'
39
39
  });
40
40
  exports.BUTTON_ACTION_TYPE = BUTTON_ACTION_TYPE;
41
+ const BUTTON_SIZE = Object.freeze({
42
+ small: 'small',
43
+ medium: 'medium'
44
+ });
45
+ exports.BUTTON_SIZE = BUTTON_SIZE;
41
46
  const ButtonTypeToIconColorMap = {
42
47
  primary: 'inversePrimary',
43
48
  secondary: 'clickable',
@@ -37,8 +37,14 @@ export const BUTTON_ACTION_TYPE = Object.freeze({
37
37
  reset: 'reset',
38
38
  });
39
39
 
40
+ export const BUTTON_SIZE = Object.freeze({
41
+ small: 'small',
42
+ medium: 'medium',
43
+ });
44
+
40
45
  export type ButtonType = $Values<typeof BUTTON_TYPES>;
41
46
  export type ButtonActionType = $Values<typeof BUTTON_ACTION_TYPE>;
47
+ export type ButtonSize = $Keys<typeof BUTTON_SIZE>;
42
48
 
43
49
  export type BaseButtonProps = {
44
50
  children?: React.Node,
@@ -66,7 +72,7 @@ export type ButtonProps = {
66
72
  iconRightType?: IconType,
67
73
  type?: ButtonType,
68
74
  isFluid?: boolean,
69
- size?: 'medium' | 'small',
75
+ size?: ButtonSize,
70
76
  ...
71
77
  };
72
78
 
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "BUTTON_ACTION_TYPE", {
9
9
  return _Button.BUTTON_ACTION_TYPE;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "BUTTON_SIZE", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Button.BUTTON_SIZE;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "BUTTON_TYPES", {
13
19
  enumerable: true,
14
20
  get: function () {
@@ -3,12 +3,14 @@
3
3
  export type {
4
4
  ButtonActionType,
5
5
  ButtonProps,
6
+ ButtonSize,
6
7
  ButtonType,
7
8
  UnstyledButtonProps,
8
9
  } from './Button';
9
10
  export {
10
11
  Button,
11
12
  BUTTON_ACTION_TYPE,
13
+ BUTTON_SIZE,
12
14
  BUTTON_TYPES,
13
15
  UnstyledButton,
14
16
  } from './Button';
@@ -7,7 +7,7 @@ exports.RangeSlider = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _color = require("../../styles/variables/_color");
9
9
  var _classify = _interopRequireDefault(require("../../utils/classify"));
10
- var _Icon = require("../Icon");
10
+ var _Button = require("../Button");
11
11
  var _RangeSliderModule = _interopRequireDefault(require("./RangeSlider.module.css"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  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); }
@@ -24,26 +24,17 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
24
24
  onChange,
25
25
  showTicks,
26
26
  iconLeftName = 'minus',
27
- iconLeftSize = _Icon.ICON_SIZE.small,
28
- iconLeftType,
27
+ btnLeftSize = _Button.BUTTON_SIZE.small,
29
28
  iconRightName = 'plus',
30
- iconRightSize = _Icon.ICON_SIZE.small,
31
- iconRightType,
32
- hideLeftIcon,
33
- hideRightIcon,
29
+ btnRightSize = _Button.BUTTON_SIZE.small,
30
+ hideLeftBtn,
31
+ hideRightBtn,
32
+ ariaLabel = 'Slider',
34
33
  ...restInputProps
35
34
  } = _ref;
36
35
  const progress = (value - min) / (max - min) * 100;
37
- const iconLeftDisabled = disabled || value <= min;
38
- const iconRightDisabled = disabled || value >= max;
39
-
40
- /**
41
- * Note(Nishant): This needs to be done because the Clickable Icon
42
- * does not support disable prop currently. This can become a refactor
43
- * task once we bake in disable support to Clickable Icon variation
44
- */
45
- const LeftIconComponent = iconLeftDisabled ? _Icon.Icon : _Icon.ClickableIcon;
46
- const RightIconComponent = iconRightDisabled ? _Icon.Icon : _Icon.ClickableIcon;
36
+ const btnLeftDisabled = disabled || value <= min;
37
+ const btnRightDisabled = disabled || value >= max;
47
38
  const progressColor = disabled ? _color.colorTextDisabled : _color.colorFillPrimary;
48
39
  const handleChange = e => {
49
40
  emitRoundedValue(e.currentTarget.value);
@@ -59,14 +50,14 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
59
50
  className: (0, _classify.default)(_RangeSliderModule.default.wrapper, {
60
51
  [_RangeSliderModule.default.disabled]: disabled
61
52
  }, classNames?.wrapper)
62
- }, !hideLeftIcon && /*#__PURE__*/React.createElement(LeftIconComponent, _extends({
63
- name: iconLeftName,
64
- size: iconLeftSize,
65
- type: iconLeftType,
66
- color: iconLeftDisabled ? 'disabled' : 'primary'
67
- }, !(disabled || value <= min) && {
53
+ }, !hideLeftBtn && /*#__PURE__*/React.createElement(_Button.Button, {
54
+ type: "ghost",
55
+ iconLeftName: iconLeftName,
56
+ size: btnLeftSize,
57
+ ariaLabel: "Decrease Value",
58
+ disabled: btnLeftDisabled,
68
59
  onClick: () => emitRoundedValue(value - step)
69
- })), /*#__PURE__*/React.createElement("div", {
60
+ }), /*#__PURE__*/React.createElement("div", {
70
61
  className: _RangeSliderModule.default.sliderContainer
71
62
  }, /*#__PURE__*/React.createElement("input", _extends({}, restInputProps, {
72
63
  type: "range",
@@ -78,6 +69,7 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
78
69
  className: _RangeSliderModule.default.slider,
79
70
  list: showTicks ? 'ticks' : undefined,
80
71
  disabled: disabled,
72
+ "aria-label": ariaLabel,
81
73
  style: {
82
74
  background: `linear-gradient(to right, ${progressColor} ${progress}%, ${_color.colorGrayLightest} ${progress}%)`
83
75
  }
@@ -89,13 +81,13 @@ const RangeSlider = /*#__PURE__*/React.forwardRef((_ref, ref) => {
89
81
  }, (_, index) => /*#__PURE__*/React.createElement("option", {
90
82
  key: index,
91
83
  value: min + index * step
92
- })))), !hideRightIcon && /*#__PURE__*/React.createElement(RightIconComponent, _extends({
93
- name: iconRightName,
94
- size: iconRightSize,
95
- type: iconRightType,
96
- color: iconRightDisabled ? 'disabled' : 'primary'
97
- }, !(disabled || value >= max) && {
84
+ })))), !hideRightBtn && /*#__PURE__*/React.createElement(_Button.Button, {
85
+ type: "ghost",
86
+ iconRightName: iconRightName,
87
+ size: btnRightSize,
88
+ ariaLabel: "Increase Value",
89
+ disabled: btnRightDisabled,
98
90
  onClick: () => emitRoundedValue(value + step)
99
- })));
91
+ }));
100
92
  });
101
93
  exports.RangeSlider = RangeSlider;
@@ -8,8 +8,8 @@ import {
8
8
  colorTextDisabled,
9
9
  } from '../../styles/variables/_color';
10
10
  import classify from '../../utils/classify';
11
- import type {IconSize, IconType} from '../Icon';
12
- import {ClickableIcon, Icon, ICON_SIZE} from '../Icon';
11
+ import type {ButtonSize} from '../Button';
12
+ import {Button, BUTTON_SIZE} from '../Button';
13
13
 
14
14
  import css from './RangeSlider.module.css';
15
15
 
@@ -24,15 +24,14 @@ export type RangeSliderProps = {
24
24
  onChange?: (value: number) => void, // We don't want to send in the event because the icon buttons also modify the value
25
25
  showTicks?: boolean,
26
26
  iconLeftName?: string,
27
- iconLeftType?: IconType,
28
- iconLeftSize?: IconSize,
27
+ btnLeftSize?: ButtonSize,
29
28
  iconRightName?: string,
30
- iconRightType?: IconType,
31
- iconRightSize?: IconSize,
29
+ btnRightSize?: ButtonSize,
32
30
  disabled?: boolean,
33
- hideLeftIcon?: boolean,
34
- hideRightIcon?: boolean,
31
+ hideLeftBtn?: boolean,
32
+ hideRightBtn?: boolean,
35
33
  classNames?: ClassNames,
34
+ ariaLabel?: string,
36
35
  ...
37
36
  };
38
37
 
@@ -51,29 +50,20 @@ export const RangeSlider: React$AbstractComponent<
51
50
  onChange,
52
51
  showTicks,
53
52
  iconLeftName = 'minus',
54
- iconLeftSize = ICON_SIZE.small,
55
- iconLeftType,
53
+ btnLeftSize = BUTTON_SIZE.small,
56
54
  iconRightName = 'plus',
57
- iconRightSize = ICON_SIZE.small,
58
- iconRightType,
59
- hideLeftIcon,
60
- hideRightIcon,
55
+ btnRightSize = BUTTON_SIZE.small,
56
+ hideLeftBtn,
57
+ hideRightBtn,
58
+ ariaLabel = 'Slider',
61
59
  ...restInputProps
62
60
  }: RangeSliderProps,
63
61
  ref,
64
62
  ) => {
65
63
  const progress = ((value - min) / (max - min)) * 100;
66
64
 
67
- const iconLeftDisabled = disabled || value <= min;
68
- const iconRightDisabled = disabled || value >= max;
69
-
70
- /**
71
- * Note(Nishant): This needs to be done because the Clickable Icon
72
- * does not support disable prop currently. This can become a refactor
73
- * task once we bake in disable support to Clickable Icon variation
74
- */
75
- const LeftIconComponent = iconLeftDisabled ? Icon : ClickableIcon;
76
- const RightIconComponent = iconRightDisabled ? Icon : ClickableIcon;
65
+ const btnLeftDisabled = disabled || value <= min;
66
+ const btnRightDisabled = disabled || value >= max;
77
67
 
78
68
  const progressColor = disabled ? colorTextDisabled : colorFillPrimary;
79
69
 
@@ -97,15 +87,14 @@ export const RangeSlider: React$AbstractComponent<
97
87
  classNames?.wrapper,
98
88
  )}
99
89
  >
100
- {!hideLeftIcon && (
101
- <LeftIconComponent
102
- name={iconLeftName}
103
- size={iconLeftSize}
104
- type={iconLeftType}
105
- color={iconLeftDisabled ? 'disabled' : 'primary'}
106
- {...(!(disabled || value <= min) && {
107
- onClick: () => emitRoundedValue(value - step),
108
- })}
90
+ {!hideLeftBtn && (
91
+ <Button
92
+ type="ghost"
93
+ iconLeftName={iconLeftName}
94
+ size={btnLeftSize}
95
+ ariaLabel="Decrease Value"
96
+ disabled={btnLeftDisabled}
97
+ onClick={() => emitRoundedValue(value - step)}
109
98
  />
110
99
  )}
111
100
 
@@ -121,6 +110,7 @@ export const RangeSlider: React$AbstractComponent<
121
110
  className={css.slider}
122
111
  list={showTicks ? 'ticks' : undefined}
123
112
  disabled={disabled}
113
+ aria-label={ariaLabel}
124
114
  style={{
125
115
  background: `linear-gradient(to right, ${progressColor} ${progress}%, ${colorGrayLightest} ${progress}%)`,
126
116
  }}
@@ -138,15 +128,14 @@ export const RangeSlider: React$AbstractComponent<
138
128
  </datalist>
139
129
  )}
140
130
  </div>
141
- {!hideRightIcon && (
142
- <RightIconComponent
143
- name={iconRightName}
144
- size={iconRightSize}
145
- type={iconRightType}
146
- color={iconRightDisabled ? 'disabled' : 'primary'}
147
- {...(!(disabled || value >= max) && {
148
- onClick: () => emitRoundedValue(value + step),
149
- })}
131
+ {!hideRightBtn && (
132
+ <Button
133
+ type="ghost"
134
+ iconRightName={iconRightName}
135
+ size={btnRightSize}
136
+ ariaLabel="Increase Value"
137
+ disabled={btnRightDisabled}
138
+ onClick={() => emitRoundedValue(value + step)}
150
139
  />
151
140
  )}
152
141
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.120",
3
+ "version": "0.1.121",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {