@calcifer-design/ui 0.1.2 → 0.2.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.
Files changed (28) hide show
  1. package/dist/components/Alert/Alert.d.ts +22 -0
  2. package/dist/components/Alert/Alert.js +142 -0
  3. package/dist/components/Alert/Alert.module.js +10 -0
  4. package/dist/components/Alert/Alert_module.css +91 -0
  5. package/dist/components/Avatar/Avatar.d.ts +8 -0
  6. package/dist/components/Avatar/Avatar.js +43 -0
  7. package/dist/components/Avatar/Avatar.module.js +8 -0
  8. package/dist/components/Avatar/Avatar_module.css +61 -0
  9. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +40 -0
  10. package/dist/components/ErrorBoundary/ErrorBoundary.js +58 -0
  11. package/dist/components/ErrorBoundary/ErrorBoundary.module.js +5 -0
  12. package/dist/components/ErrorBoundary/ErrorBoundary_module.css +6 -0
  13. package/dist/components/IconButton/IconButton.d.ts +23 -0
  14. package/dist/components/IconButton/IconButton.js +30 -0
  15. package/dist/components/IconButton/IconButton.module.js +6 -0
  16. package/dist/components/IconButton/IconButton_module.css +73 -0
  17. package/dist/components/Skeleton/Skeleton.d.ts +10 -0
  18. package/dist/components/Skeleton/Skeleton.js +34 -0
  19. package/dist/components/Skeleton/Skeleton.module.js +7 -0
  20. package/dist/components/Skeleton/Skeleton_module.css +45 -0
  21. package/dist/components/Spinner/Spinner.d.ts +12 -0
  22. package/dist/components/Spinner/Spinner.js +23 -0
  23. package/dist/components/Spinner/Spinner.module.js +8 -0
  24. package/dist/components/Spinner/Spinner_module.css +50 -0
  25. package/dist/index.d.ts +12 -0
  26. package/dist/index.js +6 -0
  27. package/dist/styles/base.css +23 -12
  28. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ export type AlertTone = 'info' | 'success' | 'warning' | 'danger';
