doom-design-system 0.3.4 → 0.4.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/dist/components/Avatar/Avatar.js +2 -1
- package/dist/components/Badge/Badge.d.ts +3 -1
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Badge/Badge.module.css +14 -2
- package/dist/components/FileUpload/FileUpload.js +4 -5
- package/dist/components/FileUpload/FileUpload.module.css +0 -5
- package/dist/components/Image/Image.d.ts +8 -0
- package/dist/components/Image/Image.js +60 -0
- package/dist/components/Image/Image.module.css +36 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Image/index.js +1 -0
- package/dist/components/Link/Link.d.ts +6 -3
- package/dist/components/Link/Link.js +27 -6
- package/dist/components/Link/Link.module.css +10 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import styles from "./Avatar.module.css";
|
|
6
|
+
import { Image } from "../Image/Image.js";
|
|
6
7
|
export function Avatar({ src, alt = "Avatar", fallback, size = "md", shape = "square", className, }) {
|
|
7
8
|
const [hasError, setHasError] = useState(false);
|
|
8
|
-
return (_jsx("div", { className: clsx(styles.avatar, styles[size], styles[shape], className), children: src && !hasError ? (_jsx(
|
|
9
|
+
return (_jsx("div", { className: clsx(styles.avatar, styles[size], styles[shape], className), children: src && !hasError ? (_jsx(Image, { src: src, alt: alt, className: styles.image, onError: () => setHasError(true), fit: "cover", rounded: false })) : (_jsx("span", { className: clsx(styles.fallback, styles[size]), children: typeof fallback === "string" ? fallback.slice(0, 2) : fallback })) }));
|
|
9
10
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
type BadgeVariant = "primary" | "success" | "warning" | "error" | "secondary" | "outline";
|
|
3
|
+
type BadgeSize = "sm" | "md" | "lg";
|
|
3
4
|
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
4
5
|
variant?: BadgeVariant;
|
|
6
|
+
size?: BadgeSize;
|
|
5
7
|
children: React.ReactNode;
|
|
6
8
|
}
|
|
7
|
-
export declare function Badge({ variant, children, className, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function Badge({ variant, size, children, className, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -14,6 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import clsx from "clsx";
|
|
15
15
|
import styles from "./Badge.module.css";
|
|
16
16
|
export function Badge(_a) {
|
|
17
|
-
var { variant = "primary", children, className } = _a, props = __rest(_a, ["variant", "children", "className"]);
|
|
18
|
-
return (_jsx("span", Object.assign({ className: clsx(styles.badge, styles[variant], className) }, props, { children: children })));
|
|
17
|
+
var { variant = "primary", size = "md", children, className } = _a, props = __rest(_a, ["variant", "size", "children", "className"]);
|
|
18
|
+
return (_jsx("span", Object.assign({ className: clsx(styles.badge, styles[variant], styles[size], className) }, props, { children: children })));
|
|
19
19
|
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
.badge {
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
|
-
|
|
4
|
+
justify-content: center;
|
|
5
5
|
border-radius: var(--radius-pill);
|
|
6
|
-
font-size: 0.75rem;
|
|
7
6
|
font-weight: 700;
|
|
8
7
|
text-transform: uppercase;
|
|
9
8
|
border: 2px solid var(--card-border);
|
|
10
9
|
box-shadow: 2px 2px 0px 0px var(--card-border);
|
|
10
|
+
line-height: 1;
|
|
11
|
+
}
|
|
12
|
+
.badge.sm {
|
|
13
|
+
padding: 0.2rem 0.6rem;
|
|
14
|
+
font-size: 0.7rem;
|
|
15
|
+
}
|
|
16
|
+
.badge.md {
|
|
17
|
+
padding: 0.25rem 0.75rem;
|
|
18
|
+
font-size: 0.75rem;
|
|
19
|
+
}
|
|
20
|
+
.badge.lg {
|
|
21
|
+
padding: 0.375rem 1rem;
|
|
22
|
+
font-size: 0.875rem;
|
|
11
23
|
}
|
|
12
24
|
.badge.primary {
|
|
13
25
|
background-color: var(--primary);
|
|
@@ -8,7 +8,7 @@ import { Stack, Flex, Switcher } from "../Layout/Layout.js";
|
|
|
8
8
|
import { Badge } from "../Badge/Badge.js";
|
|
9
9
|
import { Slat } from "../Slat/Slat.js";
|
|
10
10
|
import { Upload, File as FileIcon, FileImage, FileVideo, FileAudio, FileCode, FileArchive, FileText, FileSpreadsheet, Asterisk, X, } from "lucide-react";
|
|
11
|
-
import {
|
|
11
|
+
import { Image } from "../Image/Image.js";
|
|
12
12
|
import clsx from "clsx";
|
|
13
13
|
var Status;
|
|
14
14
|
(function (Status) {
|
|
@@ -231,8 +231,7 @@ export const FileUpload = ({ label, helperText, accept, maxSize, multiple = fals
|
|
|
231
231
|
}, children: "UPLOAD MORE FILES" }))] }))] })] })));
|
|
232
232
|
};
|
|
233
233
|
const PreviewImage = ({ src, alt }) => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
.replace(/[-_]/g, " ") || "File preview", className: clsx(styles.previewImg, { [styles.loaded]: loaded }), onLoad: () => setLoaded(true), style: loaded ? {} : { position: "absolute", opacity: 0 } })] }));
|
|
234
|
+
return (_jsx("div", { className: styles.previewWrapper, children: _jsx(Image, { src: src, alt: alt
|
|
235
|
+
.replace(/\.(jpg|jpeg|png|gif|webp|svg)$/i, "")
|
|
236
|
+
.replace(/[-_]/g, " ") || "File preview", className: styles.previewImg, fit: "cover", rounded: false }) }));
|
|
238
237
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
3
|
+
fit?: "cover" | "contain" | "fill" | "none" | "scale-down";
|
|
4
|
+
fallbackSrc?: string;
|
|
5
|
+
aspectRatio?: string | number;
|
|
6
|
+
rounded?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function Image({ src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState, useRef, useEffect } from "react";
|
|
15
|
+
import clsx from "clsx";
|
|
16
|
+
import styles from "./Image.module.css";
|
|
17
|
+
import { Skeleton } from "../Skeleton/Skeleton.js";
|
|
18
|
+
export function Image(_a) {
|
|
19
|
+
var { src, alt, className, fit, style, onLoad, onError, fallbackSrc, aspectRatio, rounded = true } = _a, props = __rest(_a, ["src", "alt", "className", "fit", "style", "onLoad", "onError", "fallbackSrc", "aspectRatio", "rounded"]);
|
|
20
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
21
|
+
const [hasError, setHasError] = useState(false);
|
|
22
|
+
const [showSkeleton, setShowSkeleton] = useState(false);
|
|
23
|
+
const timerRef = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setIsLoaded(false);
|
|
26
|
+
setHasError(false);
|
|
27
|
+
setShowSkeleton(false);
|
|
28
|
+
if (timerRef.current)
|
|
29
|
+
clearTimeout(timerRef.current);
|
|
30
|
+
timerRef.current = setTimeout(() => {
|
|
31
|
+
setShowSkeleton(true);
|
|
32
|
+
}, 150);
|
|
33
|
+
return () => {
|
|
34
|
+
if (timerRef.current)
|
|
35
|
+
clearTimeout(timerRef.current);
|
|
36
|
+
};
|
|
37
|
+
}, [src]);
|
|
38
|
+
const handleLoad = (e) => {
|
|
39
|
+
if (timerRef.current)
|
|
40
|
+
clearTimeout(timerRef.current);
|
|
41
|
+
setIsLoaded(true);
|
|
42
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
|
|
43
|
+
};
|
|
44
|
+
const handleError = (e) => {
|
|
45
|
+
if (fallbackSrc && !hasError) {
|
|
46
|
+
setHasError(true);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (timerRef.current)
|
|
50
|
+
clearTimeout(timerRef.current);
|
|
51
|
+
setIsLoaded(true);
|
|
52
|
+
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
53
|
+
};
|
|
54
|
+
return (_jsxs("div", { className: clsx(styles.wrapper, rounded && styles.rounded, className), style: Object.assign({ aspectRatio }, style), children: [!isLoaded && showSkeleton && (_jsx(Skeleton, { className: styles.skeleton, style: {
|
|
55
|
+
position: "absolute",
|
|
56
|
+
inset: 0,
|
|
57
|
+
height: "100%",
|
|
58
|
+
width: "100%",
|
|
59
|
+
} })), _jsx("img", Object.assign({ src: hasError ? fallbackSrc : src, alt: alt, className: clsx(styles.image, fit && styles[`fit-${fit}`], showSkeleton && styles["with-transition"]), onLoad: handleLoad, onError: handleError, "data-loaded": isLoaded ? "true" : "false", style: { width: "100%", height: "100%" } }, props))] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.image {
|
|
2
|
+
display: block;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
height: auto;
|
|
5
|
+
}
|
|
6
|
+
.image[data-loaded=false] {
|
|
7
|
+
opacity: 0;
|
|
8
|
+
}
|
|
9
|
+
.image.with-transition {
|
|
10
|
+
transition: opacity 0.3s ease-in-out;
|
|
11
|
+
}
|
|
12
|
+
.image.fit-cover {
|
|
13
|
+
object-fit: cover;
|
|
14
|
+
}
|
|
15
|
+
.image.fit-contain {
|
|
16
|
+
object-fit: contain;
|
|
17
|
+
}
|
|
18
|
+
.image.fit-fill {
|
|
19
|
+
object-fit: fill;
|
|
20
|
+
}
|
|
21
|
+
.image.fit-none {
|
|
22
|
+
object-fit: none;
|
|
23
|
+
}
|
|
24
|
+
.image.fit-scale-down {
|
|
25
|
+
object-fit: scale-down;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.wrapper {
|
|
29
|
+
position: relative;
|
|
30
|
+
display: block;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rounded {
|
|
35
|
+
border-radius: var(--radius);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Image";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Image.js";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
export type LinkVariant =
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type LinkVariant = "default" | "button" | "subtle";
|
|
3
3
|
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
variant?: LinkVariant;
|
|
6
|
+
prefetch?: boolean;
|
|
7
|
+
isExternal?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
6
9
|
className?: string;
|
|
7
10
|
}
|
|
8
|
-
export declare function Link({ children, variant, className, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function Link({ children, variant, prefetch, isExternal, disabled, className, onClick, onMouseEnter, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
3
|
var t = {};
|
|
4
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,10 +10,31 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import clsx from
|
|
15
|
-
import styles from
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import clsx from "clsx";
|
|
15
|
+
import styles from "./Link.module.css";
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { ExternalLink } from "lucide-react";
|
|
16
18
|
export function Link(_a) {
|
|
17
|
-
var { children, variant =
|
|
18
|
-
|
|
19
|
+
var { children, variant = "default", prefetch, isExternal, disabled, className, onClick, onMouseEnter } = _a, props = __rest(_a, ["children", "variant", "prefetch", "isExternal", "disabled", "className", "onClick", "onMouseEnter"]);
|
|
20
|
+
const [shouldPrefetch, setShouldPrefetch] = React.useState(false);
|
|
21
|
+
const handleMouseEnter = (e) => {
|
|
22
|
+
if (disabled)
|
|
23
|
+
return;
|
|
24
|
+
if (prefetch && !shouldPrefetch) {
|
|
25
|
+
setShouldPrefetch(true);
|
|
26
|
+
}
|
|
27
|
+
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
|
|
28
|
+
};
|
|
29
|
+
const handleClick = (e) => {
|
|
30
|
+
if (disabled) {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
35
|
+
};
|
|
36
|
+
const externalProps = isExternal
|
|
37
|
+
? { target: "_blank", rel: "noopener noreferrer" }
|
|
38
|
+
: {};
|
|
39
|
+
return (_jsxs("a", Object.assign({ className: clsx(styles.link, styles[variant], disabled && styles.disabled, className), onMouseEnter: handleMouseEnter, onClick: handleClick, "aria-disabled": disabled }, externalProps, props, { children: [children, isExternal && _jsx(ExternalLink, { size: 14, className: "ml-1" }), shouldPrefetch && props.href && (_jsx("link", { rel: "prefetch", href: props.href, as: "document" }))] })));
|
|
19
40
|
}
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
|
-
font-weight: 700;
|
|
6
5
|
text-decoration: none;
|
|
7
6
|
transition: all 0.2s ease-in-out;
|
|
8
7
|
cursor: pointer;
|
|
8
|
+
outline: none;
|
|
9
|
+
}
|
|
10
|
+
.link:focus-visible {
|
|
11
|
+
outline: revert;
|
|
12
|
+
}
|
|
13
|
+
.link.disabled {
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
opacity: 0.5;
|
|
16
|
+
text-decoration: none;
|
|
17
|
+
cursor: not-allowed;
|
|
9
18
|
}
|
|
10
19
|
.link.default {
|
|
11
20
|
color: var(--primary);
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/Card";
|
|
|
4
4
|
export * from "./components/Dropdown";
|
|
5
5
|
export * from "./components/Form";
|
|
6
6
|
export * from "./components/Input";
|
|
7
|
+
export * from "./components/Image";
|
|
7
8
|
export * from "./components/Layout";
|
|
8
9
|
export * from "./components/Link";
|
|
9
10
|
export * from "./components/Modal";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/Card/index.js";
|
|
|
4
4
|
export * from "./components/Dropdown/index.js";
|
|
5
5
|
export * from "./components/Form/index.js";
|
|
6
6
|
export * from "./components/Input/index.js";
|
|
7
|
+
export * from "./components/Image/index.js";
|
|
7
8
|
export * from "./components/Layout/index.js";
|
|
8
9
|
export * from "./components/Link/index.js";
|
|
9
10
|
export * from "./components/Modal/index.js";
|