@zukhruf/shadcn 0.8.45 → 0.8.46

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 +8 -1
  2. package/package.json +1 -1
  3. package/styles.css +71 -0
package/README.md CHANGED
@@ -49,6 +49,8 @@ The theme is the values of a set of CSS variables, for example `--primary`, `--b
49
49
  :root {
50
50
  --primary: oklch(0.55 0.2 260);
51
51
  --radius: 0.5rem;
52
+ --control-height: 2.5rem;
53
+ --control-background: var(--card);
52
54
  }
53
55
 
54
56
  .dark {
@@ -79,6 +81,8 @@ The `@theme inline` block of `theme.css` maps these variables to Tailwind CSS co
79
81
 
80
82
  The preset is fixed. The class strings of each component contain the preset, for example the rounded corners and the spacing of the dialog. Thus an app cannot change the preset. An app changes only the theme. See [ADR 0004](./docs/adr/0004-the-components-use-base-ui-and-the-nova-preset.md).
81
83
 
84
+ The theme also covers the density of the controls: `--control-height`, `--control-height-sm` and `--control-background` (see [what the stylesheet adds](#what-the-stylesheet-adds-to-stock-shadcnui)). Set a token, not a `className` restyle such as `h-10 bg-card` on each control. A subtree can set a second value, for example taller controls on the auth pages. See [ADR 0006](./docs/adr/0006-a-host-gets-its-looks-through-theme-tokens-and-data-attribute-patches.md).
85
+
82
86
  ## The open state of the sidebar
83
87
 
84
88
  `SidebarProvider` keeps its open state in a cookie. `SIDEBAR_COOKIE_NAME` is the name of that cookie. Use it to read the open state of the sidebar on the server, and give the value to `defaultOpen`:
@@ -119,7 +123,7 @@ Not fixed: the mobile sidebar has a hidden title and description in English (`Si
119
123
 
120
124
  ## What the stylesheet adds to stock shadcn/ui
121
125
 
122
- The stylesheet has six patches:
126
+ The stylesheet has seven patches:
123
127
 
124
128
  - **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`.
125
129
  - **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`.
@@ -129,6 +133,8 @@ The stylesheet has six patches:
129
133
 
130
134
  - **A select popup sits on its trigger.** With `alignItemWithTrigger`, the default of `SelectContent`, Base UI lines up the text of the selected item with the text of the trigger. The trigger's text starts after a 1px border and `ps-2.5`, 11px; the popup draws its edge with `ring-1`, a shadow, so the item's text started at 10px. Thus the popup sat 1px off the trigger: in Meddit at 1280px, 769–1169 for a trigger at 768–1168, and the label under the popup showed at its edge. The patch sets `padding-inline: 1px` on `[data-slot="select-content"]`, in `@layer components`. The popup then has the trigger's edges in both directions, and a popup opened without `alignItemWithTrigger` lines up its text with the trigger's text too.
131
135
 
136
+ - **The controls take their height and background from the theme.** `--control-height` sets the height of `Input`, `SelectTrigger` at `data-size="default"`, `InputGroup` and `Button` at the default size, and the minimum height of `Textarea` and `ComboboxChips`. `--control-height-sm` sets the height of `Button` at `size="sm"`. The button rules are keyed on the `group/button` class of `buttonVariants()`, so a link with the classes of a button takes them too. `--control-background` sets the background of `Input`, `Textarea`, `SelectTrigger`, `InputGroup` and `ComboboxChips`. Without a value, each rule falls back to nova: 32px (64px for `Textarea`), 28px, and `transparent` (`input/30` under `.dark`). Each rule is keyed on the nova class that it replaces, for example `[data-slot='input'].h-8`, so a class of the app that tailwind-merge swaps in for that class turns the rule off. A disabled control, an `InputGroup` with a textarea or a block-aligned addon, a hovered dark `SelectTrigger` and a button of an `InputGroup` keep their nova styles. The patch is in `@layer utilities`. See [ADR 0006](./docs/adr/0006-a-host-gets-its-looks-through-theme-tokens-and-data-attribute-patches.md).
137
+
132
138
  The cursor, the cap, the shortcut and the select popup are in layers before `utilities`. Thus a utility class of the app, for example `cursor-wait` or `max-h-none`, still changes them.
133
139
 
134
140
  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.
@@ -230,6 +236,7 @@ export const SIDEBAR_COOKIE_NAME = 'sidebar_state';
230
236
  3. [The stylesheet registers its own source and keeps its patches in layers](./docs/adr/0003-the-stylesheet-registers-its-own-source-and-keeps-its-patches-in-layers.md)
