@orangecheck/design 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import * as React2 from 'react';
4
4
  import { createContext, useState, useRef, useEffect, useCallback, useMemo, useContext } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { useTheme } from 'next-themes';
7
- import { ChevronDown, Palette, Check, Sun, Moon, X, XIcon, AlertTriangle, Pencil, ChevronLeft, ChevronRight, ChevronDownIcon, CheckIcon, ChevronUpIcon, Maximize2, Copy } from 'lucide-react';
7
+ import { ChevronDown, Palette, Check, Sun, Moon, Monitor, X, XIcon, AlertTriangle, Pencil, ChevronLeft, ChevronRight, ChevronDownIcon, CheckIcon, ChevronUpIcon, Maximize2, Copy } from 'lucide-react';
8
8
  import { Slot } from '@radix-ui/react-slot';
9
9
  import { cva } from 'class-variance-authority';
10
10
  import * as LabelPrimitive from '@radix-ui/react-label';
@@ -71,6 +71,7 @@ __export(src_exports, {
71
71
  Modal: () => Modal,
72
72
  OC_SKIN_COOKIE: () => OC_SKIN_COOKIE,
73
73
  OC_THEMES: () => OC_THEMES,
74
+ OcAppearanceMenu: () => OcAppearanceMenu,
74
75
  OcThemeBridge: () => OcThemeBridge,
75
76
  OcThemePicker: () => OcThemePicker,
76
77
  OcThemeProvider: () => OcThemeProvider,
@@ -372,6 +373,115 @@ function OcThemePicker({ className, triggerClassName, popoverClassName }) {
372
373
  )
373
374
  ] });
374
375
  }
