@papillonarts/components 0.44.0 → 0.46.0
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/build/Modern/Avatar/Avatar.d.ts +28 -0
- package/build/Modern/Avatar/Avatar.d.ts.map +1 -0
- package/build/Modern/Avatar/Avatar.docs.json +51 -0
- package/build/Modern/Avatar/Avatar.js +56 -0
- package/build/Modern/Avatar/Avatar.module.scss +36 -0
- package/build/Modern/Avatar/__tests__/Avatar.doc.md +110 -0
- package/build/Modern/Avatar/index.d.ts +3 -0
- package/build/Modern/Avatar/index.d.ts.map +1 -0
- package/build/Modern/Avatar/index.js +12 -0
- package/build/Modern/AvatarStack/AvatarStack.d.ts +14 -0
- package/build/Modern/AvatarStack/AvatarStack.d.ts.map +1 -0
- package/build/Modern/AvatarStack/AvatarStack.docs.json +81 -0
- package/build/Modern/AvatarStack/AvatarStack.js +155 -0
- package/build/Modern/AvatarStack/AvatarStack.module.scss +270 -0
- package/build/Modern/AvatarStack/__tests__/AvatarStack.doc.md +194 -0
- package/build/Modern/AvatarStack/index.d.ts +3 -0
- package/build/Modern/AvatarStack/index.d.ts.map +1 -0
- package/build/Modern/AvatarStack/index.js +12 -0
- package/build/Modern/index.d.ts +14 -0
- package/build/Modern/index.d.ts.map +1 -1
- package/build/Modern/index.js +8 -0
- package/build/Modern/type.d.ts +1 -0
- package/build/Modern/type.d.ts.map +1 -1
- package/build/Modern/utils/hasInteractiveNodes.d.ts +11 -0
- package/build/Modern/utils/hasInteractiveNodes.d.ts.map +1 -0
- package/build/Modern/utils/hasInteractiveNodes.js +64 -0
- package/build/Modern/utils/testing.d.ts +2 -0
- package/build/Modern/utils/testing.d.ts.map +1 -0
- package/build/Modern/utils/testing.js +29 -0
- package/build/Modern/utils/types/ViewportRangeKeys.d.ts +3 -0
- package/build/Modern/utils/types/ViewportRangeKeys.d.ts.map +1 -0
- package/build/Modern/utils/types/ViewportRangeKeys.js +5 -0
- package/build/Modern/utils/types/index.d.ts +1 -0
- package/build/Modern/utils/types/index.d.ts.map +1 -1
- package/build/Modern/utils/types/index.js +11 -0
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/* stylelint-disable selector-max-specificity, custom-property-pattern, no-descending-specificity, selector-not-notation */
|
|
2
|
+
.AvatarStack {
|
|
3
|
+
--avatar-border-width: 1px;
|
|
4
|
+
--mask-size: calc(100% + (var(--avatar-border-width) * 2));
|
|
5
|
+
--mask-start: -1;
|
|
6
|
+
--opacity-step: 15%;
|
|
7
|
+
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
min-width: var(--avatar-stack-size);
|
|
11
|
+
height: var(--avatar-stack-size);
|
|
12
|
+
isolation: isolate;
|
|
13
|
+
|
|
14
|
+
&:where([data-variant='cascade']) {
|
|
15
|
+
--overlap-size: calc(var(--avatar-stack-size) * 0.55);
|
|
16
|
+
--overlap-size-avatar-three-plus: calc(var(--avatar-stack-size) * 0.85);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:where([data-variant='stack']) {
|
|
20
|
+
--overlap-size: calc(var(--avatar-stack-size) * 0.55);
|
|
21
|
+
--overlap-size-avatar-three-plus: calc(var(--avatar-stack-size) * 0.55);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:where([data-responsive]) {
|
|
25
|
+
@media screen and (--viewportRange-narrow) {
|
|
26
|
+
--avatar-stack-size: var(--stackSize-narrow);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media screen and (--viewportRange-regular) {
|
|
30
|
+
--avatar-stack-size: var(--stackSize-regular);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@media screen and (--viewportRange-wide) {
|
|
34
|
+
--avatar-stack-size: var(--stackSize-wide);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:where([data-avatar-count='1'][data-shape='circle']) {
|
|
39
|
+
.AvatarItem:where([data-component='Avatar']) {
|
|
40
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
41
|
+
box-shadow: 0 0 0 var(--avatar-border-width) var(--avatar-borderColor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:where([data-avatar-count='1'][data-shape='square']) .AvatarItem {
|
|
46
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
47
|
+
box-shadow: 1px 0 rgb(0, 0, 0, 1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:where([data-avatar-count='1'][data-shape='square'][data-align-right]) .AvatarItem {
|
|
51
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
52
|
+
box-shadow: -1px 0 rgb(0, 0, 0, 1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:where([data-avatar-count='2']) {
|
|
56
|
+
/*
|
|
57
|
+
MIN-WIDTH CALC FORMULA EXPLAINED:
|
|
58
|
+
avatar size ➡️ var(--avatar-stack-size)
|
|
59
|
+
plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
|
|
60
|
+
*/
|
|
61
|
+
min-width: calc(var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:where([data-avatar-count='3'][data-variant='cascade']) {
|
|
65
|
+
/*
|
|
66
|
+
MIN-WIDTH CALC FORMULA EXPLAINED:
|
|
67
|
+
avatar size ➡️ var(--avatar-stack-size)
|
|
68
|
+
plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
|
|
69
|
+
plus the visible part of the 3rd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)
|
|
70
|
+
*/
|
|
71
|
+
min-width: calc(
|
|
72
|
+
var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)) +
|
|
73
|
+
(var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:where([data-avatar-count='3'][data-variant='stack']) {
|
|
78
|
+
/*
|
|
79
|
+
MIN-WIDTH CALC FORMULA EXPLAINED:
|
|
80
|
+
avatar size ➡️ var(--avatar-stack-size)
|
|
81
|
+
plus the visible part of the 2nd avatar & 3rd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus) * 2
|
|
82
|
+
*/
|
|
83
|
+
min-width: calc(var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 2);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:where([data-avatar-count='3+'][data-variant='cascade']) {
|
|
87
|
+
/*
|
|
88
|
+
MIN-WIDTH CALC FORMULA EXPLAINED:
|
|
89
|
+
avatar size ➡️ var(--avatar-stack-size)
|
|
90
|
+
plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
|
|
91
|
+
plus the visible part of the 3rd AND 4th avatar ➡️ (var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 2
|
|
92
|
+
*/
|
|
93
|
+
min-width: calc(
|
|
94
|
+
var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)) +
|
|
95
|
+
(var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 2
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:where([data-avatar-count='3+'][data-variant='stack']) {
|
|
100
|
+
/*
|
|
101
|
+
MIN-WIDTH CALC FORMULA EXPLAINED:
|
|
102
|
+
avatar size ➡️ var(--avatar-stack-size)
|
|
103
|
+
plus the visible part of the 2nd to 4th avatars ➡️ var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus) * 3
|
|
104
|
+
*/
|
|
105
|
+
min-width: calc(var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 3);
|
|
106
|
+
|
|
107
|
+
--overlap-size: var(--overlap-size-avatar-three-plus);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&:where([data-align-right]) {
|
|
111
|
+
--mask-start: 1;
|
|
112
|
+
|
|
113
|
+
direction: rtl;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.AvatarStackBody {
|
|
118
|
+
position: absolute;
|
|
119
|
+
display: flex;
|
|
120
|
+
|
|
121
|
+
&:where([data-disable-expand]) {
|
|
122
|
+
position: relative;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.AvatarItem {
|
|
127
|
+
--avatarSize-regular: var(--avatar-stack-size);
|
|
128
|
+
|
|
129
|
+
position: relative;
|
|
130
|
+
display: flex;
|
|
131
|
+
width: var(--avatar-stack-size);
|
|
132
|
+
height: var(--avatar-stack-size);
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
flex-shrink: 0;
|
|
135
|
+
transition:
|
|
136
|
+
margin 0.2s ease-in-out,
|
|
137
|
+
opacity 0.2s ease-in-out,
|
|
138
|
+
mask-position 0.2s ease-in-out,
|
|
139
|
+
mask-size 0.2s ease-in-out;
|
|
140
|
+
|
|
141
|
+
.AvatarStack:where([data-shape='circle']) &:is(img) {
|
|
142
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
143
|
+
box-shadow: 0 0 0 var(--avatar-border-width) transparent;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&:not([data-component='Avatar']):not(:has([data-square])) {
|
|
147
|
+
border-radius: 50%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.AvatarStack:where([data-shape='square']) &:is(img) {
|
|
151
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
152
|
+
box-shadow: 1px 0 rgb(255, 255, 255, 1);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.AvatarStack:where([data-shape='square'][data-align-right]) &:is(img) {
|
|
156
|
+
/* stylelint-disable-next-line primer/box-shadow */
|
|
157
|
+
box-shadow: -1px 0 rgb(255, 255, 255, 1);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&:first-child {
|
|
161
|
+
margin-inline-start: 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&:nth-child(n + 2) {
|
|
165
|
+
/* stylelint-disable-next-line primer/spacing */
|
|
166
|
+
margin-inline-start: calc(var(--overlap-size) * -1);
|
|
167
|
+
mask-repeat: no-repeat, no-repeat;
|
|
168
|
+
mask-size:
|
|
169
|
+
var(--mask-size) var(--mask-size),
|
|
170
|
+
auto;
|
|
171
|
+
mask-composite: exclude;
|
|
172
|
+
|
|
173
|
+
/*
|
|
174
|
+
HORIZONTAL POSITION CALC FORMULA EXPLAINED:
|
|
175
|
+
width of the visible part of the avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
|
|
176
|
+
multiply by -1 for left-aligned, 1 for right-aligned ➡️ var(--mask-start)
|
|
177
|
+
subtract the avatar border width ➡️ var(--avatar-border-width)
|
|
178
|
+
*/
|
|
179
|
+
mask-position:
|
|
180
|
+
calc((var(--avatar-stack-size) - var(--overlap-size)) * var(--mask-start) - var(--avatar-border-width)) center,
|
|
181
|
+
0 0;
|
|
182
|
+
|
|
183
|
+
/* HACK: This padding fixes a weird rendering bug where a tiiiiny outline is visible at the edges of the element */
|
|
184
|
+
/* stylelint-disable-next-line primer/spacing */
|
|
185
|
+
padding: 0.1px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* Circular mask */
|
|
189
|
+
.AvatarStack:where([data-shape='circle']) &:nth-child(n + 2) {
|
|
190
|
+
/* stylelint-disable-next-line declaration-property-value-no-unknown */
|
|
191
|
+
mask-image: radial-gradient(at 50% 50%, rgb(0, 0, 0) 70%, rgb(0, 0, 0, 0) 71%), linear-gradient(rgb(0, 0, 0) 0 0);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Square mask */
|
|
195
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(n + 2) {
|
|
196
|
+
/* stylelint-disable-next-line declaration-property-value-no-unknown */
|
|
197
|
+
mask-image: linear-gradient(at 50% 50%, rgb(0, 0, 0) 70%, rgb(0, 0, 0, 0) 71%), linear-gradient(rgb(0, 0, 0) 0 0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* Cascade variant override for nth-child(n + 3) */
|
|
201
|
+
.AvatarStack:where([data-variant='cascade']) &:nth-child(n + 3) {
|
|
202
|
+
--overlap-size: var(--overlap-size-avatar-three-plus);
|
|
203
|
+
|
|
204
|
+
/* stylelint-disable-next-line alpha-value-notation */
|
|
205
|
+
opacity: calc(100% - 2 * var(--opacity-step));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Cascade variant override for nth-child(n + 4) */
|
|
209
|
+
.AvatarStack:where([data-variant='cascade']) &:nth-child(n + 4) {
|
|
210
|
+
/* stylelint-disable-next-line alpha-value-notation */
|
|
211
|
+
opacity: calc(100% - 3 * var(--opacity-step));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* Cascade variant override for nth-child(n + 5) */
|
|
215
|
+
.AvatarStack:where([data-variant='cascade']) &:nth-child(n + 5) {
|
|
216
|
+
/* stylelint-disable-next-line alpha-value-notation */
|
|
217
|
+
opacity: calc(100% - 4 * var(--opacity-step));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(1) {
|
|
221
|
+
z-index: 5;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(2) {
|
|
225
|
+
z-index: 4;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(3) {
|
|
229
|
+
z-index: 3;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(4) {
|
|
233
|
+
z-index: 2;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.AvatarStack:where([data-shape='square']) &:nth-child(5) {
|
|
237
|
+
z-index: 1;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&:nth-child(n + 6) {
|
|
241
|
+
visibility: hidden;
|
|
242
|
+
opacity: 0;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.AvatarStackBody:not([data-disable-expand]):hover,
|
|
247
|
+
.AvatarStackBody:not([data-disable-expand]):focus-within {
|
|
248
|
+
width: auto;
|
|
249
|
+
|
|
250
|
+
.AvatarItem {
|
|
251
|
+
--mask-size: 100%; /* reset size of the mask to prevent unintentially clipping due to the additional size created by the border width */
|
|
252
|
+
|
|
253
|
+
margin-inline-start: var(--base-size-4);
|
|
254
|
+
visibility: visible;
|
|
255
|
+
opacity: 1;
|
|
256
|
+
|
|
257
|
+
/*
|
|
258
|
+
HORIZONTAL POSITION CALC FORMULA EXPLAINED:
|
|
259
|
+
width of the full avatar ➡️ var(--avatar-stack-size)
|
|
260
|
+
multiply by -1 for left-aligned, 1 for right-aligned ➡️ var(--mask-start)
|
|
261
|
+
*/
|
|
262
|
+
mask-position:
|
|
263
|
+
calc(var(--avatar-stack-size) * var(--mask-start)) center,
|
|
264
|
+
0 0;
|
|
265
|
+
|
|
266
|
+
&:first-child {
|
|
267
|
+
margin-inline-start: 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Features
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
AvatarStack all props and variants
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export interface AvatarStackProps {
|
|
11
|
+
alignRight?: boolean
|
|
12
|
+
disableExpand?: boolean
|
|
13
|
+
variant?: 'cascade' | 'stack'
|
|
14
|
+
shape?: 'circle' | 'square'
|
|
15
|
+
size?: number | ResponsiveValue<number>
|
|
16
|
+
className?: string
|
|
17
|
+
children: ReactNode
|
|
18
|
+
style?: CSSProperties
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Variants
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Default
|
|
26
|
+
|
|
27
|
+
Align Left
|
|
28
|
+
|
|
29
|
+
Align Right
|
|
30
|
+
|
|
31
|
+
Disable Expand
|
|
32
|
+
|
|
33
|
+
Custom Size
|
|
34
|
+
|
|
35
|
+
Custom Size Responsive
|
|
36
|
+
|
|
37
|
+
Custom Size on Children
|
|
38
|
+
|
|
39
|
+
Square Shape
|
|
40
|
+
|
|
41
|
+
Custom Size on Children Responsive
|
|
42
|
+
|
|
43
|
+
With Single Avatar
|
|
44
|
+
|
|
45
|
+
With Link Wrappers
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Default
|
|
49
|
+
|
|
50
|
+
> AvatarStack default variant with cascade layout
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<AvatarStack size={20}>
|
|
54
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
55
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
56
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
57
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
58
|
+
</AvatarStack>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Align Left
|
|
62
|
+
|
|
63
|
+
> AvatarStack aligned to the left (default behavior)
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<AvatarStack size={20}>
|
|
67
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
68
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
69
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
70
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
71
|
+
</AvatarStack>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Align Right
|
|
75
|
+
|
|
76
|
+
> AvatarStack aligned to the right
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<AvatarStack size={20} alignRight>
|
|
80
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
81
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
82
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
83
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
84
|
+
</AvatarStack>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Disable Expand On Hover
|
|
88
|
+
|
|
89
|
+
> AvatarStack with expansion on hover disabled
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<AvatarStack size={20} disableExpand>
|
|
93
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
94
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
95
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
96
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
97
|
+
</AvatarStack>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Custom Size On Parent
|
|
101
|
+
|
|
102
|
+
> AvatarStack with custom avatar size
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<AvatarStack size={32}>
|
|
106
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
107
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
108
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
109
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
110
|
+
</AvatarStack>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Custom Size On Parent Responsive
|
|
114
|
+
|
|
115
|
+
> AvatarStack with responsive avatar sizes
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<AvatarStack size={64}>
|
|
119
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
120
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
121
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
122
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
123
|
+
</AvatarStack>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Custom Size on Children
|
|
127
|
+
|
|
128
|
+
> AvatarStack with different sizes on each child Avatar
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
<AvatarStack size={20}>
|
|
132
|
+
<Avatar size={20} alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
133
|
+
<Avatar size={32} alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
134
|
+
<Avatar size={48} alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
135
|
+
<Avatar size={64} alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
136
|
+
</AvatarStack>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### With Square Avatars
|
|
140
|
+
|
|
141
|
+
> AvatarStack with square-shaped avatars
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
<AvatarStack size={20} shape="square">
|
|
145
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
146
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
147
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
148
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
149
|
+
</AvatarStack>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Custom Size on Children Responsive
|
|
153
|
+
|
|
154
|
+
> AvatarStack with responsive sizes on each child Avatar
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<AvatarStack size={48}>
|
|
158
|
+
<Avatar size={{ narrow: 16, regular: 32, wide: 48 }} alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
159
|
+
<Avatar size={{ narrow: 32, regular: 48, wide: 64 }} alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
160
|
+
<Avatar size={{ narrow: 48, regular: 64, wide: 96 }} alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
161
|
+
<Avatar size={{ narrow: 64, regular: 96, wide: 120 }} alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
162
|
+
</AvatarStack>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### With Single Avatar
|
|
166
|
+
|
|
167
|
+
> AvatarStack with only one avatar
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
<AvatarStack>
|
|
171
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
172
|
+
</AvatarStack>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### With Link Wrappers
|
|
176
|
+
|
|
177
|
+
> AvatarStack with Link components wrapping each Avatar
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
<AvatarStack>
|
|
181
|
+
<Link aria-label="Primer is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
|
|
182
|
+
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
|
|
183
|
+
</Link>
|
|
184
|
+
<Link aria-label="GitHub is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
|
|
185
|
+
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
|
|
186
|
+
</Link>
|
|
187
|
+
<Link aria-label="Atom is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
|
|
188
|
+
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
|
|
189
|
+
</Link>
|
|
190
|
+
<Link aria-label="GitHub Desktop is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
|
|
191
|
+
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
|
|
192
|
+
</Link>
|
|
193
|
+
</AvatarStack>
|
|
194
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Modern/AvatarStack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AvatarStack", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AvatarStack.AvatarStack;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _AvatarStack = require("./AvatarStack");
|
package/build/Modern/index.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import '@papillonarts/css/index.scss';
|
|
2
2
|
import { Pagination } from './Pagination';
|
|
3
|
+
export type { AvatarProps } from './Avatar';
|
|
4
|
+
export type { AvatarStackProps } from './AvatarStack';
|
|
3
5
|
export type { FlashProps } from './Flash';
|
|
4
6
|
export type { LinkProps } from './Link';
|
|
5
7
|
export type { PaginationProps } from './Pagination';
|
|
6
8
|
export declare const Modern: {
|
|
9
|
+
Avatar: {
|
|
10
|
+
Avatar: import("react").ForwardRefExoticComponent<{
|
|
11
|
+
size?: number | import("./hooks/useResponsiveValue").ResponsiveValue<number>;
|
|
12
|
+
square?: boolean;
|
|
13
|
+
src: string;
|
|
14
|
+
alt?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
17
|
+
};
|
|
18
|
+
AvatarStack: {
|
|
19
|
+
AvatarStack: ({ children, variant, shape, alignRight, disableExpand, size, className, style, }: import("./AvatarStack").AvatarStackProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
};
|
|
7
21
|
Flash: {
|
|
8
22
|
Flash: import("./utils/polymorphic").ForwardRefComponent<"div", import("./Flash").FlashProps>;
|
|
9
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Modern/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Modern/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAKrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBlB,CAAA"}
|
package/build/Modern/index.js
CHANGED
|
@@ -5,10 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Modern = void 0;
|
|
7
7
|
require("@papillonarts/css/index.scss");
|
|
8
|
+
var _Avatar = require("./Avatar");
|
|
9
|
+
var _AvatarStack = require("./AvatarStack");
|
|
8
10
|
var _Flash = require("./Flash");
|
|
9
11
|
var _Link = require("./Link");
|
|
10
12
|
var _Pagination = require("./Pagination");
|
|
11
13
|
var Modern = exports.Modern = {
|
|
14
|
+
Avatar: {
|
|
15
|
+
Avatar: _Avatar.Avatar
|
|
16
|
+
},
|
|
17
|
+
AvatarStack: {
|
|
18
|
+
AvatarStack: _AvatarStack.AvatarStack
|
|
19
|
+
},
|
|
12
20
|
Flash: {
|
|
13
21
|
Flash: _Flash.Flash
|
|
14
22
|
},
|
package/build/Modern/type.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/Modern/type.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/Modern/type.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds interactive nodes within the passed node.
|
|
3
|
+
* If the node itself is interactive, or children within are, it will return true.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The HTML element to search for interactive nodes in.
|
|
6
|
+
* @param ignoreSelectors - A string of selectors to ignore when searching for interactive nodes. This is useful for
|
|
7
|
+
* ignoring nodes that are conditionally interactive based on the return value of the function.
|
|
8
|
+
* @returns {boolean | undefined}
|
|
9
|
+
*/
|
|
10
|
+
export declare function hasInteractiveNodes(node: HTMLElement | null, ignoreNodes?: HTMLElement[]): boolean;
|
|
11
|
+
//# sourceMappingURL=hasInteractiveNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasInteractiveNodes.d.ts","sourceRoot":"","sources":["../../../src/Modern/utils/hasInteractiveNodes.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,WAoBxF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.hasInteractiveNodes = hasInteractiveNodes;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var nonValidSelectors = {
|
|
10
|
+
disabled: '[disabled]',
|
|
11
|
+
hidden: '[hidden]',
|
|
12
|
+
inert: '[inert]',
|
|
13
|
+
negativeTabIndex: '[tabindex="-1"]'
|
|
14
|
+
};
|
|
15
|
+
var interactiveElementsSelectors = ["a[href]", "button", 'summary', 'select', 'input:not([type=hidden])', 'textarea', '[tabindex="0"]', "audio[controls]", "video[controls]", "[contenteditable]"];
|
|
16
|
+
var interactiveElements = interactiveElementsSelectors.map(function (selector) {
|
|
17
|
+
return "".concat(selector, ":not(").concat(Object.values(nonValidSelectors).join('):not('), ")");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Combined selector for fast querySelector check
|
|
21
|
+
var interactiveSelector = interactiveElements.join(', ');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Finds interactive nodes within the passed node.
|
|
25
|
+
* If the node itself is interactive, or children within are, it will return true.
|
|
26
|
+
*
|
|
27
|
+
* @param node - The HTML element to search for interactive nodes in.
|
|
28
|
+
* @param ignoreSelectors - A string of selectors to ignore when searching for interactive nodes. This is useful for
|
|
29
|
+
* ignoring nodes that are conditionally interactive based on the return value of the function.
|
|
30
|
+
* @returns {boolean | undefined}
|
|
31
|
+
*/
|
|
32
|
+
function hasInteractiveNodes(node, ignoreNodes) {
|
|
33
|
+
if (!node || isNonValidInteractiveNode(node)) return false;
|
|
34
|
+
|
|
35
|
+
// We only need to confirm if at least one interactive node exists.
|
|
36
|
+
// If one does exist, we can abort early.
|
|
37
|
+
|
|
38
|
+
var nodesToIgnore = ignoreNodes ? [node].concat((0, _toConsumableArray2["default"])(ignoreNodes)) : [node];
|
|
39
|
+
|
|
40
|
+
// Performance optimization: Use querySelectorAll with combined selector first
|
|
41
|
+
// This avoids recursive getComputedStyle calls for each node
|
|
42
|
+
var candidates = node.querySelectorAll(interactiveSelector);
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
44
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
45
|
+
var candidate = candidates[i];
|
|
46
|
+
if (!nodesToIgnore.includes(candidate) && !isNonValidInteractiveNode(candidate)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Note: Only call getComputedStyle when CSS-based checks are insufficient
|
|
54
|
+
function isNonValidInteractiveNode(node) {
|
|
55
|
+
// Fast path: Check attribute-based states first (no style recalc needed)
|
|
56
|
+
var isNonInteractive = node.matches('[disabled], [hidden], [inert]');
|
|
57
|
+
if (isNonInteractive) return true;
|
|
58
|
+
|
|
59
|
+
// Only call getComputedStyle if attribute checks passed
|
|
60
|
+
// This is necessary for display:none and visibility:hidden which aren't detectable via attributes
|
|
61
|
+
var nodeStyle = getComputedStyle(node);
|
|
62
|
+
var isHiddenVisually = nodeStyle.display === 'none' || nodeStyle.visibility === 'hidden';
|
|
63
|
+
return isHiddenVisually;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/Modern/utils/testing.tsx"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,QAcvF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.implementsClassName = implementsClassName;
|
|
7
|
+
var _react = require("@testing-library/react");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
/* eslint-disable jest/no-export, jest/no-conditional-expect */
|
|
10
|
+
|
|
11
|
+
function implementsClassName(Component, baseClassName) {
|
|
12
|
+
test('renders with the custom className', function () {
|
|
13
|
+
var component = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
14
|
+
className: "test-class"
|
|
15
|
+
}));
|
|
16
|
+
if (baseClassName) {
|
|
17
|
+
var _component$container$;
|
|
18
|
+
// account for elements rendering in root portals
|
|
19
|
+
var baseElement = (_component$container$ = component.container.parentElement) === null || _component$container$ === void 0 ? void 0 : _component$container$.getElementsByClassName(baseClassName);
|
|
20
|
+
expect(baseElement).toHaveLength(1);
|
|
21
|
+
expect(baseElement === null || baseElement === void 0 ? void 0 : baseElement[0].classList.contains('test-class')).toBeTruthy();
|
|
22
|
+
} else {
|
|
23
|
+
var _component$container$2;
|
|
24
|
+
// account for elements rendering in root portals
|
|
25
|
+
var classNameElement = (_component$container$2 = component.container.parentElement) === null || _component$container$2 === void 0 ? void 0 : _component$container$2.getElementsByClassName('test-class');
|
|
26
|
+
expect(classNameElement).toHaveLength(1);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type ViewportRangeKeys = 'narrow' | 'narrowLandscape' | 'regular' | 'wide' | 'portrait' | 'landscape';
|
|
2
|
+
export type WidthOnlyViewportRangeKeys = Exclude<ViewportRangeKeys, 'narrowLandscape' | 'portrait' | 'landscape'>;
|
|
3
|
+
//# sourceMappingURL=ViewportRangeKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportRangeKeys.d.ts","sourceRoot":"","sources":["../../../../src/Modern/utils/types/ViewportRangeKeys.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAA;AAC5G,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,UAAU,GAAG,WAAW,CAAC,CAAA"}
|