Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/pages/project/instances/InstancesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
useQueryTable,
} from '@oxide/table'
import {
Button,
EmptyMessage,
Instances24Icon,
PageHeader,
PageTitle,
Refresh16Icon,
TableActions,
buttonStyle,
} from '@oxide/ui'
Expand Down Expand Up @@ -76,10 +78,7 @@ export function InstancesPage() {
const { Table, Column } = useQueryTable(
'instanceList',
{ path: projectParams },
{
refetchInterval: 5000,
keepPreviousData: true,
}
{ keepPreviousData: true }
)

if (!instances) return null
Expand All @@ -90,6 +89,9 @@ export function InstancesPage() {
<PageTitle icon={<Instances24Icon />}>Instances</PageTitle>
</PageHeader>
<TableActions>
<Button size="icon" variant="ghost" onClick={refetchInstances}>
<Refresh16Icon />
</Button>
<Link
to={pb.instanceNew({ orgName, projectName })}
className={buttonStyle({ size: 'sm', variant: 'default' })}
Expand Down
25 changes: 20 additions & 5 deletions libs/ui/lib/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assertUnreachable } from '@oxide/util'

import './button.css'

export const buttonSizes = ['sm', 'base'] as const
export const buttonSizes = ['sm', 'icon', 'base'] as const
export const variants = ['default', 'ghost', 'link'] as const
export const colors = ['primary', 'secondary', 'destructive', 'notice'] as const

Expand All @@ -17,6 +17,8 @@ export type Color = typeof colors[number]

const sizeStyle: Record<ButtonSize, string> = {
sm: 'h-8 px-3 text-mono-sm svg:w-4',
// meant for buttons that only contain a single icon
icon: 'h-8 w-8 text-mono-sm svg:w-4',
base: 'h-10 px-3 text-mono-md svg:w-5',
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to make icon? a separate boolean prop, but unless it put on all the relevant size styles, it would rely on the caller also passing size="sm", which is stupid. And if it does put all the relevant size styles, it's a size. So I made it a size.


Expand Down Expand Up @@ -70,7 +72,17 @@ type ButtonStyleProps = {
color?: Color
}

export type ButtonProps = React.ComponentPropsWithRef<'button'> &
export type ButtonProps = Pick<
React.ComponentProps<'button'>,
| 'className'
| 'onClick'
| 'aria-disabled'
| 'disabled'
| 'children'
| 'type'
| 'title'
| 'form'
> &
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not at all necessary, and maybe this is a me thing, but 256 more drives me crazy. I feel like I'm staring into the abyss.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's fine. It's a code change to address tooltip content though which seems to be a bit of a smell, but I agree the tooltip isn't incredibly helpful.

We should probably change these to interfaces anyway. Doing so it basically just won't show anything in the tooltip anyway, ha. That doesn't make the tooltip experience any better, but maybe it would assuage the aesthetic concern of the ... 256 more ... message without the prop restriction.

Copy link
Collaborator Author

@david-crespo david-crespo Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just the tooltip content, it's also the real possibility that there could be buttons out there with any of those props. I like being able to rule that out.

ButtonStyleProps & {
innerClassName?: string
loading?: boolean
Expand Down Expand Up @@ -106,6 +118,7 @@ const noop: MouseEventHandler<HTMLButtonElement> = (e) => {
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
type = 'button',
children,
size,
variant,
Expand All @@ -116,7 +129,8 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
disabled,
onClick,
'aria-disabled': ariaDisabled,
...rest
form,
title,
},
ref
) => {
Expand All @@ -126,11 +140,12 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
'visually-disabled': disabled,
})}
ref={ref}
type="button"
type={type}
onMouseDown={disabled ? noop : undefined}
onClick={disabled ? noop : onClick}
aria-disabled={disabled || ariaDisabled}
{...rest}
form={form}
title={title}
>
<>
{loading && <Spinner className="absolute" />}
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/lib/button/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Ghost
*/
.btn-primary-ghost {
@apply border text-accent border-accent-tertiary hover:bg-accent-secondary disabled:bg-transparent;
@apply border text-secondary border-default hover:bg-hover disabled:bg-transparent;
}

/* Removing `-ghost` so this version is default `btn-secondary` */
Expand Down