@itcase/ui 1.0.97 → 1.0.100

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.
@@ -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 {
@@ -0,0 +1,21 @@
1
+ .response {
2
+ display: flex;
3
+ flex-flow: column nowrap;
4
+ justify-content: center;
5
+ align-items: center;
6
+ gap: 32px;
7
+ &__desc {
8
+ display: flex;
9
+ flex-direction: column;
10
+ justify-content: center;
11
+ align-items: center;
12
+ gap: 16px;
13
+ }
14
+ &__button {
15
+ display: flex;
16
+ flex-direction: column;
17
+ justify-content: center;
18
+ align-items: center;
19
+ gap: 16px;
20
+ }
21
+ }
@@ -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
  }
@@ -844,8 +844,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
844
844
  if (domElement) {
845
845
  const win = getWindow(domElement);
846
846
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
847
- let currentIFrame = win.frameElement;
848
- while (currentIFrame && offsetParent && offsetWin !== win) {
847
+ let currentWin = win;
848
+ let currentIFrame = currentWin.frameElement;
849
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
849
850
  const iframeScale = getScale(currentIFrame);
850
851
  const iframeRect = currentIFrame.getBoundingClientRect();
851
852
  const css = getComputedStyle(currentIFrame);
@@ -857,7 +858,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
857
858
  height *= iframeScale.y;
858
859
  x += left;
859
860
  y += top;
860
- currentIFrame = getWindow(currentIFrame).frameElement;
861
+ currentWin = getWindow(currentIFrame);
862
+ currentIFrame = currentWin.frameElement;
861
863
  }
862
864
  }
863
865
  return rectToClientRect({
@@ -869,27 +871,14 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
869
871
  }
870
872
 
871
873
  const topLayerSelectors = [':popover-open', ':modal'];
872
- function topLayer(floating) {
873
- let isTopLayer = false;
874
- let x = 0;
875
- let y = 0;
876
- function setIsTopLayer(selector) {
874
+ function isTopLayer(floating) {
875
+ return topLayerSelectors.some(selector => {
877
876
  try {
878
- isTopLayer = isTopLayer || floating.matches(selector);
879
- } catch (e) {}
880
- }
881
- topLayerSelectors.forEach(selector => {
882
- setIsTopLayer(selector);
883
- });
884
- if (isTopLayer) {
885
- const containingBlock = getContainingBlock(floating);
886
- if (containingBlock) {
887
- const rect = containingBlock.getBoundingClientRect();
888
- x = rect.x;
889
- y = rect.y;
877
+ return floating.matches(selector);
878
+ } catch (e) {
879
+ return false;
890
880
  }
891
- }
892
- return [isTopLayer, x, y];
881
+ });
893
882
  }
894
883
 
895
884
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
@@ -899,9 +888,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
899
888
  offsetParent,
900
889
  strategy
901
890
  } = _ref;
891
+ const isFixed = strategy === 'fixed';
902
892
  const documentElement = getDocumentElement(offsetParent);
903
- const [isTopLayer] = elements ? topLayer(elements.floating) : [false];
904
- if (offsetParent === documentElement || isTopLayer) {
893
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
894
+ if (offsetParent === documentElement || topLayer && isFixed) {
905
895
  return rect;
906
896
  }
907
897
  let scroll = {
@@ -911,7 +901,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
911
901
  let scale = createCoords(1);
912
902
  const offsets = createCoords(0);
913
903
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
914
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
904
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
915
905
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
916
906
  scroll = getNodeScroll(offsetParent);
917
907
  }
@@ -1102,7 +1092,7 @@ function getDimensions(element) {
1102
1092
  };
1103
1093
  }
1104
1094
 
1105
- function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating) {
1095
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1106
1096
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
1107
1097
  const documentElement = getDocumentElement(offsetParent);
1108
1098
  const isFixed = strategy === 'fixed';
@@ -1124,17 +1114,8 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating
1124
1114
  offsets.x = getWindowScrollBarX(documentElement);
1125
1115
  }
1126
1116
  }
1127
- let x = rect.left + scroll.scrollLeft - offsets.x;
1128
- let y = rect.top + scroll.scrollTop - offsets.y;
1129
- const [isTopLayer, topLayerX, topLayerY] = topLayer(floating);
1130
- if (isTopLayer) {
1131
- x += topLayerX;
1132
- y += topLayerY;
1133
- if (isOffsetParentAnElement) {
1134
- x += offsetParent.clientLeft;
1135
- y += offsetParent.clientTop;
1136
- }
1137
- }
1117
+ const x = rect.left + scroll.scrollLeft - offsets.x;
1118
+ const y = rect.top + scroll.scrollTop - offsets.y;
1138
1119
  return {
1139
1120
  x,
1140
1121
  y,
@@ -1157,7 +1138,7 @@ function getTrueOffsetParent(element, polyfill) {
1157
1138
  // such as table ancestors and cross browser bugs.
1158
1139
  function getOffsetParent(element, polyfill) {
1159
1140
  const window = getWindow(element);
1160
- if (!isHTMLElement(element)) {
1141
+ if (!isHTMLElement(element) || isTopLayer(element)) {
1161
1142
  return window;
1162
1143
  }
1163
1144
  let offsetParent = getTrueOffsetParent(element, polyfill);
@@ -1174,7 +1155,7 @@ const getElementRects = async function (data) {
1174
1155
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1175
1156
  const getDimensionsFn = this.getDimensions;
1176
1157
  return {
1177
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy, data.floating),
1158
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1178
1159
  floating: {
1179
1160
  x: 0,
1180
1161
  y: 0,
@@ -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
+ }