@itcase/ui 1.0.97 → 1.0.99

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.
@@ -41,11 +41,12 @@ const tooltipConfig = {
41
41
  tooltipConfig.appearance = newComponent;
42
42
  }
43
43
  };
44
- function Tooltip(props) {
44
+ const Tooltip = /*#__PURE__*/React__default.default.forwardRef(function Tooltip(props, ref) {
45
45
  const {
46
46
  before,
47
47
  after,
48
48
  appearance,
49
+ children,
49
50
  className,
50
51
  text,
51
52
  title,
@@ -57,6 +58,37 @@ function Tooltip(props) {
57
58
  textColor,
58
59
  textSize
59
60
  } = props;
61
+ const tooltipTimeoutHideRef = React.useRef(null);
62
+ const isTooltipCloseAnimationInProgressRef = React.useRef(false);
63
+ const [isTooltipVisible, setIsTooltipVisible] = React.useState(null);
64
+ const openTooltip = React.useCallback(() => {
65
+ if (!isTooltipCloseAnimationInProgressRef.current) {
66
+ clearTimeout(tooltipTimeoutHideRef.current);
67
+ setIsTooltipVisible(true);
68
+ }
69
+ }, []);
70
+ const closeTooltip = React.useCallback(() => {
71
+ // Make a small delay to be able to move cursor on the tooltip without
72
+ // triggering a close, because the label and the tooltip have space between
73
+ tooltipTimeoutHideRef.current = setTimeout(() => {
74
+ setIsTooltipVisible(prevState => {
75
+ const newState = false;
76
+ if (prevState === true) {
77
+ isTooltipCloseAnimationInProgressRef.current = true;
78
+ }
79
+ return newState;
80
+ });
81
+ }, 250);
82
+ }, []);
83
+ const onAnimationEnd = React.useCallback(() => {
84
+ isTooltipCloseAnimationInProgressRef.current = false;
85
+ }, []);
86
+ React.useImperativeHandle(ref, () => ({
87
+ openTooltip,
88
+ closeTooltip
89
+ }), [openTooltip, closeTooltip]);
90
+
91
+ /* STYLES */
60
92
  const alignDirectionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
61
93
  prefix: 'align_',
62
94
  propsKey: 'alignDirection'
@@ -89,31 +121,50 @@ function Tooltip(props) {
89
121
  prefix: 'border_type_',
90
122
  propsKey: 'borderType'
91
123
  });
124
+ const elevationClass = useDeviceTargetClass.useDeviceTargetClass(props, {
125
+ prefix: 'elevation_',
126
+ propsKey: 'elevation'
127
+ });
128
+ const widthClass = useDeviceTargetClass.useDeviceTargetClass(props, {
129
+ prefix: 'width_',
130
+ propsKey: 'width'
131
+ });
132
+ const alignmentClass = useDeviceTargetClass.useDeviceTargetClass(props, {
133
+ prefix: 'alignment_',
134
+ propsKey: 'alignment'
135
+ });
92
136
  const {
93
137
  styles: tooltipStyles
94
138
  } = useStyles.useStyles(props);
139
+ const tooltipAppearanceItem = tooltipConfig.appearance[appearance] || {};
95
140
  return /*#__PURE__*/React__default.default.createElement("div", {
96
- className: clsx__default.default(className, 'tooltip', fillClass || tooltipConfig.appearance[appearance] && `fill_${tooltipConfig.appearance[appearance].fillClass}`.replace(/([A-Z])/g, '-$1').toLowerCase(), shapeClass, alignDirectionClass, alignClass, borderWidthClass, borderColorClass, borderTypeClass, sizeClass, arrowPosition && `tooltip_type_arrow tooltip_arrow_position_${arrowPosition}`, type && `tooltip_type_${type}`, set && `tooltip_set_${set}`),
97
- style: tooltipStyles
141
+ className: clsx__default.default(className, 'tooltip', isTooltipVisible === true && 'tooltip_state_open', isTooltipVisible === false && 'tooltip_state_close', fillClass || tooltipAppearanceItem.fillClass && `fill_${tooltipAppearanceItem.fillClass}`.replace(/([A-Z])/g, '-$1').toLowerCase(), shapeClass, alignDirectionClass, alignClass, alignmentClass, borderWidthClass, borderColorClass, borderTypeClass, elevationClass, sizeClass, arrowPosition && `tooltip_type_arrow tooltip_arrow_position_${arrowPosition}`, type && `tooltip_type_${type}`, set && `tooltip_set_${set}`, widthClass),
142
+ style: tooltipStyles,
143
+ onAnimationEnd: onAnimationEnd
98
144
  }, before, /*#__PURE__*/React__default.default.createElement("div", {
99
145
  className: "tooltip__inner"
100
146
  }, title && /*#__PURE__*/React__default.default.createElement(index.Title, {
101
147
  className: "tooltip__title",
102
148
  size: titleSize,
103
- textColor: titleTextColor || tooltipConfig.appearance[appearance]?.titleTextColor
149
+ textColor: titleTextColor || tooltipAppearanceItem.titleTextColor
104
150
  }, title), text && /*#__PURE__*/React__default.default.createElement(index$1.Text, {
105
151
  className: "tooltip__text",
106
152
  size: textSize,
107
- textColor: textColor || tooltipConfig.appearance[appearance]?.textColor
108
- }, text)), after);
109
- }
153
+ textColor: textColor || tooltipAppearanceItem.textColor
154
+ }, text), children), after);
155
+ });
110
156
  Tooltip.propTypes = {
157
+ after: PropTypes__default.default.string,
158
+ appearance: PropTypes__default.default.string,
159
+ arrowPosition: PropTypes__default.default.string,
160
+ before: PropTypes__default.default.string,
111
161
  children: PropTypes__default.default.any,
112
162
  className: PropTypes__default.default.string,
113
163
  fill: PropTypes__default.default.oneOf(fill.default),
114
164
  fillDesktop: PropTypes__default.default.oneOf(fill.default),
115
165
  fillMobile: PropTypes__default.default.oneOf(fill.default),
116
166
  fillTablet: PropTypes__default.default.oneOf(fill.default),
167
+ set: PropTypes__default.default.string,
117
168
  shape: PropTypes__default.default.oneOf(shape.default),
118
169
  shapeDesktop: PropTypes__default.default.oneOf(shape.default),
119
170
  shapeMobile: PropTypes__default.default.oneOf(shape.default),
@@ -128,20 +179,42 @@ Tooltip.propTypes = {
128
179
  textSizeDesktop: PropTypes__default.default.oneOf(size.default),
129
180
  textSizeMobile: PropTypes__default.default.oneOf(size.default),
130
181
  textSizeTablet: PropTypes__default.default.oneOf(size.default),
182
+ title: PropTypes__default.default.string,
183
+ titleSize: PropTypes__default.default.string,
184
+ titleTextColor: PropTypes__default.default.string,
131
185
  type: PropTypes__default.default.string
132
186
  };
133
- Tooltip.defaultProps = {
134
- label: 'Label'
135
- };
187
+ Tooltip.defaultProps = {};
136
188
  Tooltip.__docgenInfo = {
137
189
  "description": "",
138
190
  "methods": [],
139
191
  "displayName": "Tooltip",
140
192
  "props": {
141
- "label": {
142
- "defaultValue": {
143
- "value": "'Label'",
144
- "computed": false
193
+ "after": {
194
+ "description": "",
195
+ "type": {
196
+ "name": "string"
197
+ },
198
+ "required": false
199
+ },
200
+ "appearance": {
201
+ "description": "",
202
+ "type": {
203
+ "name": "string"
204
+ },
205
+ "required": false
206
+ },
207
+ "arrowPosition": {
208
+ "description": "",
209
+ "type": {
210
+ "name": "string"
211
+ },
212
+ "required": false
213
+ },
214
+ "before": {
215
+ "description": "",
216
+ "type": {
217
+ "name": "string"
145
218
  },
146
219
  "required": false
147
220
  },
@@ -195,6 +268,13 @@ Tooltip.__docgenInfo = {
195
268
  },
196
269
  "required": false
197
270
  },
271
+ "set": {
272
+ "description": "",
273
+ "type": {
274
+ "name": "string"
275
+ },
276
+ "required": false
277
+ },
198
278
  "shape": {
199
279
  "description": "",
200
280
  "type": {
@@ -319,6 +399,27 @@ Tooltip.__docgenInfo = {
319
399
  },
320
400
  "required": false
321
401
  },
402
+ "title": {
403
+ "description": "",
404
+ "type": {
405
+ "name": "string"
406
+ },
407
+ "required": false
408
+ },
409
+ "titleSize": {
410
+ "description": "",
411
+ "type": {
412
+ "name": "string"
413
+ },
414
+ "required": false
415
+ },
416
+ "titleTextColor": {
417
+ "description": "",
418
+ "type": {
419
+ "name": "string"
420
+ },
421
+ "required": false
422
+ },
322
423
  "type": {
323
424
  "description": "",
324
425
  "type": {
@@ -14,6 +14,13 @@
14
14
  bottom: 0;
15
15
  }
16
16
  }
17
+ &__dropdown {
18
+ margin: 10px 0 0 0;
19
+ position: absolute;
20
+ left: 0;
21
+ top: 100%;
22
+ z-index: 100;
23
+ }
17
24
  }
18
25
  .avatar {
19
26
  &&_mode {
@@ -1,5 +1,6 @@
1
1
  .cell {
2
2
  &__wrapper {
3
+ min-width: auto;
3
4
  ^&__data {
4
5
  display: flex;
5
6
  flex-flow: row nowrap;
@@ -74,6 +74,14 @@
74
74
  }
75
75
  }
76
76
 
77
+ .group {
78
+ ^& .width {
79
+ &_fixed {
80
+ width: 300px;
81
+ }
82
+ }
83
+ }
84
+
77
85
  .group {
78
86
  &_wrap {
79
87
  @each $val in nowrap, wrap, wrap-reverse {
@@ -1,11 +1,14 @@
1
1
  .label {
2
2
  position: relative;
3
- overflow: hidden;
4
3
  display: inline-flex;
5
4
  &__inner {
6
5
  width: 100%;
7
6
  font-size: 0;
8
7
  line-height: 0;
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+ gap: 4px;
9
12
  }
10
13
  }
11
14
  .label {
@@ -59,6 +62,11 @@
59
62
  }
60
63
  }
61
64
  }
65
+ div.label {
66
+ &__tooltip {
67
+ z-index: 12;
68
+ }
69
+ }
62
70
  .label {
63
71
  &&_text-align {
64
72
  &_left {
@@ -1,7 +1,9 @@
1
1
  .tooltip {
2
+ width: fit-content;
2
3
  position: relative;
3
4
  display: flex;
4
- animation: 0.5s tooltipShowAnimation ease;
5
+ visibility: hidden;
6
+ opacity: 0%;
5
7
  }
6
8
 
7
9
  @keyframes tooltipShowAnimation {
@@ -15,6 +17,17 @@
15
17
  }
16
18
  }
17
19
 
20
+ @keyframes tooltipHideAnimation {
21
+ 0% {
22
+ visibility: visible;
23
+ opacity: 100%;
24
+ }
25
+ 100% {
26
+ visibility: hidden;
27
+ opacity: 0%;
28
+ }
29
+ }
30
+
18
31
  .tooltip {
19
32
  &_size {
20
33
  @each $size in s, m, l {
@@ -44,16 +57,17 @@
44
57
  ^&__inner {
45
58
  position: relative;
46
59
  background-color: inherit;
60
+ z-index: 1;
47
61
  }
48
62
  &::after {
49
63
  content: '';
50
64
  display: block;
51
65
  position: absolute;
52
- background-color: inherit;
66
+ background-color: var(--tooltip-arrow-color, #fff);
53
67
  width: var(--tooltip-arrow-width);
54
68
  height: var(--tooltip-arrow-height);
55
69
  border-radius: var(--tooltip-arrow-radius);
56
- z-index: -1;
70
+ z-index: 0;
57
71
  }
58
72
  }
59
73
  }
@@ -91,6 +105,24 @@
91
105
  }
92
106
  }
93
107
 
108
+ .tooltip {
109
+ &&_state_close {
110
+ visibility: hidden;
111
+ animation-duration: 0.2s;
112
+ animation-name: tooltipHideAnimation;
113
+ opacity: 0%;
114
+ }
115
+ }
116
+
117
+ .tooltip {
118
+ &&_state_open {
119
+ visibility: visible;
120
+ animation-duration: 0.5s;
121
+ animation-name: tooltipShowAnimation;
122
+ opacity: 100%;
123
+ }
124
+ }
125
+
94
126
  :root {
95
127
  --tooltip-size-m-padding: 0;
96
128
  --tooltip-size-s-padding: 0;
@@ -101,4 +133,6 @@
101
133
  --tooltip-arrow-width: 14px;
102
134
  --tooltip-arrow-height: 14px;
103
135
  --tooltip-arrow-radius: 2px;
136
+
137
+ --tooltip-arrow-color: var(--color-surface-primary);
104
138
  }
@@ -0,0 +1,179 @@
1
+ import { Avatar } from '@itcase/ui/components/Avatar'
2
+ import {
3
+ fillHoverProps,
4
+ fillProps,
5
+ iconFillSizeProps,
6
+ iconSizeProps,
7
+ shapeProps,
8
+ sizePXProps,
9
+ textColorProps,
10
+ textSizeProps,
11
+ textWeightProps,
12
+ } from '@itcase/ui/constants'
13
+
14
+ export default {
15
+ title: 'Atoms / Avatar',
16
+ component: Avatar,
17
+ argTypes: {
18
+ advancedProps: { control: 'boolean' },
19
+ className: {
20
+ if: { arg: 'advancedProps' },
21
+ },
22
+ children: {
23
+ if: { arg: 'advancedProps' },
24
+ },
25
+ src: {
26
+ type: 'select',
27
+ options: ['assets/avatar/woman.png', 'assets/avatar/man.png'],
28
+ if: { arg: 'type', eq: 'image' },
29
+ },
30
+ onClick: {
31
+ if: { arg: 'advancedProps' },
32
+ },
33
+ shape: {
34
+ control: 'inline-radio',
35
+ options: shapeProps,
36
+ },
37
+ iconSrc: {
38
+ control: 'select',
39
+ options: [null, 'assets/40/close.svg'],
40
+ },
41
+ textSize: {
42
+ control: 'select',
43
+ options: textSizeProps,
44
+ if: { arg: 'type', eq: 'text' },
45
+ },
46
+ textColor: {
47
+ control: 'select',
48
+ options: textColorProps,
49
+ if: { arg: 'type', eq: 'text' },
50
+ },
51
+ textWeight: {
52
+ control: 'select',
53
+ options: textWeightProps,
54
+ if: { arg: 'type', eq: 'text' },
55
+ },
56
+
57
+ iconFill: {
58
+ control: 'select',
59
+ options: fillProps,
60
+ if: { arg: 'iconSrc', neq: null },
61
+ },
62
+ iconFillHover: {
63
+ options: fillHoverProps,
64
+ control: 'select',
65
+ if: { arg: 'iconSrc', neq: null },
66
+ },
67
+ iconItemFill: {
68
+ options: fillProps,
69
+ control: 'select',
70
+ if: { arg: 'iconSrc', neq: null },
71
+ },
72
+ iconSize: {
73
+ options: iconSizeProps,
74
+ control: 'inline-radio',
75
+ if: { arg: 'iconSrc', neq: null },
76
+ },
77
+ iconShape: {
78
+ options: shapeProps,
79
+ control: 'inline-radio',
80
+ if: { arg: 'iconSrc', neq: null },
81
+ },
82
+ iconFillSize: {
83
+ options: iconFillSizeProps,
84
+ control: 'inline-radio',
85
+ if: { arg: 'iconSrc', neq: null },
86
+ },
87
+ fill: {
88
+ options: fillProps,
89
+ control: 'select',
90
+ if: { arg: 'type', eq: 'text' },
91
+ },
92
+ size: {
93
+ options: sizePXProps,
94
+ control: 'inline-radio',
95
+ },
96
+ type: {
97
+ options: ['image', 'text'],
98
+ control: 'inline-radio',
99
+ },
100
+ firstName: {
101
+ if: { arg: 'type', eq: 'text' },
102
+ },
103
+ secondName: {
104
+ if: { arg: 'type', eq: 'text' },
105
+ },
106
+ mode: {
107
+ options: [null, 'skeleton'],
108
+ control: 'inline-radio',
109
+ },
110
+ },
111
+ args: {
112
+ advancedProps: false,
113
+ onClick: '',
114
+ className: '',
115
+ children: [],
116
+ shape: 'circular',
117
+ fill: 'surfaceTertiary',
118
+ size: 96,
119
+ },
120
+ }
121
+
122
+ const ImageProps = {
123
+ src: 'assets/avatar/woman.png',
124
+ type: 'image',
125
+ }
126
+
127
+ const IconProps = {
128
+ iconSrc: 'assets/40/close.svg',
129
+ iconSize: 40,
130
+ iconFill: 'accentPrimary',
131
+ iconFillHover: 'accentPrimaryHover',
132
+ iconFillSize: 40,
133
+ iconItemFill: 'accentItemPrimary',
134
+ iconItemFillHover: 'accentItemPrimaryHover',
135
+ iconShape: 'circular',
136
+ }
137
+
138
+ export const Default = {
139
+ args: {
140
+ ...ImageProps,
141
+ ...IconProps,
142
+ },
143
+ }
144
+
145
+ export const Image = {
146
+ args: {
147
+ ...ImageProps,
148
+ },
149
+ }
150
+
151
+ export const ImageWithIcon = {
152
+ args: {
153
+ ...ImageProps,
154
+ ...IconProps,
155
+ },
156
+ }
157
+
158
+ export const Text = {
159
+ args: {
160
+ firstName: 'John',
161
+ secondName: 'Doe',
162
+ textWeight: 600,
163
+ type: 'text',
164
+ },
165
+ }
166
+
167
+ export const TextWithIcon = {
168
+ args: {
169
+ ...Text.args,
170
+ ...IconProps,
171
+ },
172
+ }
173
+
174
+ export const SkeletonMode = {
175
+ args: {
176
+ ...Text.args,
177
+ mode: 'skeleton',
178
+ },
179
+ }