@spaced-out/ui-design-system 0.0.23 → 0.0.25

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,25 @@
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.25](https://github.com/spaced-out/ui-design-system/compare/v0.0.24...v0.0.25) (2023-02-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * anchor documentation fixes ([dc998a9](https://github.com/spaced-out/ui-design-system/commit/dc998a9c16ebbc6dff3f8271a0440b152f488ca4))
11
+
12
+ ### [0.0.24](https://github.com/spaced-out/ui-design-system/compare/v0.0.23...v0.0.24) (2023-02-15)
13
+
14
+
15
+ ### Features
16
+
17
+ * inline dropdown ([#65](https://github.com/spaced-out/ui-design-system/issues/65)) ([c6063d3](https://github.com/spaced-out/ui-design-system/commit/c6063d376a61dce4d94e0f0079e2dcf44c5a86bf))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * border fixes for Status inddicator ([d2b2903](https://github.com/spaced-out/ui-design-system/commit/d2b2903c37c521a95566f1016845b1ce8e8eeee5))
23
+
5
24
  ### [0.0.23](https://github.com/spaced-out/ui-design-system/compare/v0.0.23-beta.0...v0.0.23) (2023-02-14)
6
25
 
7
26
 
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.avatarSizeOptions = exports.BaseAvatar = exports.Avatar = exports.AVATAR_SIZE = exports.AVATAR_COLOR = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _Text = require("../../components/Text");
9
- var _color = require("../../styles/variables/_color");
9
+ var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
10
10
  var _classify = _interopRequireDefault(require("../../utils/classify"));
11
11
  var _Icon = require("../Icon");
12
12
  var _StatusIndicator = require("../StatusIndicator");
@@ -24,12 +24,12 @@ exports.AVATAR_SIZE = AVATAR_SIZE;
24
24
  const avatarSizeOptions = [...Object.keys(AVATAR_SIZE)];
25
25
  exports.avatarSizeOptions = avatarSizeOptions;
26
26
  const AVATAR_COLOR = Object.freeze({
27
- red: _color.colorDangerLightest,
28
- orange: _color.colorWarningLightest,
29
- green: _color.colorSuccessLightest,
30
- blue: _color.colorInformationLightest,
31
- gray: _color.colorGrayLightest,
32
- indigo: _color.colorNeutralLightest
27
+ red: COLORS.colorDangerLightest,
28
+ orange: COLORS.colorWarningLightest,
29
+ green: COLORS.colorSuccessLightest,
30
+ blue: COLORS.colorInformationLightest,
31
+ gray: COLORS.colorGrayLightest,
32
+ indigo: COLORS.colorNeutralLightest
33
33
  });
34
34
  exports.AVATAR_COLOR = AVATAR_COLOR;
35
35
  const getAvatarText = function () {
@@ -68,7 +68,8 @@ const AvatarConditionalContent = _ref2 => {
68
68
  size,
69
69
  iconType,
70
70
  color = 'blue',
71
- status
71
+ status,
72
+ statusBorderColorToken
72
73
  } = _ref2;
73
74
  return /*#__PURE__*/React.createElement("div", {
74
75
  className: _AvatarModule.default.innerContainer,
@@ -79,7 +80,8 @@ const AvatarConditionalContent = _ref2 => {
79
80
  className: (0, _classify.default)(_AvatarModule.default.statusIndicatorWrapper, _AvatarModule.default[size])
80
81
  }, /*#__PURE__*/React.createElement(_StatusIndicator.StatusIndicator, {
81
82
  status: status,
82
- withBorder: true
83
+ withBorder: true,
84
+ borderColorToken: statusBorderColorToken
83
85
  })), imageSrc ? /*#__PURE__*/React.createElement("img", {
84
86
  src: imageSrc,
85
87
  alt: "Avatar",
@@ -104,7 +106,8 @@ const Avatar = _ref3 => {
104
106
  iconType,
105
107
  color,
106
108
  ring = false,
107
- status
109
+ status,
110
+ statusBorderColorToken
108
111
  } = _ref3;
109
112
  return /*#__PURE__*/React.createElement("div", {
110
113
  className: (0, _classify.default)(_AvatarModule.default.container, {
@@ -124,7 +127,8 @@ const Avatar = _ref3 => {
124
127
  iconType: iconType,
125
128
  color: color,
126
129
  size: size,
127
- status: status
130
+ status: status,
131
+ statusBorderColorToken: statusBorderColorToken
128
132
  }))) : /*#__PURE__*/React.createElement(AvatarConditionalContent, {
129
133
  imageSrc: imageSrc,
130
134
  text: text,
@@ -132,7 +136,8 @@ const Avatar = _ref3 => {
132
136
  iconType: iconType,
133
137
  color: color,
134
138
  size: size,
135
- status: status
139
+ status: status,
140
+ statusBorderColorToken: statusBorderColorToken
136
141
  }));
137
142
  };
138
143
  exports.Avatar = Avatar;
@@ -7,6 +7,7 @@ import {
7
7
  SubTitleMedium,
8
8
  SubTitleSmall,
9
9
  } from '../../components/Text';
10
+ import * as COLORS from '../../styles/variables/_color';
10
11
  import {
11
12
  colorDangerLightest,
12
13
  colorGrayLightest,
@@ -58,6 +59,7 @@ export type AvatarProps = {
58
59
  iconType?: IconType,
59
60
  ring?: boolean,
60
61
  status?: StatusSemanticType,
62
+ statusBorderColorToken?: $Keys<typeof COLORS>,
61
63
  };
62
64
 
63
65
  const getAvatarText = (text = '') => {
@@ -100,6 +102,7 @@ export type AvatarContentProps = {
100
102
  color?: AvatarColorType,
101
103
  ring?: boolean,
102
104
  status?: StatusSemanticType,
105
+ statusBorderColorToken?: $Keys<typeof COLORS>,
103
106
  };
104
107
 
105
108
  const AvatarConditionalContent = ({
@@ -110,11 +113,16 @@ const AvatarConditionalContent = ({
110
113
  iconType,
111
114
  color = 'blue',
112
115
  status,
116
+ statusBorderColorToken,
113
117
  }: AvatarContentProps) => (
114
118
  <div className={css.innerContainer} style={{background: AVATAR_COLOR[color]}}>
115
119
  {!!status && (
116
120
  <div className={classify(css.statusIndicatorWrapper, css[size])}>
117
- <StatusIndicator status={status} withBorder />
121
+ <StatusIndicator
122
+ status={status}
123
+ withBorder
124
+ borderColorToken={statusBorderColorToken}
125
+ />
118
126
  </div>
119
127
  )}
120
128
 
@@ -139,6 +147,7 @@ export const Avatar = ({
139
147
  color,
140
148
  ring = false,
141
149
  status,
150
+ statusBorderColorToken,
142
151
  }: AvatarProps): React.Node => (
143
152
  <div
144
153
  className={classify(
@@ -163,6 +172,7 @@ export const Avatar = ({
163
172
  color={color}
164
173
  size={size}
165
174
  status={status}
175
+ statusBorderColorToken={statusBorderColorToken}
166
176
  />
167
177
  </div>
168
178
  </div>
@@ -175,6 +185,7 @@ export const Avatar = ({
175
185
  color={color}
176
186
  size={size}
177
187
  status={status}
188
+ statusBorderColorToken={statusBorderColorToken}
178
189
  />
179
190
  )}
180
191
  </div>
@@ -1,6 +1,11 @@
1
1
  // @flow strict
2
2
 
3
- export type {ButtonActionType, ButtonProps, ButtonType} from './Button';
3
+ export type {
4
+ ButtonActionType,
5
+ ButtonProps,
6
+ ButtonType,
7
+ UnstyledButtonProps,
8
+ } from './Button';
4
9
  export {
5
10
  Button,
6
11
  BUTTON_ACTION_TYPE,
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.InlineDropdown = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactDom = require("@floating-ui/react-dom");
9
+ var _space = require("../../styles/variables/_space");
10
+ var _classify = require("../../utils/classify");
11
+ var _clickAway = require("../../utils/click-away");
12
+ var _Button = require("../Button");
13
+ var _Icon = require("../Icon");
14
+ var _Menu = require("../Menu");
15
+ var _Truncate = require("../Truncate");
16
+ var _InlineDropdownModule = _interopRequireDefault(require("./InlineDropdown.module.css"));
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
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 InlineDropdown = _ref => {
22
+ let {
23
+ anchorPosition = 'bottom-start',
24
+ size = 'medium',
25
+ onOptionSelect,
26
+ menu,
27
+ classNames,
28
+ disabled,
29
+ onMenuOpen,
30
+ onMenuClose,
31
+ children,
32
+ ...restButtonProps
33
+ } = _ref;
34
+ const menuBtnRef = React.useRef();
35
+ const {
36
+ x,
37
+ y,
38
+ reference,
39
+ floating,
40
+ strategy
41
+ } = (0, _reactDom.useFloating)({
42
+ strategy: 'absolute',
43
+ placement: anchorPosition,
44
+ whileElementsMounted: _reactDom.autoUpdate,
45
+ middleware: [(0, _reactDom.shift)(), (0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
46
+ });
47
+ const onMenuToggle = isOpen => {
48
+ isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
49
+ };
50
+ return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
51
+ onChange: onMenuToggle
52
+ }, _ref2 => {
53
+ let {
54
+ isOpen,
55
+ onOpen,
56
+ cancelNext,
57
+ clickAway
58
+ } = _ref2;
59
+ return /*#__PURE__*/React.createElement("div", {
60
+ "data-testid": "InlineDropdown",
61
+ className: (0, _classify.classify)(_InlineDropdownModule.default.inlineDropdownContainer, classNames?.dropdownContainer),
62
+ ref: menuBtnRef
63
+ }, /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({}, restButtonProps, {
64
+ disabled: disabled,
65
+ ref: reference,
66
+ onClick: e => {
67
+ e.stopPropagation();
68
+ onOpen();
69
+ },
70
+ className: (0, _classify.classify)(_InlineDropdownModule.default.inlineButton, {
71
+ [_InlineDropdownModule.default.disabled]: disabled
72
+ }, _InlineDropdownModule.default[size], classNames?.buttonWrapper)
73
+ }), /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children), /*#__PURE__*/React.createElement(_Icon.Icon, {
74
+ name: isOpen ? 'caret-up' : 'caret-down',
75
+ size: "small",
76
+ type: "solid",
77
+ className: (0, _classify.classify)({
78
+ [_InlineDropdownModule.default.disabled]: disabled
79
+ })
80
+ })), isOpen && menu && /*#__PURE__*/React.createElement("div", {
81
+ onClickCapture: cancelNext,
82
+ ref: floating,
83
+ style: {
84
+ display: 'flex',
85
+ position: strategy,
86
+ top: y ?? _space.spaceNone,
87
+ left: x ?? _space.spaceNone
88
+ }
89
+ }, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
90
+ onSelect: option => {
91
+ onOptionSelect && onOptionSelect(option);
92
+ clickAway();
93
+ }
94
+ }))));
95
+ });
96
+ };
97
+ exports.InlineDropdown = InlineDropdown;
@@ -0,0 +1,134 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+ import {
5
+ // $FlowFixMe[untyped-import]
6
+ autoUpdate,
7
+ // $FlowFixMe[untyped-import]
8
+ flip,
9
+ // $FlowFixMe[untyped-import]
10
+ offset,
11
+ // $FlowFixMe[untyped-import]
12
+ shift,
13
+ // $FlowFixMe[untyped-import]
14
+ useFloating,
15
+ } from '@floating-ui/react-dom';
16
+
17
+ import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
18
+ import {classify} from '../../utils/classify';
19
+ import {ClickAway} from '../../utils/click-away';
20
+ import type {UnstyledButtonProps} from '../Button';
21
+ import {UnstyledButton} from '../Button';
22
+ import type {AnchorType} from '../ButtonDropdown';
23
+ import {Icon} from '../Icon';
24
+ import type {MenuOption, MenuProps} from '../Menu';
25
+ import {Menu} from '../Menu';
26
+ import {Truncate} from '../Truncate';
27
+
28
+ import css from './InlineDropdown.module.css';
29
+
30
+
31
+ type ClassNames = $ReadOnly<{
32
+ buttonWrapper?: string,
33
+ dropdownContainer?: string,
34
+ }>;
35
+
36
+ export type InlineDropdownProps = {
37
+ ...UnstyledButtonProps,
38
+ classNames?: ClassNames,
39
+ menu: MenuProps,
40
+ anchorPosition?: AnchorType,
41
+ onOptionSelect?: (option: MenuOption) => mixed,
42
+ onMenuOpen?: () => mixed,
43
+ onMenuClose?: () => mixed,
44
+ size?: 'medium' | 'small' | 'extraSmall',
45
+ ...
46
+ };
47
+
48
+ export const InlineDropdown = ({
49
+ anchorPosition = 'bottom-start',
50
+ size = 'medium',
51
+ onOptionSelect,
52
+ menu,
53
+ classNames,
54
+ disabled,
55
+ onMenuOpen,
56
+ onMenuClose,
57
+ children,
58
+ ...restButtonProps
59
+ }: InlineDropdownProps): React.Node => {
60
+ const menuBtnRef = React.useRef();
61
+ const {x, y, reference, floating, strategy} = useFloating({
62
+ strategy: 'absolute',
63
+ placement: anchorPosition,
64
+ whileElementsMounted: autoUpdate,
65
+ middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
66
+ });
67
+
68
+ const onMenuToggle = (isOpen: boolean) => {
69
+ isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
70
+ };
71
+
72
+ return (
73
+ <ClickAway onChange={onMenuToggle}>
74
+ {({isOpen, onOpen, cancelNext, clickAway}) => (
75
+ <div
76
+ data-testid="InlineDropdown"
77
+ className={classify(
78
+ css.inlineDropdownContainer,
79
+ classNames?.dropdownContainer,
80
+ )}
81
+ ref={menuBtnRef}
82
+ >
83
+ <UnstyledButton
84
+ {...restButtonProps}
85
+ disabled={disabled}
86
+ ref={reference}
87
+ onClick={(e) => {
88
+ e.stopPropagation();
89
+ onOpen();
90
+ }}
91
+ className={classify(
92
+ css.inlineButton,
93
+ {
94
+ [css.disabled]: disabled,
95
+ },
96
+ css[size],
97
+ classNames?.buttonWrapper,
98
+ )}
99
+ >
100
+ <Truncate>{children}</Truncate>
101
+ <Icon
102
+ name={isOpen ? 'caret-up' : 'caret-down'}
103
+ size="small"
104
+ type="solid"
105
+ className={classify({
106
+ [css.disabled]: disabled,
107
+ })}
108
+ />
109
+ </UnstyledButton>
110
+ {isOpen && menu && (
111
+ <div
112
+ onClickCapture={cancelNext}
113
+ ref={floating}
114
+ style={{
115
+ display: 'flex',
116
+ position: strategy,
117
+ top: y ?? spaceNone,
118
+ left: x ?? spaceNone,
119
+ }}
120
+ >
121
+ <Menu
122
+ {...menu}
123
+ onSelect={(option) => {
124
+ onOptionSelect && onOptionSelect(option);
125
+ clickAway();
126
+ }}
127
+ />
128
+ </div>
129
+ )}
130
+ </div>
131
+ )}
132
+ </ClickAway>
133
+ );
134
+ };
@@ -0,0 +1,44 @@
1
+ @value ( sizeFluid) from '../../styles/variables/_size.css';
2
+ @value ( spaceXXSmall) from '../../styles/variables/_space.css';
3
+ @value ( colorTextDisabled, colorFocusPrimary) from '../../styles/variables/_color.css';
4
+ @value ( borderWidthNone, borderWidthTertiary, borderRadiusXSmall) from '../../styles/variables/_border.css';
5
+
6
+ .inlineDropdownContainer {
7
+ display: flex;
8
+ position: relative;
9
+ }
10
+
11
+ .isFluid {
12
+ width: sizeFluid;
13
+ }
14
+
15
+ .inlineButton {
16
+ display: flex;
17
+ gap: spaceXXSmall;
18
+ cursor: pointer;
19
+ align-items: center;
20
+ border-radius: borderRadiusXSmall;
21
+ }
22
+
23
+ .inlineButton:focus {
24
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
25
+ borderWidthTertiary colorFocusPrimary;
26
+ }
27
+
28
+ .medium {
29
+ composes: buttonTextMedium from '../../styles/typography.module.css';
30
+ }
31
+
32
+ .small {
33
+ composes: buttonTextSmall from '../../styles/typography.module.css';
34
+ }
35
+
36
+ .extraSmall {
37
+ composes: buttonTextExtraSmall from '../../styles/typography.module.css';
38
+ }
39
+
40
+ .disabled {
41
+ pointer-events: none;
42
+ color: colorTextDisabled;
43
+ cursor: not-allowed;
44
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _InlineDropdown = require("./InlineDropdown");
7
+ Object.keys(_InlineDropdown).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _InlineDropdown[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _InlineDropdown[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './InlineDropdown';
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.StatusIndicator = exports.STATUS_SEMANTIC = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
+ var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
8
9
  var _classify = _interopRequireDefault(require("../../utils/classify"));
9
10
  var _StatusIndicatorModule = _interopRequireDefault(require("./StatusIndicator.module.css"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -24,13 +25,17 @@ const StatusIndicator = _ref => {
24
25
  classNames,
25
26
  status = 'information',
26
27
  withBorder,
28
+ borderColorToken = 'colorBackgroundTertiary',
27
29
  ...props
28
30
  } = _ref;
29
31
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
30
32
  "data-testid": "StatusIndicator",
31
33
  className: (0, _classify.default)(_StatusIndicatorModule.default.statusWrapper, _StatusIndicatorModule.default[status], {
32
34
  [_StatusIndicatorModule.default.withBorder]: withBorder
33
- }, classNames?.wrapper)
35
+ }, classNames?.wrapper),
36
+ style: {
37
+ '--border-color': COLORS[borderColorToken] || COLORS['colorBackgroundTertiary']
38
+ }
34
39
  }));
35
40
  };
36
41
  exports.StatusIndicator = StatusIndicator;
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from 'react';
4
4
 
5
+ import * as COLORS from '../../styles/variables/_color';
5
6
  import classify from '../../utils/classify';
6
7
 
7
8
  import css from './StatusIndicator.module.css';
@@ -23,6 +24,7 @@ export type StatusIndicatorProps = {
23
24
  classNames?: ClassNames,
24
25
  status?: StatusSemanticType,
25
26
  withBorder?: boolean,
27
+ borderColorToken?: $Keys<typeof COLORS>,
26
28
  ...
27
29
  };
28
30
 
@@ -30,6 +32,7 @@ export const StatusIndicator = ({
30
32
  classNames,
31
33
  status = 'information',
32
34
  withBorder,
35
+ borderColorToken = 'colorBackgroundTertiary',
33
36
  ...props
34
37
  }: StatusIndicatorProps): React.Node => (
35
38
  <div
@@ -43,5 +46,9 @@ export const StatusIndicator = ({
43
46
  },
44
47
  classNames?.wrapper,
45
48
  )}
49
+ style={{
50
+ '--border-color':
51
+ COLORS[borderColorToken] || COLORS['colorBackgroundTertiary'],
52
+ }}
46
53
  ></div>
47
54
  );
@@ -3,6 +3,7 @@
3
3
  @value (borderRadiusCircle, borderWidthTertiary) from '../../styles/variables/_border.css';
4
4
 
5
5
  .statusWrapper {
6
+ --border-color: colorBackgroundTertiary;
6
7
  display: flex;
7
8
  color: colorFillPrimary;
8
9
  width: size8;
@@ -33,5 +34,5 @@
33
34
  }
34
35
 
35
36
  .withBorder {
36
- border: borderWidthTertiary solid colorBackgroundTertiary;
37
+ border: borderWidthTertiary solid var(--border-color);
37
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {