menhir 0.1.2 → 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 +9 -2
- package/dist/alert-dialog/index.js +2 -0
- package/dist/alert-dialog/index.parts.js +7 -0
- package/dist/alert-dialog/popup/AlertDialogPopup.js +13 -0
- package/dist/core/createControllableSignal.js +15 -5
- package/dist/core/listValue.js +2 -7
- package/dist/core/slot.js +30 -0
- package/dist/dialog/close/DialogClose.js +33 -0
- package/dist/dialog/description/DialogDescription.js +27 -0
- package/dist/dialog/index.js +2 -0
- package/dist/dialog/index.parts.js +7 -0
- package/dist/dialog/popup/DialogPopup.js +13 -0
- package/dist/dialog/popup/renderDialogPopup.js +71 -0
- package/dist/dialog/root/DialogRoot.js +46 -0
- package/dist/dialog/root/DialogRootContext.js +10 -0
- package/dist/dialog/title/DialogTitle.js +27 -0
- package/dist/dialog/trigger/DialogTrigger.js +33 -0
- package/dist/floating/dismissal/dialogClose.js +67 -0
- package/dist/floating/dismissal/escape.js +44 -0
- package/dist/floating/dismissal/outsidePress.js +52 -0
- package/dist/floating/dismissal/popoverClose.js +74 -0
- package/dist/floating/dismissal/reason.js +0 -0
- package/dist/floating/focus/initialFocus.js +33 -0
- package/dist/floating/focus/returnFocus.js +65 -0
- package/dist/floating/focus/tabWrap.js +55 -0
- package/dist/floating/focus/tabbable.js +50 -0
- package/dist/floating/focus/target.js +0 -0
- package/dist/floating/hover/group.js +36 -0
- package/dist/floating/hover/hover.js +105 -0
- package/dist/floating/hover/safeArea.js +64 -0
- 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/presence/presence.js +57 -0
- package/dist/floating/scroll-lock/scrollLock.js +125 -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/popover/arrow/PopoverArrow.js +39 -0
- package/dist/popover/close/PopoverClose.js +33 -0
- package/dist/popover/description/PopoverDescription.js +27 -0
- package/dist/popover/index.js +2 -0
- package/dist/popover/index.parts.js +8 -0
- package/dist/popover/popup/PopoverPopup.js +116 -0
- package/dist/popover/popup/PopoverPopupContext.js +10 -0
- package/dist/popover/root/PopoverRoot.js +50 -0
- package/dist/popover/root/PopoverRootContext.js +10 -0
- package/dist/popover/title/PopoverTitle.js +27 -0
- package/dist/popover/trigger/PopoverTrigger.js +44 -0
- package/dist/source/alert-dialog/index.d.ts +1 -0
- package/dist/source/alert-dialog/index.js +1 -0
- package/dist/source/alert-dialog/index.parts.d.ts +6 -0
- package/dist/source/alert-dialog/index.parts.js +7 -0
- package/dist/source/alert-dialog/popup/AlertDialogPopup.d.ts +10 -0
- package/dist/source/alert-dialog/popup/AlertDialogPopup.jsx +11 -0
- package/dist/source/core/createControllableSignal.d.ts +13 -4
- package/dist/source/core/createControllableSignal.js +11 -5
- package/dist/source/core/listValue.js +4 -10
- package/dist/source/core/slot.d.ts +21 -0
- package/dist/source/core/slot.js +28 -0
- package/dist/source/dialog/close/DialogClose.d.ts +11 -0
- package/dist/source/dialog/close/DialogClose.jsx +25 -0
- package/dist/source/dialog/description/DialogDescription.d.ts +10 -0
- package/dist/source/dialog/description/DialogDescription.jsx +26 -0
- package/dist/source/dialog/index.d.ts +1 -0
- package/dist/source/dialog/index.js +1 -0
- package/dist/source/dialog/index.parts.d.ts +6 -0
- package/dist/source/dialog/index.parts.js +6 -0
- package/dist/source/dialog/popup/DialogPopup.d.ts +9 -0
- package/dist/source/dialog/popup/DialogPopup.jsx +11 -0
- package/dist/source/dialog/popup/renderDialogPopup.d.ts +40 -0
- package/dist/source/dialog/popup/renderDialogPopup.jsx +73 -0
- package/dist/source/dialog/root/DialogRoot.d.ts +20 -0
- package/dist/source/dialog/root/DialogRoot.jsx +39 -0
- package/dist/source/dialog/root/DialogRootContext.d.ts +32 -0
- package/dist/source/dialog/root/DialogRootContext.js +14 -0
- package/dist/source/dialog/title/DialogTitle.d.ts +10 -0
- package/dist/source/dialog/title/DialogTitle.jsx +26 -0
- package/dist/source/dialog/trigger/DialogTrigger.d.ts +10 -0
- package/dist/source/dialog/trigger/DialogTrigger.jsx +27 -0
- package/dist/source/floating/dismissal/dialogClose.d.ts +26 -0
- package/dist/source/floating/dismissal/dialogClose.js +69 -0
- package/dist/source/floating/dismissal/escape.d.ts +24 -0
- package/dist/source/floating/dismissal/escape.js +48 -0
- package/dist/source/floating/dismissal/outsidePress.d.ts +26 -0
- package/dist/source/floating/dismissal/outsidePress.js +50 -0
- package/dist/source/floating/dismissal/popoverClose.d.ts +28 -0
- package/dist/source/floating/dismissal/popoverClose.js +82 -0
- package/dist/source/floating/dismissal/reason.d.ts +34 -0
- package/dist/source/floating/dismissal/reason.js +1 -0
- package/dist/source/floating/focus/initialFocus.d.ts +24 -0
- package/dist/source/floating/focus/initialFocus.js +38 -0
- package/dist/source/floating/focus/returnFocus.d.ts +27 -0
- package/dist/source/floating/focus/returnFocus.js +81 -0
- package/dist/source/floating/focus/tabWrap.d.ts +21 -0
- package/dist/source/floating/focus/tabWrap.js +69 -0
- package/dist/source/floating/focus/tabbable.d.ts +16 -0
- package/dist/source/floating/focus/tabbable.js +69 -0
- package/dist/source/floating/focus/target.d.ts +8 -0
- package/dist/source/floating/focus/target.js +1 -0
- package/dist/source/floating/hover/group.d.ts +39 -0
- package/dist/source/floating/hover/group.js +38 -0
- package/dist/source/floating/hover/hover.d.ts +35 -0
- package/dist/source/floating/hover/hover.js +130 -0
- package/dist/source/floating/hover/safeArea.d.ts +23 -0
- package/dist/source/floating/hover/safeArea.js +67 -0
- 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/presence/presence.d.ts +24 -0
- package/dist/source/floating/presence/presence.js +73 -0
- package/dist/source/floating/scroll-lock/scrollLock.d.ts +27 -0
- package/dist/source/floating/scroll-lock/scrollLock.js +151 -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/dist/source/popover/arrow/PopoverArrow.d.ts +11 -0
- package/dist/source/popover/arrow/PopoverArrow.jsx +32 -0
- package/dist/source/popover/close/PopoverClose.d.ts +11 -0
- package/dist/source/popover/close/PopoverClose.jsx +25 -0
- package/dist/source/popover/description/PopoverDescription.d.ts +10 -0
- package/dist/source/popover/description/PopoverDescription.jsx +26 -0
- package/dist/source/popover/index.d.ts +1 -0
- package/dist/source/popover/index.js +1 -0
- package/dist/source/popover/index.parts.d.ts +7 -0
- package/dist/source/popover/index.parts.js +7 -0
- package/dist/source/popover/popup/PopoverPopup.d.ts +47 -0
- package/dist/source/popover/popup/PopoverPopup.jsx +120 -0
- package/dist/source/popover/popup/PopoverPopupContext.d.ts +14 -0
- package/dist/source/popover/popup/PopoverPopupContext.js +11 -0
- package/dist/source/popover/root/PopoverRoot.d.ts +20 -0
- package/dist/source/popover/root/PopoverRoot.jsx +42 -0
- package/dist/source/popover/root/PopoverRootContext.d.ts +39 -0
- package/dist/source/popover/root/PopoverRootContext.js +13 -0
- package/dist/source/popover/title/PopoverTitle.d.ts +10 -0
- package/dist/source/popover/title/PopoverTitle.jsx +26 -0
- package/dist/source/popover/trigger/PopoverTrigger.d.ts +12 -0
- package/dist/source/popover/trigger/PopoverTrigger.jsx +40 -0
- package/dist/source/tooltip/arrow/TooltipArrow.d.ts +11 -0
- package/dist/source/tooltip/arrow/TooltipArrow.jsx +32 -0
- package/dist/source/tooltip/group/TooltipGroup.d.ts +20 -0
- package/dist/source/tooltip/group/TooltipGroup.jsx +18 -0
- package/dist/source/tooltip/group/TooltipGroupContext.d.ts +2 -0
- package/dist/source/tooltip/group/TooltipGroupContext.js +5 -0
- package/dist/source/tooltip/index.d.ts +1 -0
- package/dist/source/tooltip/index.js +1 -0
- package/dist/source/tooltip/index.parts.d.ts +5 -0
- package/dist/source/tooltip/index.parts.js +5 -0
- package/dist/source/tooltip/popup/TooltipPopup.d.ts +31 -0
- package/dist/source/tooltip/popup/TooltipPopup.jsx +77 -0
- package/dist/source/tooltip/popup/TooltipPopupContext.d.ts +14 -0
- package/dist/source/tooltip/popup/TooltipPopupContext.js +11 -0
- package/dist/source/tooltip/root/TooltipRoot.d.ts +31 -0
- package/dist/source/tooltip/root/TooltipRoot.jsx +80 -0
- package/dist/source/tooltip/root/TooltipRootContext.d.ts +35 -0
- package/dist/source/tooltip/root/TooltipRootContext.js +13 -0
- package/dist/source/tooltip/trigger/TooltipTrigger.d.ts +12 -0
- package/dist/source/tooltip/trigger/TooltipTrigger.jsx +52 -0
- package/dist/tooltip/arrow/TooltipArrow.js +39 -0
- package/dist/tooltip/group/TooltipGroup.js +26 -0
- package/dist/tooltip/group/TooltipGroupContext.js +4 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/index.parts.js +6 -0
- package/dist/tooltip/popup/TooltipPopup.js +86 -0
- package/dist/tooltip/popup/TooltipPopupContext.js +10 -0
- package/dist/tooltip/root/TooltipRoot.js +79 -0
- package/dist/tooltip/root/TooltipRootContext.js +10 -0
- package/dist/tooltip/trigger/TooltipTrigger.js +54 -0
- package/package.json +28 -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,10 @@
|
|
|
1
|
+
import { isDev } from "@solidjs/web";
|
|
2
|
+
import { createContext, useContext } from "solid-js";
|
|
3
|
+
// src/tooltip/root/TooltipRootContext.ts
|
|
4
|
+
var TooltipRootContext = createContext(null);
|
|
5
|
+
function useTooltipRootContext() {
|
|
6
|
+
const context = useContext(TooltipRootContext);
|
|
7
|
+
if (isDev && !context) throw new Error("[menhir] Tooltip parts must be placed within <Tooltip.Root>.");
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
export { TooltipRootContext, useTooltipRootContext };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
2
|
+
import { renderElement } from "../../core/renderElement.js";
|
|
3
|
+
import { useTooltipRootContext } from "../root/TooltipRootContext.js";
|
|
4
|
+
import { spread, template } from "@solidjs/web";
|
|
5
|
+
import { merge, omit } from "solid-js";
|
|
6
|
+
// src/tooltip/trigger/TooltipTrigger.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<button>`);
|
|
8
|
+
/**
|
|
9
|
+
* The element the tooltip describes: a `<button type="button">` whose
|
|
10
|
+
* `aria-describedby` names the Popup. Hovering it opens the tooltip after
|
|
11
|
+
* the Root's `delay`, keyboard focus opens it at once, and a press closes
|
|
12
|
+
* it. Place it inside `Tooltip.Root`, before `Tooltip.Popup`.
|
|
13
|
+
*/
|
|
14
|
+
function TooltipTrigger(props) {
|
|
15
|
+
const root = useTooltipRootContext();
|
|
16
|
+
const ownProps = merge(root.attributes, {
|
|
17
|
+
type: "button",
|
|
18
|
+
get "aria-describedby"() {
|
|
19
|
+
return props["aria-describedby"] ?? root.popupId;
|
|
20
|
+
},
|
|
21
|
+
onFocus: (event) => {
|
|
22
|
+
if (root.trigger.matches(":focus-visible")) root.setOpen(true, {
|
|
23
|
+
reason: "trigger-focus",
|
|
24
|
+
event
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
onBlur: (event) => {
|
|
28
|
+
if (!root.trigger.matches(":hover") && !root.popup?.matches(":hover")) root.setOpen(false, {
|
|
29
|
+
reason: "trigger-focus",
|
|
30
|
+
event
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
onClick: (event) => {
|
|
34
|
+
root.pressed = true;
|
|
35
|
+
root.setOpen(false, {
|
|
36
|
+
reason: "trigger-press",
|
|
37
|
+
event
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
onPointerEnter: () => {
|
|
41
|
+
root.pressed = false;
|
|
42
|
+
},
|
|
43
|
+
ref: (element) => {
|
|
44
|
+
root.trigger = element;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render", "aria-describedby"));
|
|
48
|
+
return renderElement(props, elementProps, (p) => (() => {
|
|
49
|
+
var _el$ = _tmpl$();
|
|
50
|
+
spread(_el$, p, false);
|
|
51
|
+
return _el$;
|
|
52
|
+
})());
|
|
53
|
+
}
|
|
54
|
+
export { TooltipTrigger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "menhir",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Unstyled, accessible UI primitives for SolidJS 2.0, with small and measurable bundles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solid",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"solid": "./dist/source/accordion/index.js",
|
|
30
30
|
"import": "./dist/accordion/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./alert-dialog": {
|
|
33
|
+
"types": "./dist/source/alert-dialog/index.d.ts",
|
|
34
|
+
"solid": "./dist/source/alert-dialog/index.js",
|
|
35
|
+
"import": "./dist/alert-dialog/index.js"
|
|
36
|
+
},
|
|
32
37
|
"./checkbox": {
|
|
33
38
|
"types": "./dist/source/checkbox/index.d.ts",
|
|
34
39
|
"solid": "./dist/source/checkbox/index.js",
|
|
@@ -49,11 +54,26 @@
|
|
|
49
54
|
"solid": "./dist/source/color-scheme/local-storage/index.js",
|
|
50
55
|
"import": "./dist/color-scheme/local-storage/index.js"
|
|
51
56
|
},
|
|
57
|
+
"./dialog": {
|
|
58
|
+
"types": "./dist/source/dialog/index.d.ts",
|
|
59
|
+
"solid": "./dist/source/dialog/index.js",
|
|
60
|
+
"import": "./dist/dialog/index.js"
|
|
61
|
+
},
|
|
52
62
|
"./meter": {
|
|
53
63
|
"types": "./dist/source/meter/index.d.ts",
|
|
54
64
|
"solid": "./dist/source/meter/index.js",
|
|
55
65
|
"import": "./dist/meter/index.js"
|
|
56
66
|
},
|
|
67
|
+
"./navigation-menu": {
|
|
68
|
+
"types": "./dist/source/navigation-menu/index.d.ts",
|
|
69
|
+
"solid": "./dist/source/navigation-menu/index.js",
|
|
70
|
+
"import": "./dist/navigation-menu/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./popover": {
|
|
73
|
+
"types": "./dist/source/popover/index.d.ts",
|
|
74
|
+
"solid": "./dist/source/popover/index.js",
|
|
75
|
+
"import": "./dist/popover/index.js"
|
|
76
|
+
},
|
|
57
77
|
"./progress": {
|
|
58
78
|
"types": "./dist/source/progress/index.d.ts",
|
|
59
79
|
"solid": "./dist/source/progress/index.js",
|
|
@@ -94,10 +114,16 @@
|
|
|
94
114
|
"solid": "./dist/source/toggle-group/index.js",
|
|
95
115
|
"import": "./dist/toggle-group/index.js"
|
|
96
116
|
},
|
|
117
|
+
"./tooltip": {
|
|
118
|
+
"types": "./dist/source/tooltip/index.d.ts",
|
|
119
|
+
"solid": "./dist/source/tooltip/index.js",
|
|
120
|
+
"import": "./dist/tooltip/index.js"
|
|
121
|
+
},
|
|
97
122
|
"./package.json": "./package.json"
|
|
98
123
|
},
|
|
99
124
|
"files": [
|
|
100
|
-
"dist"
|
|
125
|
+
"dist",
|
|
126
|
+
"skills"
|
|
101
127
|
],
|
|
102
128
|
"imports": {
|
|
103
129
|
"#test-utils": "./test/index.ts"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: menhir-styling
|
|
3
|
+
description: Style Menhir components (the `menhir` package for SolidJS) in one consistent look, such as the shadcn look, or a look the user describes or shows. Use when adding styles to a Menhir component, or giving an app's Menhir components a look.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Styling Menhir components
|
|
7
|
+
|
|
8
|
+
Menhir's components are unstyled: each part exposes its state as data attributes for CSS to select. A **look** is a complete visual style for them: tokens (colours and radii), recipes for every kind of part, and worked examples built from both. Every component styled in a look uses that look's tokens and recipes, so components styled weeks apart still match.
|
|
9
|
+
|
|
10
|
+
## Looks
|
|
11
|
+
|
|
12
|
+
| Look | Styling | Worked examples |
|
|
13
|
+
| ------------------------------ | --------------- | ----------------------------- |
|
|
14
|
+
| [shadcn](looks/shadcn/LOOK.md) | Tailwind CSS v4 | Switch, Dialog, Tabs, Popover |
|
|
15
|
+
|
|
16
|
+
Each look's `LOOK.md` has its setup, what each token is for, its recipes, and the list of worked examples. When the app is styled with the other technology, translate the look's classes into it, token for token.
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
|
|
20
|
+
1. **Choose the look.** The one the user names, or the one the app already has: look for `data-look` and a look's `tokens.css` in the app. For a look the user describes or shows (a screenshot, a site, an existing design system), write its tokens first: copy the closest look's `tokens.css`, keep the token names, change the values. That look's recipes and worked examples then carry over. Done when the app has one tokens file for the look.
|
|
21
|
+
2. **Set up the look**, once per app, as its `LOOK.md` says. A look's tokens apply only inside its `data-look` attribute, and switch between light and dark with the CSS `color-scheme`, which the app sets from Menhir's color-scheme utility (`menhir/color-scheme/local-storage` or `/cookie`) or from the system. Done when the tokens apply where the components render, in light and dark.
|
|
22
|
+
3. **Style each component.** Read its parts and data attributes first, from its Markdown page, `https://menhir-ui.com/docs/components/<name>.md` (all of them are listed in `https://menhir-ui.com/llms.txt`); the types in `node_modules/menhir/dist/source/<name>/` are the installed version's. When the look has a worked example of it, start from that and change only the content. Otherwise build it from the look's recipes, taking their classes as written, and its nearest worked example: a control from Switch, a popup from Popover or Dialog, a composite from Tabs. Where no recipe covers a part, say so in your reply, with the classes you chose. Done when every part the app renders has its classes, every colour and radius comes from a token, and sizes, spacing and shadows come from the look's recipes.
|
|
23
|
+
4. **Check it in the browser.** For each component: its states (on and off, selected, disabled), open and close animations, keyboard focus on every interactive part, text contrast against its background, and the same again in the dark color scheme. Done when each one looks like the look's worked examples in both color schemes.
|
|
24
|
+
|
|
25
|
+
## Menhir's contract
|
|
26
|
+
|
|
27
|
+
What holds for every component, and so is on no single component's page. A component's parts, props and data attributes are on its Markdown page only: read them there.
|
|
28
|
+
|
|
29
|
+
- **State is in data attributes**, present or absent, such as `data-checked` and `data-unchecked`; the component's page lists each part's. In Tailwind: `data-checked:bg-primary`.
|
|
30
|
+
- **Focus** is `:focus-visible` (`focus-visible:` in Tailwind). There is no focus attribute.
|
|
31
|
+
- **`class` and `style` merge** with the part's own. A part's `render` prop renders it through the app's own component.
|
|
32
|
+
- **Popups are in the top layer**: a Dialog's Popup is a modal `<dialog>`, a Popover's Popup is a `popover` element. They need no portal and no `z-index`. The browser hides them while closed with `display: none`, so a `display` class (`flex`, `grid`) goes on an inner wrapper, never on the Popup.
|
|
33
|
+
- **A Dialog's backdrop** is the browser's `::backdrop` (`backdrop:` in Tailwind), and `m-auto` centres the dialog.
|
|
34
|
+
- **Animation**: entry from `@starting-style` on `[data-open]` (`starting:data-open:`), exit to the `[data-closed]` styles: Menhir keeps a closing popup shown until its transition or animation ends. Guard motion with `prefers-reduced-motion` (`motion-reduce:transition-none`).
|
|
35
|
+
- **A positioned popup** (Popover, Tooltip) grows from its trigger: `origin-(--transform-origin)`. Its page lists its side and alignment attributes and its other CSS variables.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
The shadcn look reproduces class strings and token values from shadcn/ui
|
|
2
|
+
(https://github.com/shadcn-ui/ui), under its licence:
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2023 shadcn
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
@@ -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
|
+
}
|