diff --git a/app/components/Sidebar.tsx b/app/components/Sidebar.tsx index 4d88d1ea3f..4ac8f141a0 100644 --- a/app/components/Sidebar.tsx +++ b/app/components/Sidebar.tsx @@ -85,7 +85,7 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
diff --git a/app/table/Table.browser.spec.tsx b/app/table/Table.browser.spec.tsx deleted file mode 100644 index 17937bb221..0000000000 --- a/app/table/Table.browser.spec.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ -import { getCoreRowModel, useReactTable, type ColumnDef } from '@tanstack/react-table' -import { expect, test } from 'vitest' -import { render } from 'vitest-browser-react' - -import { getMultiSelectCol } from './columns/select-col' -import { Table } from './Table' - -type Item = { id: string; name: string } - -const data: Item[] = [ - { id: '1', name: 'alpha' }, - { id: '2', name: 'beta' }, -] -const columns: ColumnDef[] = [ - getMultiSelectCol(), - { accessorKey: 'name', header: 'Name' }, -] - -function MultiSelectTable() { - const table = useReactTable({ - columns, - data, - enableRowSelection: true, - getCoreRowModel: getCoreRowModel(), - getRowId: (row) => row.id, - }) - return -} - -test('selects a row by clicking its checkbox cell', async () => { - const screen = await render() - const row = screen.getByRole('row', { name: 'alpha' }) - const headerCheckbox = screen.getByRole('checkbox').first() - - await row.getByRole('cell').first().click() - - await expect.element(row.getByRole('checkbox')).toBeChecked() - await expect.element(headerCheckbox).toBePartiallyChecked() - await expect.element(row).toHaveClass('is-selected') -}) - -test('selects and clears every row from the header checkbox', async () => { - const screen = await render() - const checkboxes = screen.getByRole('checkbox') - const headerCheckbox = checkboxes.first() - - await headerCheckbox.click() - await expect.element(checkboxes.nth(1)).toBeChecked() - await expect.element(checkboxes.nth(2)).toBeChecked() - await expect - .element(screen.getByRole('row', { name: 'alpha' })) - .toHaveClass('is-selected') - await expect.element(screen.getByRole('row', { name: 'beta' })).toHaveClass('is-selected') - - await headerCheckbox.click() - await expect.element(checkboxes.nth(1)).not.toBeChecked() - await expect.element(checkboxes.nth(2)).not.toBeChecked() - await expect - .element(screen.getByRole('row', { name: 'alpha' })) - .not.toHaveClass('is-selected') - await expect - .element(screen.getByRole('row', { name: 'beta' })) - .not.toHaveClass('is-selected') -}) diff --git a/app/table/Table.tsx b/app/table/Table.tsx index 17eacccd74..71f763f94e 100644 --- a/app/table/Table.tsx +++ b/app/table/Table.tsx @@ -6,26 +6,19 @@ * Copyright Oxide Computer Company */ import { flexRender, type Table as TableInstance } from '@tanstack/react-table' -import cn from 'classnames' import type { JSX } from 'react' import { Table as UITable } from '~/ui/lib/Table' export type TableProps = JSX.IntrinsicElements['table'] & { - rowClassName?: string rowHeight?: 'small' | 'large' table: TableInstance - singleSelect?: boolean - multiSelect?: boolean } /** Render a React Table table instance */ export const Table = ({ - rowClassName, rowHeight = 'small', table, - singleSelect, - multiSelect, ...tableProps }: TableProps) => ( @@ -53,47 +46,19 @@ export const Table = ({ ))} - {table.getRowModel().rows.map((row) => { - // For single-select, the entire row is clickable - const rowProps = - singleSelect && row.getCanSelect() // this means single-select only - ? { - className: cn(rowClassName, 'cursor-pointer'), - selected: row.getIsSelected(), - // select only this row - onClick: () => table.setRowSelection(() => ({ [row.id]: true })), - } - : { - className: rowClassName, - selected: - multiSelect && row.getCanMultiSelect() ? row.getIsSelected() : undefined, - } - - // For multi-select, assume the first cell is the checkbox and make the - // whole cell clickable - const firstCellProps = - multiSelect && row.getCanMultiSelect() - ? { - className: 'cursor-pointer', - onClick: () => row.toggleSelected(), - } - : {} - - return ( - - {row.getAllCells().map((cell, i) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - ) - })} + {table.getRowModel().rows.map((row) => ( + + {row.getAllCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + ))} ) diff --git a/app/table/columns/select-col.tsx b/app/table/columns/select-col.tsx deleted file mode 100644 index c34a0e7990..0000000000 --- a/app/table/columns/select-col.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ -import type { Row, Table } from '@tanstack/react-table' - -import { Checkbox } from '~/ui/lib/Checkbox' -import { Radio } from '~/ui/lib/Radio' - -// only needs to be a function because of the generic params -export const getSelectCol = () => ({ - id: 'select', - header: '', - cell: ({ row }: { row: Row }) => { - // `onChange` is empty to suppress react warning. Actual trigger happens in `Table.tsx` - return {}} /> - }, -}) - -export const getMultiSelectCol = () => ({ - id: 'select', - header: ({ table }: { table: Table }) => ( -
- -
- ), - cell: ({ row }: { row: Row }) => ( - // `onChange` is empty to suppress react warning. Actual trigger happens in `Table.tsx` - {}} /> - ), -}) diff --git a/app/ui/lib/CardBlock.tsx b/app/ui/lib/CardBlock.tsx index 71cfa1c122..6abdb2682e 100644 --- a/app/ui/lib/CardBlock.tsx +++ b/app/ui/lib/CardBlock.tsx @@ -60,7 +60,7 @@ CardBlock.Header = ({ title, description, children, titleId }: HeaderProps) => ( ) // If there's a table with a scrollbar we want to avoid it adding extra padding at the bottom -CardBlock.Body = classed.div`px-5 py-4 space-y-4 [&>*:last-child[data-simplebar]]:pb-3 [&>*:last-child[data-simplebar]]:-mb-3` +CardBlock.Body = classed.div`px-5 py-4 space-y-4 [&>.ox-table-scroller:last-child]:pb-1 [&>.ox-table-scroller:last-child]:-mb-3` CardBlock.Footer = classed.footer`flex items-center justify-between px-5 pt-4 text-secondary` diff --git a/app/ui/lib/Modal.tsx b/app/ui/lib/Modal.tsx index 155e49356e..7974bffd26 100644 --- a/app/ui/lib/Modal.tsx +++ b/app/ui/lib/Modal.tsx @@ -93,7 +93,7 @@ export function Modal({ ) } -Modal.Body = classed.div`py-2 overflow-y-auto overscroll-none` +Modal.Body = classed.div`py-2 overflow-y-auto overscroll-contain` Modal.Section = classed.div`p-4 space-y-4 border-b border-secondary text-default last-of-type:border-none text-sans-md` diff --git a/app/ui/lib/Popover.tsx b/app/ui/lib/Popover.tsx index 42822f511e..8ad8d13f23 100644 --- a/app/ui/lib/Popover.tsx +++ b/app/ui/lib/Popover.tsx @@ -34,7 +34,7 @@ export function Popover(props: PopoverProps) {
{children} diff --git a/app/ui/lib/SideModal.tsx b/app/ui/lib/SideModal.tsx index cf1307b549..e9390a7f2f 100644 --- a/app/ui/lib/SideModal.tsx +++ b/app/ui/lib/SideModal.tsx @@ -141,7 +141,7 @@ export const ResourceLabel = classed.h3`mt-1.5 flex items-center gap-1.5 text-sa SideModal.Body = ({ children }: { children?: ReactNode }) => (
{children} diff --git a/app/ui/lib/Table.tsx b/app/ui/lib/Table.tsx index 1c5f2690cf..9d26ebe233 100644 --- a/app/ui/lib/Table.tsx +++ b/app/ui/lib/Table.tsx @@ -6,20 +6,21 @@ * Copyright Oxide Computer Company */ import cn from 'classnames' -import React, { type JSX, type ReactElement } from 'react' -import SimpleBar from 'simplebar-react' +import type { JSX } from 'react' import { classed } from '~/util/classed' export type TableProps = JSX.IntrinsicElements['table'] +/** `className` goes on the outer box so sizing classes also size the frame */ export function Table({ className, ...props }: TableProps) { return ( - -
- + // a utility, not in table.css, so CardBlock.Body can override it +
+
+
+
+
+ ) } @@ -38,7 +39,7 @@ Table.HeadCell = ({ className, children, ...props }: TableHeadCellProps) => ( ) -export type TableRowProps = JSX.IntrinsicElements['tr'] & { - selected?: boolean -} -Table.Row = ({ className, selected, ...props }: TableRowProps) => ( - +export type TableRowProps = JSX.IntrinsicElements['tr'] +Table.Row = ({ className, ...props }: TableRowProps) => ( + ) -type RowElt = ReactElement - export type TableBodyProps = JSX.IntrinsicElements['tbody'] -Table.Body = ({ className, children, ...props }: TableBodyProps) => { - const rows = React.Children.toArray(children).map((c, i, siblings) => { - const child = c as RowElt - const beforeSelected = (siblings[i - 1] as RowElt | undefined)?.props.selected - const afterSelected = (siblings[i + 1] as RowElt | undefined)?.props.selected - const className = - child.props.selected && (beforeSelected || afterSelected) - ? cn( - child.props.className, - 'multi-selection', - !beforeSelected && 'selection-start', - !afterSelected && 'selection-end' - ) - : child.props.className - return React.cloneElement(child, { ...child.props, className }) - }) - return ( - - {rows} - - ) -} +Table.Body = (props: TableBodyProps) => export type TableCellProps = JSX.IntrinsicElements['td'] & { height?: 'small' | 'large' } Table.Cell = ({ height = 'small', className, children, ...props }: TableCellProps) => ( -
@@ -48,45 +49,17 @@ Table.HeadCell = ({ className, children, ...props }: TableHeadCellProps) => (
+
div { - border-bottom-width: 0px; - } - - & th, - & td { - min-width: fit-content; - white-space: nowrap; - @apply text-default; - } - - /* - Adds padding to all cells except from - the action cells since they are a fixed width - */ - & td:not(.action-col) > div { - @apply pr-8; - } - - /* First column is sticky */ - & th:first-of-type, - & td:first-of-type { - @apply bg-default sticky left-0 z-10; - } - - /* Border between sticky first column and second column: - first column owns the right border, second column drops its left border */ - & td:first-of-type > div, - & th:first-of-type > div { - @apply border-r; - } - & td:nth-of-type(2) > div, - & th:nth-of-type(2) > div { - @apply border-l-0; + &::-webkit-scrollbar-thumb:hover { + background-color: var(--content-tertiary); } +} - /* - Last column is sticky if it - is a more actions cell - */ - & th.action-col, - & td.action-col { - @apply bg-default sticky right-0 w-10; - } - & th.action-col { - @apply bg-secondary; +/* Chrome ignores the ::-webkit-scrollbar rules above if these are set, so + only apply them where those rules aren't supported (Firefox) */ +@supports not selector(::-webkit-scrollbar) { + .ox-table-scroller { + scrollbar-width: thin; + scrollbar-color: var(--content-quaternary) transparent; } - & th.action-col > div, - & td.action-col > div { - @apply !m-0 w-10 !p-0; + /* Overlay scrollbars take no space and would sit against the table. Kept + small because classic scrollbars reserve their own space on top, and CSS + can't tell the two apart. */ + .ox-table-grid { + padding-bottom: 4px; } +} - & td:last-of-type > div { - @apply -m-px; - } +.ox-table-grid { + display: grid; + width: fit-content; + min-width: 100%; +} - /* - Highlight when hovering over the action-col cell - */ - & td.action-col:hover > div { - @apply bg-raise; - } +.ox-table-grid > * { + grid-area: 1 / 1; +} - /* - We hide the default border and background on the sticky - cells. This is to stop anything underneath it showing through - at the corner. By leaving the cell square, and instead applying - it to the div child which has a rounded-md corner we cover what's - below with a background colour and still keep the styling - */ - & tr:last-of-type td:last-of-type.action-col { - @apply border-r-0 border-b-0 pr-px; - } +.ox-table-frame { + position: sticky; + left: 0; + justify-self: start; + width: 100cqw; + border: 1px solid var(--stroke-default); + border-radius: var(--table-border-radius); + pointer-events: none; + z-index: 20; +} - & tr:last-of-type td:last-of-type.action-col > div { - border-bottom-right-radius: var(--table-border-radius); - } +table.ox-table { + border-collapse: separate; + border-spacing: 0; - & tr:last-of-type td:first-of-type > div { - border-bottom-left-radius: var(--table-border-radius); + & th, + & td { + min-width: fit-content; + white-space: nowrap; + @apply text-default; } - & tr:last-of-type td:last-of-type.action-col:after { - border-bottom-right-radius: var(--table-border-radius); - @apply border-default pointer-events-none absolute top-0 right-0 bottom-0 left-0 z-0 border-r border-b content-['']; + & thead tr:not(:first-child) th { + @apply border-t-0; } - & tr:last-of-type td:last-of-type:not(.action-col) { - border-bottom-right-radius: var(--table-border-radius); + & :is(td, th):first-child { + border-left: 1px solid transparent; } - - & tr:last-of-type td:first-of-type { - @apply !border-b-0 !border-l-0; + /* not the actions header: its 1px right padding already makes it 41px */ + & td:last-child, + & th:last-child:not(.action-col) { + border-right: 1px solid transparent; } - - & tr:last-of-type td:first-of-type:after { - border-bottom-left-radius: var(--table-border-radius); - @apply border-default pointer-events-none absolute top-0 right-0 bottom-0 left-0 border-b border-l content-['']; + & tbody tr:last-child td { + border-bottom: 1px solid transparent; } - & th:first-of-type { - @apply !bg-default border-t-0 border-l-0; + & tbody tr:last-child td > div { + border-bottom-width: 0px; } - & th:first-of-type > div { - border-top-left-radius: var(--table-border-radius); - @apply bg-secondary w-[calc(100%+1px)]; + & tbody tr:last-child td:first-child { + border-bottom-left-radius: calc(var(--table-border-radius) - 1px); } - - & th:first-of-type:after { - border-top-left-radius: var(--table-border-radius); - @apply border-default pointer-events-none absolute top-0 right-0 bottom-0 left-0 border-t border-l content-['']; + & tbody tr:last-child td:last-child { + border-bottom-right-radius: calc(var(--table-border-radius) - 1px); } - & th:last-of-type.action-col { - @apply !bg-default !border-t-0 !border-r-0; + & td:not(.action-col) > div { + @apply pr-8; } - & th:last-of-type.action-col > div { - border-top-right-radius: var(--table-border-radius); - @apply bg-secondary; + & th:first-child, + & td:first-child { + @apply sticky left-0 z-10; } - - & th:last-of-type.action-col:after { - border-top-right-radius: var(--table-border-radius); - @apply border-default pointer-events-none absolute top-0 right-0 bottom-0 left-0 border-t border-r content-['']; + & td:first-child { + @apply bg-default; } - & th:last-of-type:not(.action-col) { - border-top-right-radius: var(--table-border-radius); + & td:first-child > div, + & th:first-child > div { @apply border-r; } - - & tr:not(:first-of-type) th { - @apply border-t-0; - } - - & tr:not(:first-of-type) th:after, - & tr:not(:first-of-type) th:last-of-type:not(.action-col) { - border-top-left-radius: 0; - border-top-right-radius: 0; - @apply border-t-0; - } - - /* === Begin table selection styles === */ - - /** - * Our table selection styles dictate complex behaviors like rounded-md selection corners, - * grouped selections, and seemless border overlap. To acheive this, `box-shadow` properties - * are used for selection border styles. To make this effect possible, special classes were - * added to the table. Those classes are: - * - * - `.is-selected` -- present on every selected row - * - `.multi-selection` -- present on every selected row that has at least one direct sibling which is also selected - * - `.selection-start` -- the first selected item in a `multi-selection` group - * - `.selection-end` -- the last selected item in a `multi-selection` group - */ - - /* Left-most cell of a single selection */ - & .is-selected:not(.multi-selection) td:first-child > div { - border-top-left-radius: 0.1875rem; - border-bottom-left-radius: 0.1875rem; - box-shadow: - -1px -1px var(--stroke-accent), - -1px 1px var(--stroke-accent); - } - - /* Right-most cell of a single selection */ - & .is-selected:not(.multi-selection) td:last-child > div { - border-top-right-radius: 0.1875rem; - box-shadow: - 1px -1px var(--stroke-accent), - 1px 1px var(--stroke-accent); - border-bottom-right-radius: 0.1875rem; - } - - /* All cells of a single selection */ - & .is-selected:not(.multi-selection) td > div { - box-shadow: - 0px 1px var(--stroke-accent), - 0px -1px var(--stroke-accent); - margin-top: -2px; - border-bottom: 0; - height: calc(100% + 1px); + & td:nth-child(2) > div, + & th:nth-child(2) > div { + @apply border-l-0; } - - & .is-selected:not(.multi-selection):last-of-type td > div { - margin-top: -1px; - height: calc(100% + 3px); + /* cover the header's 1px right padding so the border lines up */ + & th:first-child > div { + @apply w-[calc(100%+1px)]; } - /* Defines the top border of a selection */ - & .is-selected td > div { - box-shadow: 0px -1px var(--stroke-accent); + & .action-col { + @apply sticky right-0 w-10; } - - /* Ensures subsequent, interior selected rows don't have a top border */ - & .multi-selection:not(.selection-start):not(.selection-end) td > div { - box-shadow: none; + & td.action-col { + @apply bg-default; } - - /* Adds the selected border for the top left corner of a selection */ - & .selection-start td:first-child > div { - border-top-left-radius: 0.1875rem; - box-shadow: -1px -1px var(--stroke-accent); - margin-right: -3px; + & .action-col > div { + @apply m-0 w-10 p-0; } - /* Ensures subsequent, interior selections have side borders */ - & .multi-selection:not(.selection-start):not(.selection-end) td:first-child > div { - box-shadow: -1px 0px var(--stroke-accent); + & td.action-col:hover > div { + @apply bg-raise; } +} - & .multi-selection:not(.selection-start):not(.selection-end) td:last-child > div { - box-shadow: 1px 0px var(--stroke-accent); - } +/* +Edge shadows toggle with a transition where scroll-state queries are +supported, and otherwise track the first and last 2rem of scroll. +*/ +.ox-table-scroller { + --sticky-col-shadow: light-dark(oklch(0 0 0 / 0.075), oklch(0 0 0 / 0.3)); + --edge-shadow-transition: 250ms ease-out; +} - /* Fills gaps between borders that show up in Safari and Chrome on OSX */ - & .multi-selection:not(.selection-end) td:first-child, - & .multi-selection:not(.selection-end) td:last-child { - @apply border-accent; - } +.ox-table :is(td, th):first-child { + clip-path: inset(0 -40px 0 0); +} +.ox-table .action-col { + clip-path: inset(0 0 0 -40px); +} - /* Adds the selected border for the top right corner of a selection */ - & .selection-start td:last-child > div { - border-top-right-radius: 0.1875rem; - box-shadow: 1px -1px var(--stroke-accent); - } - /* Ensures the top right border and the cell next to it have their box-shadows overlap */ - & .selection-start td:nth-last-child(2) > div { - margin-right: -3px; +/* Tables with no actions column get the same shadow at the right edge, cast + from a box just outside the frame so it matches exactly. */ +.ox-table-grid:not(:has(.action-col)) > .ox-table-frame { + /* clip, not hidden: hidden would make the frame a scroll container, and + the fallback's scroll(nearest) timeline would track it instead */ + overflow: clip; + + &::after { + content: ''; + position: absolute; + left: 100%; + width: 1rem; + top: -1rem; + bottom: -1rem; + box-shadow: -6px 0 8px -2px var(--sticky-col-shadow); + opacity: 0; } +} - & .selection-end td > div { - box-shadow: 0px 1px var(--stroke-accent); +@supports (container-type: scroll-state) { + .ox-table-scroller { + container-type: inline-size scroll-state; } - & .selection-end td > div { - border-bottom: 0; - height: calc(100% + 3px); - margin-top: -5px; - padding-top: 3px; + .ox-table :is(td, th):first-child, + .ox-table .action-col { + transition: box-shadow var(--edge-shadow-transition); } - - /* Account for layout shift at the bottom of the table as best we can */ - & .selection-end:last-of-type td > div { - margin-top: -4px; - height: calc(100% + 8px); - margin-bottom: -1px; + .ox-table-frame::after { + transition: opacity var(--edge-shadow-transition); } - /* Correct for firefox's wider variation in table border spacing */ - @supports (-moz-appearance: none) { - & .selection-end:last-of-type td > div { - margin-top: -2px; - height: calc(100% + 4px); - padding-top: 2px; - padding-bottom: 1px; + @container scroll-state(scrollable: left) { + .ox-table :is(td, th):first-child { + box-shadow: 6px 0 8px -2px var(--sticky-col-shadow); } } - - /* Adds the selected border for the bottom left corner of a selection */ - & .selection-end td:first-child > div { - border-bottom-left-radius: 0.1875rem; - box-shadow: -1px 1px var(--stroke-accent); - margin-right: -4px; - } - - & .selection-end td:last-child > div { - border-bottom-right-radius: 0.1875rem; - box-shadow: 1px 1px var(--stroke-accent); - } - - & .selection-end td:last-child > div, - & .is-selected:not(.multi-selection) td:last-child > div { - @apply before:border-accent-tertiary relative -ml-0.5 border-l-0 before:absolute before:top-0 before:bottom-1 before:left-0.5 before:block before:h-full before:border-l; - /* Avoid layout shift caused by the border being inline with the content */ - padding-left: calc(1rem - 1px); + @container scroll-state(scrollable: right) { + .ox-table .action-col { + box-shadow: -6px 0 8px -2px var(--sticky-col-shadow); + } + /* same selector as the base rule so it wins on specificity */ + .ox-table-grid:not(:has(.action-col)) > .ox-table-frame::after { + opacity: 1; + } } - - /* === End table selection styles === */ } -/* -Drop shadow on a sticky column when content is scrolled under it, driven by -the table's horizontal scroll position. When the table fits, the timeline is -inactive and neither shadow shows. The clip-path stops the shadow spilling -above and below the cell; it's only on while there's a shadow so it doesn't -clip the selected-row border. -*/ -.ox-table { - --sticky-col-shadow: light-dark(oklch(0 0 0 / 0.075), oklch(0 0 0 / 0.6)); -} - -/* Without the guard, browsers lacking scroll timelines would run the animation - with a 0s duration and hold the start shadow's end state on every table */ -@supports (animation-timeline: scroll()) { - .ox-table :is(td, th):first-of-type { +/* without the animation-timeline guard, unsupporting browsers would hold the + end state on every table */ +@supports (animation-timeline: scroll()) and (not (container-type: scroll-state)) { + .ox-table :is(td, th):first-child { animation: sticky-start-shadow linear both; animation-timeline: scroll(nearest inline); animation-range: 0 2rem; } - .ox-table :is(td, th):last-of-type.action-col { + .ox-table .action-col { animation: sticky-end-shadow linear both; animation-timeline: scroll(nearest inline); animation-range: calc(100% - 2rem) 100%; } + .ox-table-frame::after { + animation: table-end-fade linear both; + animation-timeline: scroll(nearest inline); + animation-range: calc(100% - 2rem) 100%; + } } @keyframes sticky-start-shadow { - from { - clip-path: none; - } - 1% { - clip-path: inset(0 -40px 0 0); - } to { - clip-path: inset(0 -40px 0 0); box-shadow: 6px 0 8px -2px var(--sticky-col-shadow); } } @keyframes sticky-end-shadow { from { - clip-path: inset(0 0 0 -40px); box-shadow: -6px 0 8px -2px var(--sticky-col-shadow); } - 99% { - clip-path: inset(0 0 0 -40px); +} +@keyframes table-end-fade { + from { + opacity: 1; } to { - clip-path: none; + opacity: 0; } } - -.simplebar-scrollbar { - top: 0 !important; - height: 8px !important; -} - -.simplebar-scrollbar:before { - background-color: var(--content-quaternary); - left: 0 !important; - top: 0 !important; - right: 0 !important; - border-radius: 8px !important; -} - -.simplebar-hover.simplebar-scrollbar:before { - background-color: var(--content-tertiary); -} - -.simplebar-track.simplebar-horizontal { - height: 8px; -} diff --git a/app/ui/styles/index.css b/app/ui/styles/index.css index 846fcd4140..b361676828 100644 --- a/app/ui/styles/index.css +++ b/app/ui/styles/index.css @@ -31,7 +31,6 @@ @import '@oxide/design-system/styles/dark.css'; @import '@oxide/design-system/styles/light.css'; @import '@oxide/design-system/styles/preflight.css' layer(base); -@import 'simplebar-react/dist/simplebar.min.css' layer(components); @import 'uplot/dist/uPlot.min.css' layer(components); @import '@oxide/design-system/styles/red.css'; @@ -193,11 +192,13 @@ html, body { height: 100%; + /* stop the whole app shell rubber-banding; browsers disagree on whether + html or body controls the viewport, so set both */ + overscroll-behavior-y: none; } body { @apply text-default bg-default font-sans; - overscroll-behavior-y: none; } /* https://github.com/tailwindlabs/tailwindcss/blob/v2.2.4/src/plugins/css/preflight.css#L57 */ diff --git a/package-lock.json b/package-lock.json index c5b44255b3..2fa0e73fa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,6 @@ "remeda": "^2.30.0", "semver": "^7.7.3", "shiki": "^4.5.0", - "simplebar-react": "^3.2.6", "ts-pattern": "^5.8.0", "uplot": "^1.6.32", "uplot-react": "^1.2.4", @@ -3723,17 +3722,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/lodash": { - "version": "4.17.7", - "license": "MIT" - }, - "node_modules/@types/lodash-es": { - "version": "4.17.12", - "license": "MIT", - "dependencies": { - "@types/lodash": "*" - } - }, "node_modules/@types/md5": { "version": "2.3.5", "dev": true, @@ -5968,10 +5956,7 @@ }, "node_modules/lodash": { "version": "4.18.1", - "license": "MIT" - }, - "node_modules/lodash-es": { - "version": "4.18.1", + "dev": true, "license": "MIT" }, "node_modules/lru-cache": { @@ -7156,25 +7141,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/simplebar-core": { - "version": "1.2.6", - "license": "MIT", - "dependencies": { - "@types/lodash-es": "^4.17.6", - "lodash": "^4.17.21", - "lodash-es": "^4.17.21" - } - }, - "node_modules/simplebar-react": { - "version": "3.2.6", - "license": "MIT", - "dependencies": { - "simplebar-core": "^1.2.6" - }, - "peerDependencies": { - "react": ">=16.8.0" - } - }, "node_modules/sirv": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", diff --git a/package.json b/package.json index 7ebefde28a..136628d6c7 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,6 @@ "remeda": "^2.30.0", "semver": "^7.7.3", "shiki": "^4.5.0", - "simplebar-react": "^3.2.6", "ts-pattern": "^5.8.0", "uplot": "^1.6.32", "uplot-react": "^1.2.4", diff --git a/test/visual/regression.e2e.ts b/test/visual/regression.e2e.ts index aa25774140..fb70b06d0e 100644 --- a/test/visual/regression.e2e.ts +++ b/test/visual/regression.e2e.ts @@ -259,6 +259,32 @@ test.describe('Visual Regression', { tag: '@visual' }, () => { }) }) + // none of the standard pages are narrow enough for a table to overflow + const overflowTables = [ + { name: 'inventory sleds', url: '/system/inventory/sleds', heading: 'Inventory' }, + { name: 'instances list', url: `${p}/instances`, heading: 'Instances' }, + ] + for (const { name, url, heading } of overflowTables) { + test(`${name} overflow`, async ({ page }) => { + await page.setViewportSize({ width: 800, height: 900 }) + await page.goto(url, { waitUntil: 'networkidle' }) + await expect(page.getByRole('heading', { name: heading })).toBeVisible() + const table = page.getByRole('table').first() + const slug = name.replaceAll(' ', '-') + for (const position of ['start', 'middle', 'end'] as const) { + // by behavior, not selector, so baselines from older revisions work + await table.evaluate((el, position) => { + let node = el.parentElement + while (node && node.scrollWidth <= node.clientWidth) node = node.parentElement + if (!node) return + const max = node.scrollWidth - node.clientWidth + node.scrollLeft = position === 'start' ? 0 : position === 'middle' ? max / 2 : max + }, position) + await expect(page).toHaveScreenshot(`${slug}-overflow-${position}.png`) + } + }) + } + for (const [name, query] of Object.entries(oxqlQueries)) { test(`oxql ${name}`, async ({ page }) => { await page.goto('/system/metrics-explorer', { waitUntil: 'networkidle' })