|
5 | 5 | * |
6 | 6 | * Copyright Oxide Computer Company |
7 | 7 | */ |
8 | | -import { Link } from 'react-router-dom' |
9 | 8 |
|
10 | 9 | import { OpenLink12Icon } from '@oxide/design-system/icons/react' |
11 | 10 |
|
12 | | -import { Button, buttonStyle } from '~/ui/lib/Button' |
| 11 | +import { classed } from '~/util/classed' |
13 | 12 |
|
14 | | -type Props = { |
15 | | - title: string |
16 | | - docs?: { |
17 | | - text: string |
18 | | - link: string |
19 | | - } |
| 13 | +const LearnMore = ({ href, text }: { href: string; text: React.ReactNode }) => ( |
| 14 | + <> |
| 15 | + Learn more about{' '} |
| 16 | + <a href={href} className="text-accent-secondary hover:text-accent"> |
| 17 | + {text} |
| 18 | + <OpenLink12Icon className="ml-1 align-middle" /> |
| 19 | + </a> |
| 20 | + </> |
| 21 | +) |
| 22 | + |
| 23 | +type FooterProps = { |
| 24 | + /** Link text */ |
20 | 25 | children: React.ReactNode |
21 | | - /** String action is a link */ |
22 | | - cta: string | (() => void) |
23 | | - ctaText: string |
| 26 | + docsLink?: { text: string; href: string } |
24 | 27 | } |
25 | 28 |
|
26 | | -export const SettingsGroup = ({ title, docs, children, cta, ctaText }: Props) => { |
27 | | - return ( |
28 | | - <div className="w-full max-w-[660px] rounded-lg border text-sans-md text-secondary border-default"> |
29 | | - <div className="p-6"> |
30 | | - <div className="mb-1 text-sans-lg text-default">{title}</div> |
31 | | - {children} |
32 | | - </div> |
33 | | - <div className="flex items-center justify-between border-t px-6 py-3 border-default"> |
34 | | - {/* div always present to keep the button right-aligned */} |
35 | | - <div className="text-tertiary"> |
36 | | - {docs && ( |
37 | | - <> |
38 | | - Learn more about{' '} |
39 | | - <a href={docs.link} className="text-accent-secondary hover:text-accent"> |
40 | | - {docs.text} |
41 | | - <OpenLink12Icon className="ml-1 align-middle" /> |
42 | | - </a> |
43 | | - </> |
44 | | - )} |
45 | | - </div> |
46 | | - |
47 | | - {typeof cta === 'string' ? ( |
48 | | - <Link to={cta} className={buttonStyle({ size: 'sm' })}> |
49 | | - {ctaText} |
50 | | - </Link> |
51 | | - ) : ( |
52 | | - <Button size="sm" onClick={cta}> |
53 | | - {ctaText} |
54 | | - </Button> |
55 | | - )} |
56 | | - </div> |
| 29 | +/** Use size=sm on buttons and links! */ |
| 30 | +export const SettingsGroup = { |
| 31 | + Container: classed.div`w-full max-w-[660px] rounded-lg border text-sans-md text-secondary border-default`, |
| 32 | + Body: classed.div`p-6`, |
| 33 | + Title: classed.div`mb-1 text-sans-lg text-default`, |
| 34 | + Footer: ({ children, docsLink }: FooterProps) => ( |
| 35 | + <div className="flex items-center justify-between border-t px-6 py-3 border-default"> |
| 36 | + {/* div always present to keep the buttons right-aligned */} |
| 37 | + <div className="text-tertiary">{docsLink && <LearnMore {...docsLink} />}</div> |
| 38 | + <div className="flex gap-3">{children}</div> |
57 | 39 | </div> |
58 | | - ) |
| 40 | + ), |
59 | 41 | } |
0 commit comments