@zukhruf/shadcn 0.8.57 → 0.8.59

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 +36 -1
  2. package/package.json +1 -1
  3. package/styles.css +22 -0
package/README.md CHANGED
@@ -127,7 +127,7 @@ The stylesheet has eight patches:
127
127
 
128
128
  - **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.
129
129
 
130
- - **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).
130
+ - **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`, `ComboboxChips` and a `PopoverTrigger` rendered as an outline `Button`, the trigger of a date picker. A `Button` of another variant, and an outline `Button` that opens no popover, keep their nova background. Without a value, each rule falls back to nova: 32px (64px for `Textarea`), 28px, and `transparent` (`background` for the `PopoverTrigger`, `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`, a hovered or open `PopoverTrigger` 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).
131
131
 
132
132
  - **The field labels take their colour and size from the theme.** `FieldLabel` and `FieldTitle` both write `data-slot="field-label"`. `--field-label-foreground` sets their colour and `--field-label-font-size` their size. Without a value, a label inherits its colour and keeps nova's `text-sm`, 14px. A label in a `Field` with `data-invalid="true"` keeps the `text-destructive` it inherits from the `Field`. The size rule is keyed on `text-sm`; nova gives a label no colour class, so the colour rule has no specificity and any `text-*` class of the app wins over it. 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).
133
133
 
@@ -186,6 +186,41 @@ Use `cn` around `buttonVariants`. `Button` merges the classes that conflict thro
186
186
  </SelectContent>
187
187
  ```
188
188
 
189
+ - **Pick a date with `Popover` and `Calendar`.** Do not use `<input type="date">` or `Input type="date"`. The browser draws their popup, and it does not follow the theme, the direction or the language of the app. shadcn/ui ships the date picker as example code only: the base-nova registry has `calendar` and `calendar-example`, and no `date-picker` item. Thus the app composes it from `Popover`, `PopoverTrigger`, `PopoverContent` and `Calendar`, and keeps it in the app. Know these traps:
190
+ - `Calendar` submits nothing. Put the day in a hidden input as `yyyy-MM-dd`, so `FormData` keeps working. Build the string from the local day (`getFullYear`, `getMonth`, `getDate`). `toISOString()` gives the day in UTC, which is the day before or after in many time zones.
191
+ - Set a bound with `disabled`, for example `disabled={{ after: today }}`, not with `max`.
192
+ - For a birth date, set `captionLayout="dropdown"` with `startMonth` and `endMonth`, so the user picks the year from a list.
193
+ - For another language, pass a locale of `react-day-picker/locale` and the `dir` of the page, for example `locale={ar} dir="rtl"`.
194
+ - For a date and a time, put an `Input type="time"` beside the calendar, as the example of shadcn/ui does.
195
+
196
+ `zukhruf/no-native-control` of `@zukhruf/eslint` refuses a date, checkbox, radio or range `<input>`, and names the component to use.
197
+
198
+ ```tsx
199
+ const today = new Date();
200
+ const [born, setBorn] = useState<Date>();
201
+ const value = born
202
+ ? `${born.getFullYear()}-${String(born.getMonth() + 1).padStart(2, '0')}-${String(born.getDate()).padStart(2, '0')}`
203
+ : '';
204
+
205
+ <Popover>
206
+ <PopoverTrigger render={<Button variant="outline" />}>
207
+ {born ? born.toLocaleDateString() : 'Pick a date'}
208
+ </PopoverTrigger>
209
+ <PopoverContent className="w-auto p-0">
210
+ <Calendar
211
+ mode="single"
212
+ selected={born}
213
+ onSelect={setBorn}
214
+ disabled={{ after: today }}
215
+ captionLayout="dropdown"
216
+ startMonth={new Date(today.getFullYear() - 120, 0)}
217
+ endMonth={today}
218
+ />
219
+ </PopoverContent>
220
+ </Popover>
221
+ <input type="hidden" name="birthDate" value={value} />
222
+ ```
223
+
189
224
  - **Give a `SelectTrigger` the width that you need.** `SelectTrigger` is `w-fit` (`src/components/select.tsx`). An app that moves from an old copy adds `w-full` where the old copy had it. The migrations of the apps found this.
190
225
  - **Mount one `Toaster`.** By default, each `Toaster` reads the one `toast` manager of the package (`toastManager = toast` in `src/components/toast.tsx`). An app that moves from an old copy moves all of its toasts in one commit, and never mounts two Toasters at once.
191
226
  - **Know that the stylesheet changes the `data-*` variants of your own classes too.** `theme.css` imports `shadcn/tailwind.css`, and its `@custom-variant` rules redefine `data-open`, `data-closed`, `data-checked`, `data-unchecked`, `data-selected`, `data-disabled`, `data-active`, `data-horizontal` and `data-vertical` (`node_modules/shadcn/dist/tailwind.css`, `shadcn@4.23.0`). Stock Tailwind CSS makes `data-selected:` match an element that has the attribute, with any value ([Tailwind CSS: data attributes](https://tailwindcss.com/docs/hover-focus-and-other-states#data-attributes)). With the stylesheet, `data-selected:` matches only `[data-selected="true"]`. `data-open:`, `data-closed:`, `data-checked:`, `data-unchecked:`, `data-disabled:` and `data-active:` do not match the value `"false"`, and all of them except `data-disabled:` also match the same value of `data-state`, for example `[data-state="open"]`. `data-horizontal:` and `data-vertical:` match `[data-orientation="horizontal"]` and `[data-orientation="vertical"]`. These rules apply to each class of the app, not only to the components. For a different value, write the full form, for example `data-[selected=false]:`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/shadcn",
3
- "version": "0.8.57",
3
+ "version": "0.8.59",
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
@@ -133,6 +133,28 @@
133
133
  color-mix(in oklab, var(--input) 30%, transparent)
134
134
  );
135
135
  }
136
+
137
+ /*
138
+ * a date picker's trigger is a PopoverTrigger rendered as an outline Button,
139
+ * a field like a SelectTrigger, so it takes the token too; only the outline
140
+ * variant carries bg-background and dark:bg-input/30, so a ghost or default
141
+ * Button as a trigger keeps its look, and so does an outline Button that
142
+ * opens no popover; a hovered or open trigger keeps its nova muted background
143
+ */
144
+ [data-slot='popover-trigger'].group\/button.bg-background:not(:hover):not(
145
+ [aria-expanded='true']
146
+ ) {
147
+ background-color: var(--control-background, var(--background));
148
+ }
149
+
150
+ [data-slot='popover-trigger'].group\/button.dark\:bg-input\/30:not(
151
+ :hover
152
+ ):not([aria-expanded='true']):is(.dark, .dark *) {
153
+ background-color: var(
154
+ --control-background,
155
+ color-mix(in oklab, var(--input) 30%, transparent)
156
+ );
157
+ }
136
158
  }
137
159
 
138
160
  /*