3
+ export interface AlertProps {
4
+ tone?: AlertTone;
5
+ /** Rendered above the body as a heading. */
6
+ heading?: ReactNode;
7
+ /** The heading's level. Match it to where the alert sits in the page's outline. */
8
+ headingLevel?: 2 | 3 | 4;
9
+ children: ReactNode;
10
+ /**
11
+ * Announce this alert to assistive technology. Off by default and deliberately so: an alert
12
+ * that is already on the page at first paint would announce at whatever moment the page
13
+ * happens to settle. Turn it on only for an alert that appears in response to something the
14
+ * user just did.
15
+ */
16
+ announce?: boolean;
17
+ /** When given, a dismiss control is rendered that calls this. */
18
+ onDismiss?: () => void;
19
+ /** The dismiss control's accessible name. */
20
+ dismissLabel?: string;
21
+ }
22
+ export declare function Alert({ tone, heading, headingLevel, children, announce, onDismiss, dismissLabel, }: AlertProps): import("react").JSX.Element;
@@ -0,0 +1,142 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { IconButton } from "../IconButton/IconButton.js";
3
+ import Alert_module from "./Alert.module.js";
4
+ const toneWords = {
5
+ info: 'Information',
6
+ success: 'Success',
7
+ warning: 'Warning',
8
+ danger: 'Error'
9
+ };
10
+ const headingTags = {
11
+ 2: 'h2',
12
+ 3: 'h3',
13
+ 4: 'h4'
14
+ };
15
+ const iconProps = {
16
+ viewBox: '0 0 16 16',
17
+ fill: 'none',
18
+ stroke: 'currentColor',
19
+ strokeWidth: 1.5,
20
+ strokeLinecap: 'round',
21
+ strokeLinejoin: 'round',
22
+ 'aria-hidden': true
23
+ };
24
+ function ringMarks(tone) {
25
+ switch(tone){
26
+ case 'success':
27
+ return /*#__PURE__*/ jsx("path", {
28
+ d: "M5.25 8.25 7.25 10.25 10.9 6"
29
+ });
30
+ case 'danger':
31
+ return /*#__PURE__*/ jsxs(Fragment, {
32
+ children: [
33
+ /*#__PURE__*/ jsx("path", {
34
+ d: "m5.9 5.9 4.2 4.2"
35
+ }),
36
+ /*#__PURE__*/ jsx("path", {
37
+ d: "m10.1 5.9-4.2 4.2"
38
+ })
39
+ ]
40
+ });
41
+ case 'info':
42
+ return /*#__PURE__*/ jsxs(Fragment, {
43
+ children: [
44
+ /*#__PURE__*/ jsx("path", {
45
+ d: "M8 7.25v4"
46
+ }),
47
+ /*#__PURE__*/ jsx("path", {
48
+ d: "M8 4.9h.01"
49
+ })
50
+ ]
51
+ });
52
+ }
53
+ }
54
+ function ToneIcon({ tone }) {
55
+ if ('warning' === tone) return /*#__PURE__*/ jsxs("svg", {
56
+ ...iconProps,
57
+ children: [
58
+ /*#__PURE__*/ jsx("path", {
59
+ d: "M8 2.4 14.6 13.6H1.4z"
60
+ }),
61
+ /*#__PURE__*/ jsx("path", {
62
+ d: "M8 6.4v3.2"
63
+ }),
64
+ /*#__PURE__*/ jsx("path", {
65
+ d: "M8 11.7h.01"
66
+ })
67
+ ]
68
+ });
69
+ return /*#__PURE__*/ jsxs("svg", {
70
+ ...iconProps,
71
+ children: [
72
+ /*#__PURE__*/ jsx("circle", {
73
+ cx: "8",
74
+ cy: "8",
75
+ r: "6.25"
76
+ }),
77
+ ringMarks(tone)
78
+ ]
79
+ });
80
+ }
81
+ function DismissIcon() {
82
+ return /*#__PURE__*/ jsxs("svg", {
83
+ ...iconProps,
84
+ children: [
85
+ /*#__PURE__*/ jsx("path", {
86
+ d: "m4.5 4.5 7 7"
87
+ }),
88
+ /*#__PURE__*/ jsx("path", {
89
+ d: "m11.5 4.5-7 7"
90
+ })
91
+ ]
92
+ });
93
+ }
94
+ function Alert({ tone = 'info', heading, headingLevel = 3, children, announce = false, onDismiss, dismissLabel = 'Dismiss' }) {
95
+ const politeness = 'danger' === tone ? 'assertive' : 'polite';
96
+ const liveProps = announce ? {
97
+ role: 'assertive' === politeness ? 'alert' : 'status',
98
+ 'aria-live': politeness
99
+ } : {};
100
+ const Heading = headingTags[headingLevel] ?? 'h3';
101
+ return /*#__PURE__*/ jsxs("div", {
102
+ className: Alert_module.root,
103
+ "data-tone": tone,
104
+ "data-testid": "alert",
105
+ ...liveProps,
106
+ children: [
107
+ /*#__PURE__*/ jsx("span", {
108
+ className: Alert_module.icon,
109
+ children: /*#__PURE__*/ jsx(ToneIcon, {
110
+ tone: tone
111
+ })
112
+ }),
113
+ /*#__PURE__*/ jsxs("div", {
114
+ className: Alert_module.body,
115
+ children: [
116
+ /*#__PURE__*/ jsx("span", {
117
+ className: Alert_module.toneWord,
118
+ children: toneWords[tone]
119
+ }),
120
+ void 0 !== heading ? /*#__PURE__*/ jsx(Heading, {
121
+ className: Alert_module.heading,
122
+ children: heading
123
+ }) : null,
124
+ /*#__PURE__*/ jsx("div", {
125
+ children: children
126
+ })
127
+ ]
128
+ }),
129
+ void 0 !== onDismiss ? /*#__PURE__*/ jsx("span", {
130
+ className: Alert_module.dismiss,
131
+ children: /*#__PURE__*/ jsx(IconButton, {
132
+ label: dismissLabel,
133
+ variant: "ghost",
134
+ size: "sm",
135
+ onClick: onDismiss,
136
+ children: /*#__PURE__*/ jsx(DismissIcon, {})
137
+ })
138
+ }) : null
139
+ ]
140
+ });
141
+ }
142
+ export { Alert };
@@ -0,0 +1,10 @@
1
+ import "./Alert_module.css";
2
+ const Alert_module = {
3
+ root: "root-k99cj",
4
+ icon: "icon-GCaka",
5
+ body: "body-ZvhIH",
6
+ heading: "heading-kAg49",
7
+ dismiss: "dismiss-KQOWr",
8
+ toneWord: "toneWord-kfv8E"
9
+ };
10
+ export default Alert_module;
@@ -0,0 +1,91 @@
1
+ .root-k99cj {
2
+ align-items: flex-start;
3
+ gap: var(--space-3);
4
+ padding: var(--space-3) var(--space-4);
5
+ border: 1px solid var(--color-border);
6
+ border-inline-start: var(--border-width-strong) solid var(--color-neutral);
7
+ border-radius: var(--radius-md);
8
+ background: var(--color-surface-2);
9
+ color: var(--color-text);
10
+ font-size: var(--text-sm);
11
+ line-height: var(--leading-prose);
12
+ display: flex;
13
+ }
14
+
15
+ .root-k99cj[data-tone="info"] {
16
+ border-inline-start-color: var(--color-accent);
17
+ }
18
+
19
+ .root-k99cj[data-tone="success"] {
20
+ border-inline-start-color: var(--color-success);
21
+ }
22
+
23
+ .root-k99cj[data-tone="warning"] {
24
+ border-inline-start-color: var(--color-warning);
25
+ }
26
+
27
+ .root-k99cj[data-tone="danger"] {
28
+ border-color: var(--color-danger-border);
29
+ border-inline-start-color: var(--color-danger);
30
+ background: var(--color-danger-surface);
31
+ }
32
+
33
+ .icon-GCaka {
34
+ color: var(--color-neutral);
35
+ flex: none;
36
+ margin-block-start: var(--space-1);
37
+ display: flex;
38
+ }
39
+
40
+ .icon-GCaka > svg {
41
+ width: 1rem;
42
+ height: 1rem;
43
+ }
44
+
45
+ .root-k99cj[data-tone="info"] .icon-GCaka {
46
+ color: var(--color-accent);
47
+ }
48
+
49
+ .root-k99cj[data-tone="success"] .icon-GCaka {
50
+ color: var(--color-success);
51
+ }
52
+
53
+ .root-k99cj[data-tone="warning"] .icon-GCaka {
54
+ color: var(--color-warning);
55
+ }
56
+
57
+ .root-k99cj[data-tone="danger"] .icon-GCaka {
58
+ color: var(--color-danger);
59
+ }
60
+
61
+ .body-ZvhIH {
62
+ gap: var(--space-1);
63
+ flex-direction: column;
64
+ flex: auto;
65
+ min-width: 0;
66
+ display: flex;
67
+ }
68
+
69
+ .heading-kAg49 {
70
+ font-size: var(--text-sm);
71
+ font-weight: 600;
72
+ line-height: var(--leading-snug);
73
+ }
74
+
75
+ .dismiss-KQOWr {
76
+ flex: none;
77
+ align-self: flex-start;
78
+ }
79
+
80
+ .toneWord-kfv8E {
81
+ clip-path: inset(50%);
82
+ white-space: nowrap;
83
+ border: 0;
84
+ width: 1px;
85
+ height: 1px;
86
+ margin: -1px;
87
+ padding: 0;
88
+ position: absolute;
89
+ overflow: hidden;
90
+ }
91
+
@@ -0,0 +1,8 @@
1
+ export interface AvatarProps {
2
+ /** The person or thing this stands for. Used as the image's alt text and as the initials source. */
3
+ name: string;
4
+ src?: string;
5
+ size?: 'sm' | 'md' | 'lg';
6
+ shape?: 'circle' | 'square';
7
+ }
8
+ export declare function Avatar({ name, src, size, shape }: AvatarProps): import("react").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Avatar } from "@base-ui/react/avatar";
3
+ import Avatar_module from "./Avatar.module.js";
4
+ function leadingCharacters(word, count) {
5
+ return Array.from(word).slice(0, count).join('');
6
+ }
7
+ function initialsFrom(name) {
8
+ const words = name.normalize('NFC').trim().split(/\s+/).filter(Boolean);
9
+ const firstWord = words.at(0);
10
+ const lastWord = words.at(-1);
11
+ if (void 0 === firstWord || void 0 === lastWord) return '';
12
+ if (1 === words.length) return leadingCharacters(firstWord, 2).toUpperCase();
13
+ return `${leadingCharacters(firstWord, 1)}${leadingCharacters(lastWord, 1)}`.toUpperCase();
14
+ }
15
+ function Avatar_Avatar({ name, src, size = 'md', shape = 'circle' }) {
16
+ return /*#__PURE__*/ jsxs(Avatar.Root, {
17
+ className: Avatar_module.root,
18
+ "data-size": size,
19
+ "data-shape": shape,
20
+ "data-testid": "avatar",
21
+ children: [
22
+ void 0 !== src ? /*#__PURE__*/ jsx(Avatar.Image, {
23
+ className: Avatar_module.image,
24
+ src: src,
25
+ alt: name
26
+ }) : null,
27
+ /*#__PURE__*/ jsxs(Avatar.Fallback, {
28
+ className: Avatar_module.fallback,
29
+ children: [
30
+ /*#__PURE__*/ jsx("span", {
31
+ "aria-hidden": "true",
32
+ children: initialsFrom(name)
33
+ }),
34
+ /*#__PURE__*/ jsx("span", {
35
+ className: Avatar_module.name,
36
+ children: name
37
+ })
38
+ ]
39
+ })
40
+ ]
41
+ });
42
+ }
43
+ export { Avatar_Avatar as Avatar };
@@ -0,0 +1,8 @@
1
+ import "./Avatar_module.css";
2
+ const Avatar_module = {
3
+ root: "root-uFk_6",
4
+ image: "image-i3BrF",
5
+ fallback: "fallback-r0pag",
6
+ name: "name-cQDpe"
7
+ };
8
+ export default Avatar_module;
@@ -0,0 +1,61 @@
1
+ .root-uFk_6 {
2
+ border-radius: var(--radius-full);
3
+ background: var(--color-surface-3);
4
+ color: var(--color-text-muted);
5
+ font-size: var(--text-sm);
6
+ font-weight: 600;
7
+ line-height: var(--leading-tight);
8
+ -webkit-user-select: none;
9
+ user-select: none;
10
+ flex: none;
11
+ justify-content: center;
12
+ align-items: center;
13
+ display: inline-flex;
14
+ overflow: hidden;
15
+ }
16
+
17
+ .root-uFk_6[data-shape="square"] {
18
+ border-radius: var(--radius-md);
19
+ }
20
+
21
+ .root-uFk_6[data-size="sm"] {
22
+ width: 1.75rem;
23
+ height: 1.75rem;
24
+ font-size: var(--text-2xs);
25
+ }
26
+
27
+ .root-uFk_6[data-size="md"] {
28
+ width: 2.5rem;
29
+ height: 2.5rem;
30
+ }
31
+
32
+ .root-uFk_6[data-size="lg"] {
33
+ width: 4rem;
34
+ height: 4rem;
35
+ font-size: var(--text-lg);
36
+ }
37
+
38
+ .image-i3BrF {
39
+ object-fit: cover;
40
+ width: 100%;
41
+ height: 100%;
42
+ }
43
+
44
+ .fallback-r0pag {
45
+ justify-content: center;
46
+ align-items: center;
47
+ display: inline-flex;
48
+ }
49
+
50
+ .name-cQDpe {
51
+ clip-path: inset(50%);
52
+ white-space: nowrap;
53
+ border: 0;
54
+ width: 1px;
55
+ height: 1px;
56
+ margin: -1px;
57
+ padding: 0;
58
+ position: absolute;
59
+ overflow: hidden;
60
+ }
61
+
@@ -0,0 +1,40 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from 'react';
2
+ export interface ErrorBoundaryFallbackDetails {
3
+ error: Error;
4
+ /** Clears the caught error and renders the children again. */
5
+ reset: () => void;
6
+ }
7
+ export interface ErrorBoundaryProps {
8
+ children: ReactNode;
9
+ /** Rendered instead of the children once an error has been caught. */
10
+ fallback?: (details: ErrorBoundaryFallbackDetails) => ReactNode;
11
+ /** Called once per caught error, for logging. The second argument is the component stack. */
12
+ onError?: (error: Error, componentStack: string) => void;
13
+ /**
14
+ * When any value here changes, a boundary that has caught an error renders its children again.
15
+ * Pass the route path to clear a failure automatically when the user navigates away from it.
16
+ */
17
+ resetKeys?: readonly unknown[];
18
+ /** The default fallback's heading. */
19
+ heading?: string;
20
+ /** The heading's level. Match it to where the alert sits in the page's outline. */
21
+ headingLevel?: 2 | 3 | 4;
22
+ /** The default fallback's retry control. */
23
+ retryLabel?: string;
24
+ }
25
+ interface ErrorBoundaryState {
26
+ error: Error | null;
27
+ }
28
+ /**
29
+ * The library's only class component: `getDerivedStateFromError` and `componentDidCatch` exist
30
+ * on classes alone, so an error boundary cannot be written as a function.
31
+ */
32
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
33
+ state: ErrorBoundaryState;
34
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
35
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
36
+ componentDidUpdate(previousProps: ErrorBoundaryProps): void;
37
+ reset: () => void;
38
+ render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
39
+ }
40
+ export {};
@@ -0,0 +1,58 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Component } from "react";
3
+ import { Alert } from "../Alert/Alert.js";
4
+ import { Button } from "../Button/Button.js";
5
+ import ErrorBoundary_module from "./ErrorBoundary.module.js";
6
+ class ErrorBoundary extends Component {
7
+ state = {
8
+ error: null
9
+ };
10
+ static getDerivedStateFromError(error) {
11
+ return {
12
+ error
13
+ };
14
+ }
15
+ componentDidCatch(error, errorInfo) {
16
+ this.props.onError?.(error, errorInfo.componentStack ?? '');
17
+ }
18
+ componentDidUpdate(previousProps) {
19
+ const { resetKeys } = this.props;
20
+ if (null === this.state.error || void 0 === resetKeys) return;
21
+ const previousKeys = previousProps.resetKeys ?? [];
22
+ const changed = resetKeys.length !== previousKeys.length || resetKeys.some((key, keyIndex)=>!Object.is(key, previousKeys[keyIndex]));
23
+ if (changed) this.reset();
24
+ }
25
+ reset = ()=>{
26
+ this.setState({
27
+ error: null
28
+ });
29
+ };
30
+ render() {
31
+ const { error } = this.state;
32
+ const { children, fallback, heading = 'Something went wrong', headingLevel = 3, retryLabel = 'Try again' } = this.props;
33
+ if (null === error) return children;
34
+ if (void 0 !== fallback) return fallback({
35
+ error,
36
+ reset: this.reset
37
+ });
38
+ return /*#__PURE__*/ jsxs("div", {
39
+ className: ErrorBoundary_module.root,
40
+ children: [
41
+ /*#__PURE__*/ jsx(Alert, {
42
+ tone: "danger",
43
+ announce: true,
44
+ heading: heading,
45
+ headingLevel: headingLevel,
46
+ children: error.message
47
+ }),
48
+ /*#__PURE__*/ jsx(Button, {
49
+ variant: "secondary",
50
+ size: "sm",
51
+ onClick: this.reset,
52
+ children: retryLabel
53
+ })
54
+ ]
55
+ });
56
+ }
57
+ }
58
+ export { ErrorBoundary };
@@ -0,0 +1,5 @@
1
+ import "./ErrorBoundary_module.css";
2
+ const ErrorBoundary_module = {
3
+ root: "root-_RQKT"
4
+ };
5
+ export default ErrorBoundary_module;
@@ -0,0 +1,6 @@
1
+ .root-_RQKT {
2
+ gap: var(--space-3);
3
+ justify-items: start;
4
+ display: grid;
5
+ }
6
+
@@ -0,0 +1,23 @@
1
+ import { Button as BaseButton } from '@base-ui/react/button';
2
+ import type { ComponentPropsWithoutRef } from 'react';
3
+ export type IconButtonVariant = 'primary' | 'secondary' | 'ghost';
4
+ export type IconButtonSize = 'md' | 'sm';
5
+ export interface IconButtonProps extends Omit<ComponentPropsWithoutRef<typeof BaseButton>, 'className' | 'aria-label' | 'aria-labelledby'> {
6
+ /**
7
+ * The button's accessible name. Required: there is no visible text to fall back on.
8
+ *
9
+ * The type deliberately rejects `aria-label` and `aria-labelledby`. `aria-labelledby` beats
10
+ * `aria-label` in the accessible-name algorithm no matter which order the props are written
11
+ * in, so a caller passing it alongside `label` would silently replace the name this component
12
+ * is supposed to guarantee. TypeScript does not excess-property-check a JSX spread, though: an
13
+ * object built elsewhere and spread in as `{...props}` can still smuggle either through to the
14
+ * DOM, where it wins the accessible-name algorithm the same way. There is no runtime guard.
15
+ */
16
+ label: string;
17
+ variant?: IconButtonVariant;
18
+ size?: IconButtonSize;
19
+ /** Swaps the icon for a spinner, keeps the button focusable, and blocks activation. */
20
+ loading?: boolean;
21
+ className?: string;
22
+ }
23
+ export declare function IconButton({ label, variant, size, loading, disabled, className, children, nativeButton, ...rest }: IconButtonProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Button } from "@base-ui/react/button";
3
+ import { Spinner } from "../Spinner/Spinner.js";
4
+ import IconButton_module from "./IconButton.module.js";
5
+ function IconButton({ label, variant = 'ghost', size = 'md', loading = false, disabled, className, children, nativeButton, ...rest }) {
6
+ const isDisabled = Boolean(disabled) || loading;
7
+ const isNativeButton = nativeButton ?? !rest.render;
8
+ return /*#__PURE__*/ jsx(Button, {
9
+ ...rest,
10
+ nativeButton: isNativeButton,
11
+ className: [
12
+ IconButton_module.root,
13
+ className
14
+ ].filter(Boolean).join(' '),
15
+ "data-variant": variant,
16
+ "data-size": size,
17
+ "data-loading": loading ? '' : void 0,
18
+ disabled: isDisabled,
19
+ focusableWhenDisabled: loading,
20
+ "aria-label": label,
21
+ "aria-busy": loading || void 0,
22
+ children: /*#__PURE__*/ jsx("span", {
23
+ className: IconButton_module.icon,
24
+ children: loading ? /*#__PURE__*/ jsx(Spinner, {
25
+ size: "sm"
26
+ }) : children
27
+ })
28
+ });
29
+ }
30
+ export { IconButton };
@@ -0,0 +1,6 @@
1
+ import "./IconButton_module.css";
2
+ const IconButton_module = {
3
+ root: "root-TzUP5",
4
+ icon: "icon-WceXT"
5
+ };
6
+ export default IconButton_module;
@@ -0,0 +1,73 @@
1
+ .root-TzUP5 {
2
+ min-height: var(--size-touch);
3
+ min-width: var(--size-touch);
4
+ border-radius: var(--radius-full);
5
+ color: var(--color-text-muted);
6
+ cursor: pointer;
7
+ transition-property: background-color, color, border-color;
8
+ transition-duration: var(--motion-duration-1);
9
+ transition-timing-function: var(--motion-ease);
10
+ -webkit-tap-highlight-color: transparent;
11
+ background: none;
12
+ border: 1px solid #0000;
13
+ justify-content: center;
14
+ align-items: center;
15
+ padding: 0;
16
+ display: inline-flex;
17
+ }
18
+
19
+ .root-TzUP5[data-size="sm"] {
20
+ min-width: 2.5rem;
21
+ min-height: 2.5rem;
22
+ }
23
+
24
+ .root-TzUP5[data-variant="secondary"] {
25
+ border-radius: var(--radius-md);
26
+ background: var(--color-surface-raised);
27
+ border-color: var(--color-border-strong);
28
+ color: var(--color-text);
29
+ }
30
+
31
+ .root-TzUP5[data-variant="primary"] {
32
+ background: var(--color-accent);
33
+ color: var(--color-accent-text);
34
+ }
35
+
36
+ @media (hover: hover) {
37
+ .root-TzUP5[data-variant="ghost"]:hover:not([data-disabled]) {
38
+ background: var(--color-surface-2);
39
+ color: var(--color-text);
40
+ }
41
+
42
+ .root-TzUP5[data-variant="secondary"]:hover:not([data-disabled]) {
43
+ background: var(--color-surface-2);
44
+ }
45
+
46
+ .root-TzUP5[data-variant="primary"]:hover:not([data-disabled]) {
47
+ background: var(--color-accent-hover);
48
+ }
49
+ }
50
+
51
+ .root-TzUP5:active:not([data-disabled]) {
52
+ transform: scale(.96);
53
+ }
54
+
55
+ .root-TzUP5[data-disabled] {
56
+ cursor: not-allowed;
57
+ opacity: .45;
58
+ }
59
+
60
+ .icon-WceXT {
61
+ display: inline-flex;
62
+ }
63
+
64
+ .icon-WceXT > svg {
65
+ width: 1.25rem;
66
+ height: 1.25rem;
67
+ }
68
+
69
+ .root-TzUP5[data-size="sm"] .icon-WceXT > svg {
70
+ width: 1rem;
71
+ height: 1rem;
72
+ }
73
+
@@ -0,0 +1,10 @@
1
+ export interface SkeletonProps {
2
+ /** `text` draws one bar per line at text height, `block` a rectangle, `circle` an avatar slot. */
3
+ variant?: 'text' | 'block' | 'circle';
4
+ /** How many bars `text` draws. The last one is drawn short, as a paragraph's last line is. */
5
+ lines?: number;
6
+ /** Any CSS length. Ignored by the last line of a `text` skeleton, which is always 60%. */
7
+ width?: string;
8
+ height?: string;
9
+ }
10
+ export declare function Skeleton({ variant, lines, width, height }: SkeletonProps): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import Skeleton_module from "./Skeleton.module.js";
3
+ function Skeleton({ variant = 'text', lines = 3, width, height }) {
4
+ if ('text' !== variant) return /*#__PURE__*/ jsx("span", {
5
+ className: Skeleton_module.root,
6
+ "data-variant": variant,
7
+ "data-testid": "skeleton",
8
+ "aria-hidden": "true",
9
+ style: {
10
+ width,
11
+ height
12
+ }
13
+ });
14
+ const lineCount = Number.isFinite(lines) ? Math.min(Math.max(0, Math.trunc(lines)), 100) : 0;
15
+ return /*#__PURE__*/ jsx("span", {
16
+ className: Skeleton_module.lines,
17
+ "data-testid": "skeleton",
18
+ "aria-hidden": "true",
19
+ children: [
20
+ ...Array(lineCount).keys()
21
+ ].map((lineIndex)=>{
22
+ const isLastOfSeveral = lineCount > 1 && lineIndex === lineCount - 1;
23
+ return /*#__PURE__*/ jsx("span", {
24
+ className: Skeleton_module.root,
25
+ "data-variant": "text",
26
+ style: {
27
+ width: isLastOfSeveral ? '60%' : width,
28
+ height
29
+ }
30
+ }, lineIndex);
31
+ })
32
+ });
33
+ }
34
+ export { Skeleton };
@@ -0,0 +1,7 @@
1
+ import "./Skeleton_module.css";
2
+ const Skeleton_module = {
3
+ root: "root-pcpRR",
4
+ pulse: "pulse-QsHtA",
5
+ lines: "lines-Ni2yI"
6
+ };
7
+ export default Skeleton_module;
@@ -0,0 +1,45 @@
1
+ .root-pcpRR {
2
+ border-radius: var(--radius-sm);
3
+ background: var(--color-surface-3);
4
+ animation-name: pulse-QsHtA;
5
+ animation-duration: var(--motion-duration-4);
6
+ animation-timing-function: var(--motion-ease);
7
+ animation-iteration-count: infinite;
8
+ animation-direction: alternate;
9
+ display: block;
10
+ }
11
+
12
+ .root-pcpRR[data-variant="text"] {
13
+ width: 100%;
14
+ height: 1em;
15
+ }
16
+
17
+ .root-pcpRR[data-variant="block"] {
18
+ border-radius: var(--radius-md);
19
+ width: 100%;
20
+ height: 6rem;
21
+ }
22
+
23
+ .root-pcpRR[data-variant="circle"] {
24
+ border-radius: var(--radius-full);
25
+ width: 2.5rem;
26
+ height: 2.5rem;
27
+ }
28
+
29
+ .lines-Ni2yI {
30
+ gap: var(--space-2);
31
+ flex-direction: column;
32
+ width: 100%;
33
+ display: flex;
34
+ }
35
+
36
+ @keyframes pulse-QsHtA {
37
+ from {
38
+ opacity: .5;
39
+ }
40
+
41
+ to {
42
+ opacity: 1;
43
+ }
44
+ }
45
+
@@ -0,0 +1,12 @@
1
+ export interface SpinnerProps {
2
+ /** `sm` sits inside a button or an input, `md` beside a block of content, `lg` on a whole page. */
3
+ size?: 'sm' | 'md' | 'lg';
4
+ /**
5
+ * When given, the spinner announces itself: this text is rendered visually hidden inside a
6
+ * `role="status"` region. Leave it out whenever the thing that is loading already says so —
7
+ * `Button`'s `loading` prop sets `aria-busy` on the button itself, and a second announcement
8
+ * from the spinner inside it would be noise.
9
+ */
10
+ label?: string;
11
+ }
12
+ export declare function Spinner({ size, label }: SpinnerProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import Spinner_module from "./Spinner.module.js";
3
+ function Spinner({ size = 'md', label }) {
4
+ const ring = /*#__PURE__*/ jsx("span", {
5
+ className: Spinner_module.root,
6
+ "data-size": size,
7
+ "data-testid": "spinner",
8
+ "aria-hidden": "true"
9
+ });
10
+ if (void 0 === label) return ring;
11
+ return /*#__PURE__*/ jsxs("span", {
12
+ className: Spinner_module.wrapper,
13
+ role: "status",
14
+ children: [
15
+ ring,
16
+ /*#__PURE__*/ jsx("span", {
17
+ className: Spinner_module.label,
18
+ children: label
19
+ })
20
+ ]
21
+ });
22
+ }
23
+ export { Spinner };
@@ -0,0 +1,8 @@
1
+ import "./Spinner_module.css";
2
+ const Spinner_module = {
3
+ root: "root-txP67",
4
+ spin: "spin-yXQPz",
5
+ wrapper: "wrapper-xbqhl",
6
+ label: "label-RTZW7"
7
+ };
8
+ export default Spinner_module;
@@ -0,0 +1,50 @@
1
+ .root-txP67 {
2
+ border: var(--border-width-emphasis) solid var(--color-border-strong);
3
+ border-top-color: var(--color-accent);
4
+ border-radius: var(--radius-full);
5
+ animation-name: spin-yXQPz;
6
+ animation-duration: var(--motion-duration-4);
7
+ flex: none;
8
+ animation-timing-function: linear;
9
+ animation-iteration-count: infinite;
10
+ display: inline-block;
11
+ }
12
+
13
+ .root-txP67[data-size="sm"] {
14
+ width: 1rem;
15
+ height: 1rem;
16
+ }
17
+
18
+ .root-txP67[data-size="md"] {
19
+ width: 1.5rem;
20
+ height: 1.5rem;
21
+ }
22
+
23
+ .root-txP67[data-size="lg"] {
24
+ width: 2.5rem;
25
+ height: 2.5rem;
26
+ }
27
+
28
+ .wrapper-xbqhl {
29
+ align-items: center;
30
+ display: inline-flex;
31
+ }
32
+
33
+ .label-RTZW7 {
34
+ clip-path: inset(50%);
35
+ white-space: nowrap;
36
+ border: 0;
37
+ width: 1px;
38
+ height: 1px;
39
+ margin: -1px;
40
+ padding: 0;
41
+ position: absolute;
42
+ overflow: hidden;
43
+ }
44
+
45
+ @keyframes spin-yXQPz {
46
+ to {
47
+ transform: rotate(360deg);
48
+ }
49
+ }
50
+
package/dist/index.d.ts CHANGED
@@ -21,3 +21,15 @@ export type { NavMenuProps, NavItem, LinkRenderProps } from './components/NavMen
21
21
  export { useMediaQuery, minWidth } from './hooks/useMediaQuery.js';
22
22
  export { DataTable, createColumnHelper } from './components/DataTable/DataTable.js';
23
23
  export type { DataTableProps, ColumnDef, SortingState } from './components/DataTable/DataTable.js';
24
+ export { Spinner } from './components/Spinner/Spinner.js';
25
+ export type { SpinnerProps } from './components/Spinner/Spinner.js';
26
+ export { Skeleton } from './components/Skeleton/Skeleton.js';
27
+ export type { SkeletonProps } from './components/Skeleton/Skeleton.js';
28
+ export { IconButton } from './components/IconButton/IconButton.js';
29
+ export type { IconButtonProps, IconButtonVariant, IconButtonSize, } from './components/IconButton/IconButton.js';
30
+ export { Alert } from './components/Alert/Alert.js';
31
+ export type { AlertProps, AlertTone } from './components/Alert/Alert.js';
32
+ export { Avatar } from './components/Avatar/Avatar.js';
33
+ export type { AvatarProps } from './components/Avatar/Avatar.js';
34
+ export { ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary.js';
35
+ export type { ErrorBoundaryProps, ErrorBoundaryFallbackDetails, } from './components/ErrorBoundary/ErrorBoundary.js';
package/dist/index.js CHANGED
@@ -10,3 +10,9 @@ export { PageHeading } from "./components/PageHeading/PageHeading.js";
10
10
  export { NavMenu } from "./components/NavMenu/NavMenu.js";
11
11
  export { minWidth, useMediaQuery } from "./hooks/useMediaQuery.js";
12
12
  export { DataTable, createColumnHelper } from "./components/DataTable/DataTable.js";
13
+ export { Spinner } from "./components/Spinner/Spinner.js";
14
+ export { Skeleton } from "./components/Skeleton/Skeleton.js";
15
+ export { IconButton } from "./components/IconButton/IconButton.js";
16
+ export { Alert } from "./components/Alert/Alert.js";
17
+ export { Avatar } from "./components/Avatar/Avatar.js";
18
+ export { ErrorBoundary } from "./components/ErrorBoundary/ErrorBoundary.js";
@@ -1,4 +1,7 @@
1
- *, :before, :after {
1
+ /* Base styles shared by every app and by Storybook. Tokens come from @calcifer-design/tokens/tokens.css. */
2
+ *,
3
+ *::before,
4
+ *::after {
2
5
  box-sizing: border-box;
3
6
  }
4
7
 
@@ -13,16 +16,20 @@ html {
13
16
  }
14
17
 
15
18
  body {
16
- min-height: 100dvh;
17
19
  margin: 0;
20
+ min-height: 100dvh;
18
21
  }
19
22
 
20
- img, video {
23
+ img,
24
+ video {
21
25
  max-width: 100%;
22
26
  height: auto;
23
27
  }
24
28
 
25
- button, input, select, textarea {
29
+ button,
30
+ input,
31
+ select,
32
+ textarea {
26
33
  font: inherit;
27
34
  color: inherit;
28
35
  }
@@ -32,27 +39,31 @@ button, input, select, textarea {
32
39
  outline-offset: var(--focus-ring-offset);
33
40
  }
34
41
 
35
- h1, h2, h3 {
42
+ h1,
43
+ h2,
44
+ h3 {
36
45
  line-height: var(--leading-tight);
37
46
  letter-spacing: var(--tracking-heading);
38
47
  margin: 0;
39
48
  }
40
49
 
41
50
  p {
42
- max-width: var(--measure);
43
51
  margin: 0;
52
+ max-width: var(--measure);
44
53
  }
45
54
 
46
- code, pre {
55
+ code,
56
+ pre {
47
57
  font-family: var(--font-mono);
48
58
  }
49
59
 
50
60
  @media (prefers-reduced-motion: reduce) {
51
- *, :before, :after {
52
- scroll-behavior: auto !important;
53
- transition-duration: .01ms !important;
54
- animation-duration: .01ms !important;
61
+ *,
62
+ *::before,
63
+ *::after {
64
+ animation-duration: 0.01ms !important;
55
65
  animation-iteration-count: 1 !important;
66
+ transition-duration: 0.01ms !important;
67
+ scroll-behavior: auto !important;
56
68
  }
57
69
  }
58
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcifer-design/ui",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {