@spaced-out/ui-design-system 0.0.33 → 0.0.34

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,18 @@
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.34](https://github.com/spaced-out/ui-design-system/compare/v0.0.33...v0.0.34) (2023-02-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * avatar customisation enable ([#71](https://github.com/spaced-out/ui-design-system/issues/71)) ([0f06119](https://github.com/spaced-out/ui-design-system/commit/0f0611994a1ece78b9bc9232548b1f2634847682))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * controlled search input ([#72](https://github.com/spaced-out/ui-design-system/issues/72)) ([c089012](https://github.com/spaced-out/ui-design-system/commit/c089012a83134789e1ef4cc68e6a693a5848685e))
16
+
5
17
  ### [0.0.33](https://github.com/spaced-out/ui-design-system/compare/v0.0.32...v0.0.33) (2023-02-22)
6
18
 
7
19
 
@@ -42,15 +42,22 @@ const getAvatarText = function () {
42
42
  const AvatarTextDecorator = _ref => {
43
43
  let {
44
44
  avatarText,
45
- size
45
+ size,
46
+ className
46
47
  } = _ref;
47
48
  switch (size) {
48
49
  case 'small':
49
- return /*#__PURE__*/React.createElement(_Text.SubTitleSmall, null, avatarText);
50
+ return /*#__PURE__*/React.createElement(_Text.SubTitleSmall, {
51
+ className: className
52
+ }, avatarText);
50
53
  case 'medium':
51
- return /*#__PURE__*/React.createElement(_Text.SubTitleMedium, null, avatarText);
54
+ return /*#__PURE__*/React.createElement(_Text.SubTitleMedium, {
55
+ className: className
56
+ }, avatarText);
52
57
  case 'large':
53
- return /*#__PURE__*/React.createElement(_Text.SubTitleLarge, null, avatarText);
58
+ return /*#__PURE__*/React.createElement(_Text.SubTitleLarge, {
59
+ className: className
60
+ }, avatarText);
54
61
  }
55
62
  };
56
63
 
@@ -69,12 +76,13 @@ const AvatarConditionalContent = _ref2 => {
69
76
  iconType,
70
77
  color = 'blue',
71
78
  status,
72
- statusBorderColorToken
79
+ statusBorderColorToken,
80
+ classNames
73
81
  } = _ref2;
74
82
  return /*#__PURE__*/React.createElement("div", {
75
- className: _AvatarModule.default.innerContainer,
83
+ className: (0, _classify.default)(_AvatarModule.default.innerContainer, classNames?.content),
76
84
  style: {
77
- background: AVATAR_COLOR[color]
85
+ '--background-color': AVATAR_COLOR[color]
78
86
  }
79
87
  }, !!status && /*#__PURE__*/React.createElement("div", {
80
88
  className: (0, _classify.default)(_AvatarModule.default.statusIndicatorWrapper, _AvatarModule.default[size])
@@ -85,14 +93,16 @@ const AvatarConditionalContent = _ref2 => {
85
93
  })), imageSrc ? /*#__PURE__*/React.createElement("img", {
86
94
  src: imageSrc,
87
95
  alt: "Avatar",
88
- className: _AvatarModule.default.avatar
96
+ className: (0, _classify.default)(_AvatarModule.default.avatar, classNames?.image)
89
97
  }) : iconName ? /*#__PURE__*/React.createElement(_Icon.Icon, {
90
98
  name: iconName,
91
99
  type: iconType,
92
- size: iconSize[size]
100
+ size: iconSize[size],
101
+ className: classNames?.icon
93
102
  }) : text ? /*#__PURE__*/React.createElement(AvatarTextDecorator, {
94
103
  avatarText: getAvatarText(text),
95
- size: size
104
+ size: size,
105
+ className: classNames?.text
96
106
  }) : null);
97
107
  };
98
108
  const Avatar = _ref3 => {
@@ -117,7 +127,7 @@ const Avatar = _ref3 => {
117
127
  }, classNames?.wrapper),
118
128
  style: style
119
129
  }, ring ? /*#__PURE__*/React.createElement("div", {
120
- className: _AvatarModule.default.ring
130
+ className: (0, _classify.default)(_AvatarModule.default.ring, classNames?.ring)
121
131
  }, /*#__PURE__*/React.createElement("div", {
122
132
  className: _AvatarModule.default.whiteCircle
123
133
  }, /*#__PURE__*/React.createElement(AvatarConditionalContent, {
@@ -128,7 +138,8 @@ const Avatar = _ref3 => {
128
138
  color: color,
129
139
  size: size,
130
140
  status: status,
131
- statusBorderColorToken: statusBorderColorToken
141
+ statusBorderColorToken: statusBorderColorToken,
142
+ classNames: classNames
132
143
  }))) : /*#__PURE__*/React.createElement(AvatarConditionalContent, {
133
144
  imageSrc: imageSrc,
134
145
  text: text,
@@ -137,7 +148,8 @@ const Avatar = _ref3 => {
137
148
  color: color,
138
149
  size: size,
139
150
  status: status,
140
- statusBorderColorToken: statusBorderColorToken
151
+ statusBorderColorToken: statusBorderColorToken,
152
+ classNames: classNames
141
153
  }));
142
154
  };
