@slurp-ui/react 1.3.0 → 1.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/CHANGELOG.md +6 -0
- package/dist/Reveal/Reveal.d.ts +16 -0
- package/dist/Reveal/Reveal.js +77 -0
- package/dist/Reveal/Reveal.js.map +1 -0
- package/dist/Reveal/index.d.ts +3 -0
- package/dist/Reveal/index.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/lib/theme.d.ts +5 -0
- package/dist/lib/theme.js.map +1 -1
- package/dist/styles.css +21 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @slurp-ui/react
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b386d97: New component: `Reveal`, a large sentence whose words go from the secondary colour to the full one as the page scrolls. Colour only, lit with reduced motion and without script.
|
|
8
|
+
|
|
3
9
|
## 1.3.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface RevealOwnProps {
|
|
5
|
+
/** The sentence: plain text, at least two lines at 680px. The line breaks are chosen by the browser. */
|
|
6
|
+
children: string;
|
|
7
|
+
}
|
|
8
|
+
export type RevealProps<E extends ElementType = 'p'> = PolymorphicProps<E, RevealOwnProps>;
|
|
9
|
+
/**
|
|
10
|
+
* A large sentence whose words go from the secondary colour to the full one, one at a time, as they cross a line at
|
|
11
|
+
* 65% of the viewport height while the page scrolls. Colour only: nothing moves. Once lit a word stays lit; at the
|
|
12
|
+
* end of the page whatever is still dim lights up, so no word stays dim for good. Reduced motion, no script and no
|
|
13
|
+
* `IntersectionObserver`: the sentence is simply lit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Reveal<E extends ElementType = 'p'>(props: RevealProps<E>): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=Reveal.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { Fragment, useEffect, useRef } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/Reveal/Reveal.tsx
|
|
9
|
+
/** Milliseconds between words that light up together, and the most the whole batch waits. */
|
|
10
|
+
const STEP = 30;
|
|
11
|
+
const CAP = 400;
|
|
12
|
+
/**
|
|
13
|
+
* A large sentence whose words go from the secondary colour to the full one, one at a time, as they cross a line at
|
|
14
|
+
* 65% of the viewport height while the page scrolls. Colour only: nothing moves. Once lit a word stays lit; at the
|
|
15
|
+
* end of the page whatever is still dim lights up, so no word stays dim for good. Reduced motion, no script and no
|
|
16
|
+
* `IntersectionObserver`: the sentence is simply lit.
|
|
17
|
+
*/
|
|
18
|
+
function Reveal(props) {
|
|
19
|
+
const { as, css, className, children, ref, ...rest } = useThemeProps("Reveal", props);
|
|
20
|
+
const Root = as ?? "p";
|
|
21
|
+
const styled = useCss("Reveal", "root", css);
|
|
22
|
+
const own = useRef(null);
|
|
23
|
+
const root = useAnimationRoot({
|
|
24
|
+
...rest,
|
|
25
|
+
ref: useForkRef(ref, own)
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const el = own.current;
|
|
29
|
+
if (!el || typeof IntersectionObserver === "undefined") return;
|
|
30
|
+
if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
31
|
+
const words = [...el.querySelectorAll(".slurp-reveal-word")];
|
|
32
|
+
const dim = () => words.filter((w) => !w.hasAttribute("data-lit"));
|
|
33
|
+
const light = (list) => list.forEach((w, i) => {
|
|
34
|
+
w.style.transitionDelay = `${Math.min(i * STEP, CAP)}ms`;
|
|
35
|
+
w.setAttribute("data-lit", "");
|
|
36
|
+
});
|
|
37
|
+
el.setAttribute("data-armed", "");
|
|
38
|
+
const crossed = new IntersectionObserver((entries) => {
|
|
39
|
+
const batch = entries.filter((e) => e.isIntersecting || e.rootBounds != null && e.boundingClientRect.top < e.rootBounds.top).map((e) => e.target).sort((a, b) => words.indexOf(a) - words.indexOf(b));
|
|
40
|
+
light(batch);
|
|
41
|
+
batch.forEach((w) => crossed.unobserve(w));
|
|
42
|
+
}, { rootMargin: "0px 0px -35% 0px" });
|
|
43
|
+
words.forEach((w) => crossed.observe(w));
|
|
44
|
+
let frame = 0;
|
|
45
|
+
const atEnd = () => {
|
|
46
|
+
frame = 0;
|
|
47
|
+
const doc = document.documentElement;
|
|
48
|
+
if (window.scrollY + window.innerHeight >= doc.scrollHeight - 2) light(dim());
|
|
49
|
+
};
|
|
50
|
+
const onScroll = () => {
|
|
51
|
+
if (!frame && dim().length) frame = requestAnimationFrame(atEnd);
|
|
52
|
+
};
|
|
53
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
54
|
+
onScroll();
|
|
55
|
+
return () => {
|
|
56
|
+
crossed.disconnect();
|
|
57
|
+
window.removeEventListener("scroll", onScroll);
|
|
58
|
+
if (frame) cancelAnimationFrame(frame);
|
|
59
|
+
el.removeAttribute("data-armed");
|
|
60
|
+
words.forEach((w) => {
|
|
61
|
+
w.removeAttribute("data-lit");
|
|
62
|
+
w.style.transitionDelay = "";
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}, [children]);
|
|
66
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
67
|
+
className: cx("slurp-reveal", styled.className, className),
|
|
68
|
+
...root,
|
|
69
|
+
children: children.split(" ").map((word, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && " ", /* @__PURE__ */ jsx("span", {
|
|
70
|
+
className: "slurp-reveal-word",
|
|
71
|
+
children: word
|
|
72
|
+
})] }, i))
|
|
73
|
+
})] });
|
|
74
|
+
}
|
|
75
|
+
export { Reveal };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=Reveal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reveal.js","names":[],"sources":["../../src/Reveal/Reveal.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport { Fragment, useEffect, useRef, type ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface RevealOwnProps {\n /** The sentence: plain text, at least two lines at 680px. The line breaks are chosen by the browser. */\n children: string;\n}\n\nexport type RevealProps<E extends ElementType = 'p'> = PolymorphicProps<E, RevealOwnProps>;\n\n/** Milliseconds between words that light up together, and the most the whole batch waits. */\nconst STEP = 30;\nconst CAP = 400;\n\n/**\n * A large sentence whose words go from the secondary colour to the full one, one at a time, as they cross a line at\n * 65% of the viewport height while the page scrolls. Colour only: nothing moves. Once lit a word stays lit; at the\n * end of the page whatever is still dim lights up, so no word stays dim for good. Reduced motion, no script and no\n * `IntersectionObserver`: the sentence is simply lit.\n */\nexport function Reveal<E extends ElementType = 'p'>(props: RevealProps<E>) {\n const { as, css, className, children, ref, ...rest } = useThemeProps(\n 'Reveal',\n props as RevealProps,\n );\n const Root = (as ?? 'p') as ElementType;\n const styled = useCss('Reveal', 'root', css);\n const own = useRef<HTMLElement>(null);\n const root = useAnimationRoot({ ...rest, ref: useForkRef(ref as never, own as never) });\n\n useEffect(() => {\n const el = own.current;\n if (!el || typeof IntersectionObserver === 'undefined') return;\n if (typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches)\n return;\n const words = [...el.querySelectorAll<HTMLElement>('.slurp-reveal-word')];\n const dim = () => words.filter((w) => !w.hasAttribute('data-lit'));\n const light = (list: HTMLElement[]) =>\n list.forEach((w, i) => {\n w.style.transitionDelay = `${Math.min(i * STEP, CAP)}ms`;\n w.setAttribute('data-lit', '');\n });\n el.setAttribute('data-armed', '');\n\n const crossed = new IntersectionObserver(\n (entries) => {\n const batch = entries\n .filter(\n (e) =>\n e.isIntersecting ||\n (e.rootBounds != null && e.boundingClientRect.top < e.rootBounds.top),\n )\n .map((e) => e.target as HTMLElement)\n .sort((a, b) => words.indexOf(a) - words.indexOf(b));\n light(batch);\n batch.forEach((w) => crossed.unobserve(w));\n },\n { rootMargin: '0px 0px -35% 0px' },\n );\n words.forEach((w) => crossed.observe(w));\n\n // The page cannot scroll further: whatever is still dim lights up (checked once per frame, only while dim).\n let frame = 0;\n const atEnd = () => {\n frame = 0;\n const doc = document.documentElement;\n if (window.scrollY + window.innerHeight >= doc.scrollHeight - 2) light(dim());\n };\n const onScroll = () => {\n if (!frame && dim().length) frame = requestAnimationFrame(atEnd);\n };\n window.addEventListener('scroll', onScroll, { passive: true });\n onScroll();\n\n return () => {\n crossed.disconnect();\n window.removeEventListener('scroll', onScroll);\n if (frame) cancelAnimationFrame(frame);\n el.removeAttribute('data-armed');\n words.forEach((w) => {\n w.removeAttribute('data-lit');\n w.style.transitionDelay = '';\n });\n };\n }, [children]);\n\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-reveal', styled.className, className)} {...root}>\n {children.split(' ').map((word, i) => (\n <Fragment key={i}>\n {i > 0 && ' '}\n <span className=\"slurp-reveal-word\">{word}</span>\n </Fragment>\n ))}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAgBA,MAAM,OAAO;AACb,MAAM,MAAM;;;;;;;AAQZ,SAAgB,OAAoC,OAAuB;CACzE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,KAAK,GAAG,SAAS,cACrD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B;GACrB,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,QAAQ,sBAAsB,KAAK;EACjE;EACA,OAAO,iBAAiB,UAAU,UAAU,EAAE,SAAS,KAAK,CAAC;EAC7D,SAAS;EAET,aAAa;GACX,QAAQ,WAAW;GACnB,OAAO,oBAAoB,UAAU,QAAQ;GAC7C,IAAI,OAAO,qBAAqB,KAAK;GACrC,GAAG,gBAAgB,YAAY;GAC/B,MAAM,SAAS,MAAM;IACnB,EAAE,gBAAgB,UAAU;IAC5B,EAAE,MAAM,kBAAkB;GAC5B,CAAC;EACH;CACF,GAAG,CAAC,QAAQ,CAAC;CAEb,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;EAAG,GAAI;EACnE,UAAA,SAAS,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,MAC9B,qBAAC,UAAD,EAAA,UAAA,CACG,IAAI,KAAK,KACV,oBAAC,QAAD;GAAM,WAAU;GAAqB,UAAA;EAAW,CAAA,CACxC,EAAA,GAHK,CAGL,CACX;CACG,CAAA,CACN,EAAA,CAAA;AAEN"}
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ import { RATING_LABELS, Rating, RatingLabels, RatingProps } from "./Rating/Ratin
|
|
|
118
118
|
import "./Rating/index.js";
|
|
119
119
|
import { ResultRow, ResultRowProps } from "./ResultRow/ResultRow.js";
|
|
120
120
|
import "./ResultRow/index.js";
|
|
121
|
+
import { Reveal, RevealProps } from "./Reveal/Reveal.js";
|
|
122
|
+
import "./Reveal/index.js";
|
|
121
123
|
import { Score, ScoreProps } from "./Score/Score.js";
|
|
122
124
|
import "./Score/index.js";
|
|
123
125
|
import { SEARCH_LABELS, Search, SearchLabels, SearchProps } from "./Search/Search.js";
|
|
@@ -185,4 +187,4 @@ import { FindInPage, focusHit, useFindInPage } from "./utils/useFindInPage.js";
|
|
|
185
187
|
import { useClipboard } from "./utils/useClipboard.js";
|
|
186
188
|
import { useScrollSpy } from "./utils/useScrollSpy.js";
|
|
187
189
|
import "./utils/index.js";
|
|
188
|
-
export { AVATAR_GROUP_LABELS, type AccentInput, AccentScope, type AccentScopeProps, AnimationGroup, type AnimationGroupProps, type AnimationProps, type Appearance, Avatar, AvatarGroup, type AvatarGroupLabels, type AvatarGroupProps, type AvatarProps, type BaseProps, Bento, type BentoItem, type BentoProps, type BentoSpan, Bloom, type BloomPlacement, type BloomProps, Bubble, type BubbleProps, Button, type ButtonProps, type ButtonTone, CALENDAR_LABELS, CAROUSEL_LABELS, CHOICE_LABELS, CODE_LABELS, COMPACT_QUERY, COMPARE_LABELS, CONSENT_LABELS, CONTENTS_LABELS, CONTRAST_MIN, Calendar, type CalendarLabels, type CalendarProps, type CalendarValue, Card, type CardProps, Carousel, type CarouselLabels, type CarouselProps, Cell, type CellProps, Checkbox, type CheckboxProps, Chip, type ChipProps, Choice, type ChoiceLabels, type ChoiceOption, type ChoiceProps, Code, type CodeLabels, type CodeProps, type ColorSchemeMode, ColorSchemeScript, type ColorSchemeScriptProps, type ColorSchemeState, type ColorValue, Compare, type CompareLabels, type CompareProps, type ComponentsConfig, Consent, type ConsentLabels, type ConsentProps, type ContentRef, Contents, type ContentsItem, type ContentsLabels, type ContentsProps, type ControlSize, type ControlledOptions, Count, type CountProps, type CrumbEnd, DATEFIELD_LABELS, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, DateField, type DateFieldLabels, type DateFieldProps, type DateRange, Dialog, type DialogLabels, type DialogProps, type DismissOptions, Dock, type DockActionProps, type DockBackProps, type DockCrumbProps, type DockCrumbsProps, type DockLabels, type DockProps, type DockSearchProps, ERRORSUMMARY_LABELS, Empty, type EmptyProps, ErrorSummary, type ErrorSummaryItem, type ErrorSummaryLabels, type ErrorSummaryProps, FILEDROP_LABELS, FILTERS_LABELS, FOCUSABLE, Fact, type FactProps, Field, type FieldProps, FileDrop, type FileDropLabels, type FileDropProps, Filters, type FiltersGroupProps, type FiltersLabels, type FiltersProps, type FindInPage, Flow, type FlowProps, Fold, type FoldProps, Footer, FooterBottom, FooterGroup, type FooterGroupProps, FooterLink, type FooterLinkProps, type FooterProps, Frame, type FrameProps, Ground, Hairline, type HairlineProps, Hint, type HintProps, Kbd, type KbdProps, LIGHTBOX_LABELS, type LabelsInput, Lightbox, type LightboxImage, type LightboxLabels, type LightboxProps, Link, type LinkProps, List, type ListProps, ListRow, type ListRowProps, MULTI_SUGGEST_LABELS, Mark, type MarkProps, type MaybeResponsive, Media, type MediaProps, Menu, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, type MotionOptions, type MoveFocusOptions, MultiSuggest, type MultiSuggestLabels, type MultiSuggestProps, NOTICE_LABELS, NUMBERFIELD_LABELS, Notice, type NoticeLabels, type NoticeProps, NumberField, type NumberFieldLabels, type NumberFieldProps, PAGENAV_LABELS, PAGES_LABELS, type PageItem, PageNav, type PageNavLabels, type PageNavProps, type PageNavTarget, Pages, type PagesLabels, type PagesProps, PinField, type PinFieldProps, Placeholder, type PlaceholderProps, type PolymorphicProps, Portal, type PortalProps, Progress, type ProgressProps, Prose, type ProseProps, Quote, type QuoteProps, RATING_LABELS, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadiusValue, Rail, RailGroup, type RailGroupProps, RailLink, type RailLinkProps, type RailProps, Range, type RangeProps, Rating, type RatingLabels, type RatingProps, type ResolvedColorScheme, type Responsive, ResultRow, type ResultRowProps, type RovingFocusOptions, SEARCH_LABELS, SECRETFIELD_LABELS, SETTINGS_LABELS, SKIPLINK_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, type ScoreProps, Search, type SearchLabels, type SearchProps, SecretField, type SecretFieldLabels, type SecretFieldProps, Segmented, type SegmentedOption, type SegmentedProps, Settings, type SettingsLabels, type SettingsLanguage, type SettingsProps, Sheet, type SheetOwnProps, type SheetProps, type SheetSide, Shelf, type ShelfProps, SkipLink, type SkipLinkLabels, type SkipLinkProps, type SlurpControls, type SlurpCss, type SlurpEnterOptions, type SlurpLabels, type SlurpNavigate, type SlurpNavigateOptions, SlurpProvider, type SlurpProviderProps, type SpaceValue, Stage, type StageProps, type StatusTone, type StepItem, Steps, type StepsLabels, type StepsProps, Suggest, type SuggestLabels, type SuggestOption, type SuggestProps, Surface, type SurfaceProps, Swatch, SwatchGroup, type SwatchGroupProps, type SwatchOption, type SwatchProps, Switch, type SwitchProps, TABLE_LABELS, TOAST_LABELS, type TabItem, Table, type TableColumn, type TableLabels, type TableProps, type TableSort, Tabs, type TabsProps, Tag, type TagProps, Text, type TextProps, type TextTone, type Theme, type ThemeOptions, Tile, type TileProps, Timeline, type TimelineItem, type TimelineProps, type ToastLabels, type ToastOptions, ToastProvider, type ToastProviderProps, type TokenOverrides, Tree, type TreeItem, type TreeProps, VisuallyHidden, type VisuallyHiddenProps, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, labelsEn, labelsIt, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useClipboard, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useScrollSpy, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
|
190
|
+
export { AVATAR_GROUP_LABELS, type AccentInput, AccentScope, type AccentScopeProps, AnimationGroup, type AnimationGroupProps, type AnimationProps, type Appearance, Avatar, AvatarGroup, type AvatarGroupLabels, type AvatarGroupProps, type AvatarProps, type BaseProps, Bento, type BentoItem, type BentoProps, type BentoSpan, Bloom, type BloomPlacement, type BloomProps, Bubble, type BubbleProps, Button, type ButtonProps, type ButtonTone, CALENDAR_LABELS, CAROUSEL_LABELS, CHOICE_LABELS, CODE_LABELS, COMPACT_QUERY, COMPARE_LABELS, CONSENT_LABELS, CONTENTS_LABELS, CONTRAST_MIN, Calendar, type CalendarLabels, type CalendarProps, type CalendarValue, Card, type CardProps, Carousel, type CarouselLabels, type CarouselProps, Cell, type CellProps, Checkbox, type CheckboxProps, Chip, type ChipProps, Choice, type ChoiceLabels, type ChoiceOption, type ChoiceProps, Code, type CodeLabels, type CodeProps, type ColorSchemeMode, ColorSchemeScript, type ColorSchemeScriptProps, type ColorSchemeState, type ColorValue, Compare, type CompareLabels, type CompareProps, type ComponentsConfig, Consent, type ConsentLabels, type ConsentProps, type ContentRef, Contents, type ContentsItem, type ContentsLabels, type ContentsProps, type ControlSize, type ControlledOptions, Count, type CountProps, type CrumbEnd, DATEFIELD_LABELS, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, DateField, type DateFieldLabels, type DateFieldProps, type DateRange, Dialog, type DialogLabels, type DialogProps, type DismissOptions, Dock, type DockActionProps, type DockBackProps, type DockCrumbProps, type DockCrumbsProps, type DockLabels, type DockProps, type DockSearchProps, ERRORSUMMARY_LABELS, Empty, type EmptyProps, ErrorSummary, type ErrorSummaryItem, type ErrorSummaryLabels, type ErrorSummaryProps, FILEDROP_LABELS, FILTERS_LABELS, FOCUSABLE, Fact, type FactProps, Field, type FieldProps, FileDrop, type FileDropLabels, type FileDropProps, Filters, type FiltersGroupProps, type FiltersLabels, type FiltersProps, type FindInPage, Flow, type FlowProps, Fold, type FoldProps, Footer, FooterBottom, FooterGroup, type FooterGroupProps, FooterLink, type FooterLinkProps, type FooterProps, Frame, type FrameProps, Ground, Hairline, type HairlineProps, Hint, type HintProps, Kbd, type KbdProps, LIGHTBOX_LABELS, type LabelsInput, Lightbox, type LightboxImage, type LightboxLabels, type LightboxProps, Link, type LinkProps, List, type ListProps, ListRow, type ListRowProps, MULTI_SUGGEST_LABELS, Mark, type MarkProps, type MaybeResponsive, Media, type MediaProps, Menu, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, type MotionOptions, type MoveFocusOptions, MultiSuggest, type MultiSuggestLabels, type MultiSuggestProps, NOTICE_LABELS, NUMBERFIELD_LABELS, Notice, type NoticeLabels, type NoticeProps, NumberField, type NumberFieldLabels, type NumberFieldProps, PAGENAV_LABELS, PAGES_LABELS, type PageItem, PageNav, type PageNavLabels, type PageNavProps, type PageNavTarget, Pages, type PagesLabels, type PagesProps, PinField, type PinFieldProps, Placeholder, type PlaceholderProps, type PolymorphicProps, Portal, type PortalProps, Progress, type ProgressProps, Prose, type ProseProps, Quote, type QuoteProps, RATING_LABELS, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadiusValue, Rail, RailGroup, type RailGroupProps, RailLink, type RailLinkProps, type RailProps, Range, type RangeProps, Rating, type RatingLabels, type RatingProps, type ResolvedColorScheme, type Responsive, ResultRow, type ResultRowProps, Reveal, type RevealProps, type RovingFocusOptions, SEARCH_LABELS, SECRETFIELD_LABELS, SETTINGS_LABELS, SKIPLINK_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, type ScoreProps, Search, type SearchLabels, type SearchProps, SecretField, type SecretFieldLabels, type SecretFieldProps, Segmented, type SegmentedOption, type SegmentedProps, Settings, type SettingsLabels, type SettingsLanguage, type SettingsProps, Sheet, type SheetOwnProps, type SheetProps, type SheetSide, Shelf, type ShelfProps, SkipLink, type SkipLinkLabels, type SkipLinkProps, type SlurpControls, type SlurpCss, type SlurpEnterOptions, type SlurpLabels, type SlurpNavigate, type SlurpNavigateOptions, SlurpProvider, type SlurpProviderProps, type SpaceValue, Stage, type StageProps, type StatusTone, type StepItem, Steps, type StepsLabels, type StepsProps, Suggest, type SuggestLabels, type SuggestOption, type SuggestProps, Surface, type SurfaceProps, Swatch, SwatchGroup, type SwatchGroupProps, type SwatchOption, type SwatchProps, Switch, type SwitchProps, TABLE_LABELS, TOAST_LABELS, type TabItem, Table, type TableColumn, type TableLabels, type TableProps, type TableSort, Tabs, type TabsProps, Tag, type TagProps, Text, type TextProps, type TextTone, type Theme, type ThemeOptions, Tile, type TileProps, Timeline, type TimelineItem, type TimelineProps, type ToastLabels, type ToastOptions, ToastProvider, type ToastProviderProps, type TokenOverrides, Tree, type TreeItem, type TreeProps, VisuallyHidden, type VisuallyHiddenProps, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, labelsEn, labelsIt, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useClipboard, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useScrollSpy, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import { ResultRow } from "./ResultRow/ResultRow.js";
|
|
|
61
61
|
import { Mark } from "./Mark/Mark.js";
|
|
62
62
|
import { Empty } from "./Empty/Empty.js";
|
|
63
63
|
import { Link } from "./Link/Link.js";
|
|
64
|
+
import { Reveal } from "./Reveal/Reveal.js";
|
|
64
65
|
import { LIGHTBOX_LABELS, Lightbox } from "./Lightbox/Lightbox.js";
|
|
65
66
|
import { COMPARE_LABELS, Compare } from "./Compare/Compare.js";
|
|
66
67
|
import { Tree } from "./Tree/Tree.js";
|
|
@@ -101,4 +102,4 @@ import { RATING_LABELS, Rating } from "./Rating/Rating.js";
|
|
|
101
102
|
import { TABLE_LABELS, Table } from "./Table/Table.js";
|
|
102
103
|
import { CAROUSEL_LABELS, Carousel } from "./Carousel/Carousel.js";
|
|
103
104
|
import { focusHit, useFindInPage } from "./utils/useFindInPage.js";
|
|
104
|
-
export { AVATAR_GROUP_LABELS, AccentScope, AnimationGroup, Avatar, AvatarGroup, Bento, Bloom, Bubble, Button, CALENDAR_LABELS, CAROUSEL_LABELS, CHOICE_LABELS, CODE_LABELS, COMPACT_QUERY, COMPARE_LABELS, CONSENT_LABELS, CONTENTS_LABELS, CONTRAST_MIN, Calendar, Card, Carousel, Cell, Checkbox, Chip, Choice, Code, ColorSchemeScript, Compare, Consent, Contents, Count, DATEFIELD_LABELS, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, DateField, Dialog, Dock, ERRORSUMMARY_LABELS, Empty, ErrorSummary, FILEDROP_LABELS, FILTERS_LABELS, FOCUSABLE, Fact, Field, FileDrop, Filters, Flow, Fold, Footer, FooterBottom, FooterGroup, FooterLink, Frame, Ground, Hairline, Hint, Kbd, LIGHTBOX_LABELS, Lightbox, Link, List, ListRow, MULTI_SUGGEST_LABELS, Mark, Media, Menu, MenuGroup, MenuItem, MenuSeparator, MultiSuggest, NOTICE_LABELS, NUMBERFIELD_LABELS, Notice, NumberField, PAGENAV_LABELS, PAGES_LABELS, PageNav, Pages, PinField, Placeholder, Portal, Progress, Prose, Quote, RATING_LABELS, Radio, RadioGroup, Rail, RailGroup, RailLink, Range, Rating, ResultRow, SEARCH_LABELS, SECRETFIELD_LABELS, SETTINGS_LABELS, SKIPLINK_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, Search, SecretField, Segmented, Settings, Sheet, Shelf, SkipLink, SlurpProvider, Stage, Steps, Suggest, Surface, Swatch, SwatchGroup, Switch, TABLE_LABELS, TOAST_LABELS, Table, Tabs, Tag, Text, Tile, Timeline, ToastProvider, Tree, VisuallyHidden, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, labelsEn, labelsIt, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useClipboard, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useScrollSpy, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
|
105
|
+
export { AVATAR_GROUP_LABELS, AccentScope, AnimationGroup, Avatar, AvatarGroup, Bento, Bloom, Bubble, Button, CALENDAR_LABELS, CAROUSEL_LABELS, CHOICE_LABELS, CODE_LABELS, COMPACT_QUERY, COMPARE_LABELS, CONSENT_LABELS, CONTENTS_LABELS, CONTRAST_MIN, Calendar, Card, Carousel, Cell, Checkbox, Chip, Choice, Code, ColorSchemeScript, Compare, Consent, Contents, Count, DATEFIELD_LABELS, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, DateField, Dialog, Dock, ERRORSUMMARY_LABELS, Empty, ErrorSummary, FILEDROP_LABELS, FILTERS_LABELS, FOCUSABLE, Fact, Field, FileDrop, Filters, Flow, Fold, Footer, FooterBottom, FooterGroup, FooterLink, Frame, Ground, Hairline, Hint, Kbd, LIGHTBOX_LABELS, Lightbox, Link, List, ListRow, MULTI_SUGGEST_LABELS, Mark, Media, Menu, MenuGroup, MenuItem, MenuSeparator, MultiSuggest, NOTICE_LABELS, NUMBERFIELD_LABELS, Notice, NumberField, PAGENAV_LABELS, PAGES_LABELS, PageNav, Pages, PinField, Placeholder, Portal, Progress, Prose, Quote, RATING_LABELS, Radio, RadioGroup, Rail, RailGroup, RailLink, Range, Rating, ResultRow, Reveal, SEARCH_LABELS, SECRETFIELD_LABELS, SETTINGS_LABELS, SKIPLINK_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, Search, SecretField, Segmented, Settings, Sheet, Shelf, SkipLink, SlurpProvider, Stage, Steps, Suggest, Surface, Swatch, SwatchGroup, Switch, TABLE_LABELS, TOAST_LABELS, Table, Tabs, Tag, Text, Tile, Timeline, ToastProvider, Tree, VisuallyHidden, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, labelsEn, labelsIt, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useClipboard, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useScrollSpy, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
package/dist/lib/theme.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ import { RailProps } from "../Rail/Rail.js";
|
|
|
56
56
|
import { RangeProps } from "../Range/Range.js";
|
|
57
57
|
import { RatingProps } from "../Rating/Rating.js";
|
|
58
58
|
import { ResultRowProps } from "../ResultRow/ResultRow.js";
|
|
59
|
+
import { RevealProps } from "../Reveal/Reveal.js";
|
|
59
60
|
import { ScoreProps } from "../Score/Score.js";
|
|
60
61
|
import { SearchProps } from "../Search/Search.js";
|
|
61
62
|
import { SecretFieldProps } from "../SecretField/SecretField.js";
|
|
@@ -102,6 +103,10 @@ export interface MotionOptions extends Pick<SlurpDefaults, 'duration' | 'stagger
|
|
|
102
103
|
}
|
|
103
104
|
/** Components that read defaults and `css` overrides from the theme, with their parts. */
|
|
104
105
|
export interface ThemeComponents {
|
|
106
|
+
Reveal: {
|
|
107
|
+
props: RevealProps;
|
|
108
|
+
parts: 'root';
|
|
109
|
+
};
|
|
105
110
|
Lightbox: {
|
|
106
111
|
props: LightboxProps;
|
|
107
112
|
parts: 'root';
|
package/dist/lib/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../../src/lib/theme.ts"],"sourcesContent":["// createTheme() and the stylesheet that applies a theme. Server-safe: a theme is plain, serialisable data,\n// so it can be created in a server component and passed to <SlurpProvider>.\nimport { MOTION_DEFAULTS, type GhostKind, type SlurpDefaults } from '@slurp-ui/motion';\nimport type { blur, ColorToken, HueToken, RadiusToken, shadow, SpaceToken } from '@slurp-ui/tokens';\n\nimport type { AccentScopeProps } from '../AccentScope/AccentScope';\nimport type { BentoProps } from '../Bento/Bento';\nimport type { CardProps } from '../Card/Card';\nimport type { DockProps } from '../Dock/Dock';\nimport type { EmptyProps } from '../Empty/Empty';\nimport type { FactProps } from '../Fact/Fact';\nimport type { FiltersProps } from '../Filters/Filters';\nimport type { LinkProps } from '../Link/Link';\nimport type { ListProps, ListRowProps } from '../ListRow/ListRow';\nimport type { ResultRowProps } from '../ResultRow/ResultRow';\nimport type { ScoreProps } from '../Score/Score';\nimport type { SettingsProps } from '../Settings/Settings';\nimport type { ShelfProps } from '../Shelf/Shelf';\nimport type { StageProps } from '../Stage/Stage';\nimport type { TileProps } from '../Tile/Tile';\nimport type { CarouselProps } from '../Carousel/Carousel';\nimport type { PagesProps } from '../Pages/Pages';\nimport type { RatingProps } from '../Rating/Rating';\nimport type { StepsProps } from '../Steps/Steps';\nimport type { SuggestProps } from '../Suggest/Suggest';\nimport type { TableProps } from '../Table/Table';\nimport type { AvatarProps } from '../Avatar/Avatar';\nimport type { BloomProps } from '../Bloom/Bloom';\nimport type { BubbleProps } from '../Bubble/Bubble';\nimport type { ButtonProps } from '../Button/Button';\nimport type { CellProps } from '../Cell/Cell';\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { ChipProps } from '../Chip/Chip';\nimport type { ChoiceProps } from '../Choice/Choice';\nimport type { CountProps } from '../Count/Count';\nimport type { DialogProps } from '../Dialog/Dialog';\nimport type { FieldProps } from '../Field/Field';\nimport type { FlowProps } from '../Flow/Flow';\nimport type { FoldProps } from '../Fold/Fold';\nimport type { FrameProps } from '../Frame/Frame';\nimport type { HintProps } from '../Hint/Hint';\nimport type { MenuProps } from '../Menu/Menu';\nimport type { NoticeProps } from '../Notice/Notice';\nimport type { PlaceholderProps } from '../Placeholder/Placeholder';\nimport type { ProgressProps } from '../Progress/Progress';\nimport type { RadioGroupProps, RadioProps } from '../Radio/Radio';\nimport type { RangeProps } from '../Range/Range';\nimport type { SearchProps } from '../Search/Search';\nimport type { SegmentedProps } from '../Segmented/Segmented';\nimport type { SheetProps } from '../Sheet/Sheet';\nimport type { SurfaceProps } from '../Surface/Surface';\nimport type { SwatchGroupProps, SwatchProps } from '../Swatch/Swatch';\nimport type { SwitchProps } from '../Switch/Switch';\nimport type { TabsProps } from '../Tabs/Tabs';\nimport type { TextProps } from '../Text/Text';\nimport type { LightboxProps } from '../Lightbox/Lightbox';\nimport type { CompareProps } from '../Compare/Compare';\nimport type { TreeProps } from '../Tree/Tree';\nimport type { ConsentProps } from '../Consent/Consent';\nimport type { TimelineProps } from '../Timeline/Timeline';\nimport type { AvatarGroupProps } from '../AvatarGroup/AvatarGroup';\nimport type { MultiSuggestProps } from '../MultiSuggest/MultiSuggest';\nimport type { DateFieldProps } from '../DateField/DateField';\nimport type { CalendarProps } from '../Calendar/Calendar';\nimport type { FileDropProps } from '../FileDrop/FileDrop';\nimport type { ErrorSummaryProps } from '../ErrorSummary/ErrorSummary';\nimport type { PinFieldProps } from '../PinField/PinField';\nimport type { NumberFieldProps } from '../NumberField/NumberField';\nimport type { SecretFieldProps } from '../SecretField/SecretField';\nimport type { FooterProps } from '../Footer/Footer';\nimport type { MediaProps } from '../Media/Media';\nimport type { QuoteProps } from '../Quote/Quote';\nimport type { KbdProps } from '../Kbd/Kbd';\nimport type { TagProps } from '../Tag/Tag';\nimport type { CodeProps } from '../Code/Code';\nimport type { ContentsProps } from '../Contents/Contents';\nimport type { HairlineProps } from '../Hairline/Hairline';\nimport type { PageNavProps } from '../PageNav/PageNav';\nimport type { ProseProps } from '../Prose/Prose';\nimport type { RailProps } from '../Rail/Rail';\nimport type { SkipLinkProps } from '../SkipLink/SkipLink';\nimport { accentVars, resolveAccent } from './color';\nimport { hash, LAYER_ORDER, type SlurpCss } from './css';\n\nexport type ColorSchemeMode = 'light' | 'dark' | 'system';\nexport type ResolvedColorScheme = 'light' | 'dark';\n/** A `hue-*` preset (used as is) or any hex colour (turned into an accent with `vivid()`). */\nexport type AccentInput = `hue-${HueToken}` | `#${string}`;\n\ntype Themed = string | { light: string; dark: string };\ntype Length = string | number;\n\nexport interface TokenOverrides {\n color?: Partial<Record<ColorToken | `hue-${HueToken}`, Themed>>;\n space?: Partial<Record<SpaceToken, Length>>;\n radius?: Partial<Record<RadiusToken, Length>>;\n shadow?: Partial<Record<keyof typeof shadow, Themed>>;\n blur?: Partial<Record<keyof typeof blur, Length>>;\n}\n\n/** Defaults of the collapse / expand transitions started with useSlurp() (serialisable values only). */\nexport interface MotionOptions extends Pick<\n SlurpDefaults,\n 'duration' | 'stagger' | 'curve' | 'swell' | 'drop' | 'reducedMotion' | 'interrupt'\n> {\n goo: boolean | 'auto';\n ghost: GhostKind;\n order: 'distance' | 'dom';\n}\n\nconst { duration, stagger, curve, swell, drop, reducedMotion, interrupt } = MOTION_DEFAULTS;\nconst DEFAULT_MOTION: MotionOptions = {\n duration,\n stagger,\n curve,\n swell,\n drop,\n reducedMotion,\n interrupt,\n goo: 'auto',\n ghost: 'shape',\n order: 'distance',\n};\n\n/** Components that read defaults and `css` overrides from the theme, with their parts. */\nexport interface ThemeComponents {\n Lightbox: { props: LightboxProps; parts: 'root' };\n Compare: { props: CompareProps; parts: 'root' };\n Tree: { props: TreeProps; parts: 'root' };\n Consent: { props: ConsentProps; parts: 'root' };\n Timeline: { props: TimelineProps; parts: 'root' };\n AvatarGroup: { props: AvatarGroupProps; parts: 'root' };\n MultiSuggest: {\n props: MultiSuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'tags' | 'tag' | 'hint' | 'error';\n };\n DateField: { props: DateFieldProps; parts: 'root' };\n Calendar: { props: CalendarProps; parts: 'root' };\n FileDrop: { props: FileDropProps; parts: 'root' };\n ErrorSummary: { props: ErrorSummaryProps; parts: 'root' };\n PinField: { props: PinFieldProps; parts: 'root' };\n NumberField: { props: NumberFieldProps; parts: 'root' };\n SecretField: { props: SecretFieldProps; parts: 'root' };\n Footer: { props: FooterProps; parts: 'root' };\n Media: { props: MediaProps; parts: 'root' | 'frame' | 'media' | 'caption' };\n Quote: { props: QuoteProps; parts: 'root' | 'quote' | 'caption' };\n Kbd: { props: KbdProps; parts: 'root' };\n Tag: { props: TagProps; parts: 'root' };\n AccentScope: { props: AccentScopeProps; parts: 'root' };\n Code: { props: CodeProps; parts: 'root' | 'bar' | 'filename' | 'copy' | 'pre' };\n Contents: { props: ContentsProps; parts: 'root' | 'title' | 'list' | 'item' | 'link' };\n Hairline: { props: HairlineProps; parts: 'root' };\n PageNav: { props: PageNavProps; parts: 'root' };\n Prose: { props: ProseProps; parts: 'root' };\n Rail: { props: RailProps; parts: 'root' };\n SkipLink: { props: SkipLinkProps; parts: 'root' };\n Bento: { props: BentoProps; parts: 'root' };\n Card: { props: CardProps; parts: 'root' | 'media' | 'badge' | 'title' | 'description' };\n Dock: { props: DockProps; parts: 'root' };\n Empty: { props: EmptyProps; parts: 'root' };\n Fact: { props: FactProps; parts: 'root' };\n Filters: { props: FiltersProps; parts: 'root' };\n Link: { props: LinkProps; parts: 'root' };\n List: { props: ListProps; parts: 'root' };\n ListRow: {\n props: ListRowProps;\n parts: 'root' | 'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action';\n };\n ResultRow: { props: ResultRowProps; parts: 'root' };\n Score: { props: ScoreProps; parts: 'root' };\n Settings: { props: SettingsProps; parts: 'root' };\n Shelf: { props: ShelfProps; parts: 'root' };\n Stage: { props: StageProps; parts: 'root' };\n Tile: {\n props: TileProps;\n parts: 'root' | 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media';\n };\n Avatar: { props: AvatarProps; parts: 'root' };\n Bloom: { props: BloomProps; parts: 'root' | 'surface' | 'trigger' | 'panel' };\n Bubble: { props: BubbleProps; parts: 'root' };\n Button: { props: ButtonProps; parts: 'root' | 'icon' | 'label' | 'endIcon' };\n Cell: { props: CellProps; parts: 'root' };\n Checkbox: { props: CheckboxProps; parts: 'root' | 'input' | 'box' | 'label' };\n Chip: { props: ChipProps; parts: 'root' };\n Choice: { props: ChoiceProps; parts: 'root' };\n Count: { props: CountProps; parts: 'root' };\n Dialog: {\n props: DialogProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Field: { props: FieldProps; parts: 'root' | 'label' | 'control' | 'hint' | 'error' };\n Flow: { props: FlowProps; parts: 'root' };\n Fold: { props: FoldProps; parts: 'root' | 'heading' | 'trigger' | 'region' };\n Frame: { props: FrameProps; parts: 'root' };\n Hint: { props: HintProps; parts: 'root' };\n Menu: { props: MenuProps; parts: 'root' };\n Notice: { props: NoticeProps; parts: 'root' | 'icon' | 'title' | 'body' | 'dismiss' };\n Placeholder: { props: PlaceholderProps; parts: 'root' };\n Progress: { props: ProgressProps; parts: 'root' };\n Radio: { props: RadioProps; parts: 'root' | 'input' | 'dot' | 'label' };\n RadioGroup: { props: RadioGroupProps; parts: 'root' | 'legend' };\n Range: { props: RangeProps; parts: 'root' | 'label' | 'value' | 'control' };\n Search: { props: SearchProps; parts: 'root' | 'icon' | 'control' | 'clear' | 'status' };\n Segmented: { props: SegmentedProps; parts: 'root' | 'item' };\n Sheet: {\n props: SheetProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Surface: { props: SurfaceProps; parts: 'root' };\n Swatch: { props: SwatchProps; parts: 'root' };\n SwatchGroup: { props: SwatchGroupProps; parts: 'root' };\n Switch: { props: SwitchProps; parts: 'root' | 'input' | 'track' | 'thumb' | 'label' };\n Tabs: { props: TabsProps; parts: 'root' | 'list' | 'tab' | 'indicator' | 'panel' };\n Text: { props: TextProps; parts: 'root' };\n Suggest: {\n props: SuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'hint' | 'error';\n };\n Pages: { props: PagesProps; parts: 'root' | 'list' | 'item' | 'previous' | 'next' | 'status' };\n Steps: { props: StepsProps; parts: 'root' | 'list' | 'step' };\n Rating: { props: RatingProps; parts: 'root' };\n Table: { props: TableProps; parts: 'root' | 'table' | 'caption' };\n Carousel: {\n props: CarouselProps;\n parts: 'root' | 'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot';\n };\n}\nexport type ComponentName = keyof ThemeComponents;\n\nexport type ComponentsConfig = {\n [K in ComponentName]?: {\n defaults?: Partial<Omit<ThemeComponents[K]['props'], 'ref' | 'children' | 'css'>>;\n css?: Partial<Record<ThemeComponents[K]['parts'], SlurpCss>>;\n };\n};\n\nexport interface ThemeOptions {\n /** Initial colour scheme, until the person chooses one (default `system`). */\n colorScheme?: ColorSchemeMode;\n /** Default `hue-violet`. */\n accent?: AccentInput;\n /** Used only by Intl (numbers, prices). Not an i18n system. Default `it-IT`. */\n locale?: string;\n tokens?: TokenOverrides;\n motion?: Partial<MotionOptions>;\n components?: ComponentsConfig;\n}\n\nexport interface Theme {\n colorScheme: ColorSchemeMode;\n accent: AccentInput;\n /** The accent actually painted (hex). */\n accentColor: string;\n locale: string;\n tokens: TokenOverrides;\n motion: MotionOptions;\n components: ComponentsConfig;\n}\n\nconst DEFAULT_ACCENT: AccentInput = 'hue-violet';\n\n/** localStorage key of the chosen colour scheme (same as the design system's setTheme()). */\nexport const DEFAULT_STORAGE_KEY = 'slurp-theme';\n\nexport function createTheme(options: ThemeOptions = {}): Theme {\n const accent = options.accent ?? DEFAULT_ACCENT;\n return {\n colorScheme: options.colorScheme ?? 'system',\n accent,\n accentColor: resolveAccent(accent),\n locale: options.locale ?? 'it-IT',\n tokens: options.tokens ?? {},\n motion: { ...DEFAULT_MOTION, ...options.motion },\n components: options.components ?? {},\n };\n}\n\nexport const defaultTheme: Theme = createTheme();\n\nconst px = (v: Length) => (typeof v === 'number' ? `${v}px` : v);\n\n/** Light / dark declarations of the token overrides of a theme. */\nfunction overrideDeclarations(tokens: TokenOverrides) {\n const light: string[] = [];\n const dark: string[] = [];\n const add = (name: string, v: Themed | number) => {\n if (typeof v === 'object') {\n light.push(`--slurp-${name}:${v.light}`);\n dark.push(`--slurp-${name}:${v.dark}`);\n } else light.push(`--slurp-${name}:${px(v)}`);\n };\n for (const [k, v] of Object.entries(tokens.color ?? {})) if (v !== undefined) add(k, v);\n for (const [k, v] of Object.entries(tokens.space ?? {}))\n if (v !== undefined) add(`space-${k}`, v);\n for (const [k, v] of Object.entries(tokens.radius ?? {}))\n if (v !== undefined) add(`radius-${k}`, v);\n for (const [k, v] of Object.entries(tokens.shadow ?? {}))\n if (v !== undefined) add(`shadow-${k}`, v);\n for (const [k, v] of Object.entries(tokens.blur ?? {})) if (v !== undefined) add(`blur-${k}`, v);\n return { light, dark };\n}\n\nfunction selectors(scope: string | undefined) {\n if (!scope) {\n return {\n base: ':root,[data-theme]',\n dark: \"[data-theme='dark']\",\n systemDark: \":root:not([data-theme='light'])\",\n };\n }\n const s = `[data-slurp-theme=\"${scope}\"]`;\n return {\n base: `${s},${s} [data-theme]`,\n dark: `:root[data-theme='dark'] ${s},${s} [data-theme='dark']`,\n systemDark: `:root:not([data-theme='light']) ${s}`,\n };\n}\n\n/**\n * The stylesheet of a theme: accent variables and token overrides, on the root (or on a nested provider's `scope`)\n * and on every `data-theme` subtree, so derived values re-resolve per theme. Empty for the default theme.\n * tokens.css uses `:where()`, so these plain selectors win whatever the stylesheet order.\n */\nexport function themeCss(theme: Theme, scope?: string): string {\n const { light, dark } = overrideDeclarations(theme.tokens);\n const accent =\n theme.accent === DEFAULT_ACCENT\n ? []\n : Object.entries(accentVars(theme.accentColor)).map(([k, v]) => `${k}:${v}`);\n const base = [...accent, ...light];\n if (!base.length && !dark.length) return '';\n const sel = selectors(scope);\n const rules = [`${sel.base}{${base.join(';')}}`];\n if (dark.length) {\n rules.push(\n `${sel.dark}{${dark.join(';')}}`,\n `@media (prefers-color-scheme: dark){${sel.systemDark}{${dark.join(';')}}}`,\n );\n }\n return `${LAYER_ORDER}@layer slurp.base{${rules.join('')}}`;\n}\n\n/** Stable id of a stylesheet, for React's <style href> de-duplication. */\nexport const styleId = (prefix: string, css: string) => `slurp-${prefix}-${hash(css)}`;\n"],"mappings":";;;;;AA8GA,MAAM,EAAE,UAAU,SAAS,OAAO,OAAO,MAAM,eAAe,cAAc;AAC5E,MAAM,iBAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA,KAAK;CACL,OAAO;CACP,OAAO;AACT;AAyIA,MAAM,iBAA8B;;AAGpC,MAAa,sBAAsB;AAEnC,SAAgB,YAAY,UAAwB,CAAC,GAAU;CAC7D,MAAM,SAAS,QAAQ,UAAU;CACjC,OAAO;EACL,aAAa,QAAQ,eAAe;EACpC;EACA,aAAa,cAAc,MAAM;EACjC,QAAQ,QAAQ,UAAU;EAC1B,QAAQ,QAAQ,UAAU,CAAC;EAC3B,QAAQ;GAAE,GAAG;GAAgB,GAAG,QAAQ;EAAO;EAC/C,YAAY,QAAQ,cAAc,CAAC;CACrC;AACF;AAEA,MAAa,eAAsB,Y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AA4B,EAAE,GAAG,EAAE;EACzC,YAAY,mCAAmC;CACjD;AACF;;;;;;AAOA,SAAgB,SAAS,OAAc,OAAwB;CAC7D,MAAM,EAAE,OAAO,SAAS,qBAAqB,MAAM,MAAM;CAKzD,MAAM,OAAO,CAAC,GAHZ,MAAM,WAAW,iBACb,CAAC,IACD,OAAO,QAAQ,WAAW,MAAM,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,GACtD,GAAG,KAAK;CACjC,IAAI,CAAC,KAAK,UAAU,CAAC,KAAK,QAAQ,OAAO;CACzC,MAAM,MAAM,UAAU,KAAK;CAC3B,MAAM,QAAQ,CAAC,GAAG,IAAI,KAAK,GAAG,KAAK,KAAK,GAAG,EAAE,EAAE;CAC/C,IAAI,KAAK,QACP,MAAM,KACJ,GAAG,IAAI,KAAK,GAAG,KAAK,KAAK,GAAG,EAAE,IAC9B,uCAAuC,IAAI,WAAW,GAAG,KAAK,KAAK,GAAG,EAAE,GAC1E;CAEF,OAAO,GAAG,YAAY,oBAAoB,MAAM,KAAK,EAAE,EAAE;AAC3D;;AAGA,MAAa,WAAW,QAAgB,QAAgB,SAAS,OAAO,GAAG,KAAK,GAAG"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../src/lib/theme.ts"],"sourcesContent":["// createTheme() and the stylesheet that applies a theme. Server-safe: a theme is plain, serialisable data,\n// so it can be created in a server component and passed to <SlurpProvider>.\nimport { MOTION_DEFAULTS, type GhostKind, type SlurpDefaults } from '@slurp-ui/motion';\nimport type { blur, ColorToken, HueToken, RadiusToken, shadow, SpaceToken } from '@slurp-ui/tokens';\n\nimport type { AccentScopeProps } from '../AccentScope/AccentScope';\nimport type { BentoProps } from '../Bento/Bento';\nimport type { CardProps } from '../Card/Card';\nimport type { DockProps } from '../Dock/Dock';\nimport type { EmptyProps } from '../Empty/Empty';\nimport type { FactProps } from '../Fact/Fact';\nimport type { FiltersProps } from '../Filters/Filters';\nimport type { LinkProps } from '../Link/Link';\nimport type { ListProps, ListRowProps } from '../ListRow/ListRow';\nimport type { ResultRowProps } from '../ResultRow/ResultRow';\nimport type { ScoreProps } from '../Score/Score';\nimport type { SettingsProps } from '../Settings/Settings';\nimport type { ShelfProps } from '../Shelf/Shelf';\nimport type { StageProps } from '../Stage/Stage';\nimport type { TileProps } from '../Tile/Tile';\nimport type { CarouselProps } from '../Carousel/Carousel';\nimport type { PagesProps } from '../Pages/Pages';\nimport type { RatingProps } from '../Rating/Rating';\nimport type { StepsProps } from '../Steps/Steps';\nimport type { SuggestProps } from '../Suggest/Suggest';\nimport type { TableProps } from '../Table/Table';\nimport type { AvatarProps } from '../Avatar/Avatar';\nimport type { BloomProps } from '../Bloom/Bloom';\nimport type { BubbleProps } from '../Bubble/Bubble';\nimport type { ButtonProps } from '../Button/Button';\nimport type { CellProps } from '../Cell/Cell';\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { ChipProps } from '../Chip/Chip';\nimport type { ChoiceProps } from '../Choice/Choice';\nimport type { CountProps } from '../Count/Count';\nimport type { DialogProps } from '../Dialog/Dialog';\nimport type { FieldProps } from '../Field/Field';\nimport type { FlowProps } from '../Flow/Flow';\nimport type { FoldProps } from '../Fold/Fold';\nimport type { FrameProps } from '../Frame/Frame';\nimport type { HintProps } from '../Hint/Hint';\nimport type { MenuProps } from '../Menu/Menu';\nimport type { NoticeProps } from '../Notice/Notice';\nimport type { PlaceholderProps } from '../Placeholder/Placeholder';\nimport type { ProgressProps } from '../Progress/Progress';\nimport type { RadioGroupProps, RadioProps } from '../Radio/Radio';\nimport type { RangeProps } from '../Range/Range';\nimport type { SearchProps } from '../Search/Search';\nimport type { SegmentedProps } from '../Segmented/Segmented';\nimport type { SheetProps } from '../Sheet/Sheet';\nimport type { SurfaceProps } from '../Surface/Surface';\nimport type { SwatchGroupProps, SwatchProps } from '../Swatch/Swatch';\nimport type { SwitchProps } from '../Switch/Switch';\nimport type { TabsProps } from '../Tabs/Tabs';\nimport type { TextProps } from '../Text/Text';\nimport type { RevealProps } from '../Reveal/Reveal';\nimport type { LightboxProps } from '../Lightbox/Lightbox';\nimport type { CompareProps } from '../Compare/Compare';\nimport type { TreeProps } from '../Tree/Tree';\nimport type { ConsentProps } from '../Consent/Consent';\nimport type { TimelineProps } from '../Timeline/Timeline';\nimport type { AvatarGroupProps } from '../AvatarGroup/AvatarGroup';\nimport type { MultiSuggestProps } from '../MultiSuggest/MultiSuggest';\nimport type { DateFieldProps } from '../DateField/DateField';\nimport type { CalendarProps } from '../Calendar/Calendar';\nimport type { FileDropProps } from '../FileDrop/FileDrop';\nimport type { ErrorSummaryProps } from '../ErrorSummary/ErrorSummary';\nimport type { PinFieldProps } from '../PinField/PinField';\nimport type { NumberFieldProps } from '../NumberField/NumberField';\nimport type { SecretFieldProps } from '../SecretField/SecretField';\nimport type { FooterProps } from '../Footer/Footer';\nimport type { MediaProps } from '../Media/Media';\nimport type { QuoteProps } from '../Quote/Quote';\nimport type { KbdProps } from '../Kbd/Kbd';\nimport type { TagProps } from '../Tag/Tag';\nimport type { CodeProps } from '../Code/Code';\nimport type { ContentsProps } from '../Contents/Contents';\nimport type { HairlineProps } from '../Hairline/Hairline';\nimport type { PageNavProps } from '../PageNav/PageNav';\nimport type { ProseProps } from '../Prose/Prose';\nimport type { RailProps } from '../Rail/Rail';\nimport type { SkipLinkProps } from '../SkipLink/SkipLink';\nimport { accentVars, resolveAccent } from './color';\nimport { hash, LAYER_ORDER, type SlurpCss } from './css';\n\nexport type ColorSchemeMode = 'light' | 'dark' | 'system';\nexport type ResolvedColorScheme = 'light' | 'dark';\n/** A `hue-*` preset (used as is) or any hex colour (turned into an accent with `vivid()`). */\nexport type AccentInput = `hue-${HueToken}` | `#${string}`;\n\ntype Themed = string | { light: string; dark: string };\ntype Length = string | number;\n\nexport interface TokenOverrides {\n color?: Partial<Record<ColorToken | `hue-${HueToken}`, Themed>>;\n space?: Partial<Record<SpaceToken, Length>>;\n radius?: Partial<Record<RadiusToken, Length>>;\n shadow?: Partial<Record<keyof typeof shadow, Themed>>;\n blur?: Partial<Record<keyof typeof blur, Length>>;\n}\n\n/** Defaults of the collapse / expand transitions started with useSlurp() (serialisable values only). */\nexport interface MotionOptions extends Pick<\n SlurpDefaults,\n 'duration' | 'stagger' | 'curve' | 'swell' | 'drop' | 'reducedMotion' | 'interrupt'\n> {\n goo: boolean | 'auto';\n ghost: GhostKind;\n order: 'distance' | 'dom';\n}\n\nconst { duration, stagger, curve, swell, drop, reducedMotion, interrupt } = MOTION_DEFAULTS;\nconst DEFAULT_MOTION: MotionOptions = {\n duration,\n stagger,\n curve,\n swell,\n drop,\n reducedMotion,\n interrupt,\n goo: 'auto',\n ghost: 'shape',\n order: 'distance',\n};\n\n/** Components that read defaults and `css` overrides from the theme, with their parts. */\nexport interface ThemeComponents {\n Reveal: { props: RevealProps; parts: 'root' };\n Lightbox: { props: LightboxProps; parts: 'root' };\n Compare: { props: CompareProps; parts: 'root' };\n Tree: { props: TreeProps; parts: 'root' };\n Consent: { props: ConsentProps; parts: 'root' };\n Timeline: { props: TimelineProps; parts: 'root' };\n AvatarGroup: { props: AvatarGroupProps; parts: 'root' };\n MultiSuggest: {\n props: MultiSuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'tags' | 'tag' | 'hint' | 'error';\n };\n DateField: { props: DateFieldProps; parts: 'root' };\n Calendar: { props: CalendarProps; parts: 'root' };\n FileDrop: { props: FileDropProps; parts: 'root' };\n ErrorSummary: { props: ErrorSummaryProps; parts: 'root' };\n PinField: { props: PinFieldProps; parts: 'root' };\n NumberField: { props: NumberFieldProps; parts: 'root' };\n SecretField: { props: SecretFieldProps; parts: 'root' };\n Footer: { props: FooterProps; parts: 'root' };\n Media: { props: MediaProps; parts: 'root' | 'frame' | 'media' | 'caption' };\n Quote: { props: QuoteProps; parts: 'root' | 'quote' | 'caption' };\n Kbd: { props: KbdProps; parts: 'root' };\n Tag: { props: TagProps; parts: 'root' };\n AccentScope: { props: AccentScopeProps; parts: 'root' };\n Code: { props: CodeProps; parts: 'root' | 'bar' | 'filename' | 'copy' | 'pre' };\n Contents: { props: ContentsProps; parts: 'root' | 'title' | 'list' | 'item' | 'link' };\n Hairline: { props: HairlineProps; parts: 'root' };\n PageNav: { props: PageNavProps; parts: 'root' };\n Prose: { props: ProseProps; parts: 'root' };\n Rail: { props: RailProps; parts: 'root' };\n SkipLink: { props: SkipLinkProps; parts: 'root' };\n Bento: { props: BentoProps; parts: 'root' };\n Card: { props: CardProps; parts: 'root' | 'media' | 'badge' | 'title' | 'description' };\n Dock: { props: DockProps; parts: 'root' };\n Empty: { props: EmptyProps; parts: 'root' };\n Fact: { props: FactProps; parts: 'root' };\n Filters: { props: FiltersProps; parts: 'root' };\n Link: { props: LinkProps; parts: 'root' };\n List: { props: ListProps; parts: 'root' };\n ListRow: {\n props: ListRowProps;\n parts: 'root' | 'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action';\n };\n ResultRow: { props: ResultRowProps; parts: 'root' };\n Score: { props: ScoreProps; parts: 'root' };\n Settings: { props: SettingsProps; parts: 'root' };\n Shelf: { props: ShelfProps; parts: 'root' };\n Stage: { props: StageProps; parts: 'root' };\n Tile: {\n props: TileProps;\n parts: 'root' | 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media';\n };\n Avatar: { props: AvatarProps; parts: 'root' };\n Bloom: { props: BloomProps; parts: 'root' | 'surface' | 'trigger' | 'panel' };\n Bubble: { props: BubbleProps; parts: 'root' };\n Button: { props: ButtonProps; parts: 'root' | 'icon' | 'label' | 'endIcon' };\n Cell: { props: CellProps; parts: 'root' };\n Checkbox: { props: CheckboxProps; parts: 'root' | 'input' | 'box' | 'label' };\n Chip: { props: ChipProps; parts: 'root' };\n Choice: { props: ChoiceProps; parts: 'root' };\n Count: { props: CountProps; parts: 'root' };\n Dialog: {\n props: DialogProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Field: { props: FieldProps; parts: 'root' | 'label' | 'control' | 'hint' | 'error' };\n Flow: { props: FlowProps; parts: 'root' };\n Fold: { props: FoldProps; parts: 'root' | 'heading' | 'trigger' | 'region' };\n Frame: { props: FrameProps; parts: 'root' };\n Hint: { props: HintProps; parts: 'root' };\n Menu: { props: MenuProps; parts: 'root' };\n Notice: { props: NoticeProps; parts: 'root' | 'icon' | 'title' | 'body' | 'dismiss' };\n Placeholder: { props: PlaceholderProps; parts: 'root' };\n Progress: { props: ProgressProps; parts: 'root' };\n Radio: { props: RadioProps; parts: 'root' | 'input' | 'dot' | 'label' };\n RadioGroup: { props: RadioGroupProps; parts: 'root' | 'legend' };\n Range: { props: RangeProps; parts: 'root' | 'label' | 'value' | 'control' };\n Search: { props: SearchProps; parts: 'root' | 'icon' | 'control' | 'clear' | 'status' };\n Segmented: { props: SegmentedProps; parts: 'root' | 'item' };\n Sheet: {\n props: SheetProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Surface: { props: SurfaceProps; parts: 'root' };\n Swatch: { props: SwatchProps; parts: 'root' };\n SwatchGroup: { props: SwatchGroupProps; parts: 'root' };\n Switch: { props: SwitchProps; parts: 'root' | 'input' | 'track' | 'thumb' | 'label' };\n Tabs: { props: TabsProps; parts: 'root' | 'list' | 'tab' | 'indicator' | 'panel' };\n Text: { props: TextProps; parts: 'root' };\n Suggest: {\n props: SuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'hint' | 'error';\n };\n Pages: { props: PagesProps; parts: 'root' | 'list' | 'item' | 'previous' | 'next' | 'status' };\n Steps: { props: StepsProps; parts: 'root' | 'list' | 'step' };\n Rating: { props: RatingProps; parts: 'root' };\n Table: { props: TableProps; parts: 'root' | 'table' | 'caption' };\n Carousel: {\n props: CarouselProps;\n parts: 'root' | 'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot';\n };\n}\nexport type ComponentName = keyof ThemeComponents;\n\nexport type ComponentsConfig = {\n [K in ComponentName]?: {\n defaults?: Partial<Omit<ThemeComponents[K]['props'], 'ref' | 'children' | 'css'>>;\n css?: Partial<Record<ThemeComponents[K]['parts'], SlurpCss>>;\n };\n};\n\nexport interface ThemeOptions {\n /** Initial colour scheme, until the person chooses one (default `system`). */\n colorScheme?: ColorSchemeMode;\n /** Default `hue-violet`. */\n accent?: AccentInput;\n /** Used only by Intl (numbers, prices). Not an i18n system. Default `it-IT`. */\n locale?: string;\n tokens?: TokenOverrides;\n motion?: Partial<MotionOptions>;\n components?: ComponentsConfig;\n}\n\nexport interface Theme {\n colorScheme: ColorSchemeMode;\n accent: AccentInput;\n /** The accent actually painted (hex). */\n accentColor: string;\n locale: string;\n tokens: TokenOverrides;\n motion: MotionOptions;\n components: ComponentsConfig;\n}\n\nconst DEFAULT_ACCENT: AccentInput = 'hue-violet';\n\n/** localStorage key of the chosen colour scheme (same as the design system's setTheme()). */\nexport const DEFAULT_STORAGE_KEY = 'slurp-theme';\n\nexport function createTheme(options: ThemeOptions = {}): Theme {\n const accent = options.accent ?? DEFAULT_ACCENT;\n return {\n colorScheme: options.colorScheme ?? 'system',\n accent,\n accentColor: resolveAccent(accent),\n locale: options.locale ?? 'it-IT',\n tokens: options.tokens ?? {},\n motion: { ...DEFAULT_MOTION, ...options.motion },\n components: options.components ?? {},\n };\n}\n\nexport const defaultTheme: Theme = createTheme();\n\nconst px = (v: Length) => (typeof v === 'number' ? `${v}px` : v);\n\n/** Light / dark declarations of the token overrides of a theme. */\nfunction overrideDeclarations(tokens: TokenOverrides) {\n const light: string[] = [];\n const dark: string[] = [];\n const add = (name: string, v: Themed | number) => {\n if (typeof v === 'object') {\n light.push(`--slurp-${name}:${v.light}`);\n dark.push(`--slurp-${name}:${v.dark}`);\n } else light.push(`--slurp-${name}:${px(v)}`);\n };\n for (const [k, v] of Object.entries(tokens.color ?? {})) if (v !== undefined) add(k, v);\n for (const [k, v] of Object.entries(tokens.space ?? {}))\n if (v !== undefined) add(`space-${k}`, v);\n for (const [k, v] of Object.entries(tokens.radius ?? {}))\n if (v !== undefined) add(`radius-${k}`, v);\n for (const [k, v] of Object.entries(tokens.shadow ?? {}))\n if (v !== undefined) add(`shadow-${k}`, v);\n for (const [k, v] of Object.entries(tokens.blur ?? {})) if (v !== undefined) add(`blur-${k}`, v);\n return { light, dark };\n}\n\nfunction selectors(scope: string | undefined) {\n if (!scope) {\n return {\n base: ':root,[data-theme]',\n dark: \"[data-theme='dark']\",\n systemDark: \":root:not([data-theme='light'])\",\n };\n }\n const s = `[data-slurp-theme=\"${scope}\"]`;\n return {\n base: `${s},${s} [data-theme]`,\n dark: `:root[data-theme='dark'] ${s},${s} [data-theme='dark']`,\n systemDark: `:root:not([data-theme='light']) ${s}`,\n };\n}\n\n/**\n * The stylesheet of a theme: accent variables and token overrides, on the root (or on a nested provider's `scope`)\n * and on every `data-theme` subtree, so derived values re-resolve per theme. Empty for the default theme.\n * tokens.css uses `:where()`, so these plain selectors win whatever the stylesheet order.\n */\nexport function themeCss(theme: Theme, scope?: string): string {\n const { light, dark } = overrideDeclarations(theme.tokens);\n const accent =\n theme.accent === DEFAULT_ACCENT\n ? []\n : Object.entries(accentVars(theme.accentColor)).map(([k, v]) => `${k}:${v}`);\n const base = [...accent, ...light];\n if (!base.length && !dark.length) return '';\n const sel = selectors(scope);\n const rules = [`${sel.base}{${base.join(';')}}`];\n if (dark.length) {\n rules.push(\n `${sel.dark}{${dark.join(';')}}`,\n `@media (prefers-color-scheme: dark){${sel.systemDark}{${dark.join(';')}}}`,\n );\n }\n return `${LAYER_ORDER}@layer slurp.base{${rules.join('')}}`;\n}\n\n/** Stable id of a stylesheet, for React's <style href> de-duplication. */\nexport const styleId = (prefix: string, css: string) => `slurp-${prefix}-${hash(css)}`;\n"],"mappings":";;;;;AA+GA,MAAM,EAAE,UAAU,SAAS,OAAO,OAAO,MAAM,eAAe,cAAc;AAC5E,MAAM,iBAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA,KAAK;C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
6115
|
}
|
|
6116
6116
|
}
|
|
6117
|
+
|
|
6118
|
+
/* Reveal: the words start in the secondary colour and turn to the full one; only colour changes. Lit until armed. */
|
|
6119
|
+
@layer slurp.components {
|
|
6120
|
+
.slurp-reveal {
|
|
6121
|
+
max-width: 680px;
|
|
6122
|
+
margin: 0;
|
|
6123
|
+
color: var(--slurp-fg);
|
|
6124
|
+
font: var(--slurp-font-display-l);
|
|
6125
|
+
letter-spacing: var(--slurp-font-display-l-tracking);
|
|
6126
|
+
text-wrap: balance;
|
|
6127
|
+
}
|
|
6128
|
+
|
|
6129
|
+
.slurp-reveal[data-armed] .slurp-reveal-word {
|
|
6130
|
+
color: var(--slurp-muted);
|
|
6131
|
+
transition: color var(--slurp-duration-base) var(--slurp-ease-settle);
|
|
6132
|
+
}
|
|
6133
|
+
|
|
6134
|
+
.slurp-reveal[data-armed] .slurp-reveal-word[data-lit] {
|
|
6135
|
+
color: var(--slurp-fg);
|
|
6136
|
+
}
|
|
6137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slurp-ui/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Slurp UI: ready-made React components of the Slurp design system, with optional collapse/expand motion.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@slurp-ui/icons": "^1.3.0",
|
|
77
|
-
"@slurp-ui/
|
|
78
|
-
"@slurp-ui/
|
|
77
|
+
"@slurp-ui/motion": "^1.0.1",
|
|
78
|
+
"@slurp-ui/tokens": "^1.2.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@arethetypeswrong/cli": "^0.18.5",
|