diff options
Diffstat (limited to 'src/ui/objects/Card.tsx')
| -rw-r--r-- | src/ui/objects/Card.tsx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ui/objects/Card.tsx b/src/ui/objects/Card.tsx new file mode 100644 index 0000000..fd565e1 --- /dev/null +++ b/src/ui/objects/Card.tsx | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts"; | ||
| 2 | |||
| 3 | export type Props<Tag extends HTMLTag> = Polymorphic<{ | ||
| 4 | "as"?: Tag; | ||
| 5 | "list"?: boolean; | ||
| 6 | "quiet"?: boolean; | ||
| 7 | "thumbnail"?: boolean; | ||
| 8 | "border"?: boolean; | ||
| 9 | "no-shadow"?: boolean; | ||
| 10 | "horizontal"?: boolean; | ||
| 11 | "interactive"?: boolean; | ||
| 12 | "highlight"?: boolean; | ||
| 13 | "children"?: JSX.Element; | ||
| 14 | }>; | ||
| 15 | |||
| 16 | export const Card = <T extends HTMLTag = "article">({ | ||
| 17 | as: Tag = "article" as T, | ||
| 18 | list, | ||
| 19 | quiet, | ||
| 20 | thumbnail, | ||
| 21 | border, | ||
| 22 | "no-shadow": noShadow, | ||
| 23 | horizontal, | ||
| 24 | interactive, | ||
| 25 | highlight, | ||
| 26 | class: cls, | ||
| 27 | ...props | ||
| 28 | }: Props<T>) => ( | ||
| 29 | <Tag | ||
| 30 | class:list={[ | ||
| 31 | "o-card", | ||
| 32 | { | ||
| 33 | "l-card-list__card": list, | ||
| 34 | "o-card--borderless": !border, | ||
| 35 | "o-card--horizontal": horizontal, | ||
| 36 | "o-card--interactive": interactive, | ||
| 37 | "o-card--highlight": highlight, | ||
| 38 | "o-card--quiet": quiet, | ||
| 39 | "o-card--collapsible": Tag === "details", | ||
| 40 | "o-card--shadow": !noShadow, | ||
| 41 | "o-card--thumbnail": thumbnail, | ||
| 42 | }, | ||
| 43 | cls, | ||
| 44 | ]} | ||
| 45 | {...props} | ||
| 46 | /> | ||
| 47 | ); | ||
