@zukhruf/shadcn 0.3.21 → 0.3.22

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.
Files changed (3) hide show
  1. package/README.md +26 -2
  2. package/package.json +1 -1
  3. package/styles.css +11 -0
package/README.md CHANGED
@@ -81,12 +81,36 @@ Base UI:
81
81
 
82
82
  ## What the stylesheet adds to stock shadcn/ui
83
83
 
84
- The stylesheet has two patches:
84
+ The stylesheet has three patches:
85
85
 
86
86
  - **A pointer cursor on enabled buttons.** In Tailwind CSS 4, a button has the default cursor of the browser, not the pointer. The upgrade guide of Tailwind CSS gives a rule that sets the pointer again. The patch is that rule, in `@layer base`.
87
87
  - **A cap on the height of a dialog.** A dialog is never taller than the window minus `2rem`, and it scrolls when its content is taller. Thus the buttons at the bottom of a tall dialog stay on the screen. The rule is `max-height: calc(100dvh - 2rem); overflow-y: auto` on `[data-slot="dialog-content"]`. The patch is in `@layer components`.
88
+ - **The width of the mobile sidebar.** On a small screen, the sidebar is in a `Sheet`. The class `data-[side=left]:w-3/4` of the `Sheet` wins over the class `w-(--sidebar-width)` of the sidebar. Thus the sidebar was 3/4 of the window: 292.5px, not 288px, in a window of 390px. The patch sets `width: var(--sidebar-width)` on `[data-slot="sidebar"][data-mobile="true"][data-side]`.
88
89
 
89
- Both patches are in layers. Thus a utility class of the app, for example `cursor-wait` or `max-h-none`, still changes them.
90
+ The cursor and the cap are in layers before `utilities`. Thus a utility class of the app, for example `cursor-wait` or `max-h-none`, still changes them.
91
+
92
+ The width patch is in `@layer utilities`, because only a rule in that layer wins over a utility class. Its selector has three attributes, so it wins over the two parts of `data-[side=left]:w-3/4`. The sidebar does not give its `className` to the mobile `Sheet`, so a utility class of the app cannot get to that element. To change the mobile width, write a rule outside of a layer.
93
+
94
+ ## Links that look like buttons
95
+
96
+ A control that goes to a different page must stay a link. Do not write `<Button render={<Link />} nativeButton={false}>`. This makes an `<a>` with `role="button"`. A screen reader then calls the link a button, and the Space key activates it.
97
+
98
+ Put the classes of the button on the link:
99
+
100
+ ```tsx
101
+ import { cn } from 'cn';
102
+
103
+ import { buttonVariants } from '@zukhruf/shadcn';
104
+
105
+ <Link
106
+ href="/settings"
107
+ className={cn(buttonVariants({ variant: 'outline', size: 'sm' }))}
108
+ >
109
+ Settings
110
+ </Link>;
111
+ ```
112
+
113
+ Use `cn` around `buttonVariants`. `Button` merges the classes that conflict through `cn`, which uses tailwind-merge. Without `cn`, the classes that conflict stay on the link, and the link looks different from a button. In one app, the link had a radius of 10px, not 8px, and it was 2px wider than the button.
90
114
 
91
115
  ## Your own components
92
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/shadcn",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "Every shadcn/ui component for Base UI with the nova preset, as one package: import the components from one entry and the styles from one stylesheet.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/styles.css CHANGED
@@ -16,3 +16,14 @@
16
16
  overflow-y: auto;
17
17
  }
18
18
  }
19
+
20
+ /*
21
+ * the mobile sidebar is a Sheet, whose data-[side=…]:w-3/4 (0,2,0) beats the
22
+ * sidebar's w-(--sidebar-width) (0,1,0). Only a utilities-layer rule can beat
23
+ * a utility; (0,3,0) wins without relying on source order.
24
+ */
25
+ @layer utilities {
26
+ [data-slot='sidebar'][data-mobile='true'][data-side] {
27
+ width: var(--sidebar-width);
28
+ }
29
+ }