-
Notifications
You must be signed in to change notification settings - Fork 1
Make design system #42
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Collaborator
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. Please add the missing icons:
Collaborator
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. And recheck others |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Button, type ButtonProps, Spinner } from '@heroui/react' | ||
| import type { ReactNode } from 'react' | ||
|
|
||
| export interface UiButtonProps extends Omit<ButtonProps, 'children'> { | ||
| isLoading?: boolean | ||
| loadingText?: ReactNode | ||
| startContent?: ReactNode | ||
| endContent?: ReactNode | ||
| children?: ReactNode | ||
| } | ||
|
|
||
| export function UiButton({ | ||
| isLoading, | ||
| loadingText, | ||
| isDisabled, | ||
| startContent, | ||
| endContent, | ||
| children, | ||
| ...props | ||
| }: UiButtonProps) { | ||
| return ( | ||
| <Button isDisabled={isDisabled || isLoading} {...props}> | ||
| {isLoading ? <Spinner size='sm' color='current' aria-hidden /> : startContent} | ||
|
Collaborator
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. |
||
| {isLoading ? (loadingText ?? children) : children} | ||
| {!isLoading && endContent} | ||
|
Collaborator
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.
|
||
| </Button> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { Card, type CardProps } from '@heroui/react' | ||
|
|
||
| export type UiCardProps = CardProps | ||
|
|
||
| export const UiCard = Object.assign((props: UiCardProps) => <Card {...props} />, { | ||
|
Collaborator
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. No need to override |
||
| Header: Card.Header, | ||
| Title: Card.Title, | ||
| Description: Card.Description, | ||
| Content: Card.Content, | ||
| Footer: Card.Footer, | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { | ||
| Description, | ||
| FieldError, | ||
| Input, | ||
| InputGroup, | ||
| Label, | ||
| TextField, | ||
| type TextFieldProps, | ||
| } from '@heroui/react' | ||
| import type { ReactNode } from 'react' | ||
|
|
||
| export interface UiInputProps extends Omit<TextFieldProps, 'children'> { | ||
| label?: ReactNode | ||
| placeholder?: string | ||
| description?: ReactNode | ||
| errorMessage?: ReactNode | ||
| startContent?: ReactNode | ||
| endContent?: ReactNode | ||
| } | ||
|
|
||
| export function UiInput({ | ||
|
Collaborator
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. Let's name it |
||
| label, | ||
| placeholder, | ||
| description, | ||
| errorMessage, | ||
| isInvalid, | ||
| startContent, | ||
| endContent, | ||
| ...props | ||
| }: UiInputProps) { | ||
| const invalid = isInvalid ?? Boolean(errorMessage) | ||
| const hasGroup = Boolean(startContent || endContent) | ||
|
|
||
| return ( | ||
| <TextField isInvalid={invalid} {...props}> | ||
| {label && <Label>{label}</Label>} | ||
| {hasGroup ? ( | ||
| <InputGroup> | ||
| {startContent && <InputGroup.Prefix>{startContent}</InputGroup.Prefix>} | ||
| <InputGroup.Input placeholder={placeholder} /> | ||
| {endContent && <InputGroup.Suffix>{endContent}</InputGroup.Suffix>} | ||
| </InputGroup> | ||
| ) : ( | ||
| <Input placeholder={placeholder} /> | ||
| )} | ||
| {description && !invalid && <Description>{description}</Description>} | ||
| {invalid && errorMessage && <FieldError>{errorMessage}</FieldError>} | ||
| </TextField> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { Modal, type ModalContainerProps } from '@heroui/react' | ||
| import type { ReactNode } from 'react' | ||
|
|
||
| export interface UiModalProps { | ||
| isOpen?: boolean | ||
| defaultOpen?: boolean | ||
| onOpenChange?: (isOpen: boolean) => void | ||
| title?: ReactNode | ||
| children?: ReactNode | ||
| footer?: ReactNode | ||
| trigger?: ReactNode | ||
| size?: ModalContainerProps['size'] | ||
| placement?: ModalContainerProps['placement'] | ||
| isDismissable?: boolean | ||
| showCloseButton?: boolean | ||
| } | ||
|
Comment on lines
+4
to
+16
Collaborator
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. Let's use ModalProps from Hero UI |
||
|
|
||
| export function UiModal({ | ||
| isOpen, | ||
| defaultOpen, | ||
| onOpenChange, | ||
| title, | ||
| children, | ||
| footer, | ||
| trigger, | ||
| size, | ||
| placement, | ||
| isDismissable = true, | ||
| showCloseButton = true, | ||
| }: UiModalProps) { | ||
| return ( | ||
| <Modal.Root isOpen={isOpen} defaultOpen={defaultOpen} onOpenChange={onOpenChange}> | ||
| {trigger ? <Modal.Trigger>{trigger}</Modal.Trigger> : null} | ||
| <Modal.Backdrop isDismissable={isDismissable}> | ||
| <Modal.Container size={size} placement={placement}> | ||
| <Modal.Dialog> | ||
| {title || showCloseButton ? ( | ||
| <Modal.Header> | ||
| {title ? <Modal.Heading>{title}</Modal.Heading> : null} | ||
| {showCloseButton ? <Modal.CloseTrigger /> : null} | ||
| </Modal.Header> | ||
| ) : null} | ||
| <Modal.Body>{children}</Modal.Body> | ||
| {footer ? <Modal.Footer>{footer}</Modal.Footer> : null} | ||
| </Modal.Dialog> | ||
| </Modal.Container> | ||
| </Modal.Backdrop> | ||
| </Modal.Root> | ||
| ) | ||
| } | ||
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.
Can component name actually contain spaces? Looking at existing icons, it seems we always use PascalCase names. If that's true, do we need all this normalization logic?
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.
And add one-line comment or name regEx describing the component case