-
Notifications
You must be signed in to change notification settings - Fork 10
Enhance/storybook alert #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,13 +1,34 @@ | ||||||
| import type { Meta, StoryObj } from "@storybook/react"; | ||||||
| import { useState } from "react"; | ||||||
| import React, { useState } from "react"; | ||||||
| import { | ||||||
| Modal, | ||||||
| ModalHeader, | ||||||
| ModalTitle, | ||||||
| ModalDescription, | ||||||
| ModalFooter, | ||||||
| Button, | ||||||
| Input, | ||||||
| LabeledSwitch, | ||||||
| Field, | ||||||
| FieldLabel, | ||||||
| FieldDescription, | ||||||
| DropdownMenu, | ||||||
| DropdownMenuTrigger, | ||||||
| DropdownMenuContent, | ||||||
| DropdownMenuItem, | ||||||
| } from "./index"; | ||||||
| import { ChevronDownIcon } from "lucide-react"; | ||||||
|
|
||||||
| const ZONE_NAME_HELPER = "Give a meaningful name for your reference"; | ||||||
|
|
||||||
| const COUNTRIES = [ | ||||||
| "Bangladesh", | ||||||
| "United States", | ||||||
| "United Kingdom", | ||||||
| "Canada", | ||||||
| "Australia", | ||||||
| "Germany", | ||||||
| "France", | ||||||
| ] as const; | ||||||
|
|
||||||
| function ModalDemo() { | ||||||
| const [open, setOpen] = useState(false); | ||||||
|
|
@@ -17,27 +38,89 @@ function ModalDemo() { | |||||
| <Modal open={open} onClose={() => setOpen(false)}> | ||||||
| <ModalHeader> | ||||||
| <ModalTitle>Modal Title</ModalTitle> | ||||||
| <ModalDescription>Description text here.</ModalDescription> | ||||||
| </ModalHeader> | ||||||
| <div className="p-6">Modal content.</div> | ||||||
| <ModalFooter> | ||||||
| <Button variant="outline" onClick={() => setOpen(false)}>Cancel</Button> | ||||||
| <Button variant="outline" onClick={() => setOpen(false)}> | ||||||
| Cancel | ||||||
| </Button> | ||||||
| <Button onClick={() => setOpen(false)}>Save</Button> | ||||||
| </ModalFooter> | ||||||
| </Modal> | ||||||
| </> | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| function CreateShippingZoneDemo() { | ||||||
| const [open, setOpen] = useState(false); | ||||||
| const [restOfWorld, setRestOfWorld] = useState(false); | ||||||
|
|
||||||
| return ( | ||||||
| <> | ||||||
| <Button onClick={() => setOpen(true)}>Create Shipping Zone</Button> | ||||||
| <Modal open={open} onClose={() => setOpen(false)} size="default"> | ||||||
| <ModalHeader> | ||||||
| <ModalTitle>Create Shipping Zone</ModalTitle> | ||||||
| </ModalHeader> | ||||||
| <div className="flex flex-col gap-6 px-8 py-6"> | ||||||
| <Field> | ||||||
| <FieldLabel>Zone Name</FieldLabel> | ||||||
| <Input placeholder="Type" /> | ||||||
| <FieldDescription>{ZONE_NAME_HELPER}</FieldDescription> | ||||||
| </Field> | ||||||
|
|
||||||
| <LabeledSwitch | ||||||
| label="Rest of the world" | ||||||
| checked={restOfWorld} | ||||||
| onCheckedChange={(checked) => setRestOfWorld(checked)} | ||||||
| /> | ||||||
|
|
||||||
| <Field> | ||||||
| <FieldLabel>Countries</FieldLabel> | ||||||
| <DropdownMenu> | ||||||
| <DropdownMenuTrigger> | ||||||
| <Button | ||||||
| variant="outline" | ||||||
| className="h-9 w-full justify-between font-normal" | ||||||
| > | ||||||
| Bangladesh, United States | ||||||
| <ChevronDownIcon className="size-4 opacity-50" /> | ||||||
| </Button> | ||||||
| </DropdownMenuTrigger> | ||||||
| <DropdownMenuContent className="w-[var(--anchor-width)]"> | ||||||
| {COUNTRIES.map((country) => ( | ||||||
| <DropdownMenuItem key={country}>{country}</DropdownMenuItem> | ||||||
| ))} | ||||||
| </DropdownMenuContent> | ||||||
| </DropdownMenu> | ||||||
| <FieldDescription>{ZONE_NAME_HELPER}</FieldDescription> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy-paste issue: wrong helper text for the Countries field.
Proposed fix- <FieldDescription>{ZONE_NAME_HELPER}</FieldDescription>
+ <FieldDescription>Select the countries for this shipping zone</FieldDescription>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| </Field> | ||||||
| </div> | ||||||
| <ModalFooter> | ||||||
| <Button variant="outline" onClick={() => setOpen(false)}> | ||||||
| Cancel | ||||||
| </Button> | ||||||
| <Button onClick={() => setOpen(false)}>Create</Button> | ||||||
| </ModalFooter> | ||||||
| </Modal> | ||||||
| </> | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| const meta = { | ||||||
| title: "UI/Modal", | ||||||
| component: Modal, | ||||||
| parameters: { layout: "centered" }, | ||||||
| tags: ["autodocs"], | ||||||
| args: { open: false, onClose: () => {} }, | ||||||
| } satisfies Meta<typeof Modal>; | ||||||
|
|
||||||
| export default meta; | ||||||
|
|
||||||
| type Story = StoryObj<typeof meta>; | ||||||
|
|
||||||
| export const Default: Story = { render: () => <ModalDemo /> }; | ||||||
|
|
||||||
| export const CreateShippingZone: Story = { | ||||||
| render: () => <CreateShippingZoneDemo />, | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,8 +80,9 @@ const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>( | |
| ({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| data-slot="modal-header" | ||
| className={cn( | ||
| "flex flex-col space-y-1.5 text-center sm:text-left border-b border-border py-4 px-8", | ||
| "flex flex-col space-y-1.5 text-center sm:text-left border-b py-4 px-8", | ||
| className, | ||
| )} | ||
|
Comment on lines
+83
to
87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing By dropping the Consider keeping the Tailwind utility and fixing the root cause (likely a CSS reset stripping Proposed fix (modal.tsx)- "flex flex-col space-y-1.5 text-center sm:text-left border-b py-4 px-8",
+ "flex flex-col space-y-1.5 text-center sm:text-left border-b border-border py-4 px-8",The same applies to ModalFooter at Line 153. 🤖 Prompt for AI Agents |
||
| {...props} | ||
|
|
@@ -147,8 +148,9 @@ const ModalFooter = forwardRef<HTMLDivElement, ModalFooterProps>( | |
| ({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| data-slot="modal-footer" | ||
| className={cn( | ||
| "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 border-t border-border py-5 px-8", | ||
| "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 border-t py-5 px-8", | ||
| className, | ||
| )} | ||
| {...props} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -242,6 +242,22 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| -moz-osx-font-smoothing: grayscale; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /* ============================================ | ||||||||||||||||||||||||||||||||||||||||||||||
| Modal Header (overrides reset border-color) | ||||||||||||||||||||||||||||||||||||||||||||||
| ============================================ */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| .pui-root [data-slot="modal-header"] { | ||||||||||||||||||||||||||||||||||||||||||||||
| border-bottom: 1px solid #E9E9E9; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /* ============================================ | ||||||||||||||||||||||||||||||||||||||||||||||
| Modal Footer (overrides reset border-color) | ||||||||||||||||||||||||||||||||||||||||||||||
| ============================================ */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| .pui-root [data-slot="modal-footer"] { | ||||||||||||||||||||||||||||||||||||||||||||||
| border-top: 1px solid #E9E9E9; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+249
to
+259
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded color These overrides should use the existing Proposed fix .pui-root [data-slot="modal-header"] {
- border-bottom: 1px solid `#E9E9E9`;
+ border-bottom-color: var(--border);
}
.pui-root [data-slot="modal-footer"] {
- border-top: 1px solid `#E9E9E9`;
+ border-top-color: var(--border);
}If 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /* ============================================ | ||||||||||||||||||||||||||||||||||||||||||||||
| Component Base Styles | ||||||||||||||||||||||||||||||||||||||||||||||
| ============================================ */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
col-start-2has no effect in theWithButtonsstory.The Alert grid only switches to a 2-column layout (
grid-cols-[auto_1fr]) when ithas-[>svg]as a direct child. In this story, the SVG (fromAlertIcon) is nested inside the<div className="flex ...">wrapper, so the grid stays single-column andcol-start-2on line 134 is dead CSS.If the intent is a single-row horizontal layout, the class can simply be removed. If you want the 2-column grid to activate, move
<AlertIcon>out of the flex wrapper to be a direct child of<Alert>.🤖 Prompt for AI Agents