376
+ var MODES = [
377
+ { id: "light", label: "light", Icon: Sun },
378
+ { id: "dark", label: "dark", Icon: Moon },
379
+ { id: "system", label: "system", Icon: Monitor }
380
+ ];
381
+ function OcAppearanceMenu({
382
+ className,
383
+ triggerClassName,
384
+ popoverClassName
385
+ }) {
386
+ const { skin, setSkin, themes } = useOcSkin();
387
+ const { theme, setTheme } = useTheme();
388
+ const [open, setOpen] = useState(false);
389
+ const [mounted, setMounted] = useState(false);
390
+ const rootRef = useRef(null);
391
+ useEffect(() => setMounted(true), []);
392
+ useEffect(() => {
393
+ if (!open) return;
394
+ function onDown(e) {
395
+ if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false);
396
+ }
397
+ function onKey(e) {
398
+ if (e.key === "Escape") setOpen(false);
399
+ }
400
+ document.addEventListener("mousedown", onDown);
401
+ document.addEventListener("keydown", onKey);
402
+ return () => {
403
+ document.removeEventListener("mousedown", onDown);
404
+ document.removeEventListener("keydown", onKey);
405
+ };
406
+ }, [open]);
407
+ const activeMode = mounted ? theme ?? "system" : null;
408
+ return /* @__PURE__ */ jsxs("div", { ref: rootRef, className: cn("relative", className), children: [
409
+ /* @__PURE__ */ jsx(
410
+ "button",
411
+ {
412
+ type: "button",
413
+ "aria-label": "appearance settings",
414
+ "aria-haspopup": "menu",
415
+ "aria-expanded": open,
416
+ title: "appearance \xB7 mode + theme",
417
+ onClick: () => setOpen((v) => !v),
418
+ className: cn(
419
+ "text-muted-foreground hover:text-foreground inline-flex size-9 items-center justify-center rounded-md transition-colors outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
420
+ triggerClassName
421
+ ),
422
+ children: /* @__PURE__ */ jsx(Palette, { className: "size-4", "aria-hidden": true })
423
+ }
424
+ ),
425
+ open && /* @__PURE__ */ jsxs(
426
+ "div",
427
+ {
428
+ role: "menu",
429
+ className: cn(
430
+ "bg-popover text-popover-foreground absolute right-0 z-50 mt-2 w-64 overflow-hidden rounded-md border shadow-md",
431
+ popoverClassName
432
+ ),
433
+ children: [
434
+ /* @__PURE__ */ jsx("div", { className: "label-mono text-muted-foreground px-3 pt-3 pb-2", children: "mode" }),
435
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1 px-2 pb-2", children: MODES.map(({ id, label, Icon: Icon2 }) => {
436
+ const active = activeMode === id;
437
+ return /* @__PURE__ */ jsxs(
438
+ "button",
439
+ {
440
+ type: "button",
441
+ role: "menuitemradio",
442
+ "aria-checked": active,
443
+ onClick: () => setTheme(id),
444
+ className: cn(
445
+ "flex flex-col items-center gap-1 rounded-md border py-2 text-[11px] transition-colors",
446
+ active ? "border-primary text-foreground bg-accent" : "border-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground"
447
+ ),
448
+ children: [
449
+ /* @__PURE__ */ jsx(Icon2, { className: "size-4", "aria-hidden": true }),
450
+ label
451
+ ]
452
+ },
453
+ id
454
+ );
455
+ }) }),
456
+ /* @__PURE__ */ jsx("div", { className: "label-mono text-muted-foreground border-t px-3 pt-3 pb-1", children: "theme" }),
457
+ /* @__PURE__ */ jsx("ul", { className: "pb-1", children: themes.map((t) => {
458
+ const active = t.id === skin;
459
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
460
+ "button",
461
+ {
462
+ type: "button",
463
+ role: "menuitemradio",
464
+ "aria-checked": active,
465
+ onClick: () => setSkin(t.id),
466
+ className: cn(
467
+ "hover:bg-accent hover:text-accent-foreground flex w-full items-start gap-2 px-3 py-2 text-left transition-colors",
468
+ active && "text-foreground"
469
+ ),
470
+ children: [
471
+ /* @__PURE__ */ jsx("span", { className: "mt-0.5 size-4 shrink-0", children: active && /* @__PURE__ */ jsx(Check, { className: "text-primary size-4", "aria-hidden": true }) }),
472
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
473
+ /* @__PURE__ */ jsx("span", { className: "block text-sm font-medium", children: t.label }),
474
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground block text-xs leading-snug", children: t.description })
475
+ ] })
476
+ ]
477
+ }
478
+ ) }, t.id);
479
+ }) })
480
+ ]
481
+ }
482
+ )
483
+ ] });
484
+ }
375
485
  var buttonVariants = cva(
376
486
  "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
377
487
  {
@@ -425,6 +535,7 @@ var badgeVariants = cva(
425
535
  warning: "bg-warning text-warning-foreground [a&]:hover:bg-warning/90 border-transparent",
426
536
  success: "bg-success text-success-foreground [a&]:hover:bg-success/90 border-transparent",
427
537
  info: "bg-info text-info-foreground [a&]:hover:bg-info/90 border-transparent",
538
+ brand: "bg-brand-soft text-brand border-brand-soft",
428
539
  outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
429
540
  }
430
541
  },
@@ -1841,6 +1952,6 @@ __reExport(components_exports, ui_star);
1841
1952
  // src/index.ts
1842
1953
  __reExport(src_exports, components_exports);
1843
1954
 
1844
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, AlertWithAction, AlertWithCountdown, Badge, Bar, BitcoinAddress, Button, Card, ConfirmHost, CopyButton, DEFAULT_OC_THEME, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, ErrorBoundary, Input, Label, Modal, OC_SKIN_COOKIE, OC_THEMES, OcThemeBridge, OcThemePicker, OcThemeProvider, Pagination, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PromptHost, QrCode, REFERENCE_BTC_USD, SatsAmount, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, Sparkline, StatBlock, StatusPill, Textarea, ThemeToggle, ThemeToggleLink, Toaster, Working, WorkingPanel, badgeVariants, buttonVariants, cn, confirm, explorerUrl, formatSats, formatSatsCompact, getOcThemeInitScript, isKnownTheme, priceBoth, prompt, relativeTime, resolveTheme, satsToUsd, shortenAddress, usdToSats, useOcSkin };
1955
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, AlertWithAction, AlertWithCountdown, Badge, Bar, BitcoinAddress, Button, Card, ConfirmHost, CopyButton, DEFAULT_OC_THEME, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, ErrorBoundary, Input, Label, Modal, OC_SKIN_COOKIE, OC_THEMES, OcAppearanceMenu, OcThemeBridge, OcThemePicker, OcThemeProvider, Pagination, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PromptHost, QrCode, REFERENCE_BTC_USD, SatsAmount, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, Sparkline, StatBlock, StatusPill, Textarea, ThemeToggle, ThemeToggleLink, Toaster, Working, WorkingPanel, badgeVariants, buttonVariants, cn, confirm, explorerUrl, formatSats, formatSatsCompact, getOcThemeInitScript, isKnownTheme, priceBoth, prompt, relativeTime, resolveTheme, satsToUsd, shortenAddress, usdToSats, useOcSkin };
1845
1956
  //# sourceMappingURL=index.mjs.map
1846
1957
  //# sourceMappingURL=index.mjs.map