Skip to content

Commit eac07db

Browse files
authored
docs: Refine Tailwind examples (#9229)
* docs: Refine Tailwind examples * More refinements * fixes * lint
1 parent a4d7687 commit eac07db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+281
-236
lines changed

packages/dev/docs/pages/react-aria/home/ExampleApp.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,19 @@ export function ExampleApp(): React.ReactNode {
174174
return (
175175
<div className="h-full flex flex-col gap-4 p-4 box-border">
176176
<div className="grid grid-cols-[1fr_auto_auto] sm:grid-cols-[1.1fr_auto_auto_1fr_auto] gap-2 items-end">
177-
<SearchField aria-label="Search" value={search} onChange={setSearch} className="col-span-3 sm:col-span-1" />
177+
<SearchField aria-label="Search plants" placeholder="Search plants" value={search} onChange={setSearch} className="col-span-3 sm:col-span-1" />
178178
<DialogTrigger>
179179
<TooltipTrigger>
180-
<Button aria-label="Filters" variant="secondary" className="w-9 h-9 shrink-0 p-0 px-2 relative">
181-
<FilterIcon aria-hidden className="block w-5 h-5" />
180+
<Button aria-label="Filters" variant="secondary" className="!w-9 !h-9 shrink-0 relative">
181+
<FilterIcon aria-hidden className="block w-5 h-5 shrink-0" />
182182
{filters > 0 && <div className="absolute -top-2 -right-2 rounded-full h-4 aspect-square text-white text-xs bg-blue-600">{filters}</div>}
183183
</Button>
184184
<Tooltip>Filters</Tooltip>
185185
</TooltipTrigger>
186186
<Popover showArrow>
187187
<Dialog className="outline outline-0 p-4 box-border max-h-[inherit] overflow-auto w-[350px]">
188188
<Heading slot="title" className="text-lg font-semibold m-0 mb-2">Filters</Heading>
189-
{filters > 0 && <Button onPress={clearFilters} variant="secondary" className="absolute top-4 right-4 py-1 px-2 text-xs">Clear</Button>}
189+
{filters > 0 && <Button onPress={clearFilters} variant="secondary" className="absolute top-4 right-4 h-auto py-1 px-2 text-xs">Clear</Button>}
190190
<div className="flex flex-col gap-4">
191191
<Checkbox isSelected={favorite} onChange={setFavorite}>Favorite</Checkbox>
192192
<TagGroup label="Cycle" selectionMode="multiple" selectedKeys={cycles} onSelectionChange={setCycles} escapeKeyBehavior="none">
@@ -209,7 +209,7 @@ export function ExampleApp(): React.ReactNode {
209209
</DialogTrigger>
210210
<MenuTrigger>
211211
<TooltipTrigger>
212-
<Button aria-label="Columns" variant="secondary" className="w-9 h-9 shrink-0 p-0 hidden sm:block">
212+
<Button aria-label="Columns" variant="secondary" className="!h-9 shrink-0 p-0 hidden sm:inline-flex">
213213
<SlidersIcon aria-hidden className="block w-5 h-5" />
214214
</Button>
215215
<Tooltip>Columns</Tooltip>
@@ -222,7 +222,7 @@ export function ExampleApp(): React.ReactNode {
222222
</Menu>
223223
</MenuTrigger>
224224
<DialogTrigger>
225-
<Button aria-label="Add plant" variant="secondary" className="w-9 h-9 shrink-0 p-0 col-start-5">
225+
<Button aria-label="Add plant" variant="secondary" className="!h-9 shrink-0 p-0 col-start-5">
226226
<PlusIcon aria-hidden className="block w-5 h-5" />
227227
</Button>
228228
<PlantModal>
@@ -237,9 +237,9 @@ export function ExampleApp(): React.ReactNode {
237237
<div className="grid grid-cols-[40px_1fr_auto] gap-x-2 w-full">
238238
<img alt="" src={item.default_image?.thumbnail} className="inline rounded-sm row-span-3 object-contain h-[40px]" />
239239
<span className="truncate capitalize">{item.common_name}</span>
240-
<span className="truncate text-xs text-gray-600 dark:text-zinc-400 col-start-2 row-start-2">{item.scientific_name}</span>
240+
<span className="truncate text-xs text-neutral-600 dark:text-neutral-400 col-start-2 row-start-2">{item.scientific_name}</span>
241241
<MenuTrigger placement="bottom end" >
242-
<Button aria-label="Actions" variant="secondary" className="row-span-2 place-self-center bg-transparent dark:bg-transparent border-transparent dark:border-transparent !p-1"><MoreHorizontal className="w-5 h-5" /></Button>
242+
<Button aria-label="Actions" variant="quiet" className="row-span-2 place-self-center"><MoreHorizontal className="w-5 h-5" /></Button>
243243
<Menu onAction={action => onAction(item, action)}>
244244
<MenuItem id="favorite"><StarIcon aria-hidden className="w-4 h-4" /> {item.isFavorite ? 'Unfavorite' : 'Favorite'}</MenuItem>
245245
<MenuItem id="edit"><PencilIcon aria-hidden className="w-4 h-4" /> Edit…</MenuItem>
@@ -283,7 +283,7 @@ export function ExampleApp(): React.ReactNode {
283283
<div className="grid grid-cols-[40px_1fr] gap-x-2">
284284
<img alt="" src={item.default_image?.thumbnail} className="inline rounded-sm row-span-2 object-contain h-[40px] w-[40px]" />
285285
<span className="truncate capitalize">{item.common_name}</span>
286-
<span className="truncate text-xs text-gray-600 dark:text-zinc-400">{item.scientific_name}</span>
286+
<span className="truncate text-xs text-neutral-600 dark:text-neutral-400">{item.scientific_name}</span>
287287
</div>
288288
</Cell>
289289
);
@@ -297,7 +297,7 @@ export function ExampleApp(): React.ReactNode {
297297
return (
298298
<Cell>
299299
<MenuTrigger>
300-
<Button aria-label="Actions" variant="secondary" className="bg-transparent dark:bg-transparent border-transparent dark:border-transparent !p-1">
300+
<Button aria-label="Actions" variant="quiet">
301301
<MoreHorizontal aria-hidden className="w-5 h-5" />
302302
</Button>
303303
<Menu onAction={action => onAction(item, action)}>
@@ -340,7 +340,7 @@ export function ExampleApp(): React.ReactNode {
340340
}
341341

342342
const labelStyles = {
343-
gray: 'bg-gray-100 text-gray-600 border-gray-200 dark:bg-zinc-700 dark:text-zinc-300 dark:border-zinc-600',
343+
gray: 'bg-neutral-100 text-neutral-600 border-neutral-200 dark:bg-neutral-700 dark:text-neutral-300 dark:border-neutral-600',
344344
green: 'bg-green-100 text-green-700 border-green-200 dark:bg-green-300/20 dark:text-green-400 dark:border-green-300/10',
345345
yellow: 'bg-yellow-100 text-yellow-700 border-yellow-200 dark:bg-yellow-300/20 dark:text-yellow-400 dark:border-yellow-300/10',
346346
blue: 'bg-blue-100 text-blue-700 border-blue-200 dark:bg-blue-400/20 dark:text-blue-300 dark:border-blue-400/10'
@@ -399,7 +399,7 @@ function PlantDialog({item, onSave}: {item?: Plant | null, onSave: (item: Plant)
399399
<>
400400
<Heading
401401
slot="title"
402-
className="text-2xl font-semibold leading-6 my-0 text-slate-700 dark:text-zinc-300">
402+
className="text-2xl font-semibold leading-6 my-0 text-neutral-700 dark:text-neutral-300">
403403
{item ? 'Edit Plant' : 'Add Plant'}
404404
</Heading>
405405
<Form
@@ -424,18 +424,18 @@ function PlantDialog({item, onSave}: {item?: Plant | null, onSave: (item: Plant)
424424
setDroppedImage(URL.createObjectURL(await item.getFile()));
425425
}
426426
}}
427-
className="w-24 sm:w-32 p-2 box-border flex items-center justify-center shrink-0 border-2 border-gray-400 border-dashed rounded-xl text-gray-500 dark:text-gray-300 focus-visible:border-blue-600 forced-colors:focus-visible:border-[Highlight] focus-visible:border-solid drop-target:border-blue-600 forced-colors:drop-target:border-[Highlight] drop-target:border-solid drop-target:bg-blue-200 dark:drop-target:bg-blue-800/60 drop-target:text-blue-600 dark:drop-target:text-blue-300">
427+
className="w-24 sm:w-32 p-2 box-border flex items-center justify-center shrink-0 border-2 border-neutral-400 border-dashed rounded-xl text-neutral-500 dark:text-neutral-300 focus-visible:border-blue-600 forced-colors:focus-visible:border-[Highlight] focus-visible:border-solid drop-target:border-blue-600 forced-colors:drop-target:border-[Highlight] drop-target:border-solid drop-target:bg-blue-200 dark:drop-target:bg-blue-800/60 drop-target:text-blue-600 dark:drop-target:text-blue-300">
428428
{droppedImage
429429
? <img alt="" src={droppedImage} className="w-full h-full object-contain aspect-square" />
430430
: <Text slot="label" className="italic text-sm text-center">Drop or paste image here</Text>
431431
}
432432
<input type="hidden" name="image" value={droppedImage} />
433433
</DropZone>
434434
<div className="flex flex-col gap-3 flex-1 min-w-0">
435-
<ComboBox label="Common Name" name="common_name" isRequired items={plants} defaultInputValue={item?.common_name} allowsCustomValue autoFocus={navigator.maxTouchPoints === 0}>
435+
<ComboBox label="Common Name" placeholder="Enter plant name" name="common_name" isRequired items={plants} defaultInputValue={item?.common_name} allowsCustomValue autoFocus={navigator.maxTouchPoints === 0}>
436436
{plant => <ComboBoxItem>{plant.common_name}</ComboBoxItem>}
437437
</ComboBox>
438-
<TextField label="Scientific Name" name="scientific_name" isRequired defaultValue={item?.scientific_name?.join('')} />
438+
<TextField label="Scientific Name" placeholder="Enter scientific name" name="scientific_name" isRequired defaultValue={item?.scientific_name?.join('')} />
439439
</div>
440440
</div>
441441
<Select label="Cycle" name="cycle" isRequired defaultSelectedKey={item?.cycle}>
@@ -527,10 +527,10 @@ function PlantModal(props: ModalOverlayProps) {
527527
<svg viewBox="0 0 700 620" width={700} height={620}>
528528
<Arrow textX={52} x1={88} x2={130} y={50} href="Dialog.html">Dialog</Arrow>
529529
<Arrow textX={34} x1={88} x2={150} y={150} href="DropZone.html">DropZone</Arrow>
530-
<Arrow textX={54} x1={88} x2={150} y={272} href="Select.html">Select</Arrow>
531-
<Arrow textX={32} x1={88} x2={150} y={492} href="DatePicker.html">DatePicker</Arrow>
532-
<Arrow textX={616} x1={550} x2={612} y={126} marker="markerStart" href="ComboBox.html">ComboBox</Arrow>
533-
<Arrow textX={616} x1={550} x2={612} y={198} marker="markerStart" href="TextField.html">TextField</Arrow>
530+
<Arrow textX={54} x1={88} x2={150} y={274} href="Select.html">Select</Arrow>
531+
<Arrow textX={32} x1={88} x2={150} y={490} href="DatePicker.html">DatePicker</Arrow>
532+
<Arrow textX={616} x1={550} x2={612} y={128} marker="markerStart" href="ComboBox.html">ComboBox</Arrow>
533+
<Arrow textX={616} x1={550} x2={612} y={200} marker="markerStart" href="TextField.html">TextField</Arrow>
534534
<Arrow points="560,90 590,90 590,338 612,338 590,338 590,585 560,585" textX={616} y={338} marker="none" href="Form.html">Form</Arrow>
535535
</svg>
536536
</div>
@@ -539,7 +539,7 @@ function PlantModal(props: ModalOverlayProps) {
539539
{...props}
540540
ref={ref}
541541
className={({isEntering, isExiting}) => `
542-
w-full max-w-md max-h-full overflow-auto rounded-2xl bg-white dark:bg-zinc-800/70 dark:backdrop-blur-2xl dark:backdrop-saturate-200 forced-colors:!bg-[Canvas] box-border p-6 border-box text-left align-middle shadow-2xl bg-clip-padding border border-black/10 dark:border-white/10
542+
w-full max-w-md max-h-full overflow-auto rounded-2xl bg-white dark:bg-neutral-800/70 dark:backdrop-blur-2xl dark:backdrop-saturate-200 forced-colors:!bg-[Canvas] box-border p-6 border-box text-left align-middle shadow-2xl bg-clip-padding border border-black/10 dark:border-white/10
543543
${isEntering ? 'animate-in zoom-in-105 ease-out duration-200' : ''}
544544
${isExiting ? 'animate-out zoom-out-95 ease-in duration-200' : ''}
545545
`} />
@@ -554,16 +554,16 @@ const favoriteButtonStyles = tv({
554554
base: 'group cursor-default align-middle rounded-sm border-0 bg-transparent p-0',
555555
variants: {
556556
isSelected: {
557-
false: 'text-gray-500 dark:text-zinc-400 pressed:text-gray-600 dark:pressed:text-zinc-300',
558-
true: 'text-gray-700 dark:text-slate-300 pressed:text-gray-800 dark:pressed:text-slate-200'
557+
false: 'text-neutral-500 dark:text-neutral-400 pressed:text-neutral-600 dark:pressed:text-neutral-300',
558+
true: 'text-neutral-700 dark:text-neutral-300 pressed:text-neutral-800 dark:pressed:text-neutral-200'
559559
}
560560
}
561561
});
562562

563563
function FavoriteButton(props: ToggleButtonProps) {
564564
return (
565565
<ToggleButton aria-label="Favorite" {...props} className={favoriteButtonStyles}>
566-
<StarIcon className="block w-5 h-5 fill-white dark:fill-zinc-900 group-selected:fill-current" />
566+
<StarIcon className="block w-5 h-5 fill-white dark:fill-neutral-900 group-selected:fill-current" />
567567
</ToggleButton>
568568
);
569569
}

packages/dev/docs/pages/react-aria/home/FocusExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function FocusExample() {
2121
return (
2222
<div className="flex items-center justify-center h-full">
2323
<DialogTrigger>
24-
<Button variant="secondary" className="w-9 h-9 p-0" aria-label="Account"><CircleUser aria-hidden className="inline w-5 h-5" /></Button>
24+
<Button variant="secondary" aria-label="Account"><CircleUser aria-hidden className="inline w-5 h-5" /></Button>
2525
<Popover showArrow className="w-[250px]">
2626
<Dialog className="outline outline-0 p-4 overflow-auto flex flex-col gap-2">
2727
<Heading slot="title" className="text-lg font-semibold m-0 mb-2">Your Account</Heading>

packages/dev/docs/pages/react-aria/home/MouseAnimation.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function MouseAnimation(): ReactNode {
6060
mouseRef.current!.animate({
6161
transform: [
6262
'translate(10px, 10px)',
63-
'translate(110px, 14px)'
63+
'translate(105px, 14px)'
6464
]
6565
}, {duration: 2000, fill: 'forwards', easing: 'ease-in-out'});
6666
}
@@ -97,7 +97,7 @@ export function MouseAnimation(): ReactNode {
9797
perform() {
9898
mouseRef.current!.animate({
9999
transform: [
100-
'translate(110px, 14px)',
100+
'translate(105px, 14px)',
101101
'translate(170px, 150px)'
102102
]
103103
}, {duration: 1500, fill: 'forwards', easing: 'ease-in-out'});
@@ -151,20 +151,20 @@ export function MouseAnimation(): ReactNode {
151151
</g>
152152
</svg>
153153
<TooltipTrigger isOpen={tooltip === 'edit'} onOpenChange={(o) => onOpenChange('edit', o)}>
154-
<Button aria-label="Edit" variant="secondary" className={`w-9 h-9 p-0 relative ${hovered === 'edit' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
154+
<Button aria-label="Edit" variant="secondary" className={`relative ${hovered === 'edit' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
155155
<PencilIcon aria-hidden className="inline w-5 h-5" />
156156
</Button>
157157
<Tooltip>Edit</Tooltip>
158158
</TooltipTrigger>
159159
<TooltipTrigger isOpen={tooltip === 'share'} onOpenChange={(o) => onOpenChange('share', o)}>
160-
<Button aria-label="Share" variant="secondary" className={`w-9 h-9 p-0 relative ${hovered === 'share' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
160+
<Button aria-label="Share" variant="secondary" className={`relative ${hovered === 'share' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
161161
<ShareIcon aria-hidden className="inline w-5 h-5" />
162162
</Button>
163163
<Tooltip>Share</Tooltip>
164164
</TooltipTrigger>
165165
<TooltipTrigger isOpen={tooltip === 'settings'} onOpenChange={(o) => onOpenChange('settings', o)}>
166166
<ButtonContext.Provider value={{isPressed}}>
167-
<Button aria-label="Settings" variant="secondary" className={`w-9 h-9 p-0 relative ${hovered === 'settings' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
167+
<Button aria-label="Settings" variant="secondary" className={`relative ${hovered === 'settings' ? 'bg-gray-200 dark:bg-zinc-500' : ''}`}>
168168
<CogIcon aria-hidden className="inline w-5 h-5" />
169169
</Button>
170170
</ButtonContext.Provider>

packages/dev/s2-docs/pages/react-aria/Modal.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ export const relatedPages = [{'title': 'useModalOverlay', 'url': 'https://react-
6262
<Button>Sign up…</Button>
6363
<Modal {...props}/* PROPS */>
6464
<Dialog>
65+
<Heading slot="title" className="text-xl mt-0">Subscribe to our newsletter</Heading>
66+
<p className="text-sm">Enter your information to subscribe to our newsletter and receive updates about new features and announcements.</p>
6567
<Form>
66-
<Heading slot="title">Sign up</Heading>
67-
<TextField autoFocus label="First Name" />
68-
<TextField label="Last Name" />
69-
<Button slot="close" className="self-end">Submit</Button>
68+
<TextField autoFocus label="Name" placeholder="Enter your full name" />
69+
<TextField label="Email" placeholder="Enter your email" />
70+
<div className="flex gap-2 self-end">
71+
<Button slot="close" variant="secondary">Cancel</Button>
72+
<Button slot="close">Subscribe</Button>
73+
</div>
7074
</Form>
7175
</Dialog>
7276
</Modal>

packages/dev/s2-docs/pages/react-aria/Toolbar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const relatedPages = [{'title': 'useToolbar', 'url': 'https://react-spect
7878
<Underline size={16} />
7979
</ToggleButton>
8080
</ToggleButtonGroup>
81-
<Group aria-label="Clipboard" className="flex gap-1">
81+
<Group aria-label="Clipboard" className="flex gap-1" style={{flexDirection: 'inherit'}}>
8282
<Button aria-label="Copy" variant="secondary">
8383
<ClipboardCopy size={16} />
8484
</Button>

0 commit comments

Comments
 (0)