143
155
  exports.Avatar = Avatar;
@@ -161,7 +173,8 @@ const BaseAvatar = _ref4 => {
161
173
  }
162
174
  }, /*#__PURE__*/React.createElement(AvatarTextDecorator, {
163
175
  avatarText: text,
164
- size: size
176
+ size: size,
177
+ className: classNames?.text
165
178
  }));
166
179
  };
167
180
  exports.BaseAvatar = BaseAvatar;
@@ -25,7 +25,14 @@ import {StatusIndicator} from '../StatusIndicator';
25
25
  import css from './Avatar.module.css';
26
26
 
27
27
 
28
- type ClassNames = $ReadOnly<{wrapper?: string}>;
28
+ type ClassNames = $ReadOnly<{
29
+ wrapper?: string,
30
+ ring?: string,
31
+ content?: string,
32
+ image?: string,
33
+ icon?: string,
34
+ text?: string,
35
+ }>;
29
36
 
30
37
  export const AVATAR_SIZE = Object.freeze({
31
38
  small: 'small',
@@ -72,17 +79,21 @@ const getAvatarText = (text = '') => {
72
79
  const AvatarTextDecorator = ({
73
80
  avatarText,
74
81
  size,
82
+ className,
75
83
  }: {
76
84
  avatarText: string,
77
85
  size: AvatarSize,
86
+ className?: string,
78
87
  }) => {
79
88
  switch (size) {
80
89
  case 'small':
81
- return <SubTitleSmall>{avatarText}</SubTitleSmall>;
90
+ return <SubTitleSmall className={className}>{avatarText}</SubTitleSmall>;
82
91
  case 'medium':
83
- return <SubTitleMedium>{avatarText}</SubTitleMedium>;
92
+ return (
93
+ <SubTitleMedium className={className}>{avatarText}</SubTitleMedium>
94
+ );
84
95
  case 'large':
85
- return <SubTitleLarge>{avatarText}</SubTitleLarge>;
96
+ return <SubTitleLarge className={className}>{avatarText}</SubTitleLarge>;
86
97
  }
87
98
  };
88
99
 
@@ -103,6 +114,7 @@ export type AvatarContentProps = {
103
114
  ring?: boolean,
104
115
  status?: StatusSemanticType,
105
116
  statusBorderColorToken?: $Keys<typeof COLORS>,
117
+ classNames?: ClassNames,
106
118
  };
107
119
 
108
120
  const AvatarConditionalContent = ({
@@ -114,8 +126,14 @@ const AvatarConditionalContent = ({
114
126
  color = 'blue',
115
127
  status,
116
128
  statusBorderColorToken,
129
+ classNames,
117
130
  }: AvatarContentProps) => (
118
- <div className={css.innerContainer} style={{background: AVATAR_COLOR[color]}}>
131
+ <div
132
+ className={classify(css.innerContainer, classNames?.content)}
133
+ style={{
134
+ '--background-color': AVATAR_COLOR[color],
135
+ }}
136
+ >
119
137
  {!!status && (
120
138
  <div className={classify(css.statusIndicatorWrapper, css[size])}>
121
139
  <StatusIndicator
@@ -127,11 +145,24 @@ const AvatarConditionalContent = ({
127
145
  )}
128
146
 
129
147
  {imageSrc ? (
130
- <img src={imageSrc} alt="Avatar" className={css.avatar}></img>
148
+ <img
149
+ src={imageSrc}
150
+ alt="Avatar"
151
+ className={classify(css.avatar, classNames?.image)}
152
+ ></img>
131
153
  ) : iconName ? (
132
- <Icon name={iconName} type={iconType} size={iconSize[size]} />
154
+ <Icon
155
+ name={iconName}
156
+ type={iconType}
157
+ size={iconSize[size]}
158
+ className={classNames?.icon}
159
+ />
133
160
  ) : text ? (
134
- <AvatarTextDecorator avatarText={getAvatarText(text)} size={size} />
161
+ <AvatarTextDecorator
162
+ avatarText={getAvatarText(text)}
163
+ size={size}
164
+ className={classNames?.text}
165
+ />
135
166
  ) : null}
136
167
  </div>
137
168
  );
@@ -162,7 +193,7 @@ export const Avatar = ({
162
193
  style={style}
163
194
  >
164
195
  {ring ? (
165
- <div className={css.ring}>
196
+ <div className={classify(css.ring, classNames?.ring)}>
166
197
  <div className={css.whiteCircle}>
167
198
  <AvatarConditionalContent
168
199
  imageSrc={imageSrc}
@@ -173,6 +204,7 @@ export const Avatar = ({
173
204
  size={size}
174
205
  status={status}
175
206
  statusBorderColorToken={statusBorderColorToken}
207
+ classNames={classNames}
176
208
  />
177
209
  </div>
178
210
  </div>
@@ -186,6 +218,7 @@ export const Avatar = ({
186
218
  size={size}
187
219
  status={status}
188
220
  statusBorderColorToken={statusBorderColorToken}
221
+ classNames={classNames}
189
222
  />
190
223
  )}
191
224
  </div>
@@ -210,6 +243,10 @@ export const BaseAvatar = ({
210
243
  )}
211
244
  style={{...style, background: AVATAR_COLOR[color]}}
212
245
  >
213
- <AvatarTextDecorator avatarText={text} size={size} />
246
+ <AvatarTextDecorator
247
+ avatarText={text}
248
+ size={size}
249
+ className={classNames?.text}
250
+ />
214
251
  </div>
215
252
  );
@@ -1,4 +1,4 @@
1
- @value (colorFillPrimary, colorBackgroundTertiary, colorInformation) from '../../styles/variables/_color.css';
1
+ @value (colorFillPrimary, colorBackgroundTertiary, colorInformation, colorInformationLightest) from '../../styles/variables/_color.css';
2
2
  @value ( size34, size42, size60, sizeFluid) from '../../styles/variables/_size.css';
3
3
  @value (borderRadiusCircle, borderRadiusLarge, borderRadiusXLarge, borderWidthSecondary) from '../../styles/variables/_border.css';
4
4
  @value (spaceNone, spaceXXSmall, spaceXSmall) from '../../styles/variables/_space.css';
@@ -78,6 +78,7 @@
78
78
  }
79
79
 
80
80
  .innerContainer {
81
+ --background-color: colorInformationLightest;
81
82
  display: flex;
82
83
  position: relative;
83
84
  border-radius: borderRadiusCircle;
@@ -85,6 +86,7 @@
85
86
  height: sizeFluid;
86
87
  align-items: center;
87
88
  justify-content: center;
89
+ background: var(--background-color);
88
90
  }
89
91
 
90
92
  .statusIndicatorWrapper {
@@ -18,27 +18,26 @@ const SearchInput = _ref => {
18
18
  locked,
19
19
  placeholder = 'Search...',
20
20
  classNames,
21
+ onClear,
21
22
  ...searchInputProps
22
23
  } = _ref;
23
- const [searchValue, setSearchValue] = React.useState(value);
24
- React.useEffect(() => {
25
- setSearchValue(value);
26
- }, [value]);
27
24
  const handleClearClick = () => {
28
- setSearchValue('');
25
+ onClear?.();
29
26
  };
30
- return /*#__PURE__*/React.createElement(_Input.Input, _extends({}, searchInputProps, {
27
+ return /*#__PURE__*/React.createElement(_Input.Input, _extends({
28
+ type: "text"
29
+ }, searchInputProps, {
31
30
  classNames: {
32
31
  ...classNames,
33
- iconRight: searchValue && !(disabled || locked) ? _SearchInputModule.default.clickable : '',
34
- iconLeft: searchValue && !disabled ? _SearchInputModule.default.primaryText : ''
32
+ iconRight: value && !(disabled || locked) ? _SearchInputModule.default.clickable : '',
33
+ iconLeft: value && !disabled ? _SearchInputModule.default.primaryText : ''
35
34
  },
36
35
  placeholder: placeholder,
37
- value: searchValue,
36
+ value: value,
38
37
  disabled: disabled,
39
38
  locked: locked,
40
39
  iconLeftName: "magnifying-glass",
41
- iconRightName: searchValue && !(disabled || locked) ? 'xmark' : 'fw',
40
+ iconRightName: value && !(disabled || locked) ? 'xmark' : 'fw',
42
41
  onIconRightClick: handleClearClick
43
42
  }));
44
43
  };
@@ -33,6 +33,7 @@ export type SearchInputProps = {
33
33
  onPaste?: (e: ClipboardEvent) => mixed,
34
34
  onPaste?: (e: ClipboardEvent) => mixed,
35
35
  onContainerClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
36
+ onClear?: () => void,
36
37
  };
37
38
 
38
39
  export const SearchInput = ({
@@ -41,32 +42,28 @@ export const SearchInput = ({
41
42
  locked,
42
43
  placeholder = 'Search...',
43
44
  classNames,
45
+ onClear,
44
46
  ...searchInputProps
45
47
  }: SearchInputProps): React.Node => {
46
- const [searchValue, setSearchValue] = React.useState(value);
47
-
48
- React.useEffect(() => {
49
- setSearchValue(value);
50
- }, [value]);
51
-
52
48
  const handleClearClick = () => {
53
- setSearchValue('');
49
+ onClear?.();
54
50
  };
55
51
 
56
52
  return (
57
53
  <Input
54
+ type="text"
58
55
  {...searchInputProps}
59
56
  classNames={{
60
57
  ...classNames,
61
- iconRight: searchValue && !(disabled || locked) ? css.clickable : '',
62
- iconLeft: searchValue && !disabled ? css.primaryText : '',
58
+ iconRight: value && !(disabled || locked) ? css.clickable : '',
59
+ iconLeft: value && !disabled ? css.primaryText : '',
63
60
  }}
64
61
  placeholder={placeholder}
65
- value={searchValue}
62
+ value={value}
66
63
  disabled={disabled}
67
64
  locked={locked}
68
65
  iconLeftName="magnifying-glass"
69
- iconRightName={searchValue && !(disabled || locked) ? 'xmark' : 'fw'}
66
+ iconRightName={value && !(disabled || locked) ? 'xmark' : 'fw'}
70
67
  onIconRightClick={handleClearClick}
71
68
  />
72
69
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {