Skip to content

Commit 4362d17

Browse files
committed
Use design system components
1 parent efde0c7 commit 4362d17

12 files changed

Lines changed: 223 additions & 492 deletions

package-lock.json

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@googlemaps/js-api-loader": "^1.16.10",
13+
"@raspberrypifoundation/design-system-react": "^2.9.2",
1314
"react": "^18.3.1",
1415
"react-dom": "^18.3.1"
1516
},

src/components/Alert.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import type { ReactNode } from 'react'
2-
import { InfoIcon, ErrorIcon } from './icons'
2+
import { Alert as DSAlert } from '@raspberrypifoundation/design-system-react'
33

44
interface AlertProps {
55
variant: 'info' | 'error'
6-
title: ReactNode
6+
title: string
77
children?: ReactNode
88
}
99

10+
/** Thin wrapper over the design system Alert, keeping this app's variant names. */
1011
export function Alert({ variant, title, children }: AlertProps) {
1112
return (
12-
<div className={`alert alert-${variant}`} role={variant === 'error' ? 'alert' : undefined}>
13-
<div className="alert-header">
14-
<span className="icon">{variant === 'info' ? <InfoIcon /> : <ErrorIcon size={24} />}</span>
15-
<span>{title}</span>
16-
</div>
17-
{children && <div className="alert-body">{children}</div>}
18-
</div>
13+
<DSAlert type={variant === 'error' ? 'error' : 'information'} title={title}>
14+
{children}
15+
</DSAlert>
1916
)
2017
}

src/components/Button.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
import type { ButtonHTMLAttributes, ReactNode } from 'react'
1+
import type { MouseEvent, ReactNode } from 'react'
2+
import { Button as DSButton } from '@raspberrypifoundation/design-system-react'
23

3-
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4+
interface ButtonProps {
45
variant?: 'primary' | 'secondary'
56
icon?: ReactNode
6-
children: ReactNode
7+
children: string
8+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void
9+
disabled?: boolean
710
}
811

9-
export function Button({ variant = 'primary', icon, children, ...rest }: ButtonProps) {
12+
/** Thin wrapper over the design system Button, keeping this app's call-site API. */
13+
export function Button({ variant = 'primary', icon, children, onClick, disabled }: ButtonProps) {
1014
return (
11-
<button className={`btn btn-${variant}`} {...rest}>
12-
{icon}
13-
{children}
14-
</button>
15+
<DSButton
16+
type={variant}
17+
text={children}
18+
icon={icon}
19+
iconPosition="left"
20+
onClick={onClick}
21+
disabled={disabled}
22+
/>
1523
)
1624
}

0 commit comments

Comments
 (0)