menhir 0.1.3 → 0.1.4
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 +6 -0
- package/README.md +8 -1
- package/dist/core/createControllableSignal.js +11 -2
- package/dist/core/listValue.js +2 -7
- package/dist/floating/dismissal/escape.js +2 -1
- package/dist/floating/list-navigation/activeDescendant.js +29 -0
- package/dist/floating/list-navigation/listNavigation.js +108 -0
- package/dist/floating/list-navigation/roving.js +27 -0
- package/dist/floating/typeahead/match.js +24 -0
- package/dist/floating/typeahead/typeahead.js +56 -0
- package/dist/navigation-menu/index.js +2 -0
- package/dist/navigation-menu/index.parts.js +6 -0
- package/dist/navigation-menu/item/NavigationMenuItem.js +83 -0
- package/dist/navigation-menu/item/NavigationMenuItemContext.js +10 -0
- package/dist/navigation-menu/link/NavigationMenuLink.js +26 -0
- package/dist/navigation-menu/panel/NavigationMenuPanel.js +31 -0
- package/dist/navigation-menu/root/NavigationMenuRoot.js +100 -0
- package/dist/navigation-menu/root/NavigationMenuRootContext.js +10 -0
- package/dist/navigation-menu/trigger/NavigationMenuTrigger.js +36 -0
- package/dist/source/core/createControllableSignal.d.ts +9 -1
- package/dist/source/core/createControllableSignal.js +7 -2
- package/dist/source/core/listValue.js +4 -10
- package/dist/source/floating/dismissal/escape.d.ts +2 -1
- package/dist/source/floating/dismissal/escape.js +2 -1
- package/dist/source/floating/dismissal/reason.d.ts +5 -1
- package/dist/source/floating/list-navigation/activeDescendant.d.ts +30 -0
- package/dist/source/floating/list-navigation/activeDescendant.js +24 -0
- package/dist/source/floating/list-navigation/listNavigation.d.ts +68 -0
- package/dist/source/floating/list-navigation/listNavigation.js +148 -0
- package/dist/source/floating/list-navigation/roving.d.ts +23 -0
- package/dist/source/floating/list-navigation/roving.js +25 -0
- package/dist/source/floating/typeahead/match.d.ts +14 -0
- package/dist/source/floating/typeahead/match.js +32 -0
- package/dist/source/floating/typeahead/typeahead.d.ts +41 -0
- package/dist/source/floating/typeahead/typeahead.js +81 -0
- package/dist/source/navigation-menu/index.d.ts +1 -0
- package/dist/source/navigation-menu/index.js +1 -0
- package/dist/source/navigation-menu/index.parts.d.ts +5 -0
- package/dist/source/navigation-menu/index.parts.js +5 -0
- package/dist/source/navigation-menu/item/NavigationMenuItem.d.ts +16 -0
- package/dist/source/navigation-menu/item/NavigationMenuItem.jsx +85 -0
- package/dist/source/navigation-menu/item/NavigationMenuItemContext.d.ts +27 -0
- package/dist/source/navigation-menu/item/NavigationMenuItemContext.js +12 -0
- package/dist/source/navigation-menu/link/NavigationMenuLink.d.ts +12 -0
- package/dist/source/navigation-menu/link/NavigationMenuLink.jsx +18 -0
- package/dist/source/navigation-menu/panel/NavigationMenuPanel.d.ts +11 -0
- package/dist/source/navigation-menu/panel/NavigationMenuPanel.jsx +26 -0
- package/dist/source/navigation-menu/root/NavigationMenuRoot.d.ts +37 -0
- package/dist/source/navigation-menu/root/NavigationMenuRoot.jsx +103 -0
- package/dist/source/navigation-menu/root/NavigationMenuRootContext.d.ts +33 -0
- package/dist/source/navigation-menu/root/NavigationMenuRootContext.js +13 -0
- package/dist/source/navigation-menu/trigger/NavigationMenuTrigger.d.ts +12 -0
- package/dist/source/navigation-menu/trigger/NavigationMenuTrigger.jsx +32 -0
- package/package.json +8 -2
- package/skills/menhir-styling/SKILL.md +35 -0
- package/skills/menhir-styling/looks/shadcn/LICENSE +24 -0
- package/skills/menhir-styling/looks/shadcn/LOOK.md +106 -0
- package/skills/menhir-styling/looks/shadcn/dialog.md +63 -0
- package/skills/menhir-styling/looks/shadcn/popover.md +39 -0
- package/skills/menhir-styling/looks/shadcn/switch.md +26 -0
- package/skills/menhir-styling/looks/shadcn/tabs.md +62 -0
- package/skills/menhir-styling/looks/shadcn/tokens.css +80 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!-- Generated by website/styling-skill.ts from website/src/looks/shadcn/LOOK.md. Edit that file, then run `pnpm --filter website skill`. -->
|
|
2
|
+
|
|
3
|
+
# The shadcn look
|
|
4
|
+
|
|
5
|
+
The look of shadcn/ui's default theme (neutral, "new-york"), in Tailwind CSS v4. Its class strings follow shadcn/ui's components, rewritten for Menhir's parts and data attributes. The licence notice is in `LICENSE`, beside this file.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Once per app. Check before adding: the app may already have it.
|
|
10
|
+
|
|
11
|
+
1. Copy `tokens.css` beside the app's main stylesheet and import it there, after Tailwind:
|
|
12
|
+
|
|
13
|
+
```css
|
|
14
|
+
@import "tailwindcss";
|
|
15
|
+
@import "./tokens.css";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Put `data-look="shadcn"` on `<html>`, and `class="bg-background text-foreground"` on `<body>`. The tokens apply inside the element that has the attribute, so a page can also take the look in one part only.
|
|
19
|
+
3. Light and dark follow the CSS `color-scheme`: the tokens use `light-dark()`. The `dark:` classes in the examples need Tailwind's `dark` variant on the same condition. With Menhir's color-scheme utility, which sets `data-color-scheme` on `<html>`:
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
@custom-variant dark (&:where([data-color-scheme="dark"], [data-color-scheme="dark"] *));
|
|
23
|
+
|
|
24
|
+
:root[data-color-scheme="dark"] {
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Without the utility, `:root { color-scheme: light dark; }` follows the system, and the `dark` variant stays Tailwind's default, `prefers-color-scheme`. Use the first when the app already has the utility, and the second otherwise.
|
|
30
|
+
|
|
31
|
+
## Tokens
|
|
32
|
+
|
|
33
|
+
Use these through Tailwind classes (`bg-primary`, `text-muted-foreground`, `border-input`, `ring-ring/50`), never as raw colours. Two colours are not tokens, as in shadcn/ui, and are used only where their recipe says: black at 50% behind a dialog (`backdrop:bg-black/50`), and white text on `destructive` (`text-white`).
|
|
34
|
+
|
|
35
|
+
| Token | For |
|
|
36
|
+
| ----------------------------------- | ---------------------------------------------------------------------------------- |
|
|
37
|
+
| `background`, `foreground` | The page, and a surface that sits on it, such as a dialog |
|
|
38
|
+
| `card`, `card-foreground` | A raised box in the page, such as a tab panel |
|
|
39
|
+
| `popover`, `popover-foreground` | A positioned popup: popover, tooltip, menu |
|
|
40
|
+
| `primary`, `primary-foreground` | The main action, and the on state: a checked switch |
|
|
41
|
+
| `secondary`, `secondary-foreground` | A second action |
|
|
42
|
+
| `muted`, `muted-foreground` | A quiet background (a tab list), and secondary text |
|
|
43
|
+
| `accent`, `accent-foreground` | Hover on an outline or ghost control, a highlighted item |
|
|
44
|
+
| `destructive` | An action that deletes, and invalid fields |
|
|
45
|
+
| `border`, `input` | Borders: `border` for surfaces (the default), `input` for fields and the off state |
|
|
46
|
+
| `ring` | Focus: `ring-ring/50`, and the focused field's border |
|
|
47
|
+
|
|
48
|
+
Spacing and shadows are Tailwind's own scales (`p-6`, `gap-2`, `shadow-xs` to `shadow-lg`), which the look leaves as they are, as shadcn/ui does; the recipes say which step each part takes, so do not add spacing or shadow tokens.
|
|
49
|
+
|
|
50
|
+
Radii come from `--radius`: `rounded-md` (0.5rem) for controls, `rounded-lg` for a dialog and a tab list, `rounded-xl` for a card, `rounded-full` for a switch.
|
|
51
|
+
|
|
52
|
+
## Recipes
|
|
53
|
+
|
|
54
|
+
Every component in the look is built from these. Extend them for a component without a worked example.
|
|
55
|
+
|
|
56
|
+
- **Focus**: `outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50` on every focusable part, including a tab panel. Buttons aside, a part without a border of its own, such as a tab or an accordion's Trigger, also gets `border border-transparent`, for the focused border to colour.
|
|
57
|
+
- **Disabled**: `data-disabled:pointer-events-none data-disabled:opacity-50` on a part that has `data-disabled` (form controls, tabs, toggles, accordion items: see the component's page); `disabled:pointer-events-none disabled:opacity-50` on a plain button, such as a popup's Trigger or Close.
|
|
58
|
+
- **Controls** are `h-9` with `text-sm font-medium`. A small one is `h-8`.
|
|
59
|
+
- **Buttons**, all `inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium whitespace-nowrap transition-all motion-reduce:transition-none` plus the focus and disabled recipes. A popup's Trigger and a Cancel are outline, the main action is primary, and the button that carries out a deletion is destructive; a Trigger that only opens the confirmation stays outline:
|
|
60
|
+
- primary: `bg-primary text-primary-foreground hover:bg-primary/90`
|
|
61
|
+
- outline: `border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`
|
|
62
|
+
- secondary: `bg-secondary text-secondary-foreground hover:bg-secondary/80`
|
|
63
|
+
- ghost: `hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`
|
|
64
|
+
- destructive: `bg-destructive text-white hover:bg-destructive/90 dark:bg-destructive/60`
|
|
65
|
+
- **Fields**: `h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] motion-reduce:transition-none md:text-sm dark:bg-input/30 placeholder:text-muted-foreground`, plus focus.
|
|
66
|
+
- **On and off** (switch, checkbox): on is `data-checked:bg-primary` with `text-primary-foreground` inside; off is `data-unchecked:bg-input` or `border-input`. A checkbox's partly checked state, `data-indeterminate:`, takes the on classes.
|
|
67
|
+
- **Tracks** (switch): `inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all`, with the on and off classes and `dark:data-unchecked:bg-input/80`, plus the focus and disabled recipes. The thumb is `pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-checked:translate-x-[calc(100%-2px)] data-unchecked:translate-x-0 dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground`.
|
|
68
|
+
- **Boxes** (checkbox): `size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow dark:bg-input/30`; on, and the same for `data-indeterminate:`: `data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary` (the `dark:` one keeps `dark:bg-input/30` from covering the fill). Plus the focus and disabled recipes. The Indicator is `group flex items-center justify-center data-unchecked:hidden` and holds two icons, `size-3.5`: a check with `group-data-indeterminate:hidden` and a dash with `hidden group-data-indeterminate:block`.
|
|
69
|
+
- **Pressed** (toggle, toggle group item): `inline-flex h-9 min-w-9 items-center justify-center gap-2 rounded-md px-2 text-sm font-medium transition-[color,box-shadow] hover:bg-muted hover:text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground`, plus focus and disabled.
|
|
70
|
+
- **Selected** (tab): `data-selected:bg-background data-selected:text-foreground data-selected:shadow-sm`, and in dark `dark:data-selected:border-input dark:data-selected:bg-input/30 dark:data-selected:text-foreground`, on a `rounded-lg bg-muted p-[3px] text-muted-foreground` track. A tab that is not selected is `border border-transparent text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground`.
|
|
71
|
+
- **Disclosures** (accordion, collapsible): an accordion's Root is `w-full`, as wide as what holds it; its Item is `border-b last:border-b-0`, and its Header `m-0 flex`. The Trigger is `group flex flex-1 items-start justify-between gap-4 rounded-md border border-transparent px-2 py-4 text-left text-sm font-medium transition-all motion-reduce:transition-none hover:underline`, plus the focus and disabled recipes, and ends with the chevron down icon: `pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none group-data-open:rotate-180`. The Panel is `text-sm`, around an inner `<div class="px-2 pt-1 pb-4">`, which lines its text up with the Trigger's and keeps it clear of the Trigger's focus ring, as the Trigger's own padding does for its text: the Panel is hidden while closed, so it takes no `display` or spacing class, and it is not animated.
|
|
72
|
+
- **Icons** are inline SVG: `viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"`, `size-4` unless a recipe says otherwise. Paths: check `M4 12l5 5L20 6`, dash `M5 12h14`, close `M18 6 6 18M6 6l12 12`, chevron down `m6 9 6 6 6-6`. A button with only an icon gets its name from `<span class="sr-only">`.
|
|
73
|
+
- **Corner close** (the icon button in a dialog's corner): `absolute top-4 right-4 rounded-xs opacity-70 transition-opacity outline-none hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50`.
|
|
74
|
+
- **Surfaces**: a dialog is `rounded-lg border bg-background p-6 shadow-lg` with `backdrop:bg-black/50`, a positioned popup `rounded-md border bg-popover p-4 text-popover-foreground shadow-md`, a card `rounded-xl border bg-card p-6 text-card-foreground shadow-sm`.
|
|
75
|
+
- **Text**: titles `font-semibold` (dialog, `text-lg leading-none`) or `font-medium` (popover); descriptions `text-sm text-muted-foreground`.
|
|
76
|
+
- **Motion**: popups fade and grow from 95%: `transition-[opacity,scale] data-closed:scale-95 data-closed:opacity-0 starting:data-open:scale-95 starting:data-open:opacity-0`, 150ms for a positioned popup and 200ms for a dialog. A dialog's backdrop fades with it: `backdrop:transition-opacity backdrop:duration-200 data-closed:backdrop:opacity-0 starting:data-open:backdrop:opacity-0`. Every `transition-*` gets `motion-reduce:transition-none`.
|
|
77
|
+
|
|
78
|
+
## From shadcn/ui's source
|
|
79
|
+
|
|
80
|
+
shadcn/ui's own components use other attribute, variable and part names. What each becomes in Menhir:
|
|
81
|
+
|
|
82
|
+
| shadcn/ui | Menhir |
|
|
83
|
+
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
84
|
+
| `data-[state=checked]`, `data-[state=unchecked]` | `data-checked:`, `data-unchecked:` |
|
|
85
|
+
| `data-[state=open]`, `data-[state=closed]` | `data-open:`, `data-closed:` |
|
|
86
|
+
| `data-[state=active]` on a tab | `data-selected:` |
|
|
87
|
+
| `data-[orientation=vertical]`, `data-[disabled]` | `data-vertical:`, `data-disabled:` |
|
|
88
|
+
| `animate-in fade-in-0 zoom-in-95` | a transition, with `starting:data-open:opacity-0 starting:data-open:scale-95` |
|
|
89
|
+
| `animate-out fade-out-0 zoom-out-95` | `data-closed:opacity-0 data-closed:scale-95`: Menhir keeps the popup shown until its transition ends |
|
|
90
|
+
| `DialogOverlay` with `bg-black/50` | `backdrop:bg-black/50` on the Dialog's Popup: the backdrop is the browser's `::backdrop` |
|
|
91
|
+
| `fixed top-[50%] left-[50%] translate-…` on `DialogContent` | `m-auto`: a modal `<dialog>` centres itself |
|
|
92
|
+
| `grid` or `flex` on `DialogContent` or `PopoverContent` | an inner `<div>`: a `display` class on the Popup overrides the browser's `display: none` and shows it while closed |
|
|
93
|
+
| `[&[data-state=open]>svg]:rotate-180` | `group` on the Trigger, `group-data-open:rotate-180` on the icon |
|
|
94
|
+
| `animate-accordion-down`, `animate-accordion-up` | nothing: a Panel is hidden while closed, and is not animated |
|
|
95
|
+
| `Portal`, `z-50` | nothing: popups are in the top layer |
|
|
96
|
+
| `--radix-popover-content-transform-origin` | `--transform-origin` |
|
|
97
|
+
| `--radix-popover-trigger-width` | `--anchor-width` |
|
|
98
|
+
| `asChild` | the part's `render` prop |
|
|
99
|
+
| `cn()`, `cva()` variants, `data-slot` | plain class strings |
|
|
100
|
+
|
|
101
|
+
## Worked examples
|
|
102
|
+
|
|
103
|
+
- [Dialog](dialog.md)
|
|
104
|
+
- [Popover](popover.md)
|
|
105
|
+
- [Switch](switch.md)
|
|
106
|
+
- [Tabs](tabs.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!-- Generated by website/styling-skill.ts from website/src/examples/dialog/shadcn/. Edit those files, then run `pnpm --filter website skill`. -->
|
|
2
|
+
|
|
3
|
+
# Dialog in the shadcn look
|
|
4
|
+
|
|
5
|
+
Its parts, props and data attributes: [Dialog](https://menhir-ui.com/docs/components/dialog.md).
|
|
6
|
+
|
|
7
|
+
## DialogExample.tsx
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Dialog } from "menhir/dialog";
|
|
11
|
+
|
|
12
|
+
export default function DialogExample() {
|
|
13
|
+
return (
|
|
14
|
+
<Dialog.Root>
|
|
15
|
+
<Dialog.Trigger class="inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 text-sm font-medium whitespace-nowrap shadow-xs transition-all outline-none hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:border-input dark:bg-input/30 dark:hover:bg-input/50 motion-reduce:transition-none">
|
|
16
|
+
Edit profile
|
|
17
|
+
</Dialog.Trigger>
|
|
18
|
+
<Dialog.Popup class="m-auto w-full max-w-[calc(100%-2rem)] rounded-lg border bg-background p-6 text-foreground shadow-lg transition-[opacity,scale] duration-200 outline-none backdrop:bg-black/50 backdrop:transition-opacity backdrop:duration-200 data-closed:scale-95 data-closed:opacity-0 data-closed:backdrop:opacity-0 motion-reduce:transition-none sm:max-w-lg starting:data-open:scale-95 starting:data-open:opacity-0 starting:data-open:backdrop:opacity-0">
|
|
19
|
+
<div class="grid gap-4">
|
|
20
|
+
<div class="flex flex-col gap-2 text-center sm:text-left">
|
|
21
|
+
<Dialog.Title class="m-0 text-lg leading-none font-semibold">
|
|
22
|
+
Edit profile
|
|
23
|
+
</Dialog.Title>
|
|
24
|
+
<Dialog.Description class="m-0 text-sm text-muted-foreground">
|
|
25
|
+
Your name is shown on your posts.
|
|
26
|
+
</Dialog.Description>
|
|
27
|
+
</div>
|
|
28
|
+
<label class="grid gap-3 text-sm leading-none font-medium">
|
|
29
|
+
Name
|
|
30
|
+
<input
|
|
31
|
+
name="name"
|
|
32
|
+
value="Ada Lovelace"
|
|
33
|
+
class="h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base font-normal shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:text-sm dark:bg-input/30 motion-reduce:transition-none"
|
|
34
|
+
/>
|
|
35
|
+
</label>
|
|
36
|
+
<div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
37
|
+
<Dialog.Close class="inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium whitespace-nowrap text-primary-foreground transition-all outline-none hover:bg-primary/90 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none">
|
|
38
|
+
Done
|
|
39
|
+
</Dialog.Close>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
{/* Last, so that opening focuses the field. A modal <dialog> is
|
|
43
|
+
position: fixed, which positions the button against it. */}
|
|
44
|
+
<Dialog.Close class="absolute top-4 right-4 rounded-xs opacity-70 transition-opacity outline-none hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 motion-reduce:transition-none">
|
|
45
|
+
<svg
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
viewBox="0 0 24 24"
|
|
48
|
+
fill="none"
|
|
49
|
+
stroke="currentColor"
|
|
50
|
+
stroke-width="2"
|
|
51
|
+
stroke-linecap="round"
|
|
52
|
+
stroke-linejoin="round"
|
|
53
|
+
class="block size-4"
|
|
54
|
+
>
|
|
55
|
+
<path d="M18 6 6 18M6 6l12 12" />
|
|
56
|
+
</svg>
|
|
57
|
+
<span class="sr-only">Close</span>
|
|
58
|
+
</Dialog.Close>
|
|
59
|
+
</Dialog.Popup>
|
|
60
|
+
</Dialog.Root>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!-- Generated by website/styling-skill.ts from website/src/examples/popover/shadcn/. Edit those files, then run `pnpm --filter website skill`. -->
|
|
2
|
+
|
|
3
|
+
# Popover in the shadcn look
|
|
4
|
+
|
|
5
|
+
Its parts, props and data attributes: [Popover](https://menhir-ui.com/docs/components/popover.md).
|
|
6
|
+
|
|
7
|
+
## PopoverExample.tsx
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Popover } from "menhir/popover";
|
|
11
|
+
|
|
12
|
+
export default function PopoverExample() {
|
|
13
|
+
return (
|
|
14
|
+
<Popover.Root>
|
|
15
|
+
<Popover.Trigger class="inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 text-sm font-medium whitespace-nowrap shadow-xs transition-all outline-none hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:border-input dark:bg-input/30 dark:hover:bg-input/50 motion-reduce:transition-none">
|
|
16
|
+
Notifications
|
|
17
|
+
</Popover.Trigger>
|
|
18
|
+
<Popover.Popup
|
|
19
|
+
sideOffset={4}
|
|
20
|
+
class="w-72 origin-(--transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md transition-[opacity,scale] duration-150 outline-hidden data-closed:scale-95 data-closed:opacity-0 motion-reduce:transition-none starting:data-open:scale-95 starting:data-open:opacity-0"
|
|
21
|
+
>
|
|
22
|
+
<div class="flex flex-col gap-1 text-sm">
|
|
23
|
+
<Popover.Title class="m-0 text-sm font-medium">
|
|
24
|
+
Notifications
|
|
25
|
+
</Popover.Title>
|
|
26
|
+
<Popover.Description class="m-0 text-muted-foreground">
|
|
27
|
+
You are all caught up.
|
|
28
|
+
</Popover.Description>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="mt-4 flex justify-end">
|
|
31
|
+
<Popover.Close class="inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border bg-background px-3 text-sm font-medium whitespace-nowrap shadow-xs transition-all outline-none hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:border-input dark:bg-input/30 dark:hover:bg-input/50 motion-reduce:transition-none">
|
|
32
|
+
Close
|
|
33
|
+
</Popover.Close>
|
|
34
|
+
</div>
|
|
35
|
+
</Popover.Popup>
|
|
36
|
+
</Popover.Root>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Generated by website/styling-skill.ts from website/src/examples/switch/shadcn/. Edit those files, then run `pnpm --filter website skill`. -->
|
|
2
|
+
|
|
3
|
+
# Switch in the shadcn look
|
|
4
|
+
|
|
5
|
+
Its parts, props and data attributes: [Switch](https://menhir-ui.com/docs/components/switch.md).
|
|
6
|
+
|
|
7
|
+
## SwitchExample.tsx
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Switch } from "menhir/switch";
|
|
11
|
+
|
|
12
|
+
export default function SwitchExample() {
|
|
13
|
+
return (
|
|
14
|
+
<label class="flex items-center gap-2 text-sm leading-none font-medium select-none">
|
|
15
|
+
<Switch.Root
|
|
16
|
+
name="wifi"
|
|
17
|
+
defaultChecked
|
|
18
|
+
class="inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 data-checked:bg-primary data-disabled:pointer-events-none data-disabled:opacity-50 data-unchecked:bg-input motion-reduce:transition-none dark:data-unchecked:bg-input/80"
|
|
19
|
+
>
|
|
20
|
+
<Switch.Thumb class="pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-checked:translate-x-[calc(100%-2px)] data-unchecked:translate-x-0 motion-reduce:transition-none dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground" />
|
|
21
|
+
</Switch.Root>
|
|
22
|
+
Wi-Fi
|
|
23
|
+
</label>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!-- Generated by website/styling-skill.ts from website/src/examples/tabs/shadcn/. Edit those files, then run `pnpm --filter website skill`. -->
|
|
2
|
+
|
|
3
|
+
# Tabs in the shadcn look
|
|
4
|
+
|
|
5
|
+
Its parts, props and data attributes: [Tabs](https://menhir-ui.com/docs/components/tabs.md).
|
|
6
|
+
|
|
7
|
+
## TabsExample.tsx
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Tabs } from "menhir/tabs";
|
|
11
|
+
import { For } from "solid-js";
|
|
12
|
+
|
|
13
|
+
const sections = [
|
|
14
|
+
{
|
|
15
|
+
value: "account",
|
|
16
|
+
name: "Account",
|
|
17
|
+
content: "Your name, email address and language.",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "billing",
|
|
21
|
+
name: "Billing",
|
|
22
|
+
content: "Your plan, payment method and invoices.",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "security",
|
|
26
|
+
name: "Security",
|
|
27
|
+
content: "Your password, passkeys and signed-in devices.",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export default function TabsExample() {
|
|
32
|
+
return (
|
|
33
|
+
<Tabs.Root class="flex w-80 flex-col gap-2">
|
|
34
|
+
<Tabs.List
|
|
35
|
+
aria-label="Settings"
|
|
36
|
+
class="inline-flex h-9 w-fit items-center justify-center rounded-lg bg-muted p-[3px] text-muted-foreground"
|
|
37
|
+
>
|
|
38
|
+
<For each={sections}>
|
|
39
|
+
{(section) => (
|
|
40
|
+
<Tabs.Tab
|
|
41
|
+
value={section.value}
|
|
42
|
+
class="inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 data-disabled:pointer-events-none data-disabled:opacity-50 data-selected:bg-background data-selected:text-foreground data-selected:shadow-sm motion-reduce:transition-none dark:text-muted-foreground dark:hover:text-foreground dark:data-selected:border-input dark:data-selected:bg-input/30 dark:data-selected:text-foreground"
|
|
43
|
+
>
|
|
44
|
+
{section.name}
|
|
45
|
+
</Tabs.Tab>
|
|
46
|
+
)}
|
|
47
|
+
</For>
|
|
48
|
+
</Tabs.List>
|
|
49
|
+
<For each={sections}>
|
|
50
|
+
{(section) => (
|
|
51
|
+
<Tabs.Panel
|
|
52
|
+
value={section.value}
|
|
53
|
+
class="rounded-xl border bg-card p-6 text-sm text-card-foreground shadow-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"
|
|
54
|
+
>
|
|
55
|
+
{section.content}
|
|
56
|
+
</Tabs.Panel>
|
|
57
|
+
)}
|
|
58
|
+
</For>
|
|
59
|
+
</Tabs.Root>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* Generated by website/styling-skill.ts from website/src/looks/shadcn/tokens.css. Edit that file, then run `pnpm --filter website skill`. */
|
|
2
|
+
|
|
3
|
+
/* The shadcn look's tokens: the default theme of shadcn/ui (neutral), from
|
|
4
|
+
https://ui.shadcn.com/docs/theming. Import this file after
|
|
5
|
+
`@import "tailwindcss";`, and put data-look="shadcn" on <html>, or on the
|
|
6
|
+
element whose content takes the look.
|
|
7
|
+
|
|
8
|
+
Two changes from shadcn/ui's file. The tokens are set on
|
|
9
|
+
[data-look="shadcn"] instead of :root, so that a page can show the look in
|
|
10
|
+
one part only, as the Menhir site does. Each colour gives its light and
|
|
11
|
+
its dark value through light-dark(), so the look follows the CSS
|
|
12
|
+
color-scheme instead of a .dark class. The chart and sidebar tokens are
|
|
13
|
+
left out until a component needs them. */
|
|
14
|
+
|
|
15
|
+
@theme inline {
|
|
16
|
+
--color-background: var(--background);
|
|
17
|
+
--color-foreground: var(--foreground);
|
|
18
|
+
--color-card: var(--card);
|
|
19
|
+
--color-card-foreground: var(--card-foreground);
|
|
20
|
+
--color-popover: var(--popover);
|
|
21
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
22
|
+
--color-primary: var(--primary);
|
|
23
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
24
|
+
--color-secondary: var(--secondary);
|
|
25
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
26
|
+
--color-muted: var(--muted);
|
|
27
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
28
|
+
--color-accent: var(--accent);
|
|
29
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
30
|
+
--color-destructive: var(--destructive);
|
|
31
|
+
--color-border: var(--border);
|
|
32
|
+
--color-input: var(--input);
|
|
33
|
+
--color-ring: var(--ring);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-look="shadcn"] {
|
|
37
|
+
/* Tailwind's radius scale, from one radius: rounded-md is 0.5rem. */
|
|
38
|
+
--radius: 0.625rem;
|
|
39
|
+
--radius-sm: calc(var(--radius) * 0.6);
|
|
40
|
+
--radius-md: calc(var(--radius) * 0.8);
|
|
41
|
+
--radius-lg: var(--radius);
|
|
42
|
+
--radius-xl: calc(var(--radius) * 1.4);
|
|
43
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
44
|
+
|
|
45
|
+
/* light-dark(light value, dark value) */
|
|
46
|
+
--background: light-dark(oklch(1 0 0), oklch(0.145 0 0));
|
|
47
|
+
--foreground: light-dark(oklch(0.145 0 0), oklch(0.985 0 0));
|
|
48
|
+
--card: light-dark(oklch(1 0 0), oklch(0.205 0 0));
|
|
49
|
+
--card-foreground: light-dark(oklch(0.145 0 0), oklch(0.985 0 0));
|
|
50
|
+
--popover: light-dark(oklch(1 0 0), oklch(0.205 0 0));
|
|
51
|
+
--popover-foreground: light-dark(oklch(0.145 0 0), oklch(0.985 0 0));
|
|
52
|
+
--primary: light-dark(oklch(0.205 0 0), oklch(0.922 0 0));
|
|
53
|
+
--primary-foreground: light-dark(oklch(0.985 0 0), oklch(0.205 0 0));
|
|
54
|
+
--secondary: light-dark(oklch(0.97 0 0), oklch(0.269 0 0));
|
|
55
|
+
--secondary-foreground: light-dark(oklch(0.205 0 0), oklch(0.985 0 0));
|
|
56
|
+
--muted: light-dark(oklch(0.97 0 0), oklch(0.269 0 0));
|
|
57
|
+
--muted-foreground: light-dark(oklch(0.556 0 0), oklch(0.708 0 0));
|
|
58
|
+
--accent: light-dark(oklch(0.97 0 0), oklch(0.269 0 0));
|
|
59
|
+
--accent-foreground: light-dark(oklch(0.205 0 0), oklch(0.985 0 0));
|
|
60
|
+
--destructive: light-dark(
|
|
61
|
+
oklch(0.577 0.245 27.325),
|
|
62
|
+
oklch(0.704 0.191 22.216)
|
|
63
|
+
);
|
|
64
|
+
--border: light-dark(oklch(0.922 0 0), oklch(1 0 0 / 10%));
|
|
65
|
+
--input: light-dark(oklch(0.922 0 0), oklch(1 0 0 / 15%));
|
|
66
|
+
--ring: light-dark(oklch(0.708 0 0), oklch(0.556 0 0));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* shadcn/ui's base styles: the text colour, and every border and outline in
|
|
70
|
+
the look's colours unless a class says otherwise. The page's background is
|
|
71
|
+
the app's: bg-background on <body>. */
|
|
72
|
+
@layer base {
|
|
73
|
+
[data-look="shadcn"] {
|
|
74
|
+
color: var(--foreground);
|
|
75
|
+
}
|
|
76
|
+
[data-look="shadcn"] :where(*, ::before, ::after) {
|
|
77
|
+
border-color: var(--border);
|
|
78
|
+
outline-color: color-mix(in oklab, var(--ring) 50%, transparent);
|
|
79
|
+
}
|
|
80
|
+
}
|