Skip to content
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

Remove dependency on React Router #86

Open
david-crespo opened this issue Oct 3, 2024 · 1 comment · Fixed by #87
Open

Remove dependency on React Router #86

david-crespo opened this issue Oct 3, 2024 · 1 comment · Fixed by #87
Assignees

Comments

@david-crespo
Copy link
Collaborator

We use RR in one spot in this repo:

import { Link } from 'react-router-dom'
import { Button, buttonStyle } from '../'
const buttonStyleProps = { variant: 'ghost', size: 'sm', color: 'secondary' } as const
type Props = {
icon?: ReactElement
title: string
body?: string
} & ( // only require buttonTo or onClick if buttonText is present
| { buttonText: string; buttonTo: string }
| { buttonText: string; onClick: () => void }
| { buttonText?: never }
)
export function EmptyMessage(props: Props) {
let button: ReactElement | null = null
if (props.buttonText && 'buttonTo' in props) {
button = (
<Link className={cn('mt-6', buttonStyle(buttonStyleProps))} to={props.buttonTo}>
{props.buttonText}
</Link>
)
} else if (props.buttonText && 'onClick' in props) {
button = (
<Button {...buttonStyleProps} className="mt-6" onClick={props.onClick}>
{props.buttonText}
</Button>
)
}
return (
<div className="m-4 flex max-w-[14rem] flex-col items-center text-center">
{props.icon && (
<div className="mb-4 rounded p-1 leading-[0] text-accent bg-accent-secondary">
{props.icon}
</div>
)}
<h3 className="text-sans-semi-lg">{props.title}</h3>
{props.body && <p className="mt-1 text-sans-md text-secondary">{props.body}</p>}
{button}
</div>
)
}

And it's used only once in the entire org:

https://github.com/oxidecomputer/oxide-computer/blob/f59e4282b775b6ee582535cfc4a44b92a035c370/app/routes/events/index.tsx#L122-L126

If we inline that definition in oxide-computer we can delete EmptyMessage here and remove the dep.

@david-crespo
Copy link
Collaborator Author

Reopened by #100 with use-delegated-links.ts. It's only used on the rfd-site, so we can either inline it there or make it take navigate as an arg so the caller can pass it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant