@og-ui/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/bin/ogui.js +102 -0
- package/lib/registry.js +92 -0
- package/package.json +32 -3
- package/registry/accordion-react.json +33 -0
- package/registry/accordion.json +36 -0
- package/registry/alert-react.json +33 -0
- package/registry/alert.json +41 -0
- package/registry/avatar-react.json +33 -0
- package/registry/avatar.json +48 -0
- package/registry/badge-react.json +33 -0
- package/registry/badge.json +52 -0
- package/registry/button-react.json +33 -0
- package/registry/button.json +51 -0
- package/registry/card-react.json +33 -0
- package/registry/card.json +51 -0
- package/registry/checkbox-react.json +33 -0
- package/registry/checkbox.json +46 -0
- package/registry/dialog-react.json +33 -0
- package/registry/dialog.json +53 -0
- package/registry/index.json +1155 -0
- package/registry/input-react.json +33 -0
- package/registry/input.json +45 -0
- package/registry/menu-react.json +33 -0
- package/registry/menu.json +11 -0
- package/registry/og-ui.json +21 -0
- package/registry/pagination-react.json +33 -0
- package/registry/pagination.json +37 -0
- package/registry/popover-react.json +33 -0
- package/registry/popover.json +46 -0
- package/registry/progress-react.json +33 -0
- package/registry/progress.json +35 -0
- package/registry/select-react.json +33 -0
- package/registry/select.json +35 -0
- package/registry/skeleton-react.json +33 -0
- package/registry/skeleton.json +37 -0
- package/registry/slider-react.json +33 -0
- package/registry/slider.json +38 -0
- package/registry/surface.json +37 -0
- package/registry/switch-react.json +33 -0
- package/registry/switch.json +35 -0
- package/registry/table-react.json +33 -0
- package/registry/table.json +38 -0
- package/registry/tabs-react.json +33 -0
- package/registry/tabs.json +41 -0
- package/registry/theme-aurora.json +135 -0
- package/registry/theme-brutal.json +135 -0
- package/registry/theme-clay.json +135 -0
- package/registry/theme-clean.json +135 -0
- package/registry/theme-glass.json +135 -0
- package/registry/theme-liquid-glass.json +135 -0
- package/registry/theme-neumorphism.json +135 -0
- package/registry/theme-provider-react.json +33 -0
- package/registry/toast-react.json +33 -0
- package/registry/toast.json +46 -0
- package/registry/tooltip.json +37 -0
- package/README.md +0 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "badge",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Badge",
|
|
6
|
+
"description": "Short status labels and tags, in status colours or the theme’s six palette colours.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-badge",
|
|
10
|
+
"og-badge--accent",
|
|
11
|
+
"og-badge--success",
|
|
12
|
+
"og-badge--warning",
|
|
13
|
+
"og-badge--danger",
|
|
14
|
+
"og-badge--1",
|
|
15
|
+
"og-badge--2",
|
|
16
|
+
"og-badge--3",
|
|
17
|
+
"og-badge--4",
|
|
18
|
+
"og-badge--5",
|
|
19
|
+
"og-badge--6",
|
|
20
|
+
"og-badge--solid"
|
|
21
|
+
],
|
|
22
|
+
"group": "Actions & display",
|
|
23
|
+
"markup": [
|
|
24
|
+
{
|
|
25
|
+
"label": "Status",
|
|
26
|
+
"html": "<span class=\"og-badge og-badge--success\">Paid</span>\n<span class=\"og-badge og-badge--warning\">Pending</span>\n<span class=\"og-badge og-badge--danger\">Overdue</span>\n<span class=\"og-badge og-badge--accent\">Draft</span>\n<span class=\"og-badge og-badge--accent og-badge--solid\">Pro</span>"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "Palette",
|
|
30
|
+
"html": "<span class=\"og-badge og-badge--1\">Design</span>\n<span class=\"og-badge og-badge--2\">Marketing</span>\n<span class=\"og-badge og-badge--3\">Finance</span>\n<span class=\"og-badge og-badge--4\">Ops</span>\n<span class=\"og-badge og-badge--5\">Research</span>\n<span class=\"og-badge og-badge--6\">Support</span>"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"react": "import { Badge } from '@og-ui/react';\n\n<Badge variant=\"success\">Paid</Badge>\n<Badge variant={3}>Finance</Badge>\n<Badge variant=\"accent\" solid>Pro</Badge>",
|
|
34
|
+
"keyboard": [
|
|
35
|
+
"Not focusable. Don’t make a badge the only way to tell a state: say it in text too."
|
|
36
|
+
],
|
|
37
|
+
"notes": [
|
|
38
|
+
"--solid is meant for --accent; other colours with --solid aren’t contrast-checked."
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"registryDependencies": [
|
|
42
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
43
|
+
],
|
|
44
|
+
"files": [
|
|
45
|
+
{
|
|
46
|
+
"path": "og-ui/components/badge.css",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "og-ui/components/badge.css",
|
|
49
|
+
"content": "/*! OG UI badge | MIT | https://ui.ogom.in */\n.og-badge {\n --_c: var(--og-color-text-muted);\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 1.375rem;\n padding: 0 0.5rem;\n border: var(--og-border-width) solid color-mix(in oklab, var(--_c) 35%, transparent);\n border-radius: var(--og-radius-full);\n background: color-mix(in oklab, var(--_c) 14%, transparent);\n color: color-mix(in oklab, var(--_c) 50%, var(--og-color-text));\n font-family: var(--og-font);\n font-size: 0.75rem;\n font-weight: var(--og-font-weight-strong);\n line-height: 1;\n white-space: nowrap;\n}\n.og-badge--accent {\n --_c: var(--og-color-accent);\n}\n.og-badge--success {\n --_c: var(--og-color-success);\n}\n.og-badge--warning {\n --_c: var(--og-color-warning);\n}\n.og-badge--danger {\n --_c: var(--og-color-danger);\n}\n.og-badge--1 {\n --_c: var(--og-palette-1);\n}\n.og-badge--2 {\n --_c: var(--og-palette-2);\n}\n.og-badge--3 {\n --_c: var(--og-palette-3);\n}\n.og-badge--4 {\n --_c: var(--og-palette-4);\n}\n.og-badge--5 {\n --_c: var(--og-palette-5);\n}\n.og-badge--6 {\n --_c: var(--og-palette-6);\n}\n.og-badge--solid {\n border-color: var(--og-color-accent-border);\n background: var(--_c);\n color: var(--og-color-bg);\n}\n.og-badge--solid.og-badge--accent {\n color: var(--og-color-accent-contrast);\n}\n"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "button-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "button (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/button.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "button",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Button",
|
|
6
|
+
"description": "Actions. Default, primary, ghost and danger, in three sizes, plus a square icon button.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-button",
|
|
10
|
+
"og-button--primary",
|
|
11
|
+
"og-button--danger",
|
|
12
|
+
"og-button--ghost",
|
|
13
|
+
"og-button--sm",
|
|
14
|
+
"og-button--lg",
|
|
15
|
+
"og-button--icon",
|
|
16
|
+
"og-button--block"
|
|
17
|
+
],
|
|
18
|
+
"group": "Actions & display",
|
|
19
|
+
"markup": [
|
|
20
|
+
{
|
|
21
|
+
"label": "Variants",
|
|
22
|
+
"html": "<button class=\"og-button og-button--primary\">Save changes</button>\n<button class=\"og-button\">Cancel</button>\n<button class=\"og-button og-button--ghost\">Skip</button>\n<button class=\"og-button og-button--danger\">Delete</button>"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"label": "Sizes",
|
|
26
|
+
"html": "<button class=\"og-button og-button--primary og-button--sm\">Small</button>\n<button class=\"og-button og-button--primary\">Medium</button>\n<button class=\"og-button og-button--primary og-button--lg\">Large</button>"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "Icon and disabled",
|
|
30
|
+
"html": "<button class=\"og-button og-button--icon\" aria-label=\"Copy link\">⧉</button>\n<button class=\"og-button\" disabled>Disabled</button>"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"react": "import { Button } from '@og-ui/react';\n\n<Button variant=\"primary\">Save changes</Button>\n<Button variant=\"ghost\" size=\"sm\">Skip</Button>\n<Button icon aria-label=\"Copy link\">⧉</Button>",
|
|
34
|
+
"keyboard": [
|
|
35
|
+
"Tab focuses it; Enter and Space activate it (native <button>).",
|
|
36
|
+
"An icon button needs an aria-label."
|
|
37
|
+
],
|
|
38
|
+
"notes": []
|
|
39
|
+
},
|
|
40
|
+
"registryDependencies": [
|
|
41
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
42
|
+
],
|
|
43
|
+
"files": [
|
|
44
|
+
{
|
|
45
|
+
"path": "og-ui/components/button.css",
|
|
46
|
+
"type": "registry:file",
|
|
47
|
+
"target": "og-ui/components/button.css",
|
|
48
|
+
"content": "/*! OG UI button | MIT | https://ui.ogom.in */\n.og-button {\n background: var(--og-surface-raised-fill);\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n box-shadow: var(--og-surface-raised-shadow);\n -webkit-backdrop-filter: var(--og-surface-raised-filter);\n backdrop-filter: var(--og-surface-raised-filter);\n transition-property: transform, background-color, border-color, color, box-shadow;\n transition-duration: var(--og-motion-duration);\n transition-timing-function: var(--og-easing);\n --_h: var(--og-control-h-md);\n --_px: var(--og-control-px);\n --_fs: 0.875rem;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n height: var(--_h);\n padding: 0 var(--_px);\n border-radius: var(--og-radius-control);\n color: var(--og-color-text);\n font: inherit;\n font-family: var(--og-font);\n font-size: var(--_fs);\n font-weight: var(--og-font-weight-strong);\n line-height: 1;\n white-space: nowrap;\n text-decoration: none;\n cursor: pointer;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n position: relative;\n isolation: isolate;\n}\n.og-button::before {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: var(--og-surface-raised-highlight);\n pointer-events: none;\n z-index: -1;\n}\n.og-button:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 2px;\n}\n.og-button:disabled, .og-button[aria-disabled=true] {\n opacity: 0.5;\n cursor: not-allowed;\n transform: none;\n pointer-events: none;\n}\n.og-button:hover {\n background: color-mix(in oklab, var(--og-surface-raised-fill), var(--og-color-text) 5%);\n transform: var(--og-motion-hover);\n}\n.og-button:active {\n box-shadow: var(--og-surface-inset-shadow);\n transform: var(--og-motion-press);\n}\n.og-button--primary {\n background: var(--og-color-accent);\n border-color: var(--og-color-accent-border);\n box-shadow: var(--og-effect-glow), var(--og-surface-raised-shadow);\n color: var(--og-color-accent-contrast);\n}\n.og-button--primary:hover {\n background: color-mix(in oklab, var(--og-color-accent), var(--og-color-text) 12%);\n}\n.og-button--danger {\n background: var(--og-color-danger);\n border-color: var(--og-color-accent-border);\n color: var(--og-color-bg);\n}\n.og-button--danger:hover {\n background: color-mix(in oklab, var(--og-color-danger), #000 12%);\n}\n.og-button--ghost {\n background: transparent;\n border-color: transparent;\n box-shadow: none;\n -webkit-backdrop-filter: none;\n backdrop-filter: none;\n}\n.og-button--ghost::before {\n display: none;\n}\n.og-button--ghost:hover {\n background: color-mix(in oklab, var(--og-color-text) 8%, transparent);\n transform: none;\n}\n.og-button--ghost:active {\n box-shadow: none;\n background: color-mix(in oklab, var(--og-color-text) 12%, transparent);\n}\n.og-button--sm {\n --_h: var(--og-control-h-sm);\n --_px: calc(var(--og-control-px) * 0.75);\n --_fs: 0.8125rem;\n}\n.og-button--lg {\n --_h: var(--og-control-h-lg);\n --_px: calc(var(--og-control-px) * 1.5);\n --_fs: 1rem;\n}\n.og-button--icon {\n width: var(--_h);\n padding: 0;\n}\n.og-button--block {\n display: flex;\n width: 100%;\n}\n"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "card-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "card (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/card.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "card",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Card",
|
|
6
|
+
"description": "The raised surface for grouped content, with header, body and footer slots and six palette tints.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-card",
|
|
10
|
+
"og-card__header",
|
|
11
|
+
"og-card__title",
|
|
12
|
+
"og-card__description",
|
|
13
|
+
"og-card__body",
|
|
14
|
+
"og-card__footer",
|
|
15
|
+
"og-card--tint-1",
|
|
16
|
+
"og-card--tint-2",
|
|
17
|
+
"og-card--tint-3",
|
|
18
|
+
"og-card--tint-4",
|
|
19
|
+
"og-card--tint-5",
|
|
20
|
+
"og-card--tint-6",
|
|
21
|
+
"og-card--floating"
|
|
22
|
+
],
|
|
23
|
+
"group": "Actions & display",
|
|
24
|
+
"markup": [
|
|
25
|
+
{
|
|
26
|
+
"label": "Card",
|
|
27
|
+
"html": "<article class=\"og-card\" style=\"max-width: 22rem\">\n <header class=\"og-card__header\">\n <h3 class=\"og-card__title\">Invoice #1042</h3>\n <p class=\"og-card__description\">Acme Ltd · due in 12 days</p>\n </header>\n <div class=\"og-card__body\">₹4,200 for design work in November.</div>\n <footer class=\"og-card__footer\">\n <span class=\"og-badge og-badge--warning\">Pending</span>\n <button class=\"og-button og-button--primary og-button--sm\">Send</button>\n </footer>\n</article>"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"label": "Tints",
|
|
31
|
+
"html": "<article class=\"og-card og-card--tint-1\" style=\"max-width: 14rem\"><h3 class=\"og-card__title\">Roadmap</h3><p class=\"og-card__description\">12 open items</p></article>\n<article class=\"og-card og-card--tint-3\" style=\"max-width: 14rem\"><h3 class=\"og-card__title\">Revenue</h3><p class=\"og-card__description\">Up 8% this month</p></article>"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"react": "import { Card, Button } from '@og-ui/react';\n\n<Card\n title=\"Invoice #1042\"\n description=\"Acme Ltd · due in 12 days\"\n footer={<Button variant=\"primary\" size=\"sm\">Send</Button>}\n>\n ₹4,200 for design work in November.\n</Card>",
|
|
35
|
+
"keyboard": [
|
|
36
|
+
"Not focusable itself; Tab moves through the controls inside."
|
|
37
|
+
],
|
|
38
|
+
"notes": []
|
|
39
|
+
},
|
|
40
|
+
"registryDependencies": [
|
|
41
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
42
|
+
],
|
|
43
|
+
"files": [
|
|
44
|
+
{
|
|
45
|
+
"path": "og-ui/components/card.css",
|
|
46
|
+
"type": "registry:file",
|
|
47
|
+
"target": "og-ui/components/card.css",
|
|
48
|
+
"content": "/*! OG UI card | MIT | https://ui.ogom.in */\n.og-card {\n background: var(--og-surface-raised-fill);\n border: var(--og-border-width) solid var(--og-surface-raised-border);\n box-shadow: var(--og-surface-raised-shadow);\n -webkit-backdrop-filter: var(--og-surface-raised-filter);\n backdrop-filter: var(--og-surface-raised-filter);\n display: flex;\n flex-direction: column;\n gap: var(--og-gap);\n padding: var(--og-card-pad);\n border-radius: var(--og-radius-lg);\n color: var(--og-color-text);\n position: relative;\n isolation: isolate;\n}\n.og-card::before {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: var(--og-surface-raised-highlight);\n pointer-events: none;\n z-index: -1;\n}\n.og-card__header {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n}\n.og-card__title {\n margin: 0;\n font-family: var(--og-font-display);\n font-size: 1rem;\n font-weight: var(--og-font-weight-strong);\n line-height: 1.3;\n}\n.og-card__description {\n margin: 0;\n color: var(--og-color-text-muted);\n font-size: 0.875rem;\n line-height: 1.5;\n}\n.og-card__body {\n font-size: 0.875rem;\n line-height: 1.6;\n}\n.og-card__footer {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem;\n}\n.og-card--tint-1 {\n background: color-mix(in oklab, var(--og-palette-1) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--tint-2 {\n background: color-mix(in oklab, var(--og-palette-2) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--tint-3 {\n background: color-mix(in oklab, var(--og-palette-3) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--tint-4 {\n background: color-mix(in oklab, var(--og-palette-4) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--tint-5 {\n background: color-mix(in oklab, var(--og-palette-5) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--tint-6 {\n background: color-mix(in oklab, var(--og-palette-6) var(--og-tint-strength), var(--og-surface-raised-fill));\n --og-color-text-muted: color-mix(in oklab, var(--og-color-on-tint) 72%, transparent);\n color: var(--og-color-on-tint);\n}\n.og-card--floating {\n background: var(--og-surface-overlay-fill);\n border: var(--og-border-width) solid var(--og-surface-overlay-border);\n box-shadow: var(--og-surface-overlay-shadow);\n -webkit-backdrop-filter: var(--og-surface-overlay-filter);\n backdrop-filter: var(--og-surface-overlay-filter);\n}\n.og-card--floating::before {\n background: var(--og-surface-overlay-highlight);\n}\n"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "checkbox-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "checkbox (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's components.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/checkbox.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/components.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/components.tsx",
|
|
18
|
+
"content": "import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ReactNode,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\ntype Palette = 1 | 2 | 3 | 4 | 5 | 6;\ntype Status = 'accent' | 'success' | 'warning' | 'danger';\n\n// ---------------------------------------------------------------------------\n// Button\n\nexport interface ButtonProps extends ComponentPropsWithoutRef<'button'> {\n variant?: 'primary' | 'ghost' | 'danger';\n size?: 'sm' | 'lg';\n /** Square icon button. Give it an aria-label. */\n icon?: boolean;\n block?: boolean;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n { variant, size, icon, block, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'og-button',\n variant && `og-button--${variant}`,\n size && `og-button--${size}`,\n icon && 'og-button--icon',\n block && 'og-button--block',\n className,\n )}\n {...props}\n />\n );\n});\n\n// ---------------------------------------------------------------------------\n// Card\n\nexport interface CardProps extends Omit<ComponentPropsWithoutRef<'article'>, 'title'> {\n title?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Palette tint 1–6. */\n tint?: Palette;\n}\n\nexport const Card = forwardRef<HTMLElement, CardProps>(function Card(\n { title, description, footer, tint, className, children, ...props },\n ref,\n) {\n return (\n <article ref={ref} className={cx('og-card', tint && `og-card--tint-${tint}`, className)} {...props}>\n {(title || description) && (\n <header className=\"og-card__header\">\n {title && <h3 className=\"og-card__title\">{title}</h3>}\n {description && <p className=\"og-card__description\">{description}</p>}\n </header>\n )}\n {children !== undefined && <div className=\"og-card__body\">{children}</div>}\n {footer && <footer className=\"og-card__footer\">{footer}</footer>}\n </article>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Form controls\n\n/** Wraps a control in og-field with a label and hint when they are given. */\nfunction Field({ label, hint, children }: { label?: ReactNode; hint?: ReactNode; children: ReactNode }) {\n if (!label && !hint) return <>{children}</>;\n return (\n <label className=\"og-field\">\n {label && <span className=\"og-label\">{label}</span>}\n {children}\n {hint && <span className=\"og-hint\">{hint}</span>}\n </label>\n );\n}\n\nexport interface InputProps extends ComponentPropsWithoutRef<'input'> {\n label?: ReactNode;\n hint?: ReactNode;\n invalid?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { label, hint, invalid, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <input\n ref={ref}\n className={cx('og-input', className)}\n aria-invalid={invalid || props['aria-invalid']}\n {...props}\n />\n </Field>\n );\n});\n\nexport interface SelectProps extends ComponentPropsWithoutRef<'select'> {\n label?: ReactNode;\n hint?: ReactNode;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { label, hint, className, ...props },\n ref,\n) {\n return (\n <Field label={label} hint={hint}>\n <span className={cx('og-select', className)}>\n <select ref={ref} {...props} />\n </span>\n </Field>\n );\n});\n\nexport interface CheckboxProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n /** Shows the dash state. Sets the DOM property, which has no HTML attribute. */\n indeterminate?: boolean;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { label, indeterminate, className, ...props },\n ref,\n) {\n const setRef = (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = !!indeterminate;\n if (typeof ref === 'function') ref(el);\n else if (ref) ref.current = el;\n };\n return (\n <label className=\"og-check\">\n <input ref={setRef} type=\"checkbox\" className={cx('og-checkbox', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SwitchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'role'> {\n label?: ReactNode;\n}\n\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { label, className, ...props },\n ref,\n) {\n return (\n <label className=\"og-check\">\n <input ref={ref} type=\"checkbox\" role=\"switch\" className={cx('og-switch', className)} {...props} />\n {label}\n </label>\n );\n});\n\nexport interface SliderProps extends Omit<ComponentPropsWithoutRef<'input'>, 'type'> {\n label?: ReactNode;\n}\n\nexport const Slider = forwardRef<HTMLInputElement, SliderProps>(function Slider(\n { label, className, style, min = 0, max = 100, ...props },\n ref,\n) {\n useOgUI();\n // og-ui.js keeps the fill in sync while dragging; this covers the first render and\n // controlled value changes that don't come from the user.\n const value = Number(props.value ?? props.defaultValue ?? (Number(min) + Number(max)) / 2);\n const span = Number(max) - Number(min);\n const pct = span ? ((value - Number(min)) / span) * 100 : 0;\n return (\n <Field label={label}>\n <input\n ref={ref}\n type=\"range\"\n min={min}\n max={max}\n className={cx('og-slider', className)}\n style={{ '--_value': `${pct}%`, ...style } as CSSProperties}\n {...props}\n />\n </Field>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Display\n\nexport interface BadgeProps extends ComponentPropsWithoutRef<'span'> {\n variant?: Status | Palette;\n /** Filled. Documented for variant=\"accent\". */\n solid?: boolean;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { variant, solid, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-badge', variant && `og-badge--${variant}`, solid && 'og-badge--solid', className)}\n {...props}\n />\n );\n});\n\nexport interface AvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'color'> {\n /** Full name: used for the initials and the accessible name. */\n name: string;\n src?: string;\n color?: Palette;\n size?: 'sm' | 'lg';\n}\n\nconst initials = (name: string) =>\n name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((w) => w[0]?.toUpperCase())\n .join('');\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(\n { name, src, color, size, className, ...props },\n ref,\n) {\n return (\n <span\n ref={ref}\n className={cx('og-avatar', color && `og-avatar--${color}`, size && `og-avatar--${size}`, className)}\n role={src ? undefined : 'img'}\n aria-label={src ? undefined : name}\n {...props}\n >\n {src ? <img src={src} alt={name} /> : initials(name)}\n </span>\n );\n});\n\nexport interface AlertProps extends Omit<ComponentPropsWithoutRef<'div'>, 'title'> {\n variant?: Status;\n title?: ReactNode;\n}\n\n/** role=\"status\" by default; pass role=\"alert\" only for urgent errors. */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n { variant, title, className, children, role = 'status', ...props },\n ref,\n) {\n return (\n <div ref={ref} role={role} className={cx('og-alert', variant && `og-alert--${variant}`, className)} {...props}>\n {title && <p className=\"og-alert__title\">{title}</p>}\n {children && <p className=\"og-alert__description\">{children}</p>}\n </div>\n );\n});\n\n/** Leave out value for an indeterminate bar. Give it an aria-label. */\nexport const Progress = forwardRef<HTMLProgressElement, ComponentPropsWithoutRef<'progress'>>(function Progress(\n { className, max = 100, ...props },\n ref,\n) {\n return <progress ref={ref} max={max} className={cx('og-progress', className)} {...props} />;\n});\n\nexport interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {\n shape?: 'text' | 'circle';\n}\n\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n { shape, className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={cx('og-skeleton', shape && `og-skeleton--${shape}`, className)}\n {...props}\n />\n );\n});\n\n/** The wrapper scrolls sideways on small screens. Use className=\"og-table__num\" on number cells. */\nexport const Table = forwardRef<HTMLTableElement, ComponentPropsWithoutRef<'table'>>(function Table(\n { className, ...props },\n ref,\n) {\n return (\n <div className=\"og-table-wrap\">\n <table ref={ref} className={cx('og-table', className)} {...props} />\n </div>\n );\n});\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "checkbox",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Checkbox and radio",
|
|
6
|
+
"description": "Native checkboxes and radios, restyled, including the indeterminate state and radio groups.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-check",
|
|
10
|
+
"og-checkbox",
|
|
11
|
+
"og-radio",
|
|
12
|
+
"og-radio-group",
|
|
13
|
+
"og-radio-group--row"
|
|
14
|
+
],
|
|
15
|
+
"group": "Forms",
|
|
16
|
+
"markup": [
|
|
17
|
+
{
|
|
18
|
+
"label": "Checkboxes",
|
|
19
|
+
"html": "<label class=\"og-check\"><input type=\"checkbox\" class=\"og-checkbox\" checked /> Email me receipts</label>\n<label class=\"og-check\"><input type=\"checkbox\" class=\"og-checkbox\" /> Weekly summary</label>\n<label class=\"og-check\"><input type=\"checkbox\" class=\"og-checkbox\" disabled /> Disabled</label>"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"label": "Radio group",
|
|
23
|
+
"html": "<fieldset class=\"og-radio-group og-radio-group--row\">\n <legend class=\"og-label\">Billing</legend>\n <label class=\"og-check\"><input type=\"radio\" name=\"checkbox\" class=\"og-radio\" checked /> Monthly</label>\n <label class=\"og-check\"><input type=\"radio\" name=\"checkbox\" class=\"og-radio\" /> Yearly</label>\n</fieldset>"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"react": "import { Checkbox } from '@og-ui/react';\n\n<Checkbox label=\"Email me receipts\" defaultChecked />\n<Checkbox label=\"Select all\" indeterminate />",
|
|
27
|
+
"keyboard": [
|
|
28
|
+
"Space toggles a checkbox.",
|
|
29
|
+
"A radio group is one Tab stop; arrow keys move and select within it."
|
|
30
|
+
],
|
|
31
|
+
"notes": [
|
|
32
|
+
"Group radios in a fieldset with a legend so the group name is announced."
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"registryDependencies": [
|
|
36
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
{
|
|
40
|
+
"path": "og-ui/components/checkbox.css",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "og-ui/components/checkbox.css",
|
|
43
|
+
"content": "/*! OG UI checkbox | MIT | https://ui.ogom.in */\n.og-check {\n display: inline-flex;\n align-items: center;\n gap: 0.5rem;\n color: var(--og-color-text);\n font-family: var(--og-font);\n font-size: 0.875rem;\n cursor: pointer;\n}\n.og-check:has(:disabled) {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.og-checkbox,\n.og-radio {\n background: var(--og-surface-inset-fill);\n border: var(--og-border-width) solid var(--og-surface-inset-border);\n box-shadow: var(--og-surface-inset-shadow);\n -webkit-backdrop-filter: var(--og-surface-inset-filter);\n backdrop-filter: var(--og-surface-inset-filter);\n transition-property: transform, background-color, border-color, color, box-shadow;\n transition-duration: var(--og-motion-duration);\n transition-timing-function: var(--og-easing);\n display: inline-grid;\n place-items: center;\n flex: none;\n width: 1.25rem;\n height: 1.25rem;\n margin: 0;\n color: var(--og-color-accent-contrast);\n appearance: none;\n cursor: inherit;\n}\n.og-checkbox:focus-visible,\n.og-radio:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 2px;\n}\n.og-checkbox::before,\n.og-radio::before {\n content: \"\";\n transform: scale(0);\n transition: transform var(--og-motion-duration) var(--og-easing);\n}\n.og-checkbox:checked, .og-checkbox:indeterminate,\n.og-radio:checked,\n.og-radio:indeterminate {\n background: var(--og-color-accent);\n border-color: var(--og-color-accent-border);\n box-shadow: var(--og-surface-raised-shadow);\n}\n.og-checkbox:checked::before, .og-checkbox:indeterminate::before,\n.og-radio:checked::before,\n.og-radio:indeterminate::before {\n transform: scale(1);\n}\n\n.og-checkbox {\n border-radius: calc(var(--og-radius-sm) * 0.75);\n}\n.og-checkbox::before {\n content: \"\";\n display: inline-block;\n width: 0.875rem;\n height: 0.875rem;\n background: currentColor;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n transform: scale(0);\n}\n.og-checkbox:indeterminate::before {\n -webkit-mask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E\");\n mask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E\");\n}\n\n.og-radio {\n border-radius: var(--og-radius-full);\n}\n.og-radio::before {\n width: 0.5rem;\n height: 0.5rem;\n border-radius: var(--og-radius-full);\n background: currentColor;\n}\n\n.og-radio-group {\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n margin: 0;\n padding: 0;\n border: 0;\n}\n.og-radio-group legend {\n margin-bottom: 0.5rem;\n padding: 0;\n}\n.og-radio-group--row {\n flex-direction: row;\n flex-wrap: wrap;\n gap: 1rem;\n}\n"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "dialog-react",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "dialog (React)",
|
|
6
|
+
"description": "React component(s) from @og-ui/react's overlays.tsx, copied into your project.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@og-ui/core"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"https://ui.ogom.in/r/dialog.json"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "components/og/overlays.tsx",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "components/og/overlays.tsx",
|
|
18
|
+
"content": "import {\n cloneElement,\n forwardRef,\n useEffect,\n useId,\n useRef,\n type ComponentPropsWithoutRef,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { cx, useOgUI } from './util.js';\n\nfunction mergeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n return (el: T | null) => {\n for (const ref of refs) {\n if (typeof ref === 'function') ref(el);\n else if (ref) (ref as { current: T | null }).current = el;\n }\n };\n}\n\n// ---------------------------------------------------------------------------\n// Dialog and drawer\n\nexport interface DialogProps extends Omit<ComponentPropsWithoutRef<'dialog'>, 'title' | 'open'> {\n open: boolean;\n /** Called with false when Esc, the close button, a [data-og-close] button or the backdrop closes it. */\n onOpenChange?: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n /** Render as a drawer from the right, or from the left / bottom. */\n drawer?: boolean | 'left' | 'bottom';\n /** aria-label for the close button. */\n closeLabel?: string;\n}\n\n/**\n * A modal <dialog>: the browser traps focus, handles Esc and returns focus to the trigger.\n * Buttons inside with data-og-close close it; data-og-close=\"value\" sets returnValue.\n */\nexport const Dialog = forwardRef<HTMLDialogElement, DialogProps>(function Dialog(\n { open, onOpenChange, title, description, footer, drawer, closeLabel = 'Close', className, children, onClose, ...props },\n ref,\n) {\n useOgUI();\n const inner = useRef<HTMLDialogElement>(null);\n const titleId = useId();\n const descId = useId();\n\n useEffect(() => {\n const el = inner.current;\n if (!el || el.open === open) return;\n if (open) el.showModal();\n else el.close();\n }, [open]);\n\n return (\n <dialog\n ref={mergeRefs(ref, inner)}\n aria-labelledby={titleId}\n aria-describedby={description ? descId : undefined}\n className={cx(\n 'og-dialog',\n drawer && 'og-drawer',\n typeof drawer === 'string' && `og-drawer--${drawer}`,\n className,\n )}\n onClose={(e) => {\n onClose?.(e);\n onOpenChange?.(false);\n }}\n {...props}\n >\n <header className=\"og-dialog__header\">\n <div>\n <h2 className=\"og-dialog__title\" id={titleId}>\n {title}\n </h2>\n {description && (\n <p className=\"og-dialog__description\" id={descId}>\n {description}\n </p>\n )}\n </div>\n <button type=\"button\" className=\"og-dialog__close\" data-og-close=\"\" aria-label={closeLabel} />\n </header>\n <div className=\"og-dialog__body\">{children}</div>\n {footer && <footer className=\"og-dialog__footer\">{footer}</footer>}\n </dialog>\n );\n});\n\n// ---------------------------------------------------------------------------\n// Popover and menu (native popover API: light dismiss, Esc, top layer, focus return)\n\ntype Trigger = ReactElement<{ popoverTarget?: string; 'aria-haspopup'?: 'menu' }>;\n\nexport interface PopoverProps extends ComponentPropsWithoutRef<'div'> {\n /** The button that opens it, e.g. <Button>Share</Button>. */\n trigger: Trigger;\n}\n\nexport const Popover = forwardRef<HTMLDivElement, PopoverProps>(function Popover(\n { trigger, className, id, ...props },\n ref,\n) {\n useOgUI();\n const autoId = useId();\n const popId = id ?? autoId;\n return (\n <>\n {cloneElement(trigger, { popoverTarget: popId })}\n <div ref={ref} popover=\"auto\" id={popId} className={cx('og-popover', className)} {...props} />\n </>\n );\n});\n\nexport interface MenuProps extends ComponentPropsWithoutRef<'div'> {\n trigger: Trigger;\n /** Accessible name of the menu, e.g. \"Project actions\". */\n label: string;\n}\n\n/** og-ui.js focuses the first item and adds arrow keys, Home/End and close-on-choice. */\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n { trigger, label, className, id, ...props },\n ref,\n) {\n useOgUI();\n const autoId = useId();\n const menuId = id ?? autoId;\n return (\n <>\n {cloneElement(trigger, { popoverTarget: menuId, 'aria-haspopup': 'menu' })}\n <div\n ref={ref}\n popover=\"auto\"\n id={menuId}\n role=\"menu\"\n aria-label={label}\n className={cx('og-popover og-menu', className)}\n {...props}\n />\n </>\n );\n});\n\nexport interface MenuItemProps extends ComponentPropsWithoutRef<'button'> {\n danger?: boolean;\n}\n\nexport const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(\n { danger, className, type = 'button', ...props },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n role=\"menuitem\"\n className={cx('og-menu__item', danger && 'og-menu__item--danger', className)}\n {...props}\n />\n );\n});\n\nexport const MenuSeparator = () => <hr className=\"og-menu__separator\" />;\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "components/og/util.ts",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "components/og/util.ts",
|
|
24
|
+
"content": "import { useEffect } from 'react';\nimport { initOgUI } from '@og-ui/core/og-ui.js';\n\n/** Join class names, skipping falsy ones. */\nexport const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(' ');\n\n/**\n * Start og-ui.js (keyboard for menus and tabs, slider fill, popover placement, toasts).\n * Safe to call from every component: it only wires the document once, and only in the browser.\n */\nexport function useOgUI() {\n useEffect(() => initOgUI(), []);\n}\n\n/** Pages to show, with gaps: 1 … 4 5 [6] 7 8 … 20 */\nexport function pageList(page: number, count: number, siblings = 1): (number | 'gap')[] {\n const out: (number | 'gap')[] = [1];\n const from = Math.max(2, page - siblings);\n const to = Math.min(count - 1, page + siblings);\n if (from > 2) out.push('gap');\n for (let p = from; p <= to; p++) out.push(p);\n if (to < count - 1) out.push('gap');\n if (count > 1) out.push(count);\n return out;\n}\n"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "components/og/og-ui.d.ts",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "components/og/og-ui.d.ts",
|
|
30
|
+
"content": "declare module '@og-ui/core/og-ui.js' {\n export function initOgUI(root?: Document | Element): void;\n export function ogToast(\n title: string,\n options?: {\n description?: string;\n variant?: 'success' | 'warning' | 'danger' | 'accent';\n duration?: number;\n },\n ): () => void;\n}\n"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "dialog",
|
|
4
|
+
"type": "registry:component",
|
|
5
|
+
"title": "Dialog and drawer",
|
|
6
|
+
"description": "Modal <dialog>: the browser traps focus, handles Esc and returns focus to the trigger. Drawers slide from an edge.",
|
|
7
|
+
"meta": {
|
|
8
|
+
"classes": [
|
|
9
|
+
"og-dialog",
|
|
10
|
+
"og-dialog__header",
|
|
11
|
+
"og-dialog__title",
|
|
12
|
+
"og-dialog__description",
|
|
13
|
+
"og-dialog__body",
|
|
14
|
+
"og-dialog__footer",
|
|
15
|
+
"og-dialog__close",
|
|
16
|
+
"og-drawer",
|
|
17
|
+
"og-drawer--left",
|
|
18
|
+
"og-drawer--bottom"
|
|
19
|
+
],
|
|
20
|
+
"group": "Overlays",
|
|
21
|
+
"markup": [
|
|
22
|
+
{
|
|
23
|
+
"label": "Dialog",
|
|
24
|
+
"html": "<button class=\"og-button og-button--danger\" data-og-open=\"dialog\">Delete project</button>\n<dialog class=\"og-dialog\" id=\"dialog\" aria-labelledby=\"dialog-t\">\n <header class=\"og-dialog__header\">\n <div>\n <h2 class=\"og-dialog__title\" id=\"dialog-t\">Delete project?</h2>\n <p class=\"og-dialog__description\">This removes all 24 files. You can’t undo it.</p>\n </div>\n <button class=\"og-dialog__close\" data-og-close aria-label=\"Close\"></button>\n </header>\n <footer class=\"og-dialog__footer\">\n <button class=\"og-button og-button--ghost\" data-og-close>Cancel</button>\n <button class=\"og-button og-button--danger\" data-og-close=\"delete\">Delete</button>\n </footer>\n</dialog>"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "Drawer",
|
|
28
|
+
"html": "<button class=\"og-button\" data-og-open=\"dialog\">Filters</button>\n<dialog class=\"og-dialog og-drawer\" id=\"dialog\" aria-labelledby=\"dialog-t\">\n <header class=\"og-dialog__header\">\n <h2 class=\"og-dialog__title\" id=\"dialog-t\">Filters</h2>\n <button class=\"og-dialog__close\" data-og-close aria-label=\"Close\"></button>\n </header>\n <div class=\"og-dialog__body\">\n <label class=\"og-check\"><input type=\"checkbox\" class=\"og-checkbox\" checked /> Paid</label>\n <label class=\"og-check\"><input type=\"checkbox\" class=\"og-checkbox\" /> Overdue</label>\n </div>\n</dialog>"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"react": "import { Dialog, Button } from '@og-ui/react';\n\nconst [open, setOpen] = useState(false);\n\n<Button onClick={() => setOpen(true)}>Delete project</Button>\n<Dialog\n open={open}\n onOpenChange={setOpen}\n title=\"Delete project?\"\n description=\"This removes all 24 files.\"\n footer={<Button variant=\"danger\" data-og-close=\"delete\">Delete</Button>}\n/>\n// Drawer: <Dialog drawer=\"left\" …>",
|
|
32
|
+
"keyboard": [
|
|
33
|
+
"Opening moves focus into the dialog (first focusable control).",
|
|
34
|
+
"Tab stays inside; the page behind is inert.",
|
|
35
|
+
"Esc closes; focus returns to the button that opened it.",
|
|
36
|
+
"Buttons with data-og-close close it; clicking the backdrop closes it."
|
|
37
|
+
],
|
|
38
|
+
"notes": [
|
|
39
|
+
"For destructive dialogs consider autofocus on Cancel."
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"registryDependencies": [
|
|
43
|
+
"https://ui.ogom.in/r/og-ui.json"
|
|
44
|
+
],
|
|
45
|
+
"files": [
|
|
46
|
+
{
|
|
47
|
+
"path": "og-ui/components/dialog.css",
|
|
48
|
+
"type": "registry:file",
|
|
49
|
+
"target": "og-ui/components/dialog.css",
|
|
50
|
+
"content": "/*! OG UI dialog | MIT | https://ui.ogom.in */\n.og-dialog {\n background: var(--og-surface-overlay-fill);\n border: var(--og-border-width) solid var(--og-surface-overlay-border);\n box-shadow: var(--og-surface-overlay-shadow);\n -webkit-backdrop-filter: var(--og-surface-overlay-filter);\n backdrop-filter: var(--og-surface-overlay-filter);\n width: min(32rem, 100vw - 2rem);\n max-height: calc(100dvh - 2rem);\n padding: 0;\n border-radius: var(--og-radius-lg);\n color: var(--og-color-text);\n font-family: var(--og-font);\n overflow: auto;\n transition: opacity var(--og-motion-duration) var(--og-easing), transform var(--og-motion-duration) var(--og-easing), overlay var(--og-motion-duration) allow-discrete, display var(--og-motion-duration) allow-discrete;\n opacity: 0;\n transform: translateY(4px) scale(0.98);\n}\n.og-dialog:popover-open, .og-dialog[open] {\n opacity: 1;\n transform: none;\n}\n@starting-style {\n .og-dialog:popover-open, .og-dialog[open] {\n opacity: 0;\n transform: translateY(4px) scale(0.98);\n }\n}\n.og-dialog::backdrop {\n background: color-mix(in oklab, var(--og-color-bg) 35%, rgba(0, 0, 0, 0.45));\n transition: opacity var(--og-motion-duration) var(--og-easing), overlay var(--og-motion-duration) allow-discrete, display var(--og-motion-duration) allow-discrete;\n opacity: 0;\n}\n.og-dialog[open]::backdrop {\n opacity: 1;\n}\n@starting-style {\n .og-dialog[open]::backdrop {\n opacity: 0;\n }\n}\n.og-dialog::before {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: var(--og-surface-overlay-highlight);\n pointer-events: none;\n}\n.og-dialog > * {\n position: relative;\n}\n.og-dialog__header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 1rem;\n padding: var(--og-card-pad) var(--og-card-pad) 0;\n}\n.og-dialog__title {\n margin: 0;\n font-family: var(--og-font-display);\n font-size: 1.125rem;\n font-weight: var(--og-font-weight-strong);\n}\n.og-dialog__description {\n margin: 0.25rem 0 0;\n color: var(--og-color-text-muted);\n font-size: 0.875rem;\n}\n.og-dialog__body {\n padding: var(--og-gap) var(--og-card-pad);\n font-size: 0.875rem;\n line-height: 1.6;\n}\n.og-dialog__footer {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 0.5rem;\n padding: 0 var(--og-card-pad) var(--og-card-pad);\n}\n.og-dialog__close {\n display: inline-grid;\n place-items: center;\n flex: none;\n width: 2rem;\n height: 2rem;\n border: 0;\n border-radius: var(--og-radius-sm);\n background: transparent;\n color: var(--og-color-text-muted);\n cursor: pointer;\n}\n.og-dialog__close::after {\n content: \"\";\n display: inline-block;\n width: 1rem;\n height: 1rem;\n background: currentColor;\n -webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E\") center/contain no-repeat;\n}\n.og-dialog__close:hover {\n background: color-mix(in oklab, var(--og-color-text) 8%, transparent);\n color: var(--og-color-text);\n}\n.og-dialog__close:focus-visible {\n outline: 2px solid var(--og-color-focus-ring);\n outline-offset: 2px;\n}\n\n.og-drawer {\n width: min(24rem, 100vw);\n max-width: 100vw;\n height: 100dvh;\n max-height: 100dvh;\n margin: 0 0 0 auto;\n border-radius: var(--og-radius-lg) 0 0 var(--og-radius-lg);\n transition: opacity var(--og-motion-duration) var(--og-easing), transform var(--og-motion-duration) var(--og-easing), overlay var(--og-motion-duration) allow-discrete, display var(--og-motion-duration) allow-discrete;\n opacity: 0;\n transform: translateX(100%);\n}\n.og-drawer:popover-open, .og-drawer[open] {\n opacity: 1;\n transform: none;\n}\n@starting-style {\n .og-drawer:popover-open, .og-drawer[open] {\n opacity: 0;\n transform: translateX(100%);\n }\n}\n.og-drawer--left {\n margin: 0 auto 0 0;\n border-radius: 0 var(--og-radius-lg) var(--og-radius-lg) 0;\n transition: opacity var(--og-motion-duration) var(--og-easing), transform var(--og-motion-duration) var(--og-easing), overlay var(--og-motion-duration) allow-discrete, display var(--og-motion-duration) allow-discrete;\n opacity: 0;\n transform: translateX(-100%);\n}\n.og-drawer--left:popover-open, .og-drawer--left[open] {\n opacity: 1;\n transform: none;\n}\n@starting-style {\n .og-drawer--left:popover-open, .og-drawer--left[open] {\n opacity: 0;\n transform: translateX(-100%);\n }\n}\n.og-drawer--bottom {\n width: 100vw;\n height: auto;\n max-height: 85dvh;\n margin: auto 0 0;\n border-radius: var(--og-radius-lg) var(--og-radius-lg) 0 0;\n transition: opacity var(--og-motion-duration) var(--og-easing), transform var(--og-motion-duration) var(--og-easing), overlay var(--og-motion-duration) allow-discrete, display var(--og-motion-duration) allow-discrete;\n opacity: 0;\n transform: translateY(100%);\n}\n.og-drawer--bottom:popover-open, .og-drawer--bottom[open] {\n opacity: 1;\n transform: none;\n}\n@starting-style {\n .og-drawer--bottom:popover-open, .og-drawer--bottom[open] {\n opacity: 0;\n transform: translateY(100%);\n }\n}\n"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|