draft-components 2.4.3 → 2.5.1
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/css/draft-components.css +38 -108
- package/css/draft-components.dark.css +4 -4
- package/dist/components/avatar/avatar.d.ts +5 -4
- package/dist/components/avatar/avatar.js +22 -30
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/package.json +21 -19
- package/dist/components/avatar-group/avatar-group.d.ts +0 -7
- package/dist/components/avatar-group/avatar-group.js +0 -5
- package/dist/components/avatar-group/index.d.ts +0 -1
- package/dist/components/avatar-group/index.js +0 -1
package/css/draft-components.css
CHANGED
|
@@ -570,153 +570,83 @@
|
|
|
570
570
|
}
|
|
571
571
|
|
|
572
572
|
.dc-avatar {
|
|
573
|
-
--dc-avatar-
|
|
574
|
-
--dc-avatar-
|
|
575
|
-
--dc-avatar-
|
|
576
|
-
--dc-avatar-color:
|
|
577
|
-
--dc-avatar-
|
|
578
|
-
--dc-avatar-image-border-color: rgb(var(--dc-gray-700-rgb) / 0.1);
|
|
573
|
+
--dc-avatar-monogram-color: var(--dc-white);
|
|
574
|
+
--dc-avatar-silhouette-color: var(--dc-white);
|
|
575
|
+
--dc-avatar-bg-color-1: #94a3b8;
|
|
576
|
+
--dc-avatar-bg-color-2: #64748b;
|
|
577
|
+
--dc-avatar-border-color: rgb(var(--dc-black-rgb) / 0.025);
|
|
579
578
|
|
|
580
|
-
color-scheme: light;
|
|
581
|
-
font-family: var(--dc-primary-font);
|
|
582
|
-
font-size: var(--dc-avatar-font-size);
|
|
583
|
-
font-weight: 600;
|
|
584
|
-
line-height: 1;
|
|
585
|
-
color: var(--dc-avatar-color);
|
|
586
|
-
position: relative;
|
|
587
|
-
display: inline-flex;
|
|
588
|
-
overflow: hidden;
|
|
589
579
|
-webkit-user-select: none;
|
|
590
|
-
-moz-user-select: none;
|
|
591
|
-
user-select: none;
|
|
592
|
-
align-items: center;
|
|
593
|
-
justify-content: center;
|
|
594
|
-
width: var(--dc-avatar-size);
|
|
595
|
-
height: var(--dc-avatar-size);
|
|
596
|
-
border-radius: var(--dc-avatar-radius);
|
|
597
|
-
background: var(--dc-avatar-bg);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
.dc-avatar_image::after {
|
|
601
|
-
content: '';
|
|
602
|
-
position: absolute;
|
|
603
|
-
top: 0;
|
|
604
|
-
left: 0;
|
|
605
|
-
box-sizing: border-box;
|
|
606
|
-
width: 100%;
|
|
607
|
-
height: 100%;
|
|
608
|
-
border: 1px solid var(--dc-avatar-image-border-color);
|
|
609
|
-
border-radius: inherit;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
.dc-avatar_size_xs {
|
|
613
|
-
--dc-avatar-size: 24px;
|
|
614
|
-
--dc-avatar-font-size: 10px;
|
|
615
|
-
}
|
|
616
580
|
|
|
617
|
-
|
|
618
|
-
--dc-avatar-size: 32px;
|
|
619
|
-
--dc-avatar-font-size: 12px;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
.dc-avatar_size_lg {
|
|
623
|
-
--dc-avatar-size: 48px;
|
|
624
|
-
--dc-avatar-font-size: 20px;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
.dc-avatar_size_xl {
|
|
628
|
-
--dc-avatar-size: 56px;
|
|
629
|
-
--dc-avatar-font-size: 24px;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
.dc-avatar_square {
|
|
633
|
-
--dc-avatar-radius: 8px;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
.dc-avatar_square.dc-avatar_size_xs {
|
|
637
|
-
--dc-avatar-radius: 4px;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
.dc-avatar_square.dc-avatar_size_sm {
|
|
641
|
-
--dc-avatar-radius: 6px;
|
|
642
|
-
}
|
|
581
|
+
-moz-user-select: none;
|
|
643
582
|
|
|
644
|
-
|
|
645
|
-
--dc-avatar-radius: 9px;
|
|
583
|
+
user-select: none;
|
|
646
584
|
}
|
|
647
585
|
|
|
648
|
-
.dc-
|
|
649
|
-
--dc-avatar-
|
|
586
|
+
.dc-avatar_type_image {
|
|
587
|
+
--dc-avatar-border-color: rgb(var(--dc-black-rgb) / 0.1);
|
|
650
588
|
}
|
|
651
589
|
|
|
652
590
|
.dc-avatar_fill_pink {
|
|
653
|
-
--dc-avatar-color:
|
|
654
|
-
--dc-avatar-bg: #
|
|
591
|
+
--dc-avatar-bg-color-1: #fb7185;
|
|
592
|
+
--dc-avatar-bg-color-2: #f43f5e;
|
|
655
593
|
}
|
|
656
594
|
|
|
657
595
|
.dc-avatar_fill_red {
|
|
658
|
-
--dc-avatar-color:
|
|
659
|
-
--dc-avatar-bg: #
|
|
596
|
+
--dc-avatar-bg-color-1: #f87171;
|
|
597
|
+
--dc-avatar-bg-color-2: #ef4444;
|
|
660
598
|
}
|
|
661
599
|
|
|
662
600
|
.dc-avatar_fill_orange {
|
|
663
|
-
--dc-avatar-color:
|
|
664
|
-
--dc-avatar-bg: #
|
|
601
|
+
--dc-avatar-bg-color-1: #fb923c;
|
|
602
|
+
--dc-avatar-bg-color-2: #f97316;
|
|
665
603
|
}
|
|
666
604
|
|
|
667
605
|
.dc-avatar_fill_yellow {
|
|
668
|
-
--dc-avatar-color:
|
|
669
|
-
--dc-avatar-bg: #
|
|
606
|
+
--dc-avatar-bg-color-1: #fbbf24;
|
|
607
|
+
--dc-avatar-bg-color-2: #f59e0b;
|
|
670
608
|
}
|
|
671
609
|
|
|
672
610
|
.dc-avatar_fill_green {
|
|
673
|
-
--dc-avatar-color:
|
|
674
|
-
--dc-avatar-bg: #
|
|
611
|
+
--dc-avatar-bg-color-1: #4ade80;
|
|
612
|
+
--dc-avatar-bg-color-2: #22c55e;
|
|
675
613
|
}
|
|
676
614
|
|
|
677
615
|
.dc-avatar_fill_teal {
|
|
678
|
-
--dc-avatar-color:
|
|
679
|
-
--dc-avatar-bg: #
|
|
616
|
+
--dc-avatar-bg-color-1: #2dd4bf;
|
|
617
|
+
--dc-avatar-bg-color-2: #14b8a6;
|
|
680
618
|
}
|
|
681
619
|
|
|
682
620
|
.dc-avatar_fill_blue {
|
|
683
|
-
--dc-avatar-color:
|
|
684
|
-
--dc-avatar-bg: #
|
|
621
|
+
--dc-avatar-bg-color-1: #38bdf8;
|
|
622
|
+
--dc-avatar-bg-color-2: #0ea5e9;
|
|
685
623
|
}
|
|
686
624
|
|
|
687
625
|
.dc-avatar_fill_indigo {
|
|
688
|
-
--dc-avatar-color:
|
|
689
|
-
--dc-avatar-bg: #
|
|
626
|
+
--dc-avatar-bg-color-1: #818cf8;
|
|
627
|
+
--dc-avatar-bg-color-2: #6366f1;
|
|
690
628
|
}
|
|
691
629
|
|
|
692
630
|
.dc-avatar_fill_violet {
|
|
693
|
-
--dc-avatar-color:
|
|
694
|
-
--dc-avatar-bg: #
|
|
631
|
+
--dc-avatar-bg-color-1: #c084fc;
|
|
632
|
+
--dc-avatar-bg-color-2: #a855f7;
|
|
695
633
|
}
|
|
696
634
|
|
|
697
|
-
.dc-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
.dc-avatar-group {
|
|
706
|
-
--dc-avatar-in-group-stroke: var(--dc-primary-bg);
|
|
707
|
-
|
|
708
|
-
color-scheme: light;
|
|
709
|
-
display: inline-flex;
|
|
710
|
-
align-items: center;
|
|
711
|
-
box-sizing: border-box;
|
|
635
|
+
.dc-avatar__monogram {
|
|
636
|
+
font-family: var(--dc-primary-font);
|
|
637
|
+
font-size: 22px;
|
|
638
|
+
font-weight: 600;
|
|
639
|
+
letter-spacing: 0.025em;
|
|
640
|
+
fill: var(--dc-avatar-monogram-color);
|
|
712
641
|
}
|
|
713
642
|
|
|
714
|
-
.dc-
|
|
715
|
-
|
|
643
|
+
.dc-avatar__silhouette {
|
|
644
|
+
fill: var(--dc-avatar-silhouette-color);
|
|
716
645
|
}
|
|
717
646
|
|
|
718
|
-
.dc-
|
|
719
|
-
|
|
647
|
+
.dc-avatar__border {
|
|
648
|
+
fill: none;
|
|
649
|
+
stroke: var(--dc-avatar-border-color);
|
|
720
650
|
}
|
|
721
651
|
|
|
722
652
|
.dc-button {
|
|
@@ -289,14 +289,14 @@
|
|
|
289
289
|
|
|
290
290
|
.dark .dc-avatar,
|
|
291
291
|
.dark.dc-avatar {
|
|
292
|
-
--dc-avatar-
|
|
292
|
+
--dc-avatar-border-color: rgb(var(--dc-white-rgb) / 0.025);
|
|
293
293
|
|
|
294
294
|
color-scheme: dark;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
.dark .dc-
|
|
298
|
-
.dark.dc-
|
|
299
|
-
color
|
|
297
|
+
.dark .dc-avatar_type_image,
|
|
298
|
+
.dark.dc-avatar_type_image {
|
|
299
|
+
--dc-avatar-border-color: rgb(var(--dc-white-rgb) / 0.1);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
.dark .dc-button,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from 'react';
|
|
2
|
-
type AvatarHTMLProps = ComponentPropsWithRef<'
|
|
2
|
+
type AvatarHTMLProps = ComponentPropsWithRef<'svg'>;
|
|
3
|
+
type AvatarBaseProps = Omit<AvatarHTMLProps, 'fill'>;
|
|
3
4
|
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
5
|
export type AvatarFill = 'gray' | 'pink' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'indigo' | 'violet';
|
|
5
6
|
export type AvatarProps = {
|
|
@@ -8,7 +9,7 @@ export type AvatarProps = {
|
|
|
8
9
|
fill?: AvatarFill;
|
|
9
10
|
src?: string;
|
|
10
11
|
altText?: string;
|
|
11
|
-
|
|
12
|
-
} &
|
|
13
|
-
export declare const Avatar: import("react").ForwardRefExoticComponent<Omit<AvatarProps, "ref"> & import("react").RefAttributes<
|
|
12
|
+
monogram?: string;
|
|
13
|
+
} & AvatarBaseProps;
|
|
14
|
+
export declare const Avatar: import("react").ForwardRefExoticComponent<Omit<AvatarProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
14
15
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef,
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
const sizesInPixels = {
|
|
5
5
|
xs: 24,
|
|
@@ -8,40 +8,32 @@ const sizesInPixels = {
|
|
|
8
8
|
lg: 48,
|
|
9
9
|
xl: 56,
|
|
10
10
|
};
|
|
11
|
-
export const Avatar = forwardRef(function Avatar({ square, size = 'md', fill = 'gray', src, altText,
|
|
11
|
+
export const Avatar = forwardRef(function Avatar({ square, size = 'md', fill = 'gray', src, altText, monogram, className, ...props }, ref) {
|
|
12
|
+
const id = useId();
|
|
13
|
+
const titleId = altText ? `${id}avatar-title` : undefined;
|
|
14
|
+
const maskId = `${id}avatar-mask`;
|
|
15
|
+
const gradientId = `${id}avatar-gradient`;
|
|
12
16
|
const sizePx = sizesInPixels[size] ?? sizesInPixels.md;
|
|
13
|
-
const [type, setType] = useState(() => {
|
|
14
|
-
let type;
|
|
15
|
-
if (src) {
|
|
16
|
-
type = 'image';
|
|
17
|
-
}
|
|
18
|
-
else if (initials) {
|
|
19
|
-
type = 'initials';
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
type = 'silhouette';
|
|
23
|
-
}
|
|
24
|
-
return type;
|
|
25
|
-
});
|
|
26
17
|
let children;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}, onError: () => {
|
|
33
|
-
setType(initials ? 'initials' : 'silhouette');
|
|
34
|
-
} }));
|
|
18
|
+
let type;
|
|
19
|
+
if (src) {
|
|
20
|
+
type = 'image';
|
|
21
|
+
children = (_jsx("image", { href: src, width: "100%", height: "100%", preserveAspectRatio: "xMidYMid slice" }));
|
|
35
22
|
}
|
|
36
|
-
else if (
|
|
37
|
-
|
|
23
|
+
else if (monogram) {
|
|
24
|
+
type = 'monogram';
|
|
25
|
+
children = (_jsx("text", { className: "dc-avatar__monogram", x: "28", y: "28", dy: "5%", textAnchor: "middle", dominantBaseline: "middle", children: monogram.slice(0, 2) }));
|
|
38
26
|
}
|
|
39
27
|
else {
|
|
40
|
-
|
|
28
|
+
type = 'silhouette';
|
|
29
|
+
children = square ? (_jsx("path", { className: "dc-avatar__silhouette", fillRule: "evenodd", clipRule: "evenodd", d: "M28.0001 29.5957C33.3078 29.5957 37.6106 24.9852 37.6106 19.2979C37.6106 13.6105 33.3078 9 28.0001 9C22.6923 9 18.3895 13.6105 18.3895 19.2979C18.3895 24.9852 22.6923 29.5957 28.0001 29.5957ZM7.03967 49.4839C6.71299 51.4741 8.45242 53 10.4693 53H45.5305C47.5474 53 49.2868 51.4741 48.9601 49.4839C47.6918 41.7571 39.6459 33.3404 27.9999 33.3404C16.3538 33.3404 8.30794 41.7571 7.03967 49.4839Z" })) : (_jsx("path", { className: "dc-avatar__silhouette", fillRule: "evenodd", clipRule: "evenodd", d: "M9.28643 44.5776C12.6548 39.0053 19.3297 34.3404 27.9999 34.3404C36.6702 34.3404 43.3451 39.0054 46.7134 44.5777C42.1335 49.7439 35.447 53 28 53C20.5529 53 13.8664 49.7438 9.28643 44.5776ZM37.6106 20.2979C37.6106 25.9852 33.3078 30.5957 28.0001 30.5957C22.6923 30.5957 18.3895 25.9852 18.3895 20.2979C18.3895 14.6105 22.6923 10 28.0001 10C33.3078 10 37.6106 14.6105 37.6106 20.2979Z" }));
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
const maskElement = square
|
|
32
|
+
? _jsx("rect", { width: "56", height: "56", rx: "10", fill: "#fff" })
|
|
33
|
+
: _jsx("circle", { r: "28", cx: "28", cy: "28", fill: "#fff" });
|
|
34
|
+
return (_jsxs("svg", { ref: ref, className: classNames(className, {
|
|
35
|
+
'dc-avatar': true,
|
|
36
|
+
[`dc-avatar_type_${type}`]: type,
|
|
44
37
|
[`dc-avatar_fill_${fill}`]: fill,
|
|
45
|
-
|
|
46
|
-
}), ...props, children: children }));
|
|
38
|
+
}), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 56 56", width: sizePx, height: sizePx, role: "img", "aria-labelledby": titleId, ...props, children: [altText ? _jsx("title", { id: titleId, children: altText }) : null, _jsxs("defs", { children: [_jsx("mask", { id: maskId, children: maskElement }), _jsxs("linearGradient", { id: gradientId, x1: "0", x2: "0", y1: "0", y2: "1", children: [_jsx("stop", { stopColor: "var(--dc-avatar-bg-color-1)", offset: "0%" }), _jsx("stop", { stopColor: "var(--dc-avatar-bg-color-2)", offset: "100%" })] })] }), _jsxs("g", { mask: `url(#${maskId})`, children: [_jsx("rect", { fill: `url(#${gradientId})`, width: "56", height: "56" }), children, _jsx(maskElement.type, { ...maskElement.props, className: "dc-avatar__border", strokeWidth: "3" })] })] }));
|
|
47
39
|
});
|
package/dist/components/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draft-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "The React based UI components library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -52,48 +52,50 @@
|
|
|
52
52
|
"react-dom": ">= 18"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@alexzimakov/eslint-config": "1.
|
|
55
|
+
"@alexzimakov/eslint-config": "1.8.0",
|
|
56
56
|
"@heroicons/react": "2.0.18",
|
|
57
|
-
"@storybook/addon-actions": "7.
|
|
58
|
-
"@storybook/addon-essentials": "7.
|
|
59
|
-
"@storybook/addon-links": "7.
|
|
60
|
-
"@storybook/addon-themes": "7.
|
|
61
|
-
"@storybook/react": "7.
|
|
62
|
-
"@storybook/react-vite": "7.
|
|
57
|
+
"@storybook/addon-actions": "7.5.3",
|
|
58
|
+
"@storybook/addon-essentials": "7.5.3",
|
|
59
|
+
"@storybook/addon-links": "7.5.3",
|
|
60
|
+
"@storybook/addon-themes": "7.5.3",
|
|
61
|
+
"@storybook/react": "7.5.3",
|
|
62
|
+
"@storybook/react-vite": "7.5.3",
|
|
63
63
|
"@testing-library/dom": "9.3.3",
|
|
64
64
|
"@testing-library/jest-dom": "6.1.4",
|
|
65
65
|
"@testing-library/react": "14.0.0",
|
|
66
66
|
"@testing-library/user-event": "14.5.1",
|
|
67
|
-
"@types/node": "
|
|
68
|
-
"@types/react": "18.2.
|
|
69
|
-
"@types/react-dom": "18.2.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
71
|
-
"@typescript-eslint/parser": "6.7.5",
|
|
67
|
+
"@types/node": "20.9.0",
|
|
68
|
+
"@types/react": "18.2.37",
|
|
69
|
+
"@types/react-dom": "18.2.15",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "6.10.0",
|
|
72
71
|
"@vitest/coverage-istanbul": "0.34.6",
|
|
73
72
|
"autoprefixer": "10.4.16",
|
|
74
|
-
"eslint": "8.
|
|
75
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
73
|
+
"eslint": "8.53.0",
|
|
74
|
+
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
76
75
|
"eslint-plugin-react": "7.33.2",
|
|
77
76
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
78
77
|
"eslint-plugin-storybook": "0.6.15",
|
|
79
78
|
"eslint-plugin-testing-library": "6.1.0",
|
|
80
79
|
"husky": "8.0.3",
|
|
81
80
|
"jsdom": "22.1.0",
|
|
82
|
-
"lint-staged": "15.0.
|
|
81
|
+
"lint-staged": "15.0.2",
|
|
83
82
|
"postcss": "8.4.31",
|
|
84
83
|
"postcss-import": "15.1.0",
|
|
85
84
|
"react": "18.2.0",
|
|
86
85
|
"react-dom": "18.2.0",
|
|
87
|
-
"storybook": "7.
|
|
88
|
-
"stylelint": "15.
|
|
86
|
+
"storybook": "7.5.3",
|
|
87
|
+
"stylelint": "15.11.0",
|
|
89
88
|
"stylelint-config-standard": "34.0.0",
|
|
90
89
|
"stylelint-order": "6.0.3",
|
|
91
90
|
"typescript": "5.2.2",
|
|
92
|
-
"vite": "4.
|
|
91
|
+
"vite": "4.5.0",
|
|
93
92
|
"vitest": "0.34.6"
|
|
94
93
|
},
|
|
95
94
|
"lint-staged": {
|
|
96
95
|
"*.ts?(x)": "npm run lint-js",
|
|
97
96
|
"*.css": "npm run lint-css"
|
|
97
|
+
},
|
|
98
|
+
"dependencies": {
|
|
99
|
+
"@typescript-eslint/parser": "6.10.0"
|
|
98
100
|
}
|
|
99
101
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, JSX } from 'react';
|
|
2
|
-
type AvatarGroupBaseProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'>;
|
|
3
|
-
export type AvatarGroupProps = AvatarGroupBaseProps & {
|
|
4
|
-
children: JSX.Element | JSX.Element[];
|
|
5
|
-
};
|
|
6
|
-
export declare function AvatarGroup({ className, children, ...props }: AvatarGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
-
export function AvatarGroup({ className, children, ...props }) {
|
|
4
|
-
return (_jsx("div", { ...props, className: classNames(className, 'dc-avatar-group'), children: children }));
|
|
5
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './avatar-group.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './avatar-group.js';
|