231
237
  4. [The components use Base UI and the nova preset](./docs/adr/0004-the-components-use-base-ui-and-the-nova-preset.md)
232
238
  5. [The default theme is in `@layer base`](./docs/adr/0005-the-default-theme-is-in-layer-base.md)
239
+ 6. [A host gets its looks through theme tokens and data-attribute patches](./docs/adr/0006-a-host-gets-its-looks-through-theme-tokens-and-data-attribute-patches.md)
233
240
 
234
241
  ## Development
235
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/shadcn",
3
- "version": "0.8.45",
3
+ "version": "0.8.46",
4
4
  "description": "Each shadcn/ui component for Base UI with the nova preset, in one package. An app imports the components from one entry and the styles from one stylesheet. The shadcn CLI writes the source, and nobody edits it by hand.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/styles.css CHANGED
@@ -63,3 +63,74 @@
63
63
  unicode-bidi: plaintext;
64
64
  }
65
65
  }
66
+
67
+ /*
68
+ * Control density and tone are theme tokens (ADR 0006). A host sets
69
+ * --control-height, --control-height-sm and --control-background, and each
70
+ * patch below reads them with nova's own value as the fallback, so a host that
71
+ * sets none gets stock nova. Each patch is keyed on the nova class it replaces:
72
+ * a host class that tailwind-merge swaps in for it drops that class, and the
73
+ * patch no longer matches. They are in @layer utilities at one attribute more
74
+ * than the nova class, so they beat it without relying on source order; a
75
+ * state the nova class string styles (disabled, has-[>textarea], dark hover)
76
+ * is left out with :not(), so its nova rule still applies.
77
+ */
78
+ @layer utilities {
79
+ [data-slot='input'].h-8,
80
+ [data-slot='input-group'].h-8:not(
81
+ :has(> textarea, > [data-align='block-start'], > [data-align='block-end'])
82
+ ),
83
+ [data-slot='select-trigger'][data-size='default'].data-\[size\=default\]\:h-8,
84
+ .group\/button.h-8:not([data-size]) {
85
+ height: var(--control-height, calc(var(--spacing) * 8));
86
+ }
87
+
88
+ [data-slot='textarea'].min-h-16 {
89
+ min-height: var(--control-height, calc(var(--spacing) * 16));
90
+ }
91
+
92
+ [data-slot='combobox-chips'].min-h-8 {
93
+ min-height: var(--control-height, calc(var(--spacing) * 8));
94
+ }
95
+
96
+ /*
97
+ * a button is keyed on group/button, which every buttonVariants() carries, so
98
+ * a link with the classes of a button takes the token too; InputGroupButton
99
+ * passes data-size, so its own sizes stay
100
+ */
101
+ .group\/button.h-7:not([data-size]) {
102
+ height: var(--control-height-sm, calc(var(--spacing) * 7));
103
+ }
104
+
105
+ [data-slot='input'].bg-transparent:not(:disabled),
106
+ [data-slot='textarea'].bg-transparent:not(:disabled),
107
+ [data-slot='select-trigger'].bg-transparent,
108
+ [data-slot='combobox-chips'].bg-transparent {
109
+ background-color: var(--control-background, transparent);
110
+ }
111
+
112
+ /*
113
+ * nova's input group has no light background class to key on, so the patch
114
+ * has no specificity: every utility wins over it, a host's bg-* class, the
115
+ * kit's has-disabled:bg-input/50 and the command input's bg-input/30.
116
+ */
117
+ :where([data-slot='input-group']) {
118
+ background-color: var(--control-background, transparent);
119
+ }
120
+
121
+ [data-slot='input'].dark\:bg-input\/30:not(:disabled):is(.dark, .dark *),
122
+ [data-slot='textarea'].dark\:bg-input\/30:not(:disabled):is(.dark, .dark *),
123
+ [data-slot='select-trigger'].dark\:bg-input\/30:not(:hover):is(
124
+ .dark,
125
+ .dark *
126
+ ),
127
+ [data-slot='combobox-chips'].dark\:bg-input\/30:is(.dark, .dark *),
128
+ [data-slot='input-group'].dark\:bg-input\/30:not(:has(:disabled)):not(
129
+ [data-slot='command-input-wrapper'] > *
130
+ ):is(.dark, .dark *) {
131
+ background-color: var(
132
+ --control-background,
133
+ color-mix(in oklab, var(--input) 30%, transparent)
134
+ );
135
+ }
136
+ }