onHoverCell?.({ row: row.index })}
@@ -406,9 +413,8 @@ const TableRow = ({
{...(!directCellContent && {
flex: true,
column: true,
- background: "mainBackground",
_hover: { background: "tableRowBgHover" },
- border: { side: "bottom" },
+ border: { side: "bottom", color: "tableBorder" },
})}
>
{rowContent}
diff --git a/src/components/table/body/rowPLaceholdersRenderer.js b/src/components/table/body/rowPLaceholdersRenderer.js
index 7d814d949..731c81352 100644
--- a/src/components/table/body/rowPLaceholdersRenderer.js
+++ b/src/components/table/body/rowPLaceholdersRenderer.js
@@ -1,11 +1,6 @@
-import React, { isValidElement } from "react"
+import React from "react"
-const RowPlaceholdersRenderer = ({
- RowPlaceholder,
- items = [],
- getPlaceholderOffset,
- ...props
-}) => {
+const RowPlaceholdersRenderer = ({ RowPlaceholder, items = [], getPlaceholderOffset }) => {
if (!items.length) return null
return (
diff --git a/src/components/table/body/rowStyles.test.js b/src/components/table/body/rowStyles.test.js
index 7e226ecec..82eda998e 100644
--- a/src/components/table/body/rowStyles.test.js
+++ b/src/components/table/body/rowStyles.test.js
@@ -21,7 +21,7 @@ const dataColumns = [
]
const selectedTint = getRgbColor("primary", 0.1)({ theme: DefaultTheme })
-const depthTint = "rgba(53, 65, 74, 0.03)"
+const depthTint = "rgba(45, 62, 51, 0.03)"
const selectedRule = { modifier: '[data-selected="true"]>*>.row-content' }
const railRule = { modifier: '[data-selected="true"]>*>.row-content:first-child' }
const depthRule = { modifier: "[data-depth]>*>.row-content" }
@@ -49,6 +49,33 @@ describe.each([
["flex cells", {}],
["direct cells", { virtualizeOptions: { directCellContent: true } }],
])("Table row states with %s", (_, extraProps) => {
+ it("centers cell contents without fixing their height", async () => {
+ renderRows(extraProps)
+
+ const cell = (await rowByText("db")).querySelector('[data-testid="netdata-table-cell-name"]')
+ if (extraProps.virtualizeOptions?.directCellContent) {
+ expect(cell).toHaveStyle({ alignItems: "center" })
+ expect(cell.style.height).toBe("")
+ } else {
+ expect(cell).toHaveStyleRule("align-items", "center")
+ expect(cell).not.toHaveStyleRule("height")
+ }
+ })
+
+ it("preserves an explicit vertical cell alignment", async () => {
+ renderRows({
+ ...extraProps,
+ dataColumns: [{ ...dataColumns[0], align: "start" }],
+ })
+
+ const cell = (await rowByText("db")).querySelector('[data-testid="netdata-table-cell-name"]')
+ if (extraProps.virtualizeOptions?.directCellContent) {
+ expect(cell).toHaveStyle({ alignItems: "flex-start" })
+ } else {
+ expect(cell).toHaveStyleRule("align-items", "flex-start")
+ }
+ })
+
it("marks only selected rows", async () => {
renderRows({ rowSelection: { db: true }, ...extraProps })
@@ -98,6 +125,6 @@ describe("Table row hover", () => {
expect(row).toHaveStyleRule("background-color", rawColors.neutral.grey190, {
modifier: ":hover",
})
- expect(row).toHaveStyleRule("border-bottom", `1px solid ${rawColors.neutral.grey180}`)
+ expect(row).toHaveStyleRule("border-bottom", `1px solid ${DefaultTheme.colors.tableBorder}`)
})
})
diff --git a/src/components/table/body/scrollViewport.js b/src/components/table/body/scrollViewport.js
new file mode 100644
index 000000000..340dd4845
--- /dev/null
+++ b/src/components/table/body/scrollViewport.js
@@ -0,0 +1,82 @@
+import { useLayoutEffect } from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { getColor, getSizeBy } from "@/theme"
+import { useTableState } from "../provider"
+
+const ScrollViewport = styled(Flex)`
+ --table-pinned-left-shadow: none;
+ --table-pinned-right-shadow: none;
+
+ &[data-can-scroll-left] {
+ --table-pinned-left-shadow: block;
+ }
+
+ &[data-can-scroll-right] {
+ --table-pinned-right-shadow: block;
+ }
+
+ &[data-table-suspend-pins] [data-table-pinned] {
+ position: static !important;
+ }
+
+ [data-table-pinned]::after {
+ content: "";
+ position: absolute;
+ inset-block: 0;
+ width: ${getSizeBy(1)};
+ pointer-events: none;
+ }
+
+ [data-table-pinned="left"]::after {
+ display: var(--table-pinned-left-shadow);
+ left: 100%;
+ background-image: linear-gradient(to right, ${getColor("dropdownShadow")}, transparent);
+ }
+
+ [data-table-pinned="right"]::after {
+ display: var(--table-pinned-right-shadow);
+ right: 100%;
+ background-image: linear-gradient(to left, ${getColor("dropdownShadow")}, transparent);
+ }
+`
+
+const updateScrollEdges = (viewport, rtl) => {
+ const maximum = viewport.scrollWidth - viewport.clientWidth
+ const offset = viewport.scrollLeft + (rtl ? maximum : 0)
+ viewport.toggleAttribute("data-can-scroll-left", maximum > 0 && offset > 0.5)
+ viewport.toggleAttribute("data-can-scroll-right", maximum > 0 && maximum - offset > 0.5)
+}
+
+const selectTableGeometry = state => ({
+ sizing: state.columnSizing,
+ pinning: state.columnPinning,
+ visibleColumns: state.visibleColumns,
+})
+
+export const usePinnedEdges = (viewportRef, contentRef, hasPinnedEdges) => {
+ const { sizing, pinning, visibleColumns } = useTableState(selectTableGeometry)
+
+ useLayoutEffect(() => {
+ if (!hasPinnedEdges) return
+
+ const viewport = viewportRef.current
+ const rtl = getComputedStyle(viewport).direction === "rtl"
+ const update = () => updateScrollEdges(viewport, rtl)
+ update()
+
+ viewport.addEventListener("scroll", update, { passive: true })
+ const observer = new ResizeObserver(update)
+ observer.observe(viewport)
+ observer.observe(contentRef.current)
+
+ return () => {
+ observer.disconnect()
+ viewport.removeEventListener("scroll", update)
+ viewport.removeAttribute("data-can-scroll-left")
+ viewport.removeAttribute("data-can-scroll-right")
+ }
+ }, [hasPinnedEdges, sizing, pinning, visibleColumns, viewportRef, contentRef])
+}
+
+export default ScrollViewport
diff --git a/src/components/table/components/action.js b/src/components/table/components/action.js
index d252aa0e4..8a6b39f76 100644
--- a/src/components/table/components/action.js
+++ b/src/components/table/components/action.js
@@ -1,9 +1,40 @@
-import React, { useState, useMemo } from "react"
+import React, { useState, useMemo, useImperativeHandle } from "react"
import Tooltip from "@/components/drops/tooltip"
+import styled, { css } from "styled-components"
import Flex from "@/components/templates/flex"
+import { getColor, getRgbColor } from "@/theme"
import { ConfirmationDialog } from "@/components/confirmation-dialog"
import { Button, IconButton } from "@/components/button"
+const chipInteraction = css`
+ border-color: ${getRgbColor("primary", 0.5)};
+ background: ${getRgbColor("primary", 0.1)};
+
+ .button-icon {
+ fill: ${getColor("primary")};
+ }
+`
+
+const Chip = styled(IconButton)`
+ && {
+ color: ${getColor("textLite")};
+ border-color: var(--table-action-chip-border, ${getColor("border")});
+ }
+
+ &&:hover:not(:disabled):not([aria-disabled="true"]),
+ &&:focus-visible:not(:disabled):not([aria-disabled="true"]) {
+ ${chipInteraction}
+ }
+`
+
+const QuietChip = styled(Chip)`
+ --table-action-chip-border: transparent;
+
+ &&[aria-expanded="true"]:not(:disabled):not([aria-disabled="true"]) {
+ ${chipInteraction}
+ }
+`
+
const Action = ({
id,
icon,
@@ -32,6 +63,10 @@ const Action = ({
label,
TooltipComponent = Tooltip,
ref,
+ rowChip,
+ bulkChip,
+ hiddenControl,
+ activationRef,
...rest
}) => {
const [isConfirmationOpen, setConfirmationOpen] = useState(false)
@@ -48,6 +83,8 @@ const Action = ({
handleAction()
}
+ useImperativeHandle(activationRef, () => onActionClicked)
+
const onActionDeclined = () => {
setConfirmationOpen(false)
handleDecline?.()
@@ -58,7 +95,8 @@ const Action = ({
handleAction?.()
}
- const Component = CustomComponent || (label ? Button : IconButton)
+ const chip = !label && !CustomComponent && (bulkChip ? QuietChip : rowChip ? Chip : null)
+ const Component = CustomComponent || chip || (label ? Button : IconButton)
const componentProps = useMemo(
() => ({
@@ -71,6 +109,15 @@ const Action = ({
flavour,
iconColor,
label,
+ ...(chip
+ ? {
+ type: "button",
+ round: "50%",
+ iconColor: iconColor || "textLite",
+ ...(bulkChip ? { compact: true } : { width: "14px", height: "14px" }),
+ "aria-label": typeof tooltipText === "string" ? tooltipText : id,
+ }
+ : {}),
padding: [0.5],
...(CustomComponent ? { data: currentRow?.original || selectedRows } : {}),
...rest,
@@ -88,6 +135,9 @@ const Action = ({
currentRow?.original,
selectedRows,
CustomComponent,
+ chip,
+ bulkChip,
+ tooltipText,
rest,
]
)
@@ -122,20 +172,24 @@ const Action = ({
handleConfirm={onActionConfirmed}
/>
)}
-
-
-
-
-
+ {!hiddenControl && (
+
+
+
+
+
+ )}
>
)
}
diff --git a/src/components/table/components/pagination.js b/src/components/table/components/pagination.js
index 32a09484a..2d854f033 100644
--- a/src/components/table/components/pagination.js
+++ b/src/components/table/components/pagination.js
@@ -8,7 +8,7 @@ const Counter = styled(Text).attrs({ color: "textLite" })`
font-variant-numeric: tabular-nums;
`
-const Pagination = ({ table }) => {
+const Pagination = ({ table, surface = "mainBackground" }) => {
const {
nextPage,
previousPage,
@@ -28,8 +28,8 @@ const Pagination = ({ table }) => {
height="36px"
padding={[0, 2]}
gap={1}
- background="mainBackground"
- border={{ side: "top", color: "border" }}
+ background={surface}
+ border={{ side: "top", color: "tableBorder" }}
>
({
@@ -75,7 +75,7 @@ describe("Table pagination", () => {
expect(bar).toHaveStyleRule("height", "36px")
expect(bar).toHaveStyleRule("padding", "0 8px")
expect(bar).toHaveStyleRule("gap", "4px")
- expect(bar).toHaveStyleRule("border-top", `1px solid ${rawColors.neutral.grey180}`)
+ expect(bar).toHaveStyleRule("border-top", `1px solid ${DefaultTheme.colors.tableBorder}`)
})
it("renders the counter with tabular numerals in the lite text colour", () => {
@@ -83,6 +83,6 @@ describe("Table pagination", () => {
const counter = screen.getByTestId("pagination-counter")
expect(counter).toHaveStyleRule("font-variant-numeric", "tabular-nums")
- expect(counter).toHaveStyleRule("color", rawColors.neutral.grey120)
+ expect(counter).toHaveStyleRule("color", DefaultTheme.colors.textLite)
})
})
diff --git a/src/components/table/components/rowActionGroup.js b/src/components/table/components/rowActionGroup.js
new file mode 100644
index 000000000..591278478
--- /dev/null
+++ b/src/components/table/components/rowActionGroup.js
@@ -0,0 +1,196 @@
+import React, { useLayoutEffect, useRef, useState } from "react"
+import styled, { useTheme } from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Button } from "@/components/button"
+import Drop from "@/components/drops/drop"
+import { Icon } from "@/components/icon"
+import { controlHeight } from "@/mixins/controlSize"
+import { dropdownBorder, dropdownRound, floatingShadow } from "@/components/drops/dropdownStyles"
+import Action from "./action"
+
+const Panel = styled(Flex)`
+ ${floatingShadow}
+`
+
+const Stack = styled(Flex)`
+ > * + * {
+ margin-inline-start: -${({ theme }) => theme.constants.SIZE_SUB_UNIT}px;
+ }
+`
+
+const StackIcon = ({ icon }) => (
+
+
+
+)
+
+const resolve = (value, row) => (typeof value === "function" ? value(row) : value)
+
+const useAvailableWidth = () => {
+ const ref = useRef(null)
+ const [width, setWidth] = useState(null)
+ useLayoutEffect(() => {
+ const element = ref.current
+ const update = () => {
+ const available = element.clientWidth
+ if (available) setWidth(available)
+ }
+ update()
+ const observer = new ResizeObserver(update)
+ observer.observe(element)
+ return () => observer.disconnect()
+ }, [])
+ return [ref, width]
+}
+
+const RowActionGroup = ({ actions, row, table, testPrefix, inline }) => {
+ const theme = useTheme()
+ const size = Number.parseFloat(controlHeight("default")({ theme }))
+ const gap = theme.constants.SIZE_SUB_UNIT * 2
+ const [groupRef, width] = useAvailableWidth()
+ const triggerRef = useRef(null)
+ const panelRef = useRef(null)
+ const activate = useRef(new Map())
+ const [open, setOpen] = useState(false)
+
+ const visible = actions.flatMap(({ isVisible, ...action }) =>
+ resolve(isVisible, row.original) === false ? [] : [action]
+ )
+ const customCount = visible.filter(action => action.CustomComponent || action.label).length
+ const naturalWidth = visible.length * size + Math.max(0, visible.length - 1) * gap
+ const fits = width === null || naturalWidth <= width
+ const withStack = width >= size * 2 + gap
+ const triggerWidth = withStack ? size * 2 : size
+ let remaining = Math.max(0, Math.floor((width - triggerWidth) / (size + gap)) - customCount)
+ const overflow = fits
+ ? []
+ : visible.filter(action => {
+ if (action.CustomComponent || action.label) return false
+ if (remaining === 0) return true
+ remaining -= 1
+ return false
+ })
+ const showPanel = open && overflow.length > 0
+ const close = () => {
+ setOpen(false)
+ triggerRef.current?.focus()
+ }
+
+ useLayoutEffect(() => {
+ if (showPanel) panelRef.current?.querySelector("button:not(:disabled)")?.focus()
+ if (!showPanel && open) setOpen(false)
+ }, [showPanel, open])
+
+ return (
+ event.stopPropagation()}
+ >
+ {visible.map(
+ ({ id, handleAction, isDisabled, dataGa, disabledTooltipText, tooltipText, ...rest }) => {
+ const inOverflow = overflow.some(action => action.id === id)
+ return (
+ handleAction(row.original, table)}
+ testPrefix={testPrefix}
+ currentRow={row}
+ hiddenControl={inOverflow}
+ activationRef={activation => {
+ if (activation) activate.current.set(id, activation)
+ else activate.current.delete(id)
+ }}
+ />
+ )
+ }
+ )}
+ {overflow.length > 0 && (
+
+ )}
+ {showPanel && (
+ {
+ if (!triggerRef.current?.contains(event.target)) setOpen(false)
+ }}
+ target={triggerRef.current}
+ >
+
+ {overflow.map(action => (
+
+
+ )}
+
+ )
+}
+
+export default RowActionGroup
diff --git a/src/components/table/fluidSizing.js b/src/components/table/fluidSizing.js
new file mode 100644
index 000000000..8765430c4
--- /dev/null
+++ b/src/components/table/fluidSizing.js
@@ -0,0 +1,55 @@
+import { defaultColumnSizing } from "@tanstack/react-table"
+
+const visibleLeaves = columns =>
+ columns.flatMap(column => (column.columns ? visibleLeaves(column.columns) : [column]))
+
+export const fitColumnWidths = (columns, viewportWidth, visibility, pinning, manualSizing) => {
+ const { size, minSize, maxSize } = defaultColumnSizing
+ const pinned = new Set([...(pinning.left || []), ...(pinning.right || [])])
+ const leaves = visibleLeaves(columns)
+ .filter(({ id }) => visibility[id] !== false)
+ .map(column => {
+ const { id, notFlex } = column
+ const maximum = column.maxSize ?? maxSize
+ const minimum = Math.min(column.minSize ?? minSize, maximum)
+ const manual = Number.isFinite(manualSizing[id])
+ const preferred = manual ? manualSizing[id] : (column.size ?? size)
+ return {
+ id,
+ maximum,
+ minimum,
+ width: Math.min(Math.max(preferred, minimum), maximum),
+ fixed: manual || pinned.has(id) || notFlex,
+ }
+ })
+
+ const occupied = leaves.reduce((sum, column) => sum + column.width, 0)
+ let remaining = Math.abs(Math.round(viewportWidth - occupied))
+ const direction = viewportWidth >= occupied ? 1 : -1
+ const capacity = column =>
+ direction === 1 ? column.maximum - column.width : column.width - column.minimum
+ let flexible = leaves.filter(column => !column.fixed && capacity(column) > 0)
+
+ while (remaining > 0 && flexible.length) {
+ const share = Math.max(1, Math.floor(remaining / flexible.length))
+ for (const column of flexible) {
+ const change = Math.min(share, capacity(column), remaining)
+ column.width += direction * change
+ remaining -= change
+ }
+ flexible = flexible.filter(column => capacity(column) > 0)
+ }
+
+ const center = leaves.filter(column => !pinned.has(column.id))
+ const pinnedWidth = leaves.reduce(
+ (sum, column) => (pinned.has(column.id) ? sum + column.width : sum),
+ 0
+ )
+ return {
+ sizes: Object.fromEntries(leaves.map(({ id, width }) => [id, width])),
+ suspendPins:
+ pinnedWidth > 0 &&
+ center.length > 0 &&
+ viewportWidth - pinnedWidth < Math.min(...center.map(column => column.minimum)),
+ }
+}
diff --git a/src/components/table/fluidSizing.test.js b/src/components/table/fluidSizing.test.js
new file mode 100644
index 000000000..e7d730a04
--- /dev/null
+++ b/src/components/table/fluidSizing.test.js
@@ -0,0 +1,82 @@
+import React from "react"
+import { renderWithProviders, screen } from "testUtilities"
+import Table from "./table"
+
+const data = [{ left: "Server", name: "Node", status: "Live", right: "More" }]
+const columns = [
+ { id: "left", size: 120, minSize: 90, maxSize: 200 },
+ { id: "name", size: 180, minSize: 80, maxSize: 300 },
+ { id: "status", size: 150, minSize: 80, maxSize: 300 },
+ { id: "right", size: 80, notFlex: true },
+].map(column => ({ ...column, header: column.id, cell: ({ getValue }) => getValue() }))
+const pinning = { left: ["left"], right: ["right"] }
+
+const mockViewportWidth = width => {
+ const getWidth = Object.getOwnPropertyDescriptor(Element.prototype, "clientWidth").get
+ return jest.spyOn(Element.prototype, "clientWidth", "get").mockImplementation(function () {
+ return this.dataset?.testid === "netdata-table" ? width : getWidth.call(this)
+ })
+}
+
+it("fits untouched columns around pinned columns and a saved width without writing a preference", async () => {
+ const width = mockViewportWidth(450)
+ try {
+ const tableRef = { current: null }
+ const saveWidth = jest.fn()
+ const { rerender } = renderWithProviders(
+
+ )
+ expect(tableRef.current.getColumn("name").getSize()).toBe(130)
+ expect(tableRef.current.getColumn("status").getSize()).toBe(120)
+ expect(tableRef.current.getLeftTotalSize()).toBe(120)
+ expect(tableRef.current.getRightTotalSize()).toBe(80)
+ expect(saveWidth).not.toHaveBeenCalled()
+
+ rerender(
+
+ )
+ expect(tableRef.current.getColumn("name").getSize()).toBe(100)
+ expect(tableRef.current.getColumn("status").getSize()).toBe(150)
+ expect(saveWidth).not.toHaveBeenCalled()
+ } finally {
+ width.mockRestore()
+ }
+})
+
+it("lets pinned sections scroll with the row when they crowd out the center", async () => {
+ const width = mockViewportWidth(190)
+ try {
+ renderWithProviders(
+
+ )
+ expect(
+ (await screen.findByTestId("netdata-table")).getAttribute("data-table-suspend-pins")
+ ).toBe("")
+ } finally {
+ width.mockRestore()
+ }
+})
diff --git a/src/components/table/header/actions/action.js b/src/components/table/header/actions/action.js
index 7908c91ef..9093bae5d 100644
--- a/src/components/table/header/actions/action.js
+++ b/src/components/table/header/actions/action.js
@@ -5,7 +5,6 @@ import { mergeRefs } from "@/utils"
const HeaderAction = ({
isDisabled,
- isVisible,
testPrefix,
id,
icon,
@@ -20,18 +19,17 @@ const HeaderAction = ({
}) => {
const actionRef = useRef()
const disabled = typeof isDisabled === "function" ? isDisabled() : isDisabled
- const visible = typeof isVisible === "function" ? isVisible() : isVisible
return (
handleAction(selectedRows, table)}
tooltipText={tooltipText}
+ {...(!rest.label && typeof tooltipText === "string" ? { "aria-label": tooltipText } : {})}
disabled={(!alwaysEnabled && selectedRows?.length < 1) || disabled}
selectedRows={selectedRows}
disabledTooltipText={
diff --git a/src/components/table/header/actions/actionSurface.test.js b/src/components/table/header/actions/actionSurface.test.js
index 9d84959f6..4d0028f83 100644
--- a/src/components/table/header/actions/actionSurface.test.js
+++ b/src/components/table/header/actions/actionSurface.test.js
@@ -1,37 +1,105 @@
import React from "react"
import "jest-styled-components"
-import { renderWithProviders, screen } from "testUtilities"
+import { renderWithProviders, screen, user, within } from "testUtilities"
+import { waitFor } from "@testing-library/react"
import { DarkTheme } from "@/theme/dark"
+import { DefaultTheme } from "@/theme/default"
+import { getRgbColor } from "@/theme"
import Table from "@/components/table/table"
const data = [{ id: "node-1", name: "Node 1" }]
-const dataColumns = [{ id: "name", accessorKey: "name", header: "Name", cell: ({ getValue }) => getValue() }]
+const dataColumns = [
+ { id: "name", accessorKey: "name", header: "Name", cell: ({ getValue }) => getValue() },
+]
-const renderTable = () =>
+const renderTable = (theme, actions, props) =>
renderWithProviders(
{} } }}
+ bulkActions={actions}
getRowId={row => row.id}
+ {...props}
/>,
- { theme: DarkTheme }
+ { theme }
)
-// The search field is the prominent element in the toolbar; icon actions show a surface only on hover.
-describe("table toolbar icon actions", () => {
- it.each([["download"], ["columnVisibility"]])("%s has no resting surface", id => {
- renderTable()
- const wrapper = screen.getByTestId(new RegExp(`^netdata-table-action-${id}`)).parentElement
- expect(wrapper).not.toHaveStyleRule("background-color", DarkTheme.colors.elementBackground)
- })
-
- it("still shows a surface on hover for an enabled action", () => {
- renderTable()
- const wrapper = screen.getByTestId(/^netdata-table-action-columnVisibility/).parentElement
- expect(wrapper).toHaveStyleRule("background-color", DarkTheme.colors.borderSecondary, {
- modifier: ":hover",
+it.each([DefaultTheme, DarkTheme])(
+ "reveals the selection count and enables bulk actions",
+ async theme => {
+ const download = jest.fn()
+ const acknowledge = jest.fn()
+ renderTable(theme, {
+ acknowledge: {
+ handleAction: acknowledge,
+ icon: "checkmark_s",
+ tooltipText: "Acknowledge selected",
+ confirmation: false,
+ },
+ download: { handleAction: download, alwaysEnabled: true },
})
- })
+ const actor = user()
+ const track = screen.getByRole("group", { name: "Table actions" })
+ const acknowledgeButton = within(track).getByRole("button", { name: "Acknowledge selected" })
+ const downloadButton = within(track).getByRole("button", { name: "Download" })
+ const columnsButton = within(track).getByRole("button", { name: "Columns" })
+
+ expect(acknowledgeButton).toBeDisabled()
+ expect(acknowledgeButton.querySelector('[title="checkmark_s"]')).not.toBeNull()
+ expect(downloadButton.querySelector('[title="download"]')).not.toBeNull()
+ expect(columnsButton.querySelector('[title="columns"]')).not.toBeNull()
+ expect(downloadButton).toHaveStyleRule("min-width", "24px", { modifier: "&&" })
+ expect(downloadButton).toHaveStyleRule("border-radius", "50%")
+ expect(track).toHaveStyleRule("background-color", getRgbColor("textLite", 0.06)({ theme }))
+ await actor.click(downloadButton)
+ expect(download).toHaveBeenCalledWith([], expect.anything())
+
+ const checkbox = within(screen.getByTestId("netdata-table-row")).getByRole("checkbox")
+ await actor.click(checkbox)
+ await waitFor(() => expect(checkbox).toBeChecked())
+ expect(within(track).getByRole("status")).toHaveTextContent("1 selected")
+ expect(track).toHaveAttribute("data-selected")
+ expect(track).toHaveStyleRule("background-color", getRgbColor("primary", 0.06)({ theme }), {
+ modifier: "[data-selected]",
+ })
+ expect(acknowledgeButton).toBeEnabled()
+ await actor.click(acknowledgeButton)
+ expect(acknowledge).toHaveBeenCalledWith([data[0]], expect.anything())
+
+ await actor.click(checkbox)
+ expect(within(track).getByRole("status")).toBeEmptyDOMElement()
+ expect(acknowledgeButton).toBeDisabled()
+ }
+)
+
+it("keeps the columns menu operable with the keyboard", async () => {
+ renderTable(DarkTheme, { download: { handleAction: () => {}, alwaysEnabled: true } })
+ const actor = user()
+ const download = screen.getByRole("button", { name: "Download" })
+ const columns = screen.getByRole("button", { name: "Columns" })
+
+ await actor.click(download)
+ await actor.tab()
+ expect(columns).toHaveFocus()
+ await actor.keyboard("{Enter}")
+ expect(screen.getByText("Show columns")).toBeInTheDocument()
+ expect(columns).toHaveAttribute("aria-expanded", "true")
+})
+
+it("keeps explicit hollow columns and labeled add controls outside the compact track", () => {
+ renderTable(
+ DarkTheme,
+ {
+ download: { handleAction: () => {}, alwaysEnabled: true },
+ addEntry: { handleAction: () => {}, label: "Connect node" },
+ },
+ { columnVisibilityFlavour: "hollow" }
+ )
+
+ const track = screen.getByRole("group", { name: "Table actions" })
+ expect(within(track).getByRole("button", { name: "Download" })).toBeInTheDocument()
+ expect(track).not.toContainElement(screen.getByRole("button", { name: "Columns" }))
+ expect(track).not.toContainElement(screen.getByRole("button", { name: "Connect node" }))
})
diff --git a/src/components/table/header/actions/index.js b/src/components/table/header/actions/index.js
index c8c540f8d..ba2a9d2e2 100644
--- a/src/components/table/header/actions/index.js
+++ b/src/components/table/header/actions/index.js
@@ -4,12 +4,16 @@ import { useTableState } from "../../provider"
import { isRowSelectable } from "../../largeDataSelection"
import useActions from "./useActions"
import Action from "./action"
+import ActionTrack from "./track"
import ColumnVisibility from "./columnVisibility"
const noop = () => {}
const rerenderSelector = state => state.selectedRows
+const fitsTrack = ({ label, CustomComponent, flavour }) =>
+ !label && !CustomComponent && (!flavour || flavour === "borderless")
+
const useSelectedRowsObserver = (table, { onRowSelected = noop, rowSelection }) => {
useTableState(rerenderSelector)
const [selectedRows, setActualSelectedRows] = useState([])
@@ -51,29 +55,52 @@ const HeaderActions = ({
if (!actions.length && !enableColumnVisibility) return null
+ const columnsInTrack = enableColumnVisibility && columnVisibilityFlavour !== "hollow"
+ const columns = enableColumnVisibility && (
+
+ )
+ const visibleActions = actions.flatMap(({ isVisible, ...action }) => {
+ const visible = typeof isVisible === "function" ? isVisible() : isVisible
+ return visible === false ? [] : [action]
+ })
+ const trackedActions = visibleActions.filter(fitsTrack)
+ const showTrack =
+ columnsInTrack || trackedActions.length > 0 || (actions.length > 0 && selectedRows.length > 0)
+ const renderAction = (action, bulkChip) => (
+
+ )
+
return (
-
- {actions.map(action => (
-
- ))}
-
+
+ {showTrack && (
+
+ {trackedActions.map(action => renderAction(action, true))}
+ {columnsInTrack && columns}
+
+ )}
+ {visibleActions
+ .filter(action => !fitsTrack(action))
+ .map(action => renderAction(action, false))}
+ {!columnsInTrack && columns}
)
}
diff --git a/src/components/table/header/actions/track.js b/src/components/table/header/actions/track.js
new file mode 100644
index 000000000..e329b1ca1
--- /dev/null
+++ b/src/components/table/header/actions/track.js
@@ -0,0 +1,63 @@
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { TextSmall } from "@/components/typography"
+import { getRgbColor } from "@/theme"
+
+const Track = styled(Flex)`
+ background-color: ${getRgbColor("textLite", 0.06)};
+ transition:
+ background-color 140ms ease-out,
+ border-color 140ms ease-out;
+
+ &[data-selected] {
+ background-color: ${getRgbColor("primary", 0.06)};
+ border-color: ${getRgbColor("primary", 0.5)};
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`
+
+const Selection = styled(Flex)`
+ &:empty {
+ position: absolute;
+ }
+`
+
+const ActionTrack = ({ selectedCount, children }) => (
+
+)
+
+export default ActionTrack
diff --git a/src/components/table/header/actions/useActions.js b/src/components/table/header/actions/useActions.js
index 63c082d90..9e165df27 100644
--- a/src/components/table/header/actions/useActions.js
+++ b/src/components/table/header/actions/useActions.js
@@ -12,10 +12,22 @@ export const supportedBulkActions = {
actionButtonDirection: "reverse",
},
download: { icon: "download", confirmation: false, tooltipText: "Download" },
- toggleAlarm: { icon: "alarm_off", confirmation: false, tooltipText: "Turn of Alarms" },
+ toggleAlarm: { icon: "alarm_off", confirmation: false, tooltipText: "Toggle alarms" },
userSettings: { icon: "user", confirmation: false, tooltipText: "User Settings" },
- addEntry: { icon: "plus", alwaysEnabled: true, flavour: "default", iconColor: "white" },
- remove: { icon: "removeNode", confirmation: true, confirmLabel: "Yes", declineLabel: "No" },
+ addEntry: {
+ icon: "plus",
+ alwaysEnabled: true,
+ flavour: "default",
+ iconColor: "white",
+ tooltipText: "Add entry",
+ },
+ remove: {
+ icon: "removeNode",
+ confirmation: true,
+ tooltipText: "Remove",
+ confirmLabel: "Yes",
+ declineLabel: "No",
+ },
columnVisibility: { icon: "columns", alwaysEnabled: true, tooltipText: "Columns" },
}
diff --git a/src/components/table/header/index.js b/src/components/table/header/index.js
index 5c4dd7720..62de6e449 100644
--- a/src/components/table/header/index.js
+++ b/src/components/table/header/index.js
@@ -22,6 +22,7 @@ const Header = ({
bulkActions,
enableColumnVisibility,
enableCustomSearch,
+ surface = "mainBackground",
}) => {
tableMeta = useMemo(
() => (typeof tableMeta === "function" ? tableMeta({}, {}, null) : tableMeta),
@@ -42,13 +43,14 @@ const Header = ({
data-testid="netdata-table-header-container"
data-noprint
width="100%"
+ height={{ min: 12 }}
zIndex={10}
- background="mainBackground"
+ background={surface}
position="relative"
gap={2}
alignItems="center"
padding={[2, 4]}
- border={{ side: "bottom", color: "border" }}
+ border={{ side: "bottom", color: "tableBorder" }}
flexWrap
{...tableMeta.bulkActionsStyles}
>
diff --git a/src/components/table/header/index.test.js b/src/components/table/header/index.test.js
index 642cc7a21..a7798263f 100644
--- a/src/components/table/header/index.test.js
+++ b/src/components/table/header/index.test.js
@@ -1,8 +1,7 @@
import React from "react"
import "jest-styled-components"
import { renderWithProviders, screen } from "testUtilities"
-import { DarkTheme } from "@/theme"
-import rawColors from "@/theme/rawColors"
+import { DarkTheme, DefaultTheme } from "@/theme"
import Header from "."
const props = {
@@ -30,7 +29,7 @@ describe("Table Header", () => {
renderWithProviders()
const toolbar = screen.getByTestId("netdata-table-header-container")
- expect(toolbar).toHaveStyleRule("background-color", rawColors.neutral.white)
+ expect(toolbar).toHaveStyleRule("background-color", DefaultTheme.colors.mainBackground)
expect(toolbar).not.toHaveStyleRule("background", expect.stringContaining("gradient"))
})
@@ -39,7 +38,7 @@ describe("Table Header", () => {
expect(screen.getByTestId("netdata-table-header-container")).toHaveStyleRule(
"background-color",
- rawColors.neutral.grey15
+ DarkTheme.colors.mainBackground
)
})
@@ -49,6 +48,15 @@ describe("Table Header", () => {
expect(screen.getByTestId("netdata-table-header-container")).toHaveStyleRule("gap", "8px")
})
+ it("keeps a 48px toolbar band while allowing controls to wrap", () => {
+ renderWithProviders()
+
+ const toolbar = screen.getByTestId("netdata-table-header-container")
+ expect(toolbar).toHaveStyleRule("min-height", "48px")
+ expect(toolbar).toHaveStyleRule("flex-wrap", "wrap")
+ expect(toolbar).not.toHaveStyleRule("height", "48px")
+ })
+
it("lets bulkActionsStyles override the toolbar spacing", () => {
renderWithProviders(
diff --git a/src/components/table/helpers/filterFns.js b/src/components/table/helpers/filterFns.js
index cbe28ce0b..4bce9fb33 100644
--- a/src/components/table/helpers/filterFns.js
+++ b/src/components/table/helpers/filterFns.js
@@ -26,7 +26,7 @@ const multiSelect = (row, columnId, value) => {
if (value.length < 1) return true
return value.some(({ value: filterValue }) => {
- if (filterValue === ("all" || "")) return true
+ if (filterValue === "all") return true
return filterValue?.toLowerCase?.() === rowValue?.toLowerCase?.()
})
}
diff --git a/src/components/table/index.d.ts b/src/components/table/index.d.ts
index cb075be93..a65f304a4 100644
--- a/src/components/table/index.d.ts
+++ b/src/components/table/index.d.ts
@@ -14,7 +14,14 @@ import { StylesConfig } from "react-select"
import { supportedBulkActions } from "./header/actions/useActions"
import { supportedRowActions } from "./useColumns/useRowActions"
-type NetdataCoreColumns = Pick, "id" | "header" | "cell" | "filterFn">
+type NetdataCoreColumns = Pick<
+ ColumnDef,
+ "id" | "header" | "cell" | "filterFn" | "size" | "minSize" | "maxSize"
+> & {
+ hasActions?: boolean
+ notFlex?: boolean
+ columns?: Array>
+}
export type LargeDataSource = {
forEachExportRow?: (callback: (row: D, id: string) => void) => void
@@ -136,12 +143,18 @@ export type TableProps = {
}
testPrefix?: string
globalFilterFn?: FilterFnOption
+ enableResizing?: boolean
+ columnSizingMode?: "fluid"
+ columnSizing?: Record
+ onColumnSizingChange?: (sizes: Record) => void
columnVisibility?: VisibilityTableState
enableColumnVisibility?: boolean
columnVisibilityFlavour?: "borderless" | "hollow"
enableColumnPinning?: boolean
enableGroupByControl?: boolean
bordered?: boolean
+ surface?: string
+ coloredSortedColumn?: boolean
headerActionsBeforeChildren?: boolean
headerChildren?: ReactNode
onGlobalSearchChange?: (value: any) => void
diff --git a/src/components/table/rowActionSpacing.test.js b/src/components/table/rowActionSpacing.test.js
new file mode 100644
index 000000000..e470b125d
--- /dev/null
+++ b/src/components/table/rowActionSpacing.test.js
@@ -0,0 +1,49 @@
+import React from "react"
+import "jest-styled-components"
+import { renderWithProviders, screen, user } from "testUtilities"
+import { DefaultTheme } from "@/theme/default"
+import Table from "./table"
+
+const data = [{ id: "web", name: "Web" }]
+const dataColumns = [{ id: "name", header: "Name", cell: ({ getValue }) => getValue() }]
+
+const legacyTheme = {
+ ...DefaultTheme,
+ constants: { ...DefaultTheme.constants, CONTROL_SIZES: undefined },
+}
+
+it.each([
+ ["the current theme", DefaultTheme],
+ ["a theme without control sizes", legacyTheme],
+])(
+ "reserves the full target, gap and padding width for three row actions with %s",
+ async (_, theme) => {
+ const tableRef = { current: null }
+ const activated = []
+ renderWithProviders(
+ activated.push("edit") },
+ info: { handleAction: () => activated.push("info") },
+ goto: { handleAction: () => activated.push("goto") },
+ }}
+ />,
+ { theme }
+ )
+
+ await screen.findByTestId("netdata-table-action-edit")
+ expect(tableRef.current.getColumn("actions").getSize()).toBe(122)
+ expect(screen.getByTestId("netdata-table-cell-actions")).toHaveStyle({ alignItems: "center" })
+ expect(screen.getByTestId("action-cell")).toHaveStyleRule("align-items", "center")
+ for (const action of ["edit", "info", "goto"]) {
+ await user().click(screen.getByTestId(`netdata-table-action-${action}`))
+ }
+ expect(activated).toEqual(["edit", "info", "goto"])
+ }
+)
diff --git a/src/components/table/table.js b/src/components/table/table.js
index 95d19bcb9..abb6ba3a5 100644
--- a/src/components/table/table.js
+++ b/src/components/table/table.js
@@ -1,4 +1,4 @@
-import React, { memo, useCallback, useLayoutEffect, useMemo, useRef } from "react"
+import React, { memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react"
import {
getCoreRowModel,
getFilteredRowModel,
@@ -25,6 +25,7 @@ import Body from "./body"
import usePinning from "./usePinning"
import useVisibility from "./useVisibility"
import useSizing from "./useSizing"
+import { fitColumnWidths } from "./fluidSizing"
import useExpanding from "./useExpanding"
import usePaginating from "./usePaginating"
import useSearching from "./useSearching"
@@ -96,6 +97,7 @@ const Table = memo(props => {
onColumnVisibilityChange: visibilityChangeCb = tableDefaultProps.onColumnVisibilityChange,
columnSizing: defaultColumnSizing,
+ columnSizingMode,
onColumnSizingChange: sizingChangeCb,
enablePagination,
@@ -139,6 +141,7 @@ const Table = memo(props => {
tableRef,
className,
width,
+ surface,
overflowTooltip,
getRowCanExpand,
getRowId,
@@ -152,6 +155,8 @@ const Table = memo(props => {
)
const [columnSizing, onColumnSizingChange] = useSizing(defaultColumnSizing, sizingChangeCb)
+ const [viewportWidth, setViewportWidth] = useState(0)
+ const fluidSizing = columnSizingMode === "fluid"
const [columnPinning, onColumnPinningChange] = usePinning(defaultColumnPinning, pinningChangeCb)
@@ -179,6 +184,7 @@ const Table = memo(props => {
enableResizing,
enableSorting,
rowActions,
+ columnVisibility,
tableMeta,
})
@@ -200,15 +206,24 @@ const Table = memo(props => {
})
const tableData = largeDataPublication?.rows || data
+ const fluidGeometry = useMemo(
+ () =>
+ fluidSizing && viewportWidth > 0
+ ? fitColumnWidths(columns, viewportWidth, columnVisibility, columnPinning, columnSizing)
+ : undefined,
+ [fluidSizing, columns, viewportWidth, columnVisibility, columnPinning, columnSizing]
+ )
+
const table = useReactTable({
columns,
data: tableData,
manualPagination: !enablePagination,
columnResizeMode: "onEnd",
+ meta: { fluidSizing },
filterFns,
state: {
columnVisibility,
- columnSizing,
+ columnSizing: fluidGeometry?.sizes ?? columnSizing,
rowSelection,
globalFilter: enableCustomSearch ? "" : globalFilter,
sorting,
@@ -285,6 +300,7 @@ const Table = memo(props => {
dispatchThrottled({
sorting: state.sorting,
columnSizing: state.columnSizing,
+ columnPinning: state.columnPinning,
expanded: state.expanded,
grouping: state.grouping,
columnVisibility: state.columnVisibility,
@@ -323,8 +339,9 @@ const Table = memo(props => {
ref={ref}
className={className}
width={width}
- border={bordered ? { side: "all", color: "border" } : undefined}
- round={1}
+ background={surface}
+ border={bordered ? { side: "all", color: "tableBorder" } : undefined}
+ round={bordered ? 2 : 1}
>
{
enableColumnVisibility={enableColumnVisibility}
bulkActions={bulkActions}
enableCustomSearch={enableCustomSearch}
+ surface={surface}
>
{headerActionsBeforeChildren && headerActions}
{headerChildren || null}
@@ -347,6 +365,13 @@ const Table = memo(props => {
{
overflowTooltip={overflowTooltip}
{...rest}
{...virtualizeOptions}
+ surface={surface}
/>
{!getHasNextPage?.() && !loading && !!warning && (
@@ -379,7 +405,7 @@ const Table = memo(props => {
)}
- {enablePagination && }
+ {enablePagination && }
)
})
diff --git a/src/components/table/table.stories.js b/src/components/table/table.stories.js
index ceb6a0e9f..21552f289 100644
--- a/src/components/table/table.stories.js
+++ b/src/components/table/table.stories.js
@@ -169,8 +169,7 @@ export const Expanding = () => {
enableExpanding
dataColumns={mockDataColumns}
data={mockData()}
- onClickRow={({ data, table, fullRow }) => {
- // console.log(data, table, fullRow)
+ onClickRow={({ fullRow }) => {
console.log(fullRow.getCanExpand())
fullRow.toggleExpanded()
}}
@@ -787,6 +786,7 @@ const argTypes = {
// Appearance
bordered: prop("Appearance", "Draws a border and rounded corners around the table.", "boolean", "true", "boolean"),
+ surface: prop("Appearance", "Theme colour token for the table canvas, toolbar, headers, rows and pager.", "string", undefined, "text"),
width: prop("Appearance", "Width of the table container.", "string", undefined, "text"),
className: prop("Appearance", "Class name for the table container.", "string", undefined, "text"),
meta: prop("Appearance", "Style overrides: `cellStyles`, `headStyles`, `searchStyles`, `searchContainerStyles`, `bulkActionsStyles`, `groupByContainerStyles`, `groupBySelectStyles`. May be a function.", "TableMeta | (...args) => TableMeta", "{}", "object"),
diff --git a/src/components/table/table.usage.mdx b/src/components/table/table.usage.mdx
index 9110ee843..c7b6bdc2b 100644
--- a/src/components/table/table.usage.mdx
+++ b/src/components/table/table.usage.mdx
@@ -25,7 +25,7 @@ Shows rows of records, such as nodes, alerts or users, with optional selection,
- `enableSelection` adds a checkbox column and a select-all checkbox. `singleRowSelection` turns the checkboxes into radio buttons.
- `onRowSelected` receives the selected rows' data. For a controlled selection, pass `rowSelection` (keyed by row id) and `onRowSelectionChange`, and set `getRowId` so the keys are stable.
-- `bulkActions` adds header buttons that are enabled while rows are selected. Built-in keys are `delete`, `download`, `toggleAlarm`, `userSettings`, `addEntry`, `remove` and `columnVisibility`. Each takes a `handleAction`.
+- `bulkActions` groups standard icon actions and the default Columns trigger in a compact track. Selection adds a count and a tint. Row-dependent actions are disabled until rows are selected. Use `alwaysEnabled` for utilities such as downloads. Labeled controls, custom actions and an explicitly hollow Columns trigger sit outside the track. Built-in keys are `delete`, `download`, `toggleAlarm`, `userSettings`, `addEntry`, `remove` and `columnVisibility`. Each takes a `handleAction`.
- Actions with `confirmation` open a confirm dialog before `handleAction` runs. `delete` and `remove` do by default.
- A row with `disabled: true` in its data shows a disabled checkbox.
@@ -33,7 +33,7 @@ Shows rows of records, such as nodes, alerts or users, with optional selection,
## Row actions and clickable rows
-- `rowActions` adds a trailing `actions` column with icon buttons. Built-in keys are `delete`, `edit`, `replace`, `info`, `toggleAlarm`, `userSettings`, `remove` and `goto`.
+- `rowActions` renders neutral circular icon buttons in a trailing `actions` column. The first visible leaf column with `hasActions: true` hosts the actions at its trailing edge instead. Inline actions appear on hover and keyboard focus, and stay visible on touch. Standard icon actions that exceed the available space go into an overflow menu. Custom and labeled controls retain their own triggers. Built-in keys are `delete`, `edit`, `replace`, `info`, `toggleAlarm`, `userSettings`, `remove` and `goto`.
- Each action takes `handleAction(rowData, table)`, and optionally `isDisabled` and `isVisible` (a boolean or a function of the row).
- `onClickRow` makes rows clickable and receives `{ data, table, fullRow }`. `disableClickRow` opts individual rows out.
@@ -56,6 +56,13 @@ Shows rows of records, such as nodes, alerts or users, with optional selection,
+## Column sizing
+
+- `enableResizing` enables drag handles. A completed mouse or touch drag reports the new width through `onColumnSizingChange`. A click or canceled drag leaves saved widths alone.
+- Opt in with `columnSizingMode="fluid"` to fit unpinned columns to the scroll viewport within their declared `minSize` and `maxSize`. Pinned columns and `notFlex` columns keep their preferred sizes. Saved `columnSizing` values override fitted widths.
+- Persist the sparse manual width map emitted by `onColumnSizingChange`. Read `column.getSize()` for the resolved geometry when building custom group rows.
+- When the pinned sections leave too little room for the center, they scroll with the row while preserving pinning state.
+
## Pinning
- `enableColumnPinning` lets users pin columns from the column menu.
@@ -87,6 +94,12 @@ Shows rows of records, such as nodes, alerts or users, with optional selection,
+## Surface
+
+The default table frame uses an 8px corner radius.
+
+Pass a theme colour token to `surface` to share one background across the toolbar, column headers, rows and pager. For a table embedded in a workspace, use `surface="workspaceBackground"`. Hover, selection and dividers keep their own tokens.
+
## States
- Hover highlights the row; a selected row is tinted; the sorted column is tinted unless `coloredSortedColumn` is false.
diff --git a/src/components/table/tableBorders.test.js b/src/components/table/tableBorders.test.js
new file mode 100644
index 000000000..c88b62722
--- /dev/null
+++ b/src/components/table/tableBorders.test.js
@@ -0,0 +1,214 @@
+import React from "react"
+import "jest-styled-components"
+import { fireEvent, renderWithProviders, screen } from "testUtilities"
+import { DefaultTheme } from "@/theme"
+import Table from "./table"
+
+const theme = {
+ ...DefaultTheme,
+ colors: {
+ ...DefaultTheme.colors,
+ tableBorder: "#123456",
+ border: "#AA00BB",
+ borderSecondary: "#BB00AA",
+ },
+}
+
+const data = [{ name: "Node", cpu: 42, memory: 12 }]
+const dataColumns = ["name", "cpu", "memory"].map(id => ({
+ id,
+ header: id,
+ cell: ({ getValue }) => getValue(),
+}))
+
+it.each([false, true])(
+ "uses the independent table border for structural lines with direct cells=%s",
+ async directCellContent => {
+ const { container } = renderWithProviders(
+ ,
+ { theme }
+ )
+ expect(container.firstChild).toHaveStyleRule("border-radius", "8px")
+ expect(container.firstChild).toHaveStyleRule("overflow", "hidden")
+ expect(container.firstChild).toHaveStyleRule("border", "1px solid #123456")
+ expect(screen.getByTestId("netdata-table-header-container")).toHaveStyleRule(
+ "border-bottom",
+ "1px solid #123456"
+ )
+ expect(await screen.findByTestId("netdata-table-head")).toHaveStyleRule(
+ "border-bottom",
+ "1px solid #123456"
+ )
+ expect(screen.getByTestId("pagination-counter").parentElement).toHaveStyleRule(
+ "border-top",
+ "1px solid #123456"
+ )
+ expect(screen.getByTestId("netdata-table-header-resize-handler-memory")).toHaveStyleRule(
+ "background-color",
+ "#123456",
+ { modifier: "::after" }
+ )
+ for (const id of ["name", "cpu"]) {
+ const handle = screen.getByTestId(`netdata-table-header-resize-handler-${id}`)
+ expect(handle).toHaveStyleRule("background-color", DefaultTheme.colors.transparent.full, {
+ modifier: "::after",
+ })
+ expect(handle).toHaveStyleRule("background-color", DefaultTheme.colors.resizerLine, {
+ modifier: ":hover::after",
+ })
+ }
+ const headerSections = screen.getAllByTestId("netdata-table-headRow")
+ expect(headerSections[0].parentElement).not.toHaveStyleRule("border-right", "1px solid #123456")
+ expect(headerSections[2].parentElement).not.toHaveStyleRule("border-left", "1px solid #123456")
+ const row = screen.getByTestId("netdata-table-row")
+ expect(row).toHaveStyleRule("border-bottom", "1px solid #123456")
+ const sections = row.querySelectorAll(".row-content")
+ expect(getComputedStyle(sections[0]).borderRightColor).not.toBe("rgb(18, 52, 86)")
+ expect(getComputedStyle(sections[2]).borderLeftColor).not.toBe("rgb(18, 52, 86)")
+ }
+)
+
+it.each([false, true])(
+ "keeps header roles independent and sorted cell bases uniform with direct cells=%s",
+ async directCellContent => {
+ const surfaceTheme = {
+ ...theme,
+ colors: {
+ ...theme.colors,
+ mainBackground: "#DDEEFF",
+ panelBg: "#ABABAB",
+ tableHeaderBackground: "#FEDCBA",
+ },
+ }
+ renderWithProviders(
+ ({ id, desc: true }))}
+ coloredSortedColumn={false}
+ columnPinning={{ left: ["name"], right: ["actions"] }}
+ rowActions={{ info: { handleAction: () => {} } }}
+ virtualizeOptions={{ directCellContent }}
+ />,
+ { theme: surfaceTheme }
+ )
+ expect(await screen.findByTestId("netdata-table-head")).toHaveStyleRule(
+ "background-color",
+ "#FEDCBA"
+ )
+ screen.getAllByTestId("netdata-table-headRow").forEach(header => {
+ expect(header).toHaveStyleRule("background-color", "#FEDCBA")
+ })
+ const row = screen.getByTestId("netdata-table-row")
+ expect(row).toHaveStyleRule("background-color", "#DDEEFF")
+ const cells = row.querySelectorAll('[data-testid^="netdata-table-cell-"]')
+ expect(cells).toHaveLength(4)
+ cells.forEach(cell => {
+ expect(getComputedStyle(cell).backgroundColor).toBe("rgba(0, 0, 0, 0)")
+ let surface = cell.parentElement
+ while (getComputedStyle(surface).backgroundColor === "rgba(0, 0, 0, 0)") {
+ surface = surface.parentElement
+ }
+ expect(getComputedStyle(surface).backgroundColor).toBe("rgb(221, 238, 255)")
+ })
+ screen.getAllByTestId("netdata-table-header-cell-label-container").forEach(label => {
+ expect(getComputedStyle(label.parentElement.parentElement).backgroundColor).toBe(
+ "rgba(0, 0, 0, 0)"
+ )
+ })
+ }
+)
+
+it.each([false, true])(
+ "uses the supplied surface across the table with direct cells=%s",
+ async directCellContent => {
+ const { container } = renderWithProviders(
+ ,
+ { theme: { ...theme, colors: { ...theme.colors, workspaceBackground: "#E4F0EB" } } }
+ )
+
+ const row = await screen.findByTestId("netdata-table-row")
+ const headerRows = screen.getAllByTestId(/^netdata-table-headRow/)
+ expect(headerRows).toHaveLength(6)
+ const parts = [
+ container.firstChild,
+ screen.getByTestId("netdata-table-header-container"),
+ screen.getByTestId("netdata-table-head"),
+ ...headerRows,
+ row,
+ ...row.querySelectorAll(".row-content"),
+ screen.getByTestId("pagination-counter").parentElement,
+ ]
+
+ parts.forEach(part => {
+ expect(getComputedStyle(part).backgroundColor).toBe("rgb(228, 240, 235)")
+ })
+ }
+)
+
+it.each([false, true])(
+ "reveals only the pinned edges with more scrollable content with direct cells=%s",
+ async directCellContent => {
+ const onScroll = jest.fn()
+ renderWithProviders(
+
+ )
+ const viewport = screen.getByTestId("netdata-table")
+ await screen.findByTestId("netdata-table-row")
+ expect(viewport.querySelectorAll('[data-table-pinned="left"]')).toHaveLength(2)
+ expect(viewport.querySelectorAll('[data-table-pinned="right"]')).toHaveLength(2)
+
+ Object.defineProperties(viewport, {
+ clientWidth: { configurable: true, value: 200 },
+ scrollLeft: { configurable: true, writable: true, value: 0 },
+ scrollWidth: { configurable: true, value: 300 },
+ })
+ fireEvent.scroll(viewport)
+ expect(viewport).not.toHaveAttribute("data-can-scroll-left")
+ expect(viewport).toHaveAttribute("data-can-scroll-right")
+
+ viewport.scrollLeft = 60
+ fireEvent.scroll(viewport)
+ expect(viewport).toHaveAttribute("data-can-scroll-left")
+ expect(viewport).toHaveAttribute("data-can-scroll-right")
+
+ viewport.scrollLeft = 100
+ fireEvent.scroll(viewport)
+ expect(viewport).toHaveAttribute("data-can-scroll-left")
+ expect(viewport).not.toHaveAttribute("data-can-scroll-right")
+
+ Object.defineProperty(viewport, "scrollWidth", { configurable: true, value: 200 })
+ viewport.scrollLeft = 0
+ fireEvent.scroll(viewport)
+ expect(viewport).not.toHaveAttribute("data-can-scroll-left")
+ expect(viewport).not.toHaveAttribute("data-can-scroll-right")
+ expect(onScroll).toHaveBeenCalledTimes(4)
+ }
+)
diff --git a/src/components/table/tableInlineActions.test.js b/src/components/table/tableInlineActions.test.js
new file mode 100644
index 000000000..f1627a853
--- /dev/null
+++ b/src/components/table/tableInlineActions.test.js
@@ -0,0 +1,81 @@
+import React from "react"
+import { renderWithProviders, screen, user } from "testUtilities"
+import Table from "./table"
+
+const data = [{ name: "Web", status: "Ready" }]
+const name = { id: "name", header: "Name", cell: ({ getValue }) => getValue(), hasActions: true }
+const status = { id: "status", header: "Status", cell: ({ getValue }) => getValue() }
+
+it.each([false, true])(
+ "puts the actions into the marked column with direct cells=%s",
+ async directCellContent => {
+ const edit = jest.fn()
+ const openRow = jest.fn()
+ renderWithProviders(
+
+ )
+
+ const action = await screen.findByTestId("netdata-table-action-edit")
+ expect(screen.getByTestId("netdata-table-cell-name")).toContainElement(action)
+ expect(screen.queryByTestId("netdata-table-cell-actions")).toBeNull()
+ await user().click(action)
+ expect(edit).toHaveBeenCalledTimes(1)
+ expect(openRow).not.toHaveBeenCalled()
+ }
+)
+
+it("puts the action column back when the marked leaf is hidden", async () => {
+ renderWithProviders(
+
+ )
+
+ const action = await screen.findByTestId("netdata-table-action-edit")
+ expect(screen.getByTestId("netdata-table-cell-actions")).toContainElement(action)
+})
+
+it("keeps confirmation and disabled states when row actions overflow", async () => {
+ const descriptor = Object.getOwnPropertyDescriptor(Element.prototype, "clientWidth")
+ const clientWidth = jest
+ .spyOn(Element.prototype, "clientWidth", "get")
+ .mockImplementation(function () {
+ return this.dataset?.testid === "action-cell" ? 60 : descriptor.get.call(this)
+ })
+ const remove = jest.fn()
+ const info = jest.fn()
+
+ try {
+ renderWithProviders(
+
+ )
+
+ const more = await screen.findByRole("button", { name: "3 more row actions" })
+ await user().click(more)
+ expect(screen.getByRole("button", { name: "Information" })).toBeDisabled()
+ await user().click(screen.getByRole("button", { name: "Delete" }))
+ expect(remove).not.toHaveBeenCalled()
+ await user().click(screen.getByTestId("confirmationDialog-confirmAction"))
+ expect(remove).toHaveBeenCalledTimes(1)
+ expect(info).not.toHaveBeenCalled()
+ } finally {
+ clientWidth.mockRestore()
+ }
+})
diff --git a/src/components/table/tableResize.test.js b/src/components/table/tableResize.test.js
new file mode 100644
index 000000000..2ee9d92c0
--- /dev/null
+++ b/src/components/table/tableResize.test.js
@@ -0,0 +1,156 @@
+import React from "react"
+import { act, fireEvent, renderWithProviders, screen } from "testUtilities"
+import Table from "./table"
+
+const data = [{ name: "Server 1", status: "Online" }]
+const name = { id: "name", header: "Name", size: 120, minSize: 80, maxSize: 250 }
+const status = { id: "status", header: "Status", size: 80, minSize: 50, maxSize: 150 }
+const columns = [name, status]
+
+const setup = (props = {}) => {
+ const onColumnSizingChange = jest.fn()
+ renderWithProviders(
+
+ )
+ return onColumnSizingChange
+}
+
+const getHandle = id => screen.findByTestId(`netdata-table-header-resize-handler-${id}`)
+
+const drag = (handle, start, end) => {
+ fireEvent.mouseDown(handle, { clientX: start })
+ fireEvent.mouseMove(document, { clientX: end })
+ fireEvent.mouseUp(document, { clientX: end })
+}
+
+it("does not save a width when clicking a flexible header handle without dragging", async () => {
+ const onSizingChange = setup({ dataColumns: [{ ...name, fullWidth: true }, status] })
+ const handle = await getHandle("name")
+ Object.defineProperty(handle.parentElement, "getBoundingClientRect", {
+ value: () => ({ width: 210 }),
+ })
+
+ fireEvent.mouseDown(handle, { clientX: 100 })
+ fireEvent.mouseUp(document, { clientX: 100 })
+
+ expect(onSizingChange).not.toHaveBeenCalled()
+})
+
+it("uses the displayed width and saves the bounded width while retaining other saved columns", async () => {
+ const onSizingChange = setup({
+ dataColumns: [{ ...name, fullWidth: true }, status],
+ columnSizing: { status: 110 },
+ })
+ const handle = await getHandle("name")
+ Object.defineProperty(handle.parentElement, "getBoundingClientRect", {
+ value: () => ({ width: 280 }),
+ })
+
+ fireEvent.mouseDown(handle, { clientX: 200 })
+ fireEvent.mouseMove(document, { clientX: 150 })
+ expect(onSizingChange).not.toHaveBeenCalled()
+ fireEvent.mouseUp(document, { clientX: 150 })
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+ expect(onSizingChange).toHaveBeenCalledWith({ name: 230, status: 110 })
+})
+
+it("commits the maximum width on mouse release even when the pointer moves farther", async () => {
+ const onSizingChange = setup({ columnSizing: { name: 200, status: 110 } })
+ const handle = await getHandle("name")
+
+ drag(handle, 10, 120)
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+ expect(onSizingChange).toHaveBeenCalledWith({ name: 250, status: 110 })
+})
+
+it("saves a touch drag when the final finger lifts and retains saved widths on cancellation", async () => {
+ const onSizingChange = setup({ columnSizing: { name: 200, status: 110 } })
+ const handle = await getHandle("name")
+ const fingerAt = clientX => ({ identifier: 1, clientX })
+
+ fireEvent.touchStart(handle, { touches: [fingerAt(60)] })
+ fireEvent.touchMove(document, { touches: [fingerAt(40)], changedTouches: [fingerAt(40)] })
+ fireEvent.touchEnd(document, { touches: [], changedTouches: [fingerAt(20)] })
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+ expect(onSizingChange).toHaveBeenCalledWith({ name: 160, status: 110 })
+
+ fireEvent.touchStart(handle, { touches: [fingerAt(60)] })
+ fireEvent.touchMove(document, { touches: [fingerAt(100)], changedTouches: [fingerAt(100)] })
+ fireEvent.touchCancel(document, { touches: [], changedTouches: [fingerAt(100)] })
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+})
+
+it("resizes only eligible leaves of a group and omits the synthetic group width", async () => {
+ const onSizingChange = setup({
+ dataColumns: [
+ { id: "server", header: "Server", columns: [name, { ...status, enableResizing: false }] },
+ ],
+ columnSizing: { status: 110 },
+ })
+ const handle = await getHandle("server")
+
+ drag(handle, 10, 60)
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+ expect(onSizingChange).toHaveBeenCalledWith({ name: 170, status: 110 })
+})
+
+it("omits the group resize handle when all its leaves are ineligible", async () => {
+ setup({
+ enableResizing: false,
+ dataColumns: [{ id: "server", header: "Server", columns }],
+ })
+
+ await screen.findByText("Server")
+ expect(screen.queryByTestId("netdata-table-header-resize-handler-server")).toBeNull()
+})
+
+it("commits consecutive sparse sizing updates through the current save callback", () => {
+ const previousSave = jest.fn()
+ const save = jest.fn()
+ const tableRef = { current: null }
+ const columnSizing = { status: 110 }
+ const renderTable = onColumnSizingChange => (
+
+ )
+ const { rerender } = renderWithProviders(renderTable(previousSave))
+ rerender(renderTable(save))
+
+ act(() => {
+ tableRef.current.setColumnSizing(widths => ({ ...widths, name: 190 }))
+ tableRef.current.setColumnSizing(widths => ({ ...widths, status: 130 }))
+ })
+
+ expect(previousSave).not.toHaveBeenCalled()
+ expect(save.mock.calls).toEqual([[{ name: 190, status: 110 }], [{ name: 190, status: 130 }]])
+})
+
+it("accepts TanStack's reset map and saves only the first reset", () => {
+ const tableRef = { current: null }
+ const onSizingChange = setup({ columnSizing: { name: 200 }, tableRef })
+
+ act(() => {
+ tableRef.current.resetColumnSizing(true)
+ tableRef.current.resetColumnSizing(true)
+ })
+
+ expect(onSizingChange).toHaveBeenCalledTimes(1)
+ expect(onSizingChange).toHaveBeenCalledWith({})
+})
diff --git a/src/components/table/tableStates.test.js b/src/components/table/tableStates.test.js
index 95eafebec..055e7753c 100644
--- a/src/components/table/tableStates.test.js
+++ b/src/components/table/tableStates.test.js
@@ -1,8 +1,7 @@
import React from "react"
import "jest-styled-components"
import { renderWithProviders, screen } from "testUtilities"
-import { DarkTheme } from "@/theme"
-import rawColors from "@/theme/rawColors"
+import { DarkTheme, DefaultTheme } from "@/theme"
import Table from "./table"
const data = [{ id: "node-1", name: "Node 1" }]
@@ -15,8 +14,8 @@ describe("Table loading-more indicator", () => {
)
const text = screen.getByText("Loading more...")
- expect(text).toHaveStyleRule("color", rawColors.neutral.grey195)
- expect(text.parentElement).toHaveStyleRule("background-color", rawColors.neutral.limedSpruce)
+ expect(text).toHaveStyleRule("color", DefaultTheme.colors.tooltipText)
+ expect(text.parentElement).toHaveStyleRule("background-color", DefaultTheme.colors.tooltipBg)
expect(text.parentElement).toHaveStyleRule("border-radius", "6px")
})
@@ -26,7 +25,7 @@ describe("Table loading-more indicator", () => {
{ theme: DarkTheme }
)
- expect(screen.getByText("Loading more...")).toHaveStyleRule("color", rawColors.neutral.grey185)
+ expect(screen.getByText("Loading more...")).toHaveStyleRule("color", DarkTheme.colors.tooltipText)
})
})
@@ -61,7 +60,7 @@ describe("Table container", () => {
const { rerender, container } = renderWithProviders(
)
- expect(container.firstChild).toHaveStyleRule("border", `1px solid ${rawColors.neutral.grey180}`)
+ expect(container.firstChild).toHaveStyleRule("border", `1px solid ${DefaultTheme.colors.tableBorder}`)
rerender()
expect(container.firstChild).not.toHaveStyleRule("border", expect.anything())
diff --git a/src/components/table/useColumns/index.js b/src/components/table/useColumns/index.js
index 04a894b46..91c806339 100644
--- a/src/components/table/useColumns/index.js
+++ b/src/components/table/useColumns/index.js
@@ -1,4 +1,5 @@
-import { useMemo } from "react"
+import React, { useMemo } from "react"
+import Flex from "@/components/templates/flex"
import useRowSelection from "./useRowSelection"
import useRowActions from "./useRowActions"
@@ -7,6 +8,7 @@ export default (
{
rowActions,
enableSelection,
+ columnVisibility,
singleRowSelection,
enableResizing,
enableSorting,
@@ -24,6 +26,29 @@ export default (
return useMemo(() => {
if (!dataColumns || dataColumns.length < 1) return []
+ const actionHost =
+ rowActionsColumn &&
+ dataColumns
+ .flatMap(column => column.columns || [column])
+ .find(column => column.hasActions && columnVisibility?.[column.id] !== false)
+ const Actions = rowActionsColumn?.cell
+ const withActions = (column, minimum) => {
+ if (column !== actionHost) return column
+ const Cell = column.cell
+ return {
+ ...column,
+ minSize: Math.max(column.minSize ?? minimum, rowActionsColumn.minSize),
+ cell: props => (
+
+
+ {Cell ? | : props.getValue()}
+
+
+
+ ),
+ }
+ }
+
let isGrouped = false
dataColumns = dataColumns.map((col, index) => {
@@ -46,7 +71,7 @@ export default (
enableResizing,
footer: props => props.column.id,
tableMeta,
- ...subCol,
+ ...withActions(subCol, 60),
accessorKey: subCol.accessorKey || subCol.id,
}
}),
@@ -65,7 +90,7 @@ export default (
enableResizing,
footer: props => props.column.id,
tableMeta,
- ...col,
+ ...withActions(col, 10),
accessorKey: col.accessorKey || col.id,
}
})
@@ -82,7 +107,7 @@ export default (
: selectionColumn
)
- if (rowActionsColumn)
+ if (rowActionsColumn && !actionHost)
dataColumns.push(
isGrouped
? {
@@ -95,5 +120,13 @@ export default (
)
return dataColumns
- }, [dataColumns, rowActionsColumn, selectionColumn])
+ }, [
+ dataColumns,
+ rowActionsColumn,
+ selectionColumn,
+ columnVisibility,
+ enableResizing,
+ enableSorting,
+ tableMeta,
+ ])
}
diff --git a/src/components/table/useColumns/useRowActions.js b/src/components/table/useColumns/useRowActions.js
index d2772179c..c6332c194 100644
--- a/src/components/table/useColumns/useRowActions.js
+++ b/src/components/table/useColumns/useRowActions.js
@@ -1,6 +1,7 @@
import React, { useMemo } from "react"
-import Flex from "@/components/templates/flex"
-import Action from "../components/action"
+import { useTheme } from "styled-components"
+import { controlHeight } from "@/mixins/controlSize"
+import RowActionGroup from "../components/rowActionGroup"
export const supportedRowActions = {
delete: {
@@ -45,6 +46,9 @@ export const supportedRowActions = {
const MIN_ACTIONS_COLUMN_WIDTH = 70
export default (rowActions, { testPrefix, tableMeta } = {}) => {
+ const theme = useTheme()
+ const { SIZE_SUB_UNIT } = theme.constants
+ const actionHeight = Number.parseFloat(controlHeight("default")({ theme }))
const availableRowActions = useMemo(
() =>
Object.keys(rowActions).reduce((acc, key) => {
@@ -65,59 +69,31 @@ export default (rowActions, { testPrefix, tableMeta } = {}) => {
return useMemo(() => {
if (availableRowActions.length < 1) return null
+ const visibleSlots = Math.min(availableRowActions.length, 4)
return {
id: "actions",
enableResizing: false,
header: "Actions",
headerString: "Actions",
- cell: ({ row, table }) => (
- e.stopPropagation()}
- >
- {availableRowActions.map(
- ({
- id,
- handleAction,
- isDisabled,
- isVisible = true,
- dataGa,
- disabledTooltipText,
- tooltipText,
- ...rest
- }) => (
- handleAction(row.original, table)}
- testPrefix={testPrefix}
- currentRow={row}
- />
- )
- )}
-
+ cell: ({ row, table, inline }) => (
+
),
enableColumnFilter: false,
enableSorting: false,
enableReordering: false,
tableMeta,
- size: Math.max(MIN_ACTIONS_COLUMN_WIDTH, availableRowActions.length * 35),
- align: "end",
+ size: Math.max(
+ MIN_ACTIONS_COLUMN_WIDTH,
+ visibleSlots * actionHeight + (visibleSlots - 1) * 2 * SIZE_SUB_UNIT + 4 * SIZE_SUB_UNIT
+ ),
+ minSize: actionHeight + 4 * SIZE_SUB_UNIT,
+ align: "center",
notFlex: true,
meta: {
cellStyles: {
@@ -125,5 +101,5 @@ export default (rowActions, { testPrefix, tableMeta } = {}) => {
},
},
}
- }, [availableRowActions])
+ }, [availableRowActions, actionHeight, SIZE_SUB_UNIT, testPrefix, tableMeta])
}
diff --git a/src/components/table/useSelecting.js b/src/components/table/useSelecting.js
index 1df87d97b..b42dcbd8d 100644
--- a/src/components/table/useSelecting.js
+++ b/src/components/table/useSelecting.js
@@ -1,16 +1,14 @@
-import { useCallback, useEffect, useState, useRef } from "react"
+import { useCallback, useEffect, useState } from "react"
const noop = () => {}
const emptyObj = {}
export default (defaultRowSelection = emptyObj, onChange = noop) => {
const [rowSelection, setRowSelection] = useState(() => defaultRowSelection)
- const initialSetRef = useRef(false)
useEffect(() => {
if (rowSelection === defaultRowSelection) return
- // initialSetRef.current = true
setRowSelection(defaultRowSelection)
}, [defaultRowSelection])
diff --git a/src/components/table/useSizing.js b/src/components/table/useSizing.js
index 16f7334c8..d31d8254c 100644
--- a/src/components/table/useSizing.js
+++ b/src/components/table/useSizing.js
@@ -1,26 +1,31 @@
-import { useCallback, useEffect, useState, useRef } from "react"
+import { useCallback, useLayoutEffect, useRef, useState } from "react"
+import isEqual from "lodash/isEqual"
const noop = () => {}
const emptyObj = {}
export default (defaultColumnSizing = emptyObj, onChange = noop) => {
const [columnSizing, setColumnSizing] = useState(() => defaultColumnSizing)
- const initialSetRef = useRef(false)
+ const currentSizing = useRef(defaultColumnSizing)
- useEffect(() => {
- if (columnSizing === defaultColumnSizing) return
+ useLayoutEffect(() => {
+ if (isEqual(currentSizing.current, defaultColumnSizing)) return
- initialSetRef.current = true
+ currentSizing.current = defaultColumnSizing
setColumnSizing(defaultColumnSizing)
}, [defaultColumnSizing])
const onSizingChange = useCallback(
- getValue => {
- const newValue = getValue(columnSizing)
- onChange(newValue)
- setColumnSizing(newValue)
+ update => {
+ const previous = currentSizing.current
+ const next = typeof update === "function" ? update(previous) : update
+ if (isEqual(previous, next)) return
+
+ currentSizing.current = next
+ setColumnSizing(next)
+ onChange(next)
},
- [columnSizing]
+ [onChange]
)
return [columnSizing, onSizingChange]
diff --git a/src/components/tabs/README.md b/src/components/tabs/README.md
index 4cba6e308..278b63a0f 100644
--- a/src/components/tabs/README.md
+++ b/src/components/tabs/README.md
@@ -55,3 +55,26 @@ const selected = paths.findIndex(p => p === pathParam)
Fairwell
```
+
+### Neutral line tabs
+
+`variant="line" appearance="neutral"` renders native buttons with neutral ink and a selected-only underline. The profile uses 34px height, 12px side padding, 7px gap, inherited font family, 13px/20px text, 500 idle and 600 selected weight, square corners and no maximum width. Hover and expanded triggers use `controlHoverBackground`; keyboard focus uses `segmentedFocus` inset by 4px. Rich labels keep their own icon and status colors.
+
+Use `label` for React content, including multiple counts or domain status indicators. IDs, refs, ARIA and handlers pass through. A popup trigger can override `role="button"`, `aria-selected={undefined}` and `tabIndex={0}`.
+
+Within ``, Left and Right Arrow move focus and selection between enabled tabs and wrap at the ends. Home and End focus and select the first and last enabled tabs. Use the `selected` and `onChange` props to control the active tab from an external panel.
+
+Neutral tabs honor `height`, `width`, `maxWidth`, `padding`, `gap`, `round`, `fontSize`, `lineHeight` and `fontWeight`. Numeric dimensions, spacing and font sizes use local 4px units; font sizes also accept CSS strings. `lineHeight` follows CSS: numbers are unitless and strings pass through. Other line, contained and raised appearances keep their defaults.
+
+```jsx
+
+ Collectors
+ 2
+ >
+ }
+/>
+```
diff --git a/src/components/tabs/__snapshots__/tabs.test.js.snap b/src/components/tabs/__snapshots__/tabs.test.js.snap
index 989db4864..7b5a5a92b 100644
--- a/src/components/tabs/__snapshots__/tabs.test.js.snap
+++ b/src/components/tabs/__snapshots__/tabs.test.js.snap
@@ -5,7 +5,7 @@ exports[`Tabs states * should render uncontrolled 1`] = `
display: flex;
flex-direction: column;
flex-wrap: nowrap;
- color: #526161;
+ color: #2D3E33;
}
.c1 {
@@ -16,7 +16,7 @@ exports[`Tabs states * should render uncontrolled 1`] = `
align-items: center;
justify-content: start;
padding: 0;
- color: #526161;
+ color: #2D3E33;
overflow-y: hidden;
overflow-x: auto;
}
@@ -27,11 +27,11 @@ exports[`Tabs states * should render uncontrolled 1`] = `
align-items: center;
justify-content: center;
padding: 0 12px;
- color: #526161;
+ color: #2D3E33;
}
.c2 {
- box-shadow: inset 0 -1px 0 #DBE1E1;
+ box-shadow: inset 0 -1px 0 #C5D0C8;
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
}
@@ -86,7 +86,7 @@ exports[`Tabs states * should render uncontrolled 1`] = `
opacity: 1;
pointer-events: auto;
transition: color 140ms ease-out,background 140ms ease-out,box-shadow 140ms ease-out;
- color: #526161;
+ color: #2D3E33;
background: rgba(255,255,255,0.0);
box-shadow: none;
}
@@ -97,17 +97,17 @@ exports[`Tabs states * should render uncontrolled 1`] = `
}
.c6>span {
- color: #526161;
+ color: #2D3E33;
}
.c6:hover {
- color: #35414A;
- background: #F6F7F7;
- box-shadow: inset 0 -2px 0 #708585;
+ color: #2D3E33;
+ background: #EEF3EF;
+ box-shadow: inset 0 -2px 0 #5C6A61;
}
.c6:hover>span {
- color: #35414A;
+ color: #2D3E33;
}
.c5 {
diff --git a/src/components/tabs/neutral.test.js b/src/components/tabs/neutral.test.js
new file mode 100644
index 000000000..51ad10b5c
--- /dev/null
+++ b/src/components/tabs/neutral.test.js
@@ -0,0 +1,173 @@
+import React, { createRef } from "react"
+import { renderWithProviders, screen, user } from "testUtilities"
+import { DefaultTheme, DarkTheme } from "@/theme"
+import StatusWord from "@/components/pill/statusWord"
+import { Tab, Tabs } from "."
+
+it.each([
+ ["light", DefaultTheme],
+ ["dark", DarkTheme],
+])("preserves neutral line geometry and rich status labels in %s", (_, theme) => {
+ renderWithProviders(
+
+
+ Collectors
+
+ 0
+
+
+ 2
+
+ >
+ }
+ />
+
+ ,
+ { theme }
+ )
+ const [selected, idle] = screen.getAllByRole("tab")
+ expect(selected.tagName).toBe("BUTTON")
+ expect(selected).toHaveStyle({
+ display: "inline-flex",
+ height: "34px",
+ padding: "0 12px",
+ gap: "7px",
+ fontFamily: "inherit",
+ fontVariantNumeric: "inherit",
+ textAlign: "inherit",
+ appearance: "none",
+ fontSize: "13px",
+ lineHeight: "20px",
+ fontWeight: "600",
+ borderRadius: "0",
+ maxWidth: "none",
+ color: theme.colors.textFocus,
+ })
+ expect(selected).toHaveStyleRule("border", "0")
+ expect(idle).toHaveStyleRule("font-weight", "500")
+ expect(idle).toHaveStyleRule("color", theme.colors.textFocus)
+ expect(selected).toHaveStyleRule("box-shadow", `inset 0 -2px 0 ${theme.colors.textFocus}`)
+ expect(idle).toHaveStyleRule("box-shadow", "none")
+ for (const tab of [selected, idle]) {
+ expect(tab).toHaveStyleRule("background", theme.colors.controlHoverBackground, {
+ modifier: ":hover",
+ })
+ expect(tab).toHaveStyleRule("background", theme.colors.controlHoverBackground, {
+ modifier: '[aria-expanded="true"]',
+ })
+ expect(tab).toHaveStyleRule("outline-color", theme.colors.segmentedFocus, {
+ modifier: ":focus-visible",
+ })
+ expect(tab).toHaveStyleRule("outline-offset", "-4px", { modifier: ":focus-visible" })
+ expect(tab).not.toHaveStyleRule("color", expect.any(String), { modifier: "&>span" })
+ }
+ expect(screen.getAllByTestId("status-word")[0]).toHaveStyle({
+ color: theme.colors.statusMutedText,
+ })
+ expect(screen.getAllByTestId("status-word")[1]).toHaveStyle({
+ color: theme.colors.statusErrorText,
+ })
+})
+
+it("honors explicit neutral line dimensions and typography", () => {
+ const { rerender } = renderWithProviders(
+
+ )
+ const tab = screen.getByRole("tab")
+ expect(tab).toHaveStyle({
+ height: "36px",
+ maxWidth: "240px",
+ padding: "4px 16px",
+ gap: "8px",
+ borderRadius: "4px",
+ fontSize: "16px",
+ lineHeight: "24px",
+ fontWeight: "400",
+ })
+ expect(screen.getByText("Custom")).toHaveStyleRule("font-size", "inherit")
+ rerender()
+ expect(screen.getByRole("tab")).toHaveStyleRule("line-height", "1.5")
+})
+
+it("retains native activation, refs, IDs and popup semantics for a neutral line trigger", async () => {
+ const onClick = jest.fn()
+ const ref = createRef()
+ renderWithProviders(
+
+ )
+ const trigger = screen.getByRole("button", { name: "More" })
+ expect(ref.current).toBe(trigger)
+ expect(trigger).not.toHaveAttribute("aria-selected")
+ expect(trigger).toHaveAttribute("aria-controls", "more-types")
+ expect(trigger.id).toBe("more-trigger")
+ trigger.focus()
+ await user().keyboard("{Enter} ")
+ expect(onClick).toHaveBeenCalledTimes(2)
+})
+
+it("moves focus and selection to the first and last enabled neutral line tabs", async () => {
+ renderWithProviders(
+
+
+ Overview content
+ Nodes content
+
+
+ )
+ const keyboard = user()
+ const overview = screen.getByRole("tab", { name: "Overview" })
+ const nodes = screen.getByRole("tab", { name: "Nodes" })
+
+ await keyboard.tab()
+ expect(overview).toHaveFocus()
+
+ await keyboard.keyboard("{End}")
+ expect(nodes).toHaveFocus()
+ expect(nodes).toHaveAttribute("aria-selected", "true")
+ expect(screen.getByText("Nodes content")).toBeInTheDocument()
+
+ await keyboard.keyboard("{Home}")
+ expect(overview).toHaveFocus()
+ expect(overview).toHaveAttribute("aria-selected", "true")
+ expect(screen.getByText("Overview content")).toBeInTheDocument()
+})
+
+it("leaves default line and contained appearances unchanged", () => {
+ renderWithProviders(
+ <>
+
+
+ >
+ )
+ const [line, contained] = screen.getAllByRole("tab")
+ expect(line.tagName).toBe("DIV")
+ expect(line).toHaveStyleRule("height", "32px")
+ expect(line).toHaveStyleRule("font-variant-numeric", "tabular-nums")
+ expect(line).toHaveStyleRule("box-shadow", `inset 0 -2px 0 ${DefaultTheme.colors.primary}`)
+ expect(contained.tagName).toBe("DIV")
+ expect(contained).toHaveStyleRule("height", "22px")
+})
diff --git a/src/components/tabs/styled.js b/src/components/tabs/styled.js
index 44482d053..47c9060d1 100644
--- a/src/components/tabs/styled.js
+++ b/src/components/tabs/styled.js
@@ -2,8 +2,14 @@ import styled, { css } from "styled-components"
import { getColor, getSizeBy } from "@/theme/utils"
import Flex from "@/components/templates/flex"
import { segmentedTrack, segmentedItem } from "@/mixins/segmented"
+import { focusRingOutline } from "@/mixins/focusRing"
+import height from "@/components/templates/mixins/height"
+import width from "@/components/templates/mixins/width"
+import round from "@/mixins/round"
const isContained = ({ variant }) => variant === "contained"
+export const isNeutralLine = ({ variant = "line", appearance }) =>
+ variant === "line" && appearance === "neutral"
export const StyledTabsWrapper = styled(Flex).attrs(props => ({
column: true,
@@ -18,7 +24,6 @@ export const StyledTabs = styled(Flex).attrs(props => ({
justifyContent: "start",
alignItems: "center",
padding: props.column ? [0, 0.5] : [0],
- flex: false,
// Contained strips hold a few items and must not clip the items' outer focus ring.
overflow: isContained(props) ? "visible" : { horizontal: "auto", vertical: "hidden" },
flex: 0,
@@ -53,8 +58,22 @@ const activeColorByFlavour = {
const transparent = ["transparent", "full"]
-const colors = ({ theme, active, flavour, variant }) => {
+const neutralLineColors = css`
+ color: ${getColor("textFocus")};
+ background: ${getColor(transparent)};
+ box-shadow: ${({ active, theme }) =>
+ active ? `inset 0 -2px 0 ${getColor("textFocus")({ theme })}` : "none"};
+
+ &:hover,
+ &[aria-expanded="true"] {
+ background: ${getColor("controlHoverBackground")};
+ }
+`
+
+const colors = props => {
+ const { theme, active, flavour, variant } = props
if (variant === "contained") return segmentedItem
+ if (isNeutralLine(props)) return neutralLineColors
const color = active ? activeColorByFlavour[flavour] || activeColorByFlavour.default : "text"
const resolvedColor = getColor(color)({ theme })
@@ -84,6 +103,7 @@ const colors = ({ theme, active, flavour, variant }) => {
export const StyledTab = styled(Flex).attrs(props => ({
small: true,
padding: isContained(props) ? [0, 1.25] : [0, 3],
+ ...(isNeutralLine(props) ? { as: "button", type: "button", flex: false } : {}),
...props,
}))`
white-space: nowrap;
@@ -130,10 +150,37 @@ export const StyledTab = styled(Flex).attrs(props => ({
}
${colors}
+ ${props =>
+ isNeutralLine(props) &&
+ css`
+ display: inline-flex;
+ border: 0;
+ border-radius: 0;
+ font-family: inherit;
+ font-style: inherit;
+ font-variant-numeric: inherit;
+ text-align: inherit;
+ appearance: none;
+ font-size: ${({ fontSize = 3.25 }) =>
+ typeof fontSize === "number" ? getSizeBy(fontSize / 2) : fontSize};
+ line-height: ${props => props.lineHeight ?? getSizeBy(2.5)(props)};
+ font-weight: ${({ active, fontWeight }) => fontWeight ?? (active ? 600 : 500)};
+ max-width: ${({ maxWidth }) => maxWidth ?? "none"};
+ height: ${getSizeBy(4.25)};
+ ${height}
+ ${width}
+ ${round}
+
+ &:focus-visible {
+ ${focusRingOutline}
+ outline-color: ${getColor("segmentedFocus")};
+ outline-offset: ${getSizeBy(-0.5)};
+ }
+ `}
`
export const TabLabel = styled.span`
- font-size: 13px;
+ font-size: ${props => (isNeutralLine(props) ? "inherit" : "13px")};
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
@@ -160,6 +207,31 @@ export const StyledTabMenu = styled(Flex)`
cursor: pointer;
justify-content: flex-start;
&:hover {
- background: ${getColor("menuItemHover")};
+ background: ${({ active }) => getColor(active ? "menuItemSelectedHover" : "menuItemHover")};
+ }
+`
+
+export const VerticalTab = styled(StyledTab).attrs({
+ variant: "line",
+ appearance: "neutral",
+ round: 1,
+ padding: [1, 3],
+ height: { min: 7 },
+ width: "100%",
+})`
+ justify-content: flex-start;
+ height: auto;
+ color: ${({ active }) => getColor(active ? "menuItemSelectedText" : "text")};
+ background: ${({ active }) => getColor(active ? "menuItemSelected" : transparent)};
+ box-shadow: ${({ active, theme }) =>
+ active ? `inset 3px 0 0 ${getColor("primary")({ theme })}` : "none"};
+
+ &:hover {
+ background: ${({ active }) => getColor(active ? "menuItemSelectedHover" : "menuItemHover")};
+ }
+
+ > span {
+ text-align: start;
+ white-space: normal;
}
`
diff --git a/src/components/tabs/tab.d.ts b/src/components/tabs/tab.d.ts
index 15fc36198..aa6c78eb3 100644
--- a/src/components/tabs/tab.d.ts
+++ b/src/components/tabs/tab.d.ts
@@ -1,17 +1,26 @@
-import { ChangeEvent, FC } from "react"
+import { CSSProperties, FC, MouseEvent, ReactNode, Ref } from "react"
-export interface TabProps {
+import { FlexProps } from "@/components/templates/flex"
+
+export interface TabProps extends FlexProps {
active?: boolean
disabled?: boolean
"data-testid"?: string
count?: number
icon?: string
index?: number
- label: JSX.Element | string
+ label: ReactNode | ((props: TabProps) => ReactNode)
maxWidth?: number | string
minWidth?: number | string
- onChange?: (e: ChangeEvent) => void
+ onChange?: (index: number, event: MouseEvent) => void
small?: boolean
+ variant?: "line" | "contained"
+ appearance?: "raised" | "neutral"
+ fontSize?: number | string
+ lineHeight?: CSSProperties["lineHeight"]
+ fontWeight?: number | string
+ ref?: Ref
+ accent?: boolean
[s: string]: any
}
diff --git a/src/components/tabs/tab.js b/src/components/tabs/tab.js
index 82a38f6f5..ae133f8e6 100644
--- a/src/components/tabs/tab.js
+++ b/src/components/tabs/tab.js
@@ -1,6 +1,7 @@
import React, { useCallback } from "react"
+import { RaisedSegmentedItem } from "@/components/button/segmented"
import { Icon } from "@/components/icon"
-import { StyledTab, StyledTabMenu, TabCount, TabLabel } from "./styled"
+import { StyledTab, StyledTabMenu, VerticalTab, TabCount, TabLabel, isNeutralLine } from "./styled"
const tabRoleProps = ({ active, disabled }) => ({
role: "tab",
@@ -9,16 +10,18 @@ const tabRoleProps = ({ active, disabled }) => ({
tabIndex: active && !disabled ? 0 : -1,
})
-export const Tab = ({ index, isMenuItem, onChange, icon, count, ...rest }) => {
+export const Tab = ({ index, isMenuItem, onChange, icon, count, vertical, ...rest }) => {
const onClick = useCallback(e => onChange && onChange(index || 0, e), [index, onChange])
- const TabComponent = isMenuItem ? StyledTabMenu : StyledTab
+ const isRaised = !vertical && rest.variant === "contained" && rest.appearance === "raised"
+ const LineTab = vertical ? VerticalTab : StyledTab
+ const TabComponent = isMenuItem ? StyledTabMenu : isRaised ? RaisedSegmentedItem : LineTab
const hasSlots = !!icon || count !== undefined
return (
{
{typeof rest.label === "function" ? (
rest.label({ index, isMenuItem, icon, count, ...rest })
) : typeof rest.label === "string" ? (
- {rest.label}
+
+ {rest.label}
+
) : (
rest.label
)}
diff --git a/src/components/tabs/tabs-hooks.js b/src/components/tabs/tabs-hooks.js
index b0f0d1971..de04c00b9 100644
--- a/src/components/tabs/tabs-hooks.js
+++ b/src/components/tabs/tabs-hooks.js
@@ -1,7 +1,9 @@
import React, { Children, useState, useCallback, useMemo, useEffect } from "react"
import { Tab } from "./tab"
-export const useBuildTabs = (children, activeIndex, onChange, variant) => {
+export const useBuildTabs = (children, activeIndex, onChange, styleOptions) => {
+ const { variant, appearance, accent, vertical, panelId } = styleOptions
+
return useMemo(() => {
const indeces = []
const nav = []
@@ -11,7 +13,7 @@ export const useBuildTabs = (children, activeIndex, onChange, variant) => {
Children.forEach(children, (tab, index) => {
const props = tab?.props || {}
- if (firstActiveIndex < 0 && !props.disabled) firstActiveIndex = index
+ if (firstActiveIndex < 0 && tab && !props.disabled) firstActiveIndex = index
const isActive = activeIndex === indeces.length
const key = `${index}-${props.label}`
@@ -21,7 +23,12 @@ export const useBuildTabs = (children, activeIndex, onChange, variant) => {
{
}
if (isActive) {
- activeIsDisabled = !!props.disabled
+ activeIsDisabled = !!props.disabled || (vertical && !tab)
content = props.children
}
indeces.push(index)
})
+ if (vertical && !nav.some(tab => tab.props.active)) activeIsDisabled = true
return [nav, content, firstActiveIndex, activeIsDisabled]
- }, [children, activeIndex, onChange, variant])
+ }, [children, activeIndex, onChange, variant, appearance, accent, vertical, panelId])
}
export const useSetActive = (selected = 0, onChange) => {
diff --git a/src/components/tabs/tabs.d.ts b/src/components/tabs/tabs.d.ts
index 0dee0829b..33188b3b8 100644
--- a/src/components/tabs/tabs.d.ts
+++ b/src/components/tabs/tabs.d.ts
@@ -1,14 +1,17 @@
-import { ChangeEvent, FC, ReactNode } from "react"
+import { ComponentType, FC } from "react"
export interface TabsProps {
className?: string
"data-testid"?: string
noDefaultBorder?: boolean
- onChange: (e: ChangeEvent) => void
- selected: boolean
- TabContent?: ReactNode
- TabsHeader?: ReactNode
+ onChange?: (index: number) => void
+ selected?: number
+ TabContent?: ComponentType
+ TabsHeader?: ComponentType
variant?: "line" | "contained"
+ orientation?: "horizontal" | "vertical"
+ appearance?: "raised" | "neutral"
+ accent?: boolean
[s: string]: any
}
diff --git a/src/components/tabs/tabs.js b/src/components/tabs/tabs.js
index 7d86ac739..476514a0b 100644
--- a/src/components/tabs/tabs.js
+++ b/src/components/tabs/tabs.js
@@ -1,13 +1,17 @@
-import React, { Fragment, useCallback, useEffect } from "react"
-import { StyledTabs, StyledTabsWrapper } from "./styled"
+import React, { Fragment, useCallback, useEffect, useId } from "react"
+import Flex from "@/components/templates/flex"
+import { SegmentedTrack } from "@/components/button/segmented"
+import { isNeutralLine, StyledTabs, StyledTabsWrapper } from "./styled"
import { useBuildTabs, useSetActive } from "./tabs-hooks"
-const stepByKey = { ArrowRight: 1, ArrowLeft: -1 }
+const horizontalSteps = { ArrowRight: 1, ArrowLeft: -1 }
+const verticalSteps = { ArrowDown: 1, ArrowUp: -1 }
// Roving focus: arrows move to the next enabled tab and select it, wrapping at the ends.
-const moveFocus = e => {
- const step = stepByKey[e.key]
- if (!step) return
+const moveFocus = (e, vertical, supportsBoundaryKeys) => {
+ const step = (vertical ? verticalSteps : horizontalSteps)[e.key]
+ const boundary = supportsBoundaryKeys && (e.key === "Home" || e.key === "End")
+ if (!step && !boundary) return
const tabs = Array.from(
e.currentTarget.querySelectorAll('[role="tab"]:not([aria-disabled="true"])')
@@ -16,7 +20,9 @@ const moveFocus = e => {
if (current < 0) return
e.preventDefault()
- const next = tabs[(current + step + tabs.length) % tabs.length]
+ const next = boundary
+ ? tabs[e.key === "Home" ? 0 : tabs.length - 1]
+ : tabs[(current + step + tabs.length) % tabs.length]
next.focus()
next.click()
}
@@ -27,50 +33,101 @@ export const Tabs = ({
selected,
children,
TabsHeader = Fragment,
- TabContent = Fragment,
+ TabContent,
noDefaultBorder,
variant = "line",
+ orientation = "horizontal",
+ appearance,
+ accent,
tabsProps,
tabHeaderProps,
tabContentProps,
ref,
...rest
}) => {
+ const id = useId()
+ const vertical = orientation === "vertical"
+ const Panel = TabContent ?? (vertical ? Flex : Fragment)
+ const panelId = vertical && Panel !== Fragment ? (tabContentProps?.id ?? id) : undefined
const [activeIndex, setActiveIndex] = useSetActive(selected, onChange)
const [nav, content, firstActiveIndex, activeIsDisabled] = useBuildTabs(
children,
activeIndex,
setActiveIndex,
- variant
+ { variant, appearance, accent, vertical, panelId }
)
+ const isRaised = !vertical && variant === "contained" && appearance === "raised"
+ const supportsBoundaryKeys = vertical || isRaised || isNeutralLine({ variant, appearance })
+
const onKeyDown = useCallback(
e => {
- moveFocus(e)
+ moveFocus(e, vertical, supportsBoundaryKeys)
tabsProps?.onKeyDown?.(e)
},
- [tabsProps]
+ [tabsProps, vertical, supportsBoundaryKeys]
)
useEffect(() => {
if (activeIsDisabled && activeIndex !== firstActiveIndex) setActiveIndex(firstActiveIndex)
}, [activeIndex, firstActiveIndex, activeIsDisabled, setActiveIndex])
+ const activeTabId = panelId && nav.find(tab => tab.props.active)?.props.id
+
return (
-
+
-
- {nav}
-
+ {isRaised ? (
+
+ {nav}
+
+ ) : (
+
+ {nav}
+
+ )}
- {content}
+
+ {content}
+
)
}
diff --git a/src/components/tabs/tabs.test.js b/src/components/tabs/tabs.test.js
index 1507a5411..ca7d2950e 100644
--- a/src/components/tabs/tabs.test.js
+++ b/src/components/tabs/tabs.test.js
@@ -3,7 +3,7 @@
*/
import React, { useState } from "react"
-import { renderWithProviders, fireEvent } from "testUtilities"
+import { renderWithProviders, fireEvent, user } from "testUtilities"
import { Tabs, Tab } from "."
describe("Tabs states", () => {
@@ -388,7 +388,7 @@ describe("Tabs contained variant", () => {
const { container } = renderContained()
const strip = container.querySelector("nav")
expect(strip).toHaveStyleRule("background", getRgbColor("textLite", 0.12)({ theme }))
- expect(strip).toHaveStyleRule("border", `1px solid ${light.borderSecondary}`)
+ expect(strip).toHaveStyleRule("border", `1px solid ${light.segmentedBorder}`)
expect(strip).toHaveStyleRule("display", "inline-flex")
expect(strip).toHaveStyleRule("align-self", "flex-start")
expect(strip).not.toHaveStyleRule("box-shadow", expect.anything())
@@ -426,6 +426,113 @@ describe("Tabs contained variant", () => {
})
})
+describe("Tabs raised contained appearance", () => {
+ const { DefaultTheme, DarkTheme } = require("@/theme")
+
+ const renderRaised = (props = {}, options) =>
+ renderWithProviders(
+
+ Overview content
+
+ Billing content
+
+ Nodes content
+ ,
+ options
+ )
+
+ it.each([
+ ["light", DefaultTheme],
+ ["dark", DarkTheme],
+ ])("uses the raised segmented primitives and accent tokens in %s theme", (_, theme) => {
+ const { getByRole, getAllByRole } = renderRaised(
+ { accent: true, tabsProps: { "aria-label": "View switcher" } },
+ { theme }
+ )
+ const [active, , inactive] = getAllByRole("tab")
+
+ expect(getByRole("tablist").tagName).toBe("NAV")
+ expect(getByRole("tablist")).toHaveAttribute("aria-label", "View switcher")
+ expect(active.tagName).toBe("BUTTON")
+ expect(active).toHaveStyleRule("color", theme.colors.segmentedAccentText)
+ expect(active).toHaveStyleRule("background-color", theme.colors.segmentedAccentBackground)
+ expect(active).toHaveStyleRule("box-shadow", theme.shadows.segmentedAccentSelected)
+ expect(active).toHaveStyleRule("color", theme.colors.segmentedAccentText, {
+ modifier: ":hover",
+ })
+ expect(inactive).toHaveStyleRule("color", theme.colors.statusMutedText)
+ expect(inactive).toHaveStyleRule("box-shadow", "none")
+ expect(active).toHaveStyleRule("outline-color", theme.colors.segmentedFocus, {
+ modifier: ":focus-visible",
+ })
+ })
+
+ it("keeps controlled selection, native activation, and external tab attributes", async () => {
+ const onChange = jest.fn()
+ const { getAllByRole, queryByText } = renderWithProviders(
+
+
+ Overview content
+
+
+ Nodes content
+
+
+ )
+ const [, nodes] = getAllByRole("tab")
+
+ expect(getAllByRole("tab")[0]).toHaveAttribute("id", "overview-tab")
+ expect(getAllByRole("tab")[0]).toHaveAttribute("aria-controls", "overview-panel")
+ expect(nodes).toHaveAttribute("aria-label", "Node view")
+ nodes.focus()
+ await user().keyboard("{Enter}")
+ expect(onChange).toHaveBeenCalledTimes(1)
+ expect(onChange).toHaveBeenLastCalledWith(1)
+ await user().keyboard(" ")
+ expect(onChange).toHaveBeenCalledTimes(2)
+ expect(onChange).toHaveBeenLastCalledWith(1)
+ expect(queryByText("Overview content")).toBeInTheDocument()
+ })
+
+ it("uses Home and End only for raised tabs while arrows keep wrapping past disabled tabs", () => {
+ const { getAllByRole, queryByText } = renderRaised()
+ const [overview, , nodes] = getAllByRole("tab")
+
+ overview.focus()
+ fireEvent.keyDown(overview, { key: "End" })
+ expect(nodes).toHaveFocus()
+ expect(queryByText("Nodes content")).toBeInTheDocument()
+
+ fireEvent.keyDown(nodes, { key: "Home" })
+ expect(overview).toHaveFocus()
+ expect(queryByText("Overview content")).toBeInTheDocument()
+
+ fireEvent.keyDown(overview, { key: "ArrowLeft" })
+ expect(nodes).toHaveFocus()
+ })
+
+ it("does not add a panel when the active tab has no content", () => {
+ const { queryByRole } = renderWithProviders(
+
+
+
+ )
+
+ expect(queryByRole("tabpanel")).not.toBeInTheDocument()
+ })
+
+ it("preserves a supplied content wrapper when the active tab has no content", () => {
+ const Panel = ({ children }) =>
+ const { queryByTestId } = renderWithProviders(
+
+
+
+ )
+
+ expect(queryByTestId("panel")).toBeInTheDocument()
+ })
+})
+
describe("Tabs accessibility", () => {
const renderStrip = (props = {}) =>
renderWithProviders(
@@ -485,6 +592,37 @@ describe("Tabs accessibility", () => {
expect(onChange).toHaveBeenCalledWith(2)
})
+ it("enables Home and End only while the raised appearance is active", () => {
+ const tabsProps = {}
+ const renderTabs = appearance => (
+
+ Overview content
+ Nodes content
+
+ )
+ const { getAllByRole, rerender } = renderWithProviders(renderTabs())
+ let [overview, nodes] = getAllByRole("tab")
+
+ overview.focus()
+ fireEvent.keyDown(overview, { key: "End" })
+ expect(overview).toHaveFocus()
+
+ rerender(renderTabs("raised"))
+ const raisedTabs = getAllByRole("tab")
+ overview = raisedTabs[0]
+ nodes = raisedTabs[1]
+ overview.focus()
+ fireEvent.keyDown(overview, { key: "End" })
+ expect(nodes).toHaveFocus()
+
+ rerender(renderTabs())
+ const defaultTabs = getAllByRole("tab")
+ nodes = defaultTabs[1]
+ nodes.focus()
+ fireEvent.keyDown(nodes, { key: "Home" })
+ expect(nodes).toHaveFocus()
+ })
+
it("shows a focus ring on keyboard focus", () => {
const { getAllByRole } = renderStrip()
const { DefaultTheme } = require("@/theme")
diff --git a/src/components/tabs/tabs.usage.mdx b/src/components/tabs/tabs.usage.mdx
index f17c981a8..deaa9b5ed 100644
--- a/src/components/tabs/tabs.usage.mdx
+++ b/src/components/tabs/tabs.usage.mdx
@@ -36,12 +36,13 @@ The strip lines up with the content edge. Space between the strip and the conten
- `variant="line"` is the default: tabs sit on a divider and the selected tab gets an underline.
- `variant="contained"` draws the strip as a track, the same look as segmented value pickers, and raises the selected tab. It has no divider and no underline, and it is only as wide as its tabs. Use it for a small switch between views, such as Charts and Table.
+- Add `appearance="raised"` to a contained strip to use the shared raised segmented controls. Set `accent` when the selected tab should use the accent text, background, and outline tokens.
## Flavours and sizes
-These apply to line tabs. Contained tabs always use the raised style and are 22px tall.
+These apply to line tabs. Default contained tabs use the compact 22px segmented style; the raised appearance follows the shared raised segmented controls.
- `flavour` sets the colour of the selected underline: `default` and `success` use the primary colour, `warning` and `error` use their status colour. Hover never changes hue.
- Default tabs are 32px tall. `small={false}` makes them 40px. `green` gives compact 24px tabs (32px with `small={false}`).
@@ -60,7 +61,7 @@ These apply to line tabs. Contained tabs always use the raised style and are 22p
## Accessibility
- The strip is a `nav` with `role="tablist"`. Each tab has `role="tab"` and `aria-selected`; disabled tabs set `aria-disabled`.
-- Only the selected tab is in the page tab order. Left and right arrow keys move to the previous or next enabled tab and select it, wrapping at the ends, in both variants.
+- Only the selected tab is in the page tab order. Left and right arrow keys move to the previous or next enabled tab and select it, wrapping at the ends, in both variants. Raised contained tabs also support Home and End.
- The `icon` is hidden from screen readers, because the label already names the tab.
## Do and don't
@@ -69,3 +70,11 @@ These apply to line tabs. Contained tabs always use the raised style and are 22p
- Do use counters sparingly and neutral, since counts are not status.
- Don't nest tab strips.
- Don't put more tabs than fit; the strip scrolls horizontally but hides its scrollbar.
+
+### Vertical navigation
+
+Use `orientation="vertical"` for a workspace sidebar. Tabs use the menu selection
+and hover colors, and Up/Down, Home and End move to enabled tabs. The default
+panel has `role="tabpanel"` and is labelled by its selected tab. Pass
+`TabContent={Fragment}` for a caller-owned external panel with its own ARIA IDs.
+Use `tabsProps` to set the rail's width, surface, divider and accessible name.
diff --git a/src/components/tabs/vertical.test.js b/src/components/tabs/vertical.test.js
new file mode 100644
index 000000000..558532481
--- /dev/null
+++ b/src/components/tabs/vertical.test.js
@@ -0,0 +1,35 @@
+import React from "react"
+import { renderWithProviders, screen, user } from "testUtilities"
+import { Tab, Tabs } from "."
+
+it("selects and labels a vertical panel with keyboard navigation", async () => {
+ renderWithProviders(
+
+ Info panel
+
+ Nodes panel
+
+ )
+ const keyboard = user()
+ const info = screen.getByRole("tab", { name: "Info" })
+ const nodes = screen.getByRole("tab", { name: "Nodes" })
+ expect(screen.getByRole("tablist")).toHaveAttribute("aria-orientation", "vertical")
+ await keyboard.tab()
+ expect(info).toHaveFocus()
+ expect(screen.getByRole("tabpanel", { name: "Info" })).toHaveTextContent("Info panel")
+
+ await keyboard.keyboard("{ArrowDown}")
+ expect(nodes).toHaveFocus()
+ expect(nodes).toHaveAttribute("aria-selected", "true")
+ expect(screen.getByRole("tabpanel", { name: "Nodes" })).toHaveTextContent("Nodes panel")
+ expect(screen.getByRole("tabpanel").id).toBe(nodes.getAttribute("aria-controls"))
+
+ await keyboard.keyboard("{ArrowRight}")
+ expect(nodes).toHaveFocus()
+ await keyboard.keyboard("{ArrowUp}")
+ expect(info).toHaveFocus()
+ await keyboard.keyboard("{End}")
+ expect(nodes).toHaveFocus()
+ await keyboard.keyboard("{Home}")
+ expect(info).toHaveFocus()
+})
diff --git a/src/components/templates/flex/index.stories.js b/src/components/templates/flex/index.stories.js
index 751e5d677..32c664ee3 100644
--- a/src/components/templates/flex/index.stories.js
+++ b/src/components/templates/flex/index.stories.js
@@ -87,7 +87,7 @@ export const Alignment = () => (
{["start", "center", "end", "between", "around", "evenly"].map(value => (
- justifyContent="{value}"
+ {`justifyContent="${value}"`}
- cpu
- ram
diff --git a/src/components/templates/layer/backdropContainer.js b/src/components/templates/layer/backdropContainer.js
index c51a0e720..9bf6d360e 100644
--- a/src/components/templates/layer/backdropContainer.js
+++ b/src/components/templates/layer/backdropContainer.js
@@ -2,6 +2,7 @@ import React from "react"
import styled from "styled-components"
import backdropBlur from "@/components/templates/layer/mixins/backdropBlur"
import { scrimColor } from "@/components/templates/layer/mixins/elevation"
+import background from "@/components/templates/mixins/background"
const Container = styled.div`
position: fixed;
@@ -16,6 +17,7 @@ const Backdrop = styled.div`
inset: 0;
pointer-events: all;
background-color: ${scrimColor};
+ ${background};
${backdropBlur};
`
diff --git a/src/components/templates/layer/index.d.ts b/src/components/templates/layer/index.d.ts
index 618236a65..052fe203a 100644
--- a/src/components/templates/layer/index.d.ts
+++ b/src/components/templates/layer/index.d.ts
@@ -1,4 +1,5 @@
-import { MarginProps } from "../../../mixins/types"
+import React from "react"
+import { ColorType, MarginProps } from "../../../mixins/types"
export interface PositionProps {
position?:
@@ -18,7 +19,19 @@ export interface FullProps {
}
export interface LayerProps extends MarginProps, FullProps, PositionProps {
+ children?: React.ReactNode
+ zIndex?: number | string
backdrop?: boolean
+ backdropContainerProps?: React.HTMLAttributes & {
+ zIndex?: number | string
+ "data-testid"?: string
+ }
+ backdropProps?: React.HTMLAttributes & {
+ background?: ColorType
+ backgroundOpacity?: number
+ backdropBlur?: boolean | number | string
+ "data-testid"?: string
+ }
onClickOutside?: Function
onEsc?: Function
borderShadow?: boolean
diff --git a/src/components/templates/layer/index.test.js b/src/components/templates/layer/index.test.js
index fe32c8acd..8742954be 100644
--- a/src/components/templates/layer/index.test.js
+++ b/src/components/templates/layer/index.test.js
@@ -178,7 +178,7 @@ describe("backdrop and elevation", () => {
const { getByTestId } = renderWithProviders(layer content)
expect(getByTestId("layer-backdrop")).toHaveStyleRule(
"background-color",
- "rgba(53, 65, 74, 0.32)"
+ "rgba(57, 65, 60, 0.32)"
)
})
@@ -188,7 +188,7 @@ describe("backdrop and elevation", () => {
})
expect(getByTestId("layer-backdrop")).toHaveStyleRule(
"background-color",
- "rgba(8, 10, 10, 0.6)"
+ "rgba(8, 10, 9, 0.6)"
)
})
diff --git a/src/components/templates/layer/mixins/elevation.js b/src/components/templates/layer/mixins/elevation.js
index 8e034f4a5..22becdedc 100644
--- a/src/components/templates/layer/mixins/elevation.js
+++ b/src/components/templates/layer/mixins/elevation.js
@@ -1,4 +1,4 @@
-import { getColor, getRgbColor } from "@/theme/utils"
+import { getColor, getRgbColor, getSizeBy } from "@/theme/utils"
// Luminance of mainBackground, so custom themes built on either palette pick the right scrim.
export const isDarkTheme = props => {
@@ -19,6 +19,9 @@ export const modalShadow = props => {
return `0 16px 40px -8px ${color}, 0 2px 6px ${color}`
}
+export const dialogShadow = props =>
+ `0 ${getSizeBy(2)(props)} ${getSizeBy(6)(props)} ${getRgbColor("onColorDark", isDarkTheme(props) ? 0.5 : 0.2)(props)}`
+
// A plain black wash barely dims the dark app, so dark gets a denser near-black scrim.
export const scrimColor = props =>
isDarkTheme(props)
diff --git a/src/components/templates/layer/mixins/elevation.test.js b/src/components/templates/layer/mixins/elevation.test.js
index d9043e6b2..aa484076a 100644
--- a/src/components/templates/layer/mixins/elevation.test.js
+++ b/src/components/templates/layer/mixins/elevation.test.js
@@ -19,8 +19,8 @@ describe("elevation", () => {
})
it("uses an ink scrim on light and a near-black scrim on dark", () => {
- expect(scrimColor({ theme: DefaultTheme })).toBe("rgba(53, 65, 74, 0.32)")
- expect(scrimColor({ theme: DarkTheme })).toBe("rgba(8, 10, 10, 0.6)")
+ expect(scrimColor({ theme: DefaultTheme })).toBe("rgba(57, 65, 60, 0.32)")
+ expect(scrimColor({ theme: DarkTheme })).toBe("rgba(8, 10, 9, 0.6)")
})
})
diff --git a/src/components/templates/mixins/border.test.js b/src/components/templates/mixins/border.test.js
index 32ab17938..cb3ea2abe 100644
--- a/src/components/templates/mixins/border.test.js
+++ b/src/components/templates/mixins/border.test.js
@@ -1,6 +1,3 @@
-import React from "react"
-import { renderWithProviders } from "testUtilities"
-import styled from "styled-components"
import { DefaultTheme as theme } from "@/theme/default"
import styledBorder from "./border"
diff --git a/src/components/templates/mixins/index.d.ts b/src/components/templates/mixins/index.d.ts
index 95b3282f2..7fa4686d8 100644
--- a/src/components/templates/mixins/index.d.ts
+++ b/src/components/templates/mixins/index.d.ts
@@ -13,8 +13,13 @@ type BorderSizeType = "all" | "horizontal" | "vertical" | "top" | "right" | "bot
export interface BorderProps {
border?:
| boolean
- | BorderSizeType
- | { side: BorderSizeType; color?: ColorType; size?: DimensionsType; type?: string }
+ | ColorType
+ | {
+ side: BorderSizeType | BorderSizeType[]
+ color?: ColorType
+ size?: DimensionsType
+ type?: string
+ }
}
export interface DirectionProps {
diff --git a/src/components/toggle/README.md b/src/components/toggle/README.md
index 8cd235027..fde8e3406 100644
--- a/src/components/toggle/README.md
+++ b/src/components/toggle/README.md
@@ -13,6 +13,10 @@ interface ToggleProps {
labelRight?: string
Label?: React.ComponentType
colored?: boolean
+ size?: "default" | "small" | "compact"
+ variant?: "default" | "outline"
+ activateOnEnter?: boolean
+ labelGap?: number
ref?: React.MutableRefObject
className?: string
disabled?: boolean
@@ -30,3 +34,37 @@ export const ContolledToggle = () => {
return
}
```
+
+### Compact outline switches
+
+`size` defaults to `"default"` (40×20 track, 14px knob). `"small"` is 34×20 with a 13px knob;
+`"compact"` is 26×16 with a 9px knob. All dimensions use the theme size unit.
+
+`variant="outline"` draws a transparent off track with a 1.5px border. It uses
+`controlBorder` for the off border and knob, `segmentedAccentText` for the checked track,
+`buttonNeutralText` for its checked knob, `textFocus` for off hover, and `segmentedFocus`
+for keyboard focus. Disabled outline switches dim the track while their labels stay legible.
+The default variant retains its existing palette.
+
+`activateOnEnter` defaults to false, preserving native checkbox keyboard behavior. Set it to
+true when replacing a button switch that activated with Enter as well as Space. Enter is
+handled once per press and does not submit the surrounding form; a caller's `onKeyDown`
+can prevent the activation. The real checkbox retains the switch role and native
+`onChange`, focus, blur, disabled and ARIA props.
+
+`labelGap` uses the 4px spacing scale, including fractions; omit it for the existing theme
+size-unit gap. `Label="span"` lets the label inherit surrounding typography.
+
+```jsx
+ setEnabled(event.currentTarget.checked)}
+ aria-label="Collector"
+ labelRight={enabled ? "On" : "Off"}
+ Label="span"
+ labelGap={1.75}
+/>
+```
diff --git a/src/components/toggle/__snapshots__/toggle.test.js.snap b/src/components/toggle/__snapshots__/toggle.test.js.snap
index 2a398ada8..e70374b73 100644
--- a/src/components/toggle/__snapshots__/toggle.test.js.snap
+++ b/src/components/toggle/__snapshots__/toggle.test.js.snap
@@ -4,10 +4,10 @@ exports[`Toggle test * should render with labels 1`] = `
.c2 {
font-family: "IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif;
font-style: normal;
- font-size: 12px;
+ font-size: 13px;
line-height: 16px;
font-weight: normal;
- color: #526161;
+ color: #2D3E33;
text-transform: none;
}
@@ -43,8 +43,8 @@ exports[`Toggle test * should render with labels 1`] = `
box-sizing: border-box;
width: 40px;
height: 20px;
- background: #FFFFFF;
- border: 1px solid #708585;
+ background: #F6F8F6;
+ border: 1px solid #5C6A61;
border-radius: 100px;
transition: background-color 140ms ease-out,border-color 140ms ease-out;
display: block;
@@ -66,11 +66,11 @@ exports[`Toggle test * should render with labels 1`] = `
top: 2px;
transform: none;
transition: transform 140ms ease-out,background-color 140ms ease-out;
- background-color: #35414A;
+ background-color: #39413C;
}
.c0:hover .c7 {
- border-color: #526161;
+ border-color: #2D3E33;
}
.c5:focus-visible+.c7 {
@@ -160,8 +160,8 @@ exports[`Toggle test * should render with required props 1`] = `
box-sizing: border-box;
width: 40px;
height: 20px;
- background: #FFFFFF;
- border: 1px solid #708585;
+ background: #F6F8F6;
+ border: 1px solid #5C6A61;
border-radius: 100px;
transition: background-color 140ms ease-out,border-color 140ms ease-out;
display: block;
@@ -183,11 +183,11 @@ exports[`Toggle test * should render with required props 1`] = `
top: 2px;
transform: none;
transition: transform 140ms ease-out,background-color 140ms ease-out;
- background-color: #35414A;
+ background-color: #39413C;
}
.c0:hover .c5 {
- border-color: #526161;
+ border-color: #2D3E33;
}
.c3:focus-visible+.c5 {
diff --git a/src/components/toggle/outline.test.js b/src/components/toggle/outline.test.js
new file mode 100644
index 000000000..1f12411ec
--- /dev/null
+++ b/src/components/toggle/outline.test.js
@@ -0,0 +1,99 @@
+import React from "react"
+import { renderWithProviders, screen, user } from "testUtilities"
+import { DefaultTheme } from "@/theme/default"
+import { DarkTheme } from "@/theme/dark"
+import { Toggle } from "."
+
+const OutlineToggle = props => (
+ {}} {...props} />
+)
+
+it.each([
+ ["small", "34px", "20px", "13px", "2px", "14px"],
+ ["compact", "26px", "16px", "9px", "2px", "10px"],
+])(
+ "centres the %s outline switch knob at both ends",
+ (size, width, height, knob, inset, travel) => {
+ const { rerender } = renderWithProviders()
+ const track = screen.getByRole("switch").nextElementSibling
+ expect(track).toHaveStyleRule("width", width)
+ expect(track).toHaveStyleRule("height", height)
+ expect(track).toHaveStyleRule("border-width", "1.5px")
+ expect(track).toHaveStyleRule("width", knob, { modifier: ":after" })
+ expect(track).toHaveStyleRule("height", knob, { modifier: ":after" })
+ expect(track).toHaveStyleRule("left", inset, { modifier: ":after" })
+ expect(track).toHaveStyleRule("top", inset, { modifier: ":after" })
+ rerender()
+ expect(screen.getByRole("switch").nextElementSibling).toHaveStyleRule(
+ "transform",
+ `translateX(${travel})`,
+ { modifier: ":after" }
+ )
+ }
+)
+
+it.each([
+ ["light", DefaultTheme],
+ ["dark", DarkTheme],
+])("uses the outline palette in the %s theme", (_, theme) => {
+ const { rerender } = renderWithProviders(, { theme })
+ const track = screen.getByRole("switch").nextElementSibling
+ expect(track).toHaveStyleRule("background", "rgba(255,255,255,0.0)")
+ expect(track).toHaveStyleRule("border-color", theme.colors.controlBorder)
+ expect(track).toHaveStyleRule("background-color", theme.colors.controlBorder, {
+ modifier: ":after",
+ })
+ rerender()
+ const onTrack = screen.getByRole("switch").nextElementSibling
+ expect(onTrack).toHaveStyleRule("background", theme.colors.segmentedAccentText)
+ expect(onTrack).toHaveStyleRule("border-color", theme.colors.segmentedAccentText)
+ expect(onTrack).toHaveStyleRule("background-color", theme.colors.buttonNeutralText, {
+ modifier: ":after",
+ })
+})
+
+it("opts into Enter activation once without submitting its form", async () => {
+ const onChange = jest.fn()
+ const onSubmit = jest.fn(e => e.preventDefault())
+ renderWithProviders(
+
+ )
+ await user().tab()
+ await user().keyboard("{Enter}")
+ expect(onChange).toHaveBeenCalledTimes(1)
+ expect(onSubmit).not.toHaveBeenCalled()
+})
+
+it("retains checkbox Enter behavior by default", async () => {
+ const onChange = jest.fn()
+ renderWithProviders()
+ await user().tab()
+ await user().keyboard("{Enter}")
+ expect(onChange).not.toHaveBeenCalled()
+})
+
+it("keeps a compact switch label clickable with a fractional label gap", async () => {
+ const onChange = jest.fn()
+ renderWithProviders(
+
+ )
+ expect(screen.getByText("On")).toHaveStyleRule("margin-left", "7px")
+ await user().click(screen.getByText("On"))
+ expect(onChange).toHaveBeenCalledTimes(1)
+})
+
+it("dims only the disabled outline track while keeping its state word legible", () => {
+ const { container } = renderWithProviders(
+
+ )
+ expect(container.querySelector("label")).not.toHaveStyleRule("opacity", "0.4")
+ expect(screen.getByRole("switch").nextElementSibling).toHaveStyleRule("opacity", "0.4")
+})
diff --git a/src/components/toggle/styled.js b/src/components/toggle/styled.js
index ab11d3235..4c02a3354 100644
--- a/src/components/toggle/styled.js
+++ b/src/components/toggle/styled.js
@@ -5,11 +5,25 @@ import visuallyHidden from "@/mixins/visuallyHidden"
import margin from "@/mixins/margin"
import alignSelf from "@/mixins/alignSelf"
+const sizes = {
+ default: { width: 40, height: 20, knob: 14 },
+ small: { width: 34, height: 20, knob: 13 },
+ compact: { width: 26, height: 16, knob: 9 },
+}
+
+const dimensions = ({ size }) => sizes[size] || sizes.default
+const dimension = key => props => getSizeBy(dimensions(props)[key] / 8)(props)
+const inset = props =>
+ (dimensions(props).height - (props.variant === "outline" ? 3 : 2) - dimensions(props).knob) / 2
+const knobInset = props => getSizeBy(inset(props) / 8)(props)
+const knobTravel = props =>
+ getSizeBy((dimensions(props).width - dimensions(props).height) / 8)(props)
+
export const ToggleContainer = styled.div`
display: block;
box-sizing: border-box;
- width: ${getSizeBy(5)};
- height: ${getSizeBy(2.5)};
+ width: ${dimension("width")};
+ height: ${dimension("height")};
`
// Visually hidden instead of display:none so the switch stays reachable by keyboard.
@@ -27,7 +41,7 @@ export const StyledLabel = styled.label`
display: flex;
flex-flow: row nowrap;
align-items: center;
- ${({ disabled }) => disabled && "opacity: 0.4;"}
+ ${({ disabled, variant }) => disabled && variant !== "outline" && "opacity: 0.4;"}
`
const getTrackFill = ({ checked, colored, checkedColor }) => {
@@ -44,8 +58,8 @@ const getKnobColor = ({ colored, checked, uncheckedColor, defaultColor }) => {
export const StyledToggle = styled.div`
box-sizing: border-box;
- width: ${getSizeBy(5)};
- height: ${getSizeBy(2.5)};
+ width: ${dimension("width")};
+ height: ${dimension("height")};
background: ${getTrackFill};
border: 1px solid ${getColor("textLite")};
${props => props.checked && `border-color: ${getTrackFill(props)(props)};`}
@@ -65,12 +79,12 @@ export const StyledToggle = styled.div`
display: block;
position: absolute;
content: "";
- width: ${getSizeBy(1.75)};
- height: ${getSizeBy(1.75)};
+ width: ${dimension("knob")};
+ height: ${dimension("knob")};
border-radius: 50%;
- left: ${getSizeBy(0.25)};
- top: ${getSizeBy(0.25)};
- transform: ${props => (props.checked ? `translateX(${getSizeBy(2.5)(props)})` : "none")};
+ left: ${knobInset};
+ top: ${knobInset};
+ transform: ${props => (props.checked ? `translateX(${knobTravel(props)})` : "none")};
transition:
transform 140ms ease-out,
background-color 140ms ease-out;
@@ -100,6 +114,37 @@ export const StyledToggle = styled.div`
}
`}
+ ${({ variant, checked, disabled }) =>
+ variant === "outline" &&
+ css`
+ background: ${checked ? getColor("segmentedAccentText") : getColor(["transparent", "full"])};
+ opacity: ${disabled ? 0.4 : 1};
+ cursor: ${disabled ? "not-allowed" : "pointer"};
+ pointer-events: auto;
+ border-width: ${getSizeBy(0.1875)};
+ border-color: ${getColor(checked ? "segmentedAccentText" : "controlBorder")};
+ border-radius: ${getSizeBy(12.5)};
+
+ ${HiddenToggleInput}:focus-visible + & {
+ outline-color: ${getColor("segmentedFocus")};
+ }
+
+ &:after {
+ background-color: ${getColor(checked ? "buttonNeutralText" : "controlBorder")};
+ }
+
+ ${!disabled &&
+ css`
+ ${StyledLabel}:hover & {
+ border-color: ${getColor(checked ? "segmentedAccentText" : "textFocus")};
+ ${checked &&
+ css`
+ background: ${getColor("segmentedAccentText")};
+ `}
+ }
+ `}
+ `}
+
@media (prefers-reduced-motion: reduce) {
transition: none;
@@ -110,6 +155,8 @@ export const StyledToggle = styled.div`
`
export const LabelText = styled.span`
- ${({ right, ...props }) =>
- right ? `margin-left: ${getSizeUnit(props)}px;` : `margin-right: ${getSizeUnit(props)}px;`}
+ ${({ right, labelGap, ...props }) => {
+ const gap = labelGap === undefined ? `${getSizeUnit(props)}px` : getSizeBy(labelGap / 2)(props)
+ return right ? `margin-left: ${gap};` : `margin-right: ${gap};`
+ }}
`
diff --git a/src/components/toggle/toggle.d.ts b/src/components/toggle/toggle.d.ts
index df50bb636..2795b4386 100644
--- a/src/components/toggle/toggle.d.ts
+++ b/src/components/toggle/toggle.d.ts
@@ -1,4 +1,4 @@
-import { FC, ReactNode } from "react"
+import { FC, ReactNode, ElementType } from "react"
import { AlignSelfProps, MarginProps } from "@/mixins/types"
export interface ToggleProps extends AlignSelfProps, MarginProps {
@@ -7,9 +7,13 @@ export interface ToggleProps extends AlignSelfProps, MarginProps {
colored?: boolean
"data-testid"?: string
disabled?: boolean
- Label: ReactNode
- labelLeft?: string
- labelRight?: string
+ Label?: ElementType
+ size?: "default" | "small" | "compact"
+ variant?: "default" | "outline"
+ activateOnEnter?: boolean
+ labelGap?: number
+ labelLeft?: ReactNode
+ labelRight?: ReactNode
[s: string]: any
}
diff --git a/src/components/toggle/toggle.js b/src/components/toggle/toggle.js
index e2655e441..cb8aecf1d 100644
--- a/src/components/toggle/toggle.js
+++ b/src/components/toggle/toggle.js
@@ -21,39 +21,59 @@ export const Toggle = ({
labelLeft = children,
labelRight,
Label = Text,
+ labelGap,
colored = false,
margin,
alignSelf,
toggleProps = {},
+ size = "default",
+ variant = "default",
+ activateOnEnter = false,
+ onKeyDown,
...props
}) => {
const { accessibility, visual } = splitAccessibility(toggleProps)
return (
-
+
{labelLeft && (
-
+
{labelLeft}
)}
-
+
{
+ onKeyDown?.(event)
+ if (activateOnEnter && event.key === "Enter" && !event.defaultPrevented) {
+ event.preventDefault()
+ if (!event.repeat) event.currentTarget.click()
+ }
+ }}
/>
{labelRight && (
-
+
{labelRight}
)}
diff --git a/src/components/toggle/toggle.stories.js b/src/components/toggle/toggle.stories.js
index 52bc4543b..9a6b17fcd 100644
--- a/src/components/toggle/toggle.stories.js
+++ b/src/components/toggle/toggle.stories.js
@@ -45,6 +45,25 @@ export const States = () => (
)
+export const Outline = () => (
+
+ {["small", "compact"].map(size => (
+
+
+
+
+
+ ))}
+
+)
+
export const TwoOptions = () => {
const [checked, setChecked] = useState(false)
@@ -135,7 +154,8 @@ export default {
control: "object",
},
onChange: {
- description: "Change handler of the underlying checkbox input; read event.currentTarget.checked.",
+ description:
+ "Change handler of the underlying checkbox input; read event.currentTarget.checked.",
table: { type: { summary: "(e: ChangeEvent) => void" } },
action: "onChange",
},
diff --git a/src/components/toggle/toggle.test.js b/src/components/toggle/toggle.test.js
index 59945f73f..94c562890 100644
--- a/src/components/toggle/toggle.test.js
+++ b/src/components/toggle/toggle.test.js
@@ -28,8 +28,8 @@ describe("Toggle test", () => {
expect(checkbox).toBeInTheDocument()
const toggle = getByRole("switch").nextElementSibling
- expect(toggle).toHaveStyleRule("background", "#FFFFFF")
- expect(toggle).toHaveStyleRule("background-color", "#35414A", { modifier: ":after" })
+ expect(toggle).toHaveStyleRule("background", DefaultTheme.colors.mainBackground)
+ expect(toggle).toHaveStyleRule("background-color", DefaultTheme.colors.iconColor, { modifier: ":after" })
expect(container).toMatchSnapshot()
})
@@ -48,7 +48,7 @@ describe("Toggle test", () => {
expect(checkbox).toBeDisabled()
const toggle = getByRole("switch").nextElementSibling
- expect(toggle).toHaveStyleRule("background-color", "#35414A", { modifier: ":after" })
+ expect(toggle).toHaveStyleRule("background-color", DefaultTheme.colors.iconColor, { modifier: ":after" })
})
it(" * should be colored", () => {
@@ -120,7 +120,7 @@ describe("Toggle visuals", () => {
it("draws the unchecked track with a 3:1 border", () => {
renderWithProviders( {}} />)
const track = getTrack()
- expect(track).toHaveStyleRule("border", "1px solid #708585")
+ expect(track).toHaveStyleRule("border", `1px solid ${DefaultTheme.colors.textLite}`)
expect(screen.getByRole("switch")).not.toBeChecked()
})
@@ -172,7 +172,7 @@ describe("Toggle visuals", () => {
const { rerender } = renderWithProviders(
{}} />
)
- expect(getTrack()).toHaveStyleRule("background-color", "#819595", {
+ expect(getTrack()).toHaveStyleRule("background-color", "#8A938D", {
modifier: ":after",
})
rerender( {}} />)
@@ -186,7 +186,7 @@ describe("Toggle visuals", () => {
`,
}
const { rerender } = renderWithProviders( {}} />)
- expect(getTrack()).toHaveStyleRule("border-color", "#526161", hover)
+ expect(getTrack()).toHaveStyleRule("border-color", DefaultTheme.colors.text, hover)
rerender( {}} />)
expect(getTrack()).toHaveStyleRule("background", DefaultTheme.colors.primaryHover, hover)
})
@@ -221,7 +221,7 @@ describe("Toggle fix pass", () => {
const { rerender } = renderWithProviders( {}} />, {
theme: DarkTheme,
})
- expect(getTrack()).toHaveStyleRule("background-color", "#B7C2C2", {
+ expect(getTrack()).toHaveStyleRule("background-color", DarkTheme.colors.iconColor, {
modifier: ":after",
})
rerender( {}} />)
@@ -232,7 +232,7 @@ describe("Toggle fix pass", () => {
it("keeps the dark slate off knob in the light theme", () => {
renderWithProviders( {}} />)
- expect(getTrack()).toHaveStyleRule("background-color", "#35414A", {
+ expect(getTrack()).toHaveStyleRule("background-color", DefaultTheme.colors.iconColor, {
modifier: ":after",
})
})
diff --git a/src/components/typography/index.d.ts b/src/components/typography/index.d.ts
index ca3ad7a8c..e09166ee9 100644
--- a/src/components/typography/index.d.ts
+++ b/src/components/typography/index.d.ts
@@ -16,7 +16,8 @@ import {
} from "./mixins"
export interface TypographyProps
- extends StyledComponentProps,
+ extends
+ StyledComponentProps,
AlignSelfProps,
TextAlignType,
TextDecorationType,
@@ -26,6 +27,7 @@ export interface TypographyProps
MarginProps,
PaddingProps,
OpacityProps {
+ monospace?: boolean
strong?: boolean
color?: ColorType
truncate?: boolean
diff --git a/src/components/typography/index.test.js b/src/components/typography/index.test.js
index e6182a3d4..9592c3985 100644
--- a/src/components/typography/index.test.js
+++ b/src/components/typography/index.test.js
@@ -56,23 +56,23 @@ it("renders headers with strong false as normal weight", () => {
expect(container.firstChild).toHaveStyleRule("font-weight", "normal")
})
-it("keeps the heading and text size scale unchanged", () => {
+it("renders the heading and text size scale", () => {
const scale = [
- [H0, "26px", "32px"],
- [H1, "24px", "28px"],
- [H2, "22px", "24px"],
- [H3, "20px", "24px"],
- [H4, "16px", "21px"],
- [H5, "14px", "18px"],
- [H6, "12px", "14px"],
- [TextHuge, "24px", "32px"],
- [TextBigger, "16px", "18px"],
- [TextBig, "14px", "20px"],
- [Text, "12px", "16px"],
- [TextSmall, "11px", "14px"],
- [TextMicro, "10px", "13px"],
- [TextNano, "8px", "10px"],
- [TextFemto, "7px", "8px"],
+ [H0, "27px", "32px"],
+ [H1, "25px", "28px"],
+ [H2, "23px", "26px"],
+ [H3, "21px", "24px"],
+ [H4, "17px", "21px"],
+ [H5, "15px", "18px"],
+ [H6, "13px", "14px"],
+ [TextHuge, "25px", "32px"],
+ [TextBigger, "17px", "18px"],
+ [TextBig, "15px", "20px"],
+ [Text, "13px", "16px"],
+ [TextSmall, "12px", "14px"],
+ [TextMicro, "11px", "13px"],
+ [TextNano, "9px", "10px"],
+ [TextFemto, "8px", "10px"],
]
scale.forEach(([Component, fontSize, lineHeight]) => {
const { container, unmount } = renderWithProviders(Typo content)
@@ -82,6 +82,19 @@ it("keeps the heading and text size scale unchanged", () => {
})
})
+it("preserves explicit font size and line height overrides", () => {
+ const { getByText } = renderWithProviders(
+ <>
+ Inherited line box
+ Explicit line box
+ >
+ )
+ expect(getByText("Inherited line box")).toHaveStyleRule("font-size", "18px")
+ expect(getByText("Inherited line box")).toHaveStyleRule("line-height", "18px")
+ expect(getByText("Explicit line box")).toHaveStyleRule("font-size", "14px")
+ expect(getByText("Explicit line box")).toHaveStyleRule("line-height", "19px")
+})
+
it("renders texts as normal weight", () => {
texts.forEach(Component => {
const { container, unmount } = renderWithProviders(Typo content)
diff --git a/src/components/typography/monospace.test.js b/src/components/typography/monospace.test.js
new file mode 100644
index 000000000..affb579e5
--- /dev/null
+++ b/src/components/typography/monospace.test.js
@@ -0,0 +1,71 @@
+import React from "react"
+import { createRef } from "react"
+import { StyleSheetManager } from "styled-components"
+import isPropValid from "@emotion/is-prop-valid"
+import { renderWithProviders, screen } from "testUtilities"
+import { DefaultTheme, DarkTheme } from "@/theme"
+import { TextBig } from "./index"
+
+it.each([
+ ["light", DefaultTheme],
+ ["dark", DarkTheme],
+])(
+ "uses the %s theme monospace family without changing title geometry or native props",
+ (_, base) => {
+ const family = "Editor Mono, monospace"
+ const theme = { ...base, constants: { ...base.constants, FONT_MONOSPACE: family } }
+ const ref = createRef()
+ renderWithProviders(
+ typeof target !== "string" || isPropValid(prop)}
+ >
+
+ plain
+
+
+ strong
+
+ default
+ ,
+ { theme }
+ )
+ const plain = screen.getByText("plain")
+ expect(plain.tagName).toBe("SPAN")
+ expect(plain.id).toBe("literal")
+ expect(ref.current).toBe(plain)
+ expect(plain).toHaveStyle({
+ fontFamily: family,
+ fontSize: "15px",
+ lineHeight: "20px",
+ fontWeight: "normal",
+ })
+ expect(screen.getByText("strong")).toHaveStyle({
+ fontFamily: family,
+ fontSize: "15px",
+ lineHeight: "20px",
+ fontWeight: "600",
+ })
+ expect(
+ getComputedStyle(screen.getByText("default")).fontFamily.startsWith('"IBM Plex Sans"')
+ ).toBe(true)
+ }
+)
+
+it("falls back to the shared editor monospace stack when a custom theme omits it", () => {
+ renderWithProviders(
+ typeof target !== "string" || isPropValid(prop)}
+ >
+ literal
+ ,
+ {
+ theme: {
+ ...DefaultTheme,
+ constants: { ...DefaultTheme.constants, FONT_MONOSPACE: undefined },
+ },
+ }
+ )
+ expect(getComputedStyle(screen.getByText("literal")).fontFamily).toBe(
+ "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"
+ )
+})
diff --git a/src/components/typography/typography.js b/src/components/typography/typography.js
index 9b8433cd4..bf2534ada 100644
--- a/src/components/typography/typography.js
+++ b/src/components/typography/typography.js
@@ -1,5 +1,6 @@
import styled, { css } from "styled-components"
-import { getColor } from "@/theme"
+import { getColor, getOrElse } from "@/theme"
+import { FONT_MONOSPACE } from "@/theme/default/constants"
import alignSelf from "@/mixins/alignSelf"
import margin from "@/mixins/margin"
import padding from "@/mixins/padding"
@@ -58,7 +59,19 @@ const typography = css`
export const makeTypography = (Component, { fontSize, lineHeight, strong, color }) => styled(
Component
).attrs(props => (color && props.color === undefined ? { color } : {}))`
- font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Ubuntu, "Helvetica Neue", sans-serif;
+ font-family:
+ "IBM Plex Sans",
+ -apple-system,
+ BlinkMacSystemFont,
+ "Segoe UI",
+ Ubuntu,
+ "Helvetica Neue",
+ sans-serif;
+ ${({ monospace }) =>
+ monospace &&
+ css`
+ font-family: ${getOrElse(["constants", "FONT_MONOSPACE"], FONT_MONOSPACE)};
+ `}
font-style: normal;
${makeFontSize(fontSize)}
${makeLineHeight(lineHeight)}
@@ -67,7 +80,7 @@ export const makeTypography = (Component, { fontSize, lineHeight, strong, color
`
export const makeH0 = Component =>
makeTypography(Component, {
- fontSize: "26px",
+ fontSize: "27px",
lineHeight: "32px",
strong: true,
color: "main",
@@ -75,7 +88,7 @@ export const makeH0 = Component =>
export const makeH1 = Component =>
makeTypography(Component, {
- fontSize: "24px",
+ fontSize: "25px",
lineHeight: "28px",
strong: true,
color: "main",
@@ -83,15 +96,15 @@ export const makeH1 = Component =>
export const makeH2 = Component =>
makeTypography(Component, {
- fontSize: "22px",
- lineHeight: "24px",
+ fontSize: "23px",
+ lineHeight: "26px",
strong: true,
color: "main",
})
export const makeH3 = Component =>
makeTypography(Component, {
- fontSize: "20px",
+ fontSize: "21px",
lineHeight: "24px",
strong: true,
color: "main",
@@ -99,7 +112,7 @@ export const makeH3 = Component =>
export const makeH4 = Component =>
makeTypography(Component, {
- fontSize: "16px",
+ fontSize: "17px",
lineHeight: "21px",
strong: true,
color: "main",
@@ -107,7 +120,7 @@ export const makeH4 = Component =>
export const makeH5 = Component =>
makeTypography(Component, {
- fontSize: "14px",
+ fontSize: "15px",
lineHeight: "18px",
strong: true,
color: "main",
@@ -115,7 +128,7 @@ export const makeH5 = Component =>
export const makeH6 = Component =>
makeTypography(Component, {
- fontSize: "12px",
+ fontSize: "13px",
lineHeight: "14px",
strong: true,
color: "main",
@@ -125,48 +138,48 @@ export const makeH6 = Component =>
export const makeFemto = Component =>
makeTypography(Component, {
- fontSize: "7px",
- lineHeight: "8px",
+ fontSize: "8px",
+ lineHeight: "10px",
})
export const makeNano = Component =>
makeTypography(Component, {
- fontSize: "8px",
+ fontSize: "9px",
lineHeight: "10px",
})
export const makeMicro = Component =>
makeTypography(Component, {
- fontSize: "10px",
+ fontSize: "11px",
lineHeight: "13px",
})
export const makeSmall = Component =>
makeTypography(Component, {
- fontSize: "11px",
+ fontSize: "12px",
lineHeight: "14px",
})
export const makeText = Component =>
makeTypography(Component, {
- fontSize: "12px",
+ fontSize: "13px",
lineHeight: "16px",
})
export const makeBig = Component =>
makeTypography(Component, {
- fontSize: "14px",
+ fontSize: "15px",
lineHeight: "20px",
})
export const makeBigger = Component =>
makeTypography(Component, {
- fontSize: "16px",
+ fontSize: "17px",
lineHeight: "18px",
})
export const makeHuge = Component =>
makeTypography(Component, {
- fontSize: "24px",
+ fontSize: "25px",
lineHeight: "32px",
})
diff --git a/src/components/typography/typography.usage.mdx b/src/components/typography/typography.usage.mdx
index 0afc8118a..75cea489f 100644
--- a/src/components/typography/typography.usage.mdx
+++ b/src/components/typography/typography.usage.mdx
@@ -13,13 +13,13 @@ Text and heading components that apply the Netdata font, size, line height, weig
## Headings
-- `H0` to `H6` are strong (600) by default. Sizes: H0 26px, H1 24px, H2 22px, H3 20px, H4 16px, H5 14px, H6 12px.
+- `H0` to `H6` are strong (600) by default. Sizes: H0 27px, H1 25px, H2 23px, H3 21px, H4 17px, H5 15px, H6 13px.
- `H0` and `H1` render an `h1`; `H2` to `H6` render `h2` to `h6`. Use `as` when the page outline needs a different level.
- Pass `strong={false}` for regular weight.
## Text
-- Sizes: `TextHuge` 24px, `TextBigger` 16px, `TextBig` 14px, `Text` 12px (the regular body size), `TextSmall` 11px, `TextMicro` 10px, `TextNano` 8px, `TextFemto` 7px.
+- Sizes: `TextHuge` 25px, `TextBigger` 17px, `TextBig` 15px, `Text` 13px (the regular body size), `TextSmall` 12px, `TextMicro` 11px, `TextNano` 9px, `TextFemto` 8px.
- Text components render a `span` and are regular weight. Pass `strong` for 600.
diff --git a/src/components/visuallyHidden/index.d.ts b/src/components/visuallyHidden/index.d.ts
new file mode 100644
index 000000000..ef9c0db19
--- /dev/null
+++ b/src/components/visuallyHidden/index.d.ts
@@ -0,0 +1,10 @@
+import { HTMLAttributes, FC, Ref } from "react"
+
+export interface VisuallyHiddenProps extends HTMLAttributes {
+ as?: any
+ ref?: Ref
+ [key: string]: any
+}
+
+declare const VisuallyHidden: FC
+export default VisuallyHidden
diff --git a/src/components/visuallyHidden/index.js b/src/components/visuallyHidden/index.js
new file mode 100644
index 000000000..7f53a7307
--- /dev/null
+++ b/src/components/visuallyHidden/index.js
@@ -0,0 +1,8 @@
+import styled from "styled-components"
+import visuallyHidden from "@/mixins/visuallyHidden"
+
+const VisuallyHidden = styled.span`
+ ${visuallyHidden}
+`
+
+export default VisuallyHidden
diff --git a/src/components/visuallyHidden/index.test.js b/src/components/visuallyHidden/index.test.js
new file mode 100644
index 000000000..fe4793f2e
--- /dev/null
+++ b/src/components/visuallyHidden/index.test.js
@@ -0,0 +1,34 @@
+import React, { createRef } from "react"
+import { renderWithProviders, screen } from "testUtilities"
+import VisuallyHidden from "./index"
+
+it("keeps a hidden label in the accessible name with a native ref", () => {
+ const ref = createRef()
+ renderWithProviders(
+ <>
+
+ Secret path
+
+
+ >
+ )
+ expect(screen.getByRole("textbox", { name: "Secret path" })).toBeInTheDocument()
+ expect(ref.current.tagName).toBe("LABEL")
+ expect(ref.current).not.toHaveAttribute("aria-hidden")
+ expect(ref.current).toHaveStyleRule("position", "absolute")
+ expect(ref.current).toHaveStyleRule("clip", "rect(0 0 0 0)")
+ expect(ref.current).toHaveStyleRule("width", "1px")
+})
+
+it("preserves live-region attributes and literal text on the default span", () => {
+ renderWithProviders(
+
+ 3 changes
+
+ )
+ const hidden = screen.getByRole("status")
+ expect(hidden.tagName).toBe("SPAN")
+ expect(hidden).toHaveAttribute("aria-live", "polite")
+ expect(hidden).toHaveTextContent("3 changes")
+ expect(hidden).toHaveAttribute("data-testid", "announcement")
+})
diff --git a/src/hooks/useDropElement/index.js b/src/hooks/useDropElement/index.js
index f55e99019..da7f90ba4 100644
--- a/src/hooks/useDropElement/index.js
+++ b/src/hooks/useDropElement/index.js
@@ -11,7 +11,7 @@ export default () => {
return () => {
try {
document.body.removeChild(el)
- } catch (e) {
+ } catch {
// Do nothing
}
}
diff --git a/src/hooks/useFocusAfterCommit/index.d.ts b/src/hooks/useFocusAfterCommit/index.d.ts
new file mode 100644
index 000000000..506860c94
--- /dev/null
+++ b/src/hooks/useFocusAfterCommit/index.d.ts
@@ -0,0 +1,3 @@
+export default function useFocusAfterCommit(
+ focus?: (element: HTMLElement) => void
+): (resolve: () => HTMLElement | null | undefined) => void
diff --git a/src/hooks/useFocusAfterCommit/index.js b/src/hooks/useFocusAfterCommit/index.js
new file mode 100644
index 000000000..d1340421d
--- /dev/null
+++ b/src/hooks/useFocusAfterCommit/index.js
@@ -0,0 +1,21 @@
+import { useCallback, useLayoutEffect, useRef } from "react"
+
+const focusElement = element => element.focus()
+
+const useFocusAfterCommit = (focus = focusElement) => {
+ const pending = useRef(null)
+
+ useLayoutEffect(() => {
+ const resolve = pending.current
+ if (!resolve) return
+ pending.current = null
+ const element = resolve()
+ if (element) focus(element)
+ })
+
+ return useCallback(resolve => {
+ pending.current = resolve
+ }, [])
+}
+
+export default useFocusAfterCommit
diff --git a/src/hooks/useFocusAfterCommit/index.test.js b/src/hooks/useFocusAfterCommit/index.test.js
new file mode 100644
index 000000000..e78e3bf57
--- /dev/null
+++ b/src/hooks/useFocusAfterCommit/index.test.js
@@ -0,0 +1,58 @@
+import React, { useRef, useState } from "react"
+import { render, screen } from "@testing-library/react"
+import userEvent from "@testing-library/user-event"
+import useFocusAfterCommit from "."
+
+const Fixture = ({ focus, label = "Open" }) => {
+ const [open, setOpen] = useState(false)
+ const target = useRef(null)
+ const focusAfterCommit = useFocusAfterCommit(focus)
+ return (
+ <>
+
+ {open ? (
+
+
+
+ ) : null}
+ >
+ )
+}
+
+describe("useFocusAfterCommit", () => {
+ it("focuses a target mounted by the next commit", async () => {
+ const user = userEvent.setup()
+ render()
+
+ await user.click(screen.getByRole("button", { name: "Open" }))
+
+ expect(document.activeElement).toBe(screen.getByTestId("target"))
+ })
+
+ it("supports caller-defined focus behavior", async () => {
+ const user = userEvent.setup()
+ render( target.querySelector("button")?.focus()} />)
+
+ await user.click(screen.getByRole("button", { name: "Open" }))
+
+ expect(document.activeElement).toBe(screen.getByRole("button", { name: "Nested action" }))
+ })
+
+ it("does not repeat a focus request after a later render", async () => {
+ const user = userEvent.setup()
+ const { rerender } = render()
+
+ await user.click(screen.getByRole("button", { name: "Open" }))
+ await user.click(screen.getByRole("button", { name: "Nested action" }))
+ rerender()
+
+ expect(document.activeElement).toBe(screen.getByRole("button", { name: "Nested action" }))
+ })
+})
diff --git a/src/hooks/useFocusTrap/index.d.ts b/src/hooks/useFocusTrap/index.d.ts
new file mode 100644
index 000000000..37b5e32bb
--- /dev/null
+++ b/src/hooks/useFocusTrap/index.d.ts
@@ -0,0 +1,19 @@
+import type { RefObject } from "react"
+
+type FocusableElement = HTMLElement | SVGElement
+
+export function getFocusCandidates(
+ container: ParentNode,
+ options?: { includeHiddenInputs?: boolean }
+): FocusableElement[]
+
+export function trapTabFocus(
+ event: Pick,
+ candidates: readonly FocusableElement[],
+ options: { active: Element | null; outside?: boolean; emptyTarget?: FocusableElement }
+): void
+
+export function useFocusTrap(
+ container: HTMLElement | null,
+ options?: { restoreFocus?: RefObject }
+): void
diff --git a/src/hooks/useFocusTrap/index.js b/src/hooks/useFocusTrap/index.js
new file mode 100644
index 000000000..28ce3c705
--- /dev/null
+++ b/src/hooks/useFocusTrap/index.js
@@ -0,0 +1,61 @@
+import { useEffect } from "react"
+
+const input = "input:not([disabled])"
+const focusable = [
+ "a[href]",
+ "button:not([disabled])",
+ "select:not([disabled])",
+ "textarea:not([disabled])",
+ "[tabindex]:not([tabindex='-1'])",
+].join(",")
+
+export const getFocusCandidates = (container, { includeHiddenInputs = false } = {}) =>
+ Array.from(
+ container.querySelectorAll(
+ includeHiddenInputs ? `${focusable},${input}` : `${focusable},${input}:not([type='hidden'])`
+ )
+ )
+
+export const trapTabFocus = (event, candidates, { active, outside = false, emptyTarget }) => {
+ if (event.key !== "Tab") return
+ if (!candidates.length) {
+ event.preventDefault()
+ emptyTarget?.focus()
+ return
+ }
+
+ const first = candidates[0]
+ const last = candidates[candidates.length - 1]
+ const boundary = event.shiftKey ? first : last
+ if (!outside && active !== boundary) return
+
+ event.preventDefault()
+ const target = event.shiftKey ? last : first
+ target.focus()
+}
+
+const getFocusable = container =>
+ getFocusCandidates(container, { includeHiddenInputs: true }).filter(
+ element => element.getAttribute("aria-hidden") !== "true" && element.tabIndex !== -1
+ )
+
+export const useFocusTrap = (container, { restoreFocus } = {}) => {
+ useEffect(() => {
+ if (!container) return
+ const [first] = getFocusable(container)
+ const initial = first || container
+ initial.focus({ preventScroll: true })
+
+ const handleKeyDown = event => {
+ if (event.key !== "Tab") return
+ const active = document.activeElement
+ trapTabFocus(event, getFocusable(container), { active, outside: !container.contains(active) })
+ }
+
+ document.addEventListener("keydown", handleKeyDown, true)
+ return () => {
+ document.removeEventListener("keydown", handleKeyDown, true)
+ restoreFocus?.current?.focus({ preventScroll: true })
+ }
+ }, [container, restoreFocus])
+}
diff --git a/src/hooks/useFocusTrap/index.test.js b/src/hooks/useFocusTrap/index.test.js
new file mode 100644
index 000000000..3c5fea9c7
--- /dev/null
+++ b/src/hooks/useFocusTrap/index.test.js
@@ -0,0 +1,80 @@
+import React, { useRef, useState } from "react"
+import { render, screen, userEvent } from "testUtilities"
+import { getFocusCandidates, useFocusTrap } from "."
+
+const Picker = () => {
+ const [open, setOpen] = useState(false)
+ const [container, setContainer] = useState(null)
+ const restoreFocus = useRef(null)
+ useFocusTrap(container, { restoreFocus })
+
+ return (
+ <>
+
+
+ {open ? (
+
+
+
+
+
+
+ ) : null}
+ >
+ )
+}
+
+it("focuses the first choice, wraps in both directions, and restores the opener", async () => {
+ const user = userEvent.setup()
+ render()
+ const open = screen.getByRole("button", { name: "Open picker" })
+ const outside = screen.getByRole("button", { name: "Outside" })
+ await user.click(open)
+
+ const first = screen.getByRole("button", { name: "First choice" })
+ const last = screen.getByRole("button", { name: "Close picker" })
+ expect(first).toHaveFocus()
+ await user.tab({ shift: true })
+ expect(last).toHaveFocus()
+ await user.tab()
+ expect(first).toHaveFocus()
+ await user.tab()
+ expect(last).toHaveFocus()
+ await user.click(outside)
+ await user.tab({ shift: true })
+ expect(last).toHaveFocus()
+ await user.keyboard("{Enter}")
+ expect(open).toHaveFocus()
+})
+
+it("keeps the hidden-input selector policy explicit and retains opted-in tabindex candidates", () => {
+ render(
+
+
+
+
+
+ Docs
+
+
+
+ )
+ const node = screen.getByTestId("candidates")
+ const explicit = screen.getByTestId("explicit-hidden")
+ const implicit = screen.getByTestId("implicit-hidden")
+ const link = screen.getByTestId("link")
+ const programmatic = screen.getByTestId("programmatic")
+ expect(getFocusCandidates(node)).toEqual([explicit, link, programmatic])
+ expect(getFocusCandidates(node, { includeHiddenInputs: true })).toEqual([
+ implicit,
+ explicit,
+ link,
+ programmatic,
+ ])
+})
diff --git a/src/hooks/useKeyboardEsc/index.d.ts b/src/hooks/useKeyboardEsc/index.d.ts
new file mode 100644
index 000000000..90361aa77
--- /dev/null
+++ b/src/hooks/useKeyboardEsc/index.d.ts
@@ -0,0 +1,9 @@
+type ComposingKeyboardEvent = Pick
+
+export declare const isComposingKey: (
+ event: ComposingKeyboardEvent | { nativeEvent: ComposingKeyboardEvent }
+) => boolean
+
+declare const useKeyboardEsc: (onEsc?: ((event: KeyboardEvent) => void) | null) => void
+
+export default useKeyboardEsc
diff --git a/src/hooks/useKeyboardEsc/index.js b/src/hooks/useKeyboardEsc/index.js
index 203b8e47d..7830a78e0 100644
--- a/src/hooks/useKeyboardEsc/index.js
+++ b/src/hooks/useKeyboardEsc/index.js
@@ -1,13 +1,20 @@
import { useEffect } from "react"
const ESC = 27
+const IME = 229
+
+export const isComposingKey = event => {
+ const native = event.nativeEvent || event
+ return native.isComposing || native.keyCode === IME
+}
export default onEsc =>
useEffect(() => {
if (!onEsc) return
const onKeydown = event => {
- if (event.keyCode === ESC) {
+ if (isComposingKey(event)) return
+ if (event.key === "Escape" || event.code === "Escape" || event.keyCode === ESC) {
onEsc(event)
}
}
diff --git a/src/hooks/useKeyboardEsc/index.test.js b/src/hooks/useKeyboardEsc/index.test.js
index 2a21faf42..8baeb1919 100644
--- a/src/hooks/useKeyboardEsc/index.test.js
+++ b/src/hooks/useKeyboardEsc/index.test.js
@@ -1,5 +1,5 @@
import { renderHookWithProviders, fireEvent } from "testUtilities"
-import useKeyboardEsc from "./index"
+import useKeyboardEsc, { isComposingKey } from "./index"
const addEventListener = document.addEventListener
afterEach(() => (document.addEventListener = addEventListener))
@@ -13,18 +13,38 @@ it("renders", () => {
expect(document.addEventListener).toHaveBeenCalledTimes(0)
})
-it("triggers on enter keystroke", () => {
+it("passes modern and legacy Escape events to the callback", () => {
const callback = jest.fn()
renderHookWithProviders(() => useKeyboardEsc(callback))
+ fireEvent.keyDown(document, { key: "Escape" })
+ fireEvent.keyDown(document, { code: "Escape" })
fireEvent.keyDown(document, { keyCode: 27 })
- expect(callback).toHaveBeenCalledTimes(1)
+
+ expect(callback.mock.calls.map(([event]) => [event.key, event.code, event.keyCode])).toEqual([
+ ["Escape", "", 0],
+ ["", "Escape", 0],
+ ["", "", 27],
+ ])
})
-it("does not trigger on non enter keystroke", () => {
+it("ignores other keys and Escape during IME composition", () => {
const callback = jest.fn()
renderHookWithProviders(() => useKeyboardEsc(callback))
- fireEvent.keyDown(document, { keyCode: 26 })
+ fireEvent.keyDown(document, { key: "Enter", code: "Enter", keyCode: 13 })
+ fireEvent.keyDown(document, { key: "Escape", keyCode: 27, isComposing: true })
+ fireEvent.keyDown(document, { key: "Escape", code: "Escape", keyCode: 229 })
+
expect(callback).toHaveBeenCalledTimes(0)
})
+
+it("reads composition from a React keyboard event's native event", () => {
+ const composing = new KeyboardEvent("keydown", { key: "Escape", isComposing: true })
+ const ordinary = new KeyboardEvent("keydown", { key: "Escape" })
+
+ expect([
+ isComposingKey({ nativeEvent: composing }),
+ isComposingKey({ nativeEvent: ordinary }),
+ ]).toEqual([true, false])
+})
diff --git a/src/index.js b/src/index.js
index ec655fc5c..a5c9ef30c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,4 @@
-export { Button, IconButton, ButtonGroup, useRovingFocus } from "./components/button"
+export { Button, IconButton, ButtonGroup, focusInList, useRovingFocus } from "./components/button"
export { Sidebar, PortalSidebar } from "./components/sidebar"
export { Icon, iconsList, IconComponents } from "./components/icon"
@@ -47,12 +47,13 @@ export {
getSizeUnit,
getSizeBy,
getRgbColor,
+ getReadableColor,
getOrElse,
propOrElse,
getColor,
} from "./theme"
export { devices, breakpoints } from "./media"
-export { Checkbox, useCheckboxesList } from "./components/checkbox"
+export { Checkbox, CheckboxIndicator, useCheckboxesList } from "./components/checkbox"
export * from "./components/input"
export * from "./mixins"
export { Toggle } from "./components/toggle"
@@ -69,12 +70,18 @@ export { default as TooltipInk } from "./components/drops/tooltip/tooltipInk"
export { default as Popover } from "./components/drops/popover"
export { default as Menu } from "./components/drops/menu"
export { default as MenuDropdown } from "./components/drops/menu/dropdown"
+export { default as DropdownSelectionCheck } from "./components/drops/dropdownSelectionCheck"
export {
default as MenuDropdownItem,
ItemContainer as MenuItemContainer,
} from "./components/drops/menu/dropdownItem"
export { default as MenuButton } from "./components/drops/menu/menuButton"
-export { dropdownBorder, dropdownRound } from "./components/drops/dropdownStyles"
+export {
+ dropdownBorder,
+ dropdownRound,
+ getDropdownOptionColors,
+ insetMenuRound,
+} from "./components/drops/dropdownStyles"
export { default as Flex } from "./components/templates/flex"
export { default as makeFlex } from "./components/templates/flex/flex"
@@ -102,8 +109,11 @@ export { default as useNavigationArrows } from "./organisms/navigation/hooks/use
export { default as Intersection } from "./components/intersection"
export { default as useIntersection } from "./hooks/useIntersection"
+export { default as useKeyboardEsc, isComposingKey } from "./hooks/useKeyboardEsc"
+export { getFocusCandidates, trapTabFocus, useFocusTrap } from "./hooks/useFocusTrap"
+export { default as useFocusAfterCommit } from "./hooks/useFocusAfterCommit"
-export { default as Pill, StatusWord, MarkCounts } from "./components/pill"
+export { default as Pill, StatusDot, StatusWord, MarkCounts } from "./components/pill"
export { default as ProgressBar } from "./components/progressBar"
@@ -136,3 +146,9 @@ export { default as CopyToClipboard } from "./components/copyToClipboard"
export { GlobalStyles } from "./global-styles"
export * from "./utils"
+
+export { default as VisuallyHidden } from "./components/visuallyHidden"
+
+export { default as Skeleton } from "./components/skeleton"
+export { getScrollInset } from "./utils/getScrollInset"
+export { virtualRangeWithIndex } from "./utils/virtualRangeWithIndex"
diff --git a/src/mixins/controlSize.test.js b/src/mixins/controlSize.test.js
index 8f06f7804..eeee9dea6 100644
--- a/src/mixins/controlSize.test.js
+++ b/src/mixins/controlSize.test.js
@@ -21,14 +21,14 @@ describe("control size ladder", () => {
it("is one theme constant shared by both themes", () => {
expect(DefaultTheme.constants.CONTROL_SIZES).toEqual({
compact: { height: 24, fontSize: 12 },
- default: { height: 28, fontSize: 13 },
+ default: { height: 30, fontSize: 13 },
large: { height: 32, fontSize: 14 },
})
expect(DarkTheme.constants.CONTROL_SIZES).toBe(DefaultTheme.constants.CONTROL_SIZES)
})
it.each([
- [{}, "28px", "13px"],
+ [{}, "30px", "13px"],
[{ large: true }, "32px", "14px"],
[{ compact: true }, "24px", "12px"],
[{ size: "large" }, "32px", "14px"],
diff --git a/src/mixins/focusRing.d.ts b/src/mixins/focusRing.d.ts
new file mode 100644
index 000000000..29e6ff415
--- /dev/null
+++ b/src/mixins/focusRing.d.ts
@@ -0,0 +1,14 @@
+import { RuleSet } from "styled-components"
+import { ColorType } from "./types"
+
+export interface FocusRingOptions {
+ offset?: number
+ color?: ColorType
+ radius?: number | string
+}
+
+export declare const focusRingAt: (options?: FocusRingOptions) => RuleSet
+export declare const focusRing: RuleSet
+export declare const focusRingOutline: RuleSet
+export declare const fieldFocusRing: RuleSet
+export declare const fieldFocusWithinRing: RuleSet
diff --git a/src/mixins/focusRing.js b/src/mixins/focusRing.js
index 842cafb71..24d807623 100644
--- a/src/mixins/focusRing.js
+++ b/src/mixins/focusRing.js
@@ -1,10 +1,21 @@
import { css } from "styled-components"
import { getColor, getSizeBy } from "@/theme"
-// Selector-agnostic ring, for controls whose visual box is a sibling of a hidden native input.
-export const focusRingOutline = css`
- outline: ${getSizeBy(0.25)} solid ${getColor("primary")};
- outline-offset: ${getSizeBy(0.25)};
+const ringOutline = ({ offset = 2, color = "primary", radius } = {}) => css`
+ outline: ${getSizeBy(0.25)} solid ${getColor(color)};
+ outline-offset: ${getSizeBy(offset / 8)};
+ ${radius !== undefined &&
+ css`
+ border-radius: ${typeof radius === "number" ? getSizeBy(radius / 2) : radius};
+ `}
+`
+
+export const focusRingOutline = ringOutline()
+
+export const focusRingAt = options => css`
+ &:focus-visible {
+ ${ringOutline(options)}
+ }
`
export const focusRing = css`
@@ -12,9 +23,7 @@ export const focusRing = css`
outline: none;
}
- &:focus-visible {
- ${focusRingOutline}
- }
+ ${focusRingAt()}
`
// A 2px edge drawn inside the field (border + inset line): one clear line that overflow cannot clip.
diff --git a/src/mixins/focusRing.test.js b/src/mixins/focusRing.test.js
index d62ffa7e6..f9f5e5a35 100644
--- a/src/mixins/focusRing.test.js
+++ b/src/mixins/focusRing.test.js
@@ -4,7 +4,7 @@ import { render, screen } from "@testing-library/react"
import "jest-styled-components"
import { DefaultTheme, DarkTheme } from "@/theme"
import rawColors from "@/theme/rawColors"
-import { focusRing, fieldFocusRing, focusRingOutline } from "./focusRing"
+import { focusRing, fieldFocusRing, focusRingOutline, focusRingAt } from "./focusRing"
const Ring = styled.button`
${focusRing}
@@ -56,3 +56,19 @@ describe("focusRingOutline", () => {
expect(el).toHaveStyleRule("outline-offset", "2px", { modifier: "input:focus-visible+&" })
})
})
+
+it.each([DefaultTheme, DarkTheme])("preserves an explicit inset focus role in $name", theme => {
+ const InsetRing = styled.button`
+ ${focusRingAt({ offset: -2, color: "segmentedFocus", radius: "var(--field-radius)" })}
+ `
+ renderIn(theme, inset)
+ const ring = screen.getByRole("button", { name: "inset" })
+ expect(ring).toHaveStyleRule("outline", `2px solid ${theme.colors.segmentedFocus}`, {
+ modifier: ":focus-visible",
+ })
+ expect(ring).toHaveStyleRule("outline-offset", "-2px", { modifier: ":focus-visible" })
+ expect(ring).toHaveStyleRule("border-radius", "var(--field-radius)", {
+ modifier: ":focus-visible",
+ })
+ expect(ring).not.toHaveStyleRule("outline", "none", { modifier: ":focus" })
+})
diff --git a/src/mixins/index.js b/src/mixins/index.js
index b8c67cb86..f6c70e240 100644
--- a/src/mixins/index.js
+++ b/src/mixins/index.js
@@ -10,4 +10,12 @@ export { default as round } from "./round"
export { default as textTransform } from "./textTransform"
export { default as webkitVisibleScrollbar } from "./webkitVisibleScrollbar"
export { default as zIndex } from "./zIndex"
-export { focusRing, focusRingOutline, fieldFocusRing, fieldFocusWithinRing } from "./focusRing"
+export {
+ focusRing,
+ focusRingAt,
+ focusRingOutline,
+ fieldFocusRing,
+ fieldFocusWithinRing,
+} from "./focusRing"
+
+export { default as visuallyHidden } from "./visuallyHidden"
diff --git a/src/mixins/margin.js b/src/mixins/margin.js
index 099c2467d..dee5dd181 100644
--- a/src/mixins/margin.js
+++ b/src/mixins/margin.js
@@ -7,7 +7,6 @@ export default ({ theme, margin }) => {
return `margin: ${getDimensions(theme, margin)};`
}
- // eslint-disable-next-line no-console
console.error("Please provide an array (max 4 elements) for `margin` style helper.")
return ""
diff --git a/src/mixins/padding.js b/src/mixins/padding.js
index b6bada8f6..815ed05e3 100644
--- a/src/mixins/padding.js
+++ b/src/mixins/padding.js
@@ -7,7 +7,6 @@ export default ({ theme, padding }) => {
return `padding: ${getDimensions(theme, padding)};`
}
- // eslint-disable-next-line no-console
console.error("Please provide an array (max 4 elements) for `padding` style helper.")
return ""
diff --git a/src/mixins/segmented.js b/src/mixins/segmented.js
index ec50d2c0f..436526403 100644
--- a/src/mixins/segmented.js
+++ b/src/mixins/segmented.js
@@ -9,7 +9,7 @@ export const segmentedTrack = css`
gap: ${getSizeBy(0.25)};
padding: ${getSizeBy(0.375)};
border-radius: ${getSizeBy(0.5)};
- border: 1px solid ${getColor("borderSecondary")};
+ border: 1px solid ${getColor("segmentedBorder")};
background: ${getRgbColor("textLite", 0.12)};
`
diff --git a/src/mixins/segmented.test.js b/src/mixins/segmented.test.js
index 0f0354df2..4fcefc1f2 100644
--- a/src/mixins/segmented.test.js
+++ b/src/mixins/segmented.test.js
@@ -21,7 +21,7 @@ describe("segmented track", () => {
)
const track = screen.getByTestId("t")
- expect(track).toHaveStyleRule("border", `1px solid ${colors.borderSecondary}`)
+ expect(track).toHaveStyleRule("border", `1px solid ${colors.segmentedBorder}`)
expect(track).toHaveStyleRule("padding", "3px")
expect(track).toHaveStyleRule("border-radius", "4px")
})
diff --git a/src/mixins/types.d.ts b/src/mixins/types.d.ts
index bdb2fecf8..21fef3eb8 100644
--- a/src/mixins/types.d.ts
+++ b/src/mixins/types.d.ts
@@ -6,7 +6,7 @@ export type CSSPropertiesValueType = number | string
export type DimensionsType =
| CSSPropertiesValueType
- | { min?: CSSPropertiesValueType; max?: CSSPropertiesValueType }
+ | { min?: CSSPropertiesValueType; max?: CSSPropertiesValueType; base?: CSSPropertiesValueType }
export type MultiplierType = number
@@ -54,6 +54,7 @@ export interface AlignSelfProps {
export interface RoundProps {
round?:
| boolean
+ | string
| MultiplierType
| {
side?:
@@ -65,7 +66,7 @@ export interface RoundProps {
| "top-right"
| "bottom-left"
| "bottom-right"
- size?: MultiplierType
+ size?: MultiplierType | string
}
}
diff --git a/src/mixins/webkitVisibleScrollbar.js b/src/mixins/webkitVisibleScrollbar.js
index f4c7e30ee..ecbbd3692 100644
--- a/src/mixins/webkitVisibleScrollbar.js
+++ b/src/mixins/webkitVisibleScrollbar.js
@@ -1,32 +1,40 @@
import { css } from "styled-components"
-import { getSizeBy, getRgbColor } from "@/theme/utils"
+import { getColor, getRgbColor, getSizeBy } from "@/theme/utils"
+
+const thumb = getRgbColor("controlBorder", 0.32)
+const thumbHover = getColor("main")
export default css`
- scrollbar-width: ${getSizeBy(1)};
- scrollbar-color: ${getRgbColor("scrollBarThumb", 0.3)} ${getRgbColor("scrollBarThumb", 0.1)};
+ @media (forced-colors: none) {
+ scrollbar-width: thin;
+ scrollbar-color: ${thumb} transparent;
- &::-webkit-scrollbar {
- width: ${getSizeBy(1)};
- }
+ @supports selector(::-webkit-scrollbar) {
+ scrollbar-width: auto;
+ scrollbar-color: auto;
- &::-webkit-scrollbar-track {
- background-color: ${getRgbColor("scrollBarTrack", 1)};
- border: 1px solid ${getRgbColor("scrollBarBorder", 0.4)};
- border-radius: ${getSizeBy(1)};
- }
- &::-webkit-scrollbar-thumb {
- width: ${getSizeBy(0.5)};
- border: 1px solid ${getRgbColor("scrollBarBorder", 1)};
- border-radius: ${getSizeBy(1)};
- background-color: ${getRgbColor("scrollBarThumb", 1)};
- }
- &::-webkit-scrollbar-thumb:hover {
- background-color: ${getRgbColor("scrollBarThumbHover", 1)};
- }
- &::-webkit-scrollbar-track-piece {
- background-color: ${getRgbColor("scrollBarThumb", 0.3)};
- }
- &::-webkit-scrollbar-corner {
- background-color: ${getRgbColor("scrollBarThumb", 0.3)};
+ &::-webkit-scrollbar {
+ width: ${getSizeBy(1)};
+ height: ${getSizeBy(1)};
+ }
+
+ &::-webkit-scrollbar-track,
+ &::-webkit-scrollbar-corner {
+ background: transparent;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ border: ${getSizeBy(0.25)} solid transparent;
+ border-radius: ${getSizeBy(1)};
+ background: ${thumb};
+ background-clip: padding-box;
+ }
+
+ &::-webkit-scrollbar-thumb:hover,
+ &::-webkit-scrollbar-thumb:active {
+ border-width: ${getSizeBy(0.125)};
+ background-color: ${thumbHover};
+ }
+ }
}
`
diff --git a/src/organisms/documentation/search/discourse/api.js b/src/organisms/documentation/search/discourse/api.js
index edd2df164..361490fa5 100644
--- a/src/organisms/documentation/search/discourse/api.js
+++ b/src/organisms/documentation/search/discourse/api.js
@@ -30,7 +30,7 @@ const fetchTopics = async (searchTerm, onSuccess) => {
if (!response.data) return
if (onSuccess) onSuccess(response)
- } catch (e) {
+ } catch {
return
}
}
diff --git a/src/organisms/documentation/search/discourse/index.js b/src/organisms/documentation/search/discourse/index.js
index cf7618532..d2bd643b3 100644
--- a/src/organisms/documentation/search/discourse/index.js
+++ b/src/organisms/documentation/search/discourse/index.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from "react"
+import { useEffect, useState } from "react"
import fetchTopics from "./api"
const DiscourseSearch = ({ children, ...rest }) => {
diff --git a/src/organisms/navigation/hooks/useNavigationScroll.test.js b/src/organisms/navigation/hooks/useNavigationScroll.test.js
index 856824d64..b70464466 100644
--- a/src/organisms/navigation/hooks/useNavigationScroll.test.js
+++ b/src/organisms/navigation/hooks/useNavigationScroll.test.js
@@ -15,7 +15,9 @@ describe("useNavigationScroll", () => {
let scrollLeft = 10
Object.defineProperty(strip, "scrollLeft", {
get: () => scrollLeft,
- set: value => (scrollLeft = value),
+ set: value => {
+ scrollLeft = value
+ },
configurable: true,
})
diff --git a/src/proposals/dropdowns/dropdown.js b/src/proposals/dropdowns/dropdown.js
new file mode 100644
index 000000000..ce7f5f6c5
--- /dev/null
+++ b/src/proposals/dropdowns/dropdown.js
@@ -0,0 +1,397 @@
+import React, { useId, useRef, useState } from "react"
+import styled, { css } from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Icon } from "@/components/icon"
+import SearchInput from "@/components/search"
+import { Text, TextSmall } from "@/components/typography"
+import { getColor } from "@/theme"
+
+const alerts = [
+ {
+ id: "systemd_service_unit_failed_state",
+ title: "Systemd service failed",
+ source: "Systemd",
+ severity: "Warning",
+ shortcut: "Systemd",
+ recent: true,
+ },
+ {
+ id: "system_post_update_reboot_status",
+ title: "Reboot required after update",
+ source: "System updates",
+ severity: "Warning",
+ shortcut: "Reboot status",
+ recent: true,
+ },
+ {
+ id: "disk_space_usage",
+ title: "Disk space usage",
+ source: "Storage",
+ severity: "Critical",
+ shortcut: "Disk space",
+ recent: true,
+ },
+ {
+ id: "plugin_data_collection_status",
+ title: "Data collection stopped",
+ source: "Collectors",
+ severity: "Warning",
+ },
+ {
+ id: "load_average_15",
+ title: "15-minute load average",
+ source: "CPU",
+ severity: "Clear",
+ },
+ {
+ id: "smbios_memory_comparison_unavailable",
+ title: "Memory comparison unavailable",
+ source: "Hardware",
+ severity: "Clear",
+ },
+]
+
+export const directions = {
+ inset: {
+ letter: "A",
+ title: "Inset list",
+ summary: "Dense, familiar rows with a soft selection.",
+ },
+ sections: {
+ letter: "B",
+ title: "Status sections",
+ summary: "Readable names, severity labels, and distinct groups.",
+ details: true,
+ },
+ command: {
+ letter: "C",
+ title: "Command menu",
+ summary: "One result list with small shortcuts for recent alerts.",
+ shortcuts: true,
+ },
+}
+
+const severityColors = {
+ Critical: "statusErrorText",
+ Warning: "statusWarningText",
+ Clear: "statusMutedText",
+}
+
+const Pane = styled(Flex)`
+ min-width: 0;
+ background: ${getColor("dropdown")};
+ border: 1px solid ${getColor("border")};
+ border-radius: 14px;
+ box-shadow: 0 12px 28px ${getColor("dropdownShadow")};
+ overflow: clip;
+
+ &[data-layout="command"] {
+ background: ${getColor("panelBg")};
+ }
+`
+
+const Inset = styled(Flex)`
+ padding: 12px;
+ min-width: 0;
+`
+
+const PaneHeader = styled(Inset)`
+ padding-bottom: 8px;
+
+ [data-layout="command"] & {
+ padding-bottom: 12px;
+ border-bottom: 1px solid ${getColor("borderSecondary")};
+ }
+`
+
+const Search = styled(SearchInput)`
+ width: 100%;
+ min-width: 0;
+`
+
+const Group = styled(Flex)`
+ min-width: 0;
+
+ & + & {
+ margin-top: 10px;
+ }
+
+ [data-layout="inset"] & + & {
+ padding-top: 10px;
+ border-top: 1px solid ${getColor("borderSecondary")};
+ }
+
+ [data-layout="sections"] & {
+ padding: 6px;
+ border: 1px solid ${getColor("borderSecondary")};
+ border-radius: 9px;
+ }
+`
+
+const GroupLabel = styled(TextSmall)`
+ padding: 2px 7px 4px;
+ color: ${getColor("textLite")};
+ font-weight: 600;
+`
+
+const buttonReset = css`
+ appearance: none;
+ border: 0;
+ background: transparent;
+ font: inherit;
+ text-align: start;
+ color: inherit;
+ cursor: pointer;
+ min-width: 0;
+
+ &:focus-visible {
+ outline: 2px solid ${getColor("segmentedFocus")};
+ outline-offset: -2px;
+ }
+`
+
+const Row = styled.button`
+ ${buttonReset};
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+ padding: 0 8px;
+ min-height: 34px;
+ border-radius: 7px;
+
+ &:hover {
+ background: ${getColor("menuItemHover")};
+ }
+
+ &[aria-current="true"] {
+ color: ${getColor("menuItemSelectedText")};
+ background: ${getColor("menuItemSelected")};
+ }
+
+ &[aria-current="true"]:hover {
+ background: ${getColor("menuItemSelectedHover")};
+ }
+
+ [data-layout="sections"] & {
+ min-height: 45px;
+ padding: 4px 7px;
+ }
+
+ [data-layout="command"] & {
+ min-height: 36px;
+ }
+
+ [data-layout="command"] &[aria-current="true"] {
+ box-shadow: inset 2px 0 ${getColor("primary")};
+ }
+`
+
+const Shortcut = styled.button`
+ ${buttonReset};
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 3px 8px;
+ max-width: 100%;
+ min-height: 26px;
+ border: 1px solid ${getColor("border")};
+ border-radius: 6px;
+ background: ${getColor("controlBackground")};
+
+ &:hover {
+ background: ${getColor("menuItemHover")};
+ }
+`
+
+const RowText = styled(Flex)`
+ flex: 1 1 auto;
+ min-width: 0;
+
+ & > * {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ min-width: 0;
+ }
+`
+
+const Dot = styled.span`
+ flex: none;
+ width: 7px;
+ height: 7px;
+ border-radius: 50%;
+ background: ${({ $severity }) => getColor(severityColors[$severity])};
+`
+
+const StatusText = styled(TextSmall)`
+ flex: none;
+ color: ${({ $severity }) => getColor(severityColors[$severity])};
+`
+
+const Marker = styled.span`
+ flex: 0 0 14px;
+ display: grid;
+ place-items: center;
+`
+
+const ListBody = styled(Inset)`
+ max-height: min(390px, 62dvh);
+ overflow-y: auto;
+ overflow-x: hidden;
+ scrollbar-width: thin;
+ overscroll-behavior: contain;
+`
+
+const HeaderIcon = ({ name, color = "textLite" }) => (
+
+)
+
+const AlertRow = ({ alert, details, current, onSelect }) => (
+ onSelect(alert.id)}
+ >
+ {details ? null : }
+
+ {details ? alert.title : alert.id}
+ {details ? {alert.id} : null}
+
+ {details ? (
+
+ {alert.severity}
+
+ ) : null}
+
+ {current ? : null}
+
+
+)
+
+const AlertGroup = ({ label, items, details, selected, onSelect }) =>
+ items.length ? (
+
+ {label}
+ {items.map(alert => (
+
+ ))}
+
+ ) : null
+
+const focusResults = (event, container) => {
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return
+ const rows = Array.from(container.querySelectorAll("[data-dropdown-option]"))
+ if (!rows.length) return
+ const current = rows.indexOf(event.target)
+ if (current < 0 && event.key !== "ArrowDown") return
+ const next = {
+ ArrowDown: (current + 1) % rows.length,
+ ArrowUp: (current - 1 + rows.length) % rows.length,
+ Home: 0,
+ End: rows.length - 1,
+ }[event.key]
+ event.preventDefault()
+ rows[next].focus()
+}
+
+export const AlertDropdown = ({ direction }) => {
+ const [selected, setSelected] = useState(alerts[0].id)
+ const [query, setQuery] = useState("")
+ const container = useRef(null)
+ const titleId = useId()
+ const { details, shortcuts } = directions[direction]
+ const term = query.trim().toLowerCase()
+ const visible = alerts.filter(({ id, title, source, severity }) =>
+ `${id} ${title} ${source} ${severity}`.toLowerCase().includes(term)
+ )
+ const recents = term ? [] : visible.filter(alert => alert.recent)
+ const results = term || shortcuts ? visible : visible.filter(alert => !alert.recent)
+ const recentShortcuts = recents.filter(alert => alert.id !== selected)
+
+ const selectShortcut = id => {
+ setSelected(id)
+ container.current.querySelector(`[data-dropdown-option="${CSS.escape(id)}"]`)?.focus()
+ }
+
+ return (
+ focusResults(event, container.current)}
+ >
+
+
+
+
+
+ Alerts
+
+
+ {alerts.length} alerts
+
+ setQuery("")}
+ />
+
+
+ {shortcuts && recentShortcuts.length ? (
+
+ Recent shortcuts
+
+ {recentShortcuts.map(alert => (
+ selectShortcut(alert.id)}
+ >
+
+ {alert.shortcut}
+
+ ))}
+
+
+ ) : null}
+ {!shortcuts ? (
+
+ ) : null}
+
+ {visible.length ? null : (
+
+ No matching alerts
+
+ )}
+
+
+ )
+}
diff --git a/src/proposals/dropdowns/dropdowns.stories.js b/src/proposals/dropdowns/dropdowns.stories.js
new file mode 100644
index 000000000..32c103b72
--- /dev/null
+++ b/src/proposals/dropdowns/dropdowns.stories.js
@@ -0,0 +1,78 @@
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Text, TextSmall } from "@/components/typography"
+import { getColor } from "@/theme"
+import { AlertDropdown, directions } from "./dropdown"
+
+const Comparison = styled.div`
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 288px), 1fr));
+ gap: 20px;
+ width: min(1200px, calc(100vw - 32px));
+ padding: 16px 0;
+ max-height: 100dvh;
+ overflow-y: auto;
+ margin: 0 auto;
+`
+
+const Specimen = styled(Flex)`
+ width: 100%;
+ min-width: 0;
+`
+
+const Standalone = styled.div`
+ width: min(390px, calc(100vw - 32px));
+`
+
+const Letter = styled(TextSmall)`
+ display: grid;
+ place-items: center;
+ flex: 0 0 24px;
+ height: 24px;
+ border-radius: 6px;
+ background: ${getColor("menuItemSelected")};
+ color: ${getColor("menuItemSelectedText")};
+`
+
+const DropdownSpecimen = ({ direction }) => {
+ const { letter, title, summary } = directions[direction]
+
+ return (
+
+
+
+ {letter}
+
+ {title}
+
+
+ {summary}
+
+
+
+ )
+}
+
+export default {
+ title: "Proposals/Searchable dropdowns",
+ parameters: { layout: "fullscreen" },
+}
+
+export const Compare = () => (
+
+ {Object.keys(directions).map(direction => (
+
+ ))}
+
+)
+
+const SingleDirection = ({ direction }) => (
+
+
+
+)
+
+export const InsetList = () =>
+export const StatusSections = () =>
+export const CommandMenu = () =>
diff --git a/src/proposals/hues/distribution.js b/src/proposals/hues/distribution.js
new file mode 100644
index 000000000..7a53aed0d
--- /dev/null
+++ b/src/proposals/hues/distribution.js
@@ -0,0 +1,49 @@
+// Story-only replica of cloud-frontend `components/distribution` (ProgressBar + dot legend).
+import React from "react"
+import { useTheme } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { Text } from "@/components/typography"
+import ProgressBar from "@/components/progressBar"
+
+export const useIsDark = () => useTheme().name === "Dark"
+
+// Same rounding as CF `distribution/utils.js`, so tiny segments vanish exactly as they do in the app.
+const toSegments = data => {
+ const total = data.reduce((sum, { value }) => sum + value, 0)
+ if (total === 0) return data.map(item => ({ ...item, width: "0%" }))
+ let used = 0
+ return data.map((item, index) => {
+ const width = index === data.length - 1 ? 100 - used : Math.floor((item.value / total) * 100)
+ used += width
+ return { ...item, width: `${width}%` }
+ })
+}
+
+const swatchRound = { dot: "50%", square: "2px" }
+
+const LegendItem = ({ label, value, color, textColor, swatch }) => (
+
+
+
+ {label} {value}
+
+
+)
+
+export const Distribution = ({ data, textColor, swatch = "dot" }) => (
+
+
+
+ {data.map(item => (
+
+ ))}
+
+
+)
diff --git a/src/proposals/hues/hues.stories.js b/src/proposals/hues/hues.stories.js
new file mode 100644
index 000000000..4a62aab6b
--- /dev/null
+++ b/src/proposals/hues/hues.stories.js
@@ -0,0 +1,77 @@
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Side } from "../refresh/layout"
+import { RampNodeTypes, TodayNodeTypes } from "./nodeTypes"
+import { InsightTypes as InsightScene } from "./insightTypes"
+
+export default {
+ title: "Proposals/Hues",
+ parameters: { layout: "padded" },
+}
+
+// The preview frame centres stories in a 100vh box, so a tall story scrolls itself to keep "Today" reachable.
+const Scroll = styled(Flex).attrs({ column: true, gap: 8, padding: [4] })`
+ max-height: 100vh;
+ overflow-y: auto;
+`
+
+const Options = ({ children }) => {children}
+
+export const NodeTypes = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+export const InsightTypes = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+)
diff --git a/src/proposals/hues/insightTypes.js b/src/proposals/hues/insightTypes.js
new file mode 100644
index 000000000..1efda26d7
--- /dev/null
+++ b/src/proposals/hues/insightTypes.js
@@ -0,0 +1,187 @@
+// Story-only replica of CF Insights type styling (report sample cards + "new report" menu), with hue options.
+import React from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { Icon } from "@/components/icon"
+import { Text, TextBig, TextSmall } from "@/components/typography"
+import { getSizeBy } from "@/theme"
+
+// `today` names the kit's *_colored insight icons, whose fills are baked into the SVG and ignore `color`;
+// `glyph` is the closest single-colour kit icon, so a proposed colour can actually apply.
+const types = [
+ {
+ key: "anomalies",
+ group: "insights",
+ title: "Anomaly Analysis",
+ description: "Spots unusual behavior in your systems and explains what’s happening.",
+ today: "anomalyAnalysis",
+ glyph: "anomaliesLens",
+ hue: "insightsPurple",
+ },
+ {
+ key: "performance",
+ group: "insights",
+ title: "Performance Optimization",
+ description: "Identifies when resources compete or slow each other down.",
+ today: "performanceOptimization",
+ glyph: "chart_gauge",
+ hue: "insightsGreen",
+ },
+ {
+ key: "capacity",
+ group: "insights",
+ title: "Capacity Planning",
+ description: "Predicts future trends and highlights key turning points.",
+ today: "capacityPlanning",
+ glyph: "line_chart",
+ hue: "insightsYellow",
+ },
+ {
+ key: "summary",
+ group: "insights",
+ title: "Infrastructure Summary",
+ description: "A quick overview of any problems and how they affect your services.",
+ today: "automatedTroubleshooting",
+ glyph: "view_list",
+ hue: "insightsViolet",
+ },
+ {
+ key: "investigation",
+ group: "investigations",
+ title: "New Investigation",
+ today: "investigation",
+ glyph: "search",
+ hue: "insightsBlue",
+ },
+ {
+ key: "alertInvestigation",
+ group: "investigations",
+ title: "Alert Investigation",
+ today: "alertInvestigation",
+ glyph: "alarm_bell",
+ hue: "insightsRed",
+ },
+]
+
+const groups = [
+ { key: "insights", label: "Insights", icon: "view_list" },
+ { key: "investigations", label: "Investigations", icon: "search_s" },
+]
+
+const neutralHover = { hoverBg: "menuItemHover", hoverBorder: "border" }
+
+// Each scheme maps a type to: icon name, glyph colour, label colour and the hovered tile's surface.
+export const schemes = {
+ today: {
+ type: ({ today, hue }) => ({
+ icon: today,
+ glyph: hue,
+ label: hue,
+ hoverBg: `${hue}Semi`,
+ hoverBorder: hue,
+ }),
+ },
+ A: {
+ type: ({ glyph }) => ({ icon: glyph, glyph: "primaryAI", label: "text", ...neutralHover }),
+ },
+ B: {
+ type: ({ key, glyph }) => ({
+ icon: glyph,
+ glyph: key === "alertInvestigation" ? "error" : "iconColor",
+ label: "text",
+ ...neutralHover,
+ }),
+ },
+ C: {
+ type: ({ glyph }) => ({ icon: glyph, glyph: "iconColor", label: "text", ...neutralHover }),
+ groupIcon: { name: "ai", color: "primaryAI" },
+ },
+}
+
+const CardsGrid = styled(Box)`
+ display: grid;
+ grid-template-columns: repeat(4, minmax(${getSizeBy(20)}, 1fr));
+ gap: ${getSizeBy(2)};
+`
+
+const TilesGrid = styled(Box)`
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: ${getSizeBy(1)};
+`
+
+const GroupHeader = ({ group, scheme }) => {
+ const { name, color } = scheme.groupIcon || { name: group.icon, color: "menuItem" }
+ return (
+
+
+
+ {group.label}
+
+
+ )
+}
+
+const ReportCard = ({ type, style }) => (
+
+
+
+ {type.title}
+
+ {type.description}
+
+ Explore in demo space
+
+
+)
+
+const MenuTile = ({ type, style, hovered }) => (
+
+
+ {type.title}
+
+)
+
+// The first tile of each group is drawn hovered so the hover surface can be judged too.
+export const InsightTypes = ({ schemeKey }) => {
+ const scheme = schemes[schemeKey]
+ const rows = types.map(type => ({ type, style: scheme.type(type) }))
+
+ return (
+
+
+
+
+ {rows
+ .filter(({ type }) => type.group === "insights")
+ .map(({ type, style }) => (
+
+ ))}
+
+
+
+ {groups.map(group => (
+
+
+
+ {rows
+ .filter(({ type }) => type.group === group.key)
+ .map(({ type, style }, index) => (
+
+ ))}
+
+
+ ))}
+
+
+ )
+}
diff --git a/src/proposals/hues/nodeTypes.js b/src/proposals/hues/nodeTypes.js
new file mode 100644
index 000000000..b44586344
--- /dev/null
+++ b/src/proposals/hues/nodeTypes.js
@@ -0,0 +1,91 @@
+// Story-only replica of the CF Overview "Total Nodes" distributions row, with node-type hue options.
+import React from "react"
+import Flex from "@/components/templates/flex"
+import { Text } from "@/components/typography"
+import { Distribution, useIsDark } from "./distribution"
+
+const counts = { live: 171, offline: 6, stale: 2, parents: 1, children: 176, standalone: 2 }
+const alerts = { critical: 3, warning: 11 }
+
+const statusData = [
+ { label: "Live", value: counts.live, color: "success" },
+ { label: "Offline", value: counts.offline, color: "offline" },
+ { label: "Stale", value: counts.stale, color: "stale" },
+]
+
+const alertData = [
+ { label: "Critical", value: alerts.critical, color: "error" },
+ { label: "Warning", value: alerts.warning, color: "warning" },
+]
+
+const grey = step => ["neutral", `grey${step}`]
+const blue = step => ["blue", `blue${step}`]
+
+// Light themes read darkest = heaviest; on a dark surface the brightest step carries the weight.
+const ramps = {
+ neutral: { light: [100, 140, 170].map(grey), dark: [170, 130, 90].map(grey) },
+ blue: { light: [90, 130, 170].map(blue), dark: [170, 130, 90].map(blue) },
+}
+
+const todayColors = [
+ ["blue", "indigo"],
+ ["purple", "lilac"],
+ ["yellow", "yellow120"],
+]
+
+const nodeTypeData = ([parents, children, standalone]) => [
+ { label: "Parents", value: counts.parents, color: parents },
+ { label: "Children", value: counts.children, color: children },
+ { label: "Standalone", value: counts.standalone, color: standalone },
+]
+
+const Column = ({ title, children }) => (
+
+
+ {title}
+
+ {children}
+
+)
+
+const Count = ({ label, value }) => (
+
+ {label} {value}
+
+)
+
+// The row as CF lays it out: Total Nodes + node types side by side, then Active Alerts.
+const DistributionsRow = ({ nodeTypes }) => (
+
+
+ }
+ >
+
+
+ {nodeTypes}
+
+ }>
+
+
+
+)
+
+export const TodayNodeTypes = () => (
+ } />
+)
+
+export const RampNodeTypes = ({ ramp, swatch }) => {
+ const colors = ramps[ramp][useIsDark() ? "dark" : "light"]
+ return (
+ }
+ />
+ )
+}
diff --git a/src/proposals/pr5951/actions.js b/src/proposals/pr5951/actions.js
new file mode 100644
index 000000000..471dec858
--- /dev/null
+++ b/src/proposals/pr5951/actions.js
@@ -0,0 +1,150 @@
+// Copied from PR 5951: components/tooltip.js, iconAction.js, rovingFocus.js, tabStrip.js.
+import React, { forwardRef, useCallback } from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import BaseTooltip from "@/components/drops/tooltip"
+import { mergeRefs } from "@/utils"
+import { getColor, getSizeBy } from "@/theme"
+import { eyebrow, focusRingAt } from "./tokens"
+
+const Panel = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ gap: ${getSizeBy(0.25)};
+ max-width: ${({ wide }) => (wide ? 480 : 320)}px;
+ margin: ${getSizeBy(0.75)};
+ padding: ${getSizeBy(1)} ${getSizeBy(1.25)};
+ border: 1px solid var(--dyncfg-popover-border);
+ border-radius: var(--dyncfg-radius-md);
+ background: var(--dyncfg-popover-bg);
+ box-shadow: var(--dyncfg-popover-shadow);
+ font-size: 12px;
+ line-height: 18px;
+ font-weight: 400;
+ color: ${getColor("textFocus")};
+ overflow-wrap: anywhere;
+`
+
+const TooltipTitle = styled(Box).attrs({ as: "span" })`
+ ${eyebrow}
+`
+
+// The PR also mutes the tooltip when focus is returned programmatically (useMovedFocusQuiet); omitted.
+export const Tooltip = ({ content, title, wide, delay = 0, zIndex = 1000, children, ...rest }) => {
+ const renderContent = useCallback(
+ () => (
+
+ {title ? {title} : null}
+ {typeof content === "function" ? content() : content}
+
+ ),
+ [content, title, wide]
+ )
+
+ if (!content) return children
+
+ return (
+
+ {children}
+
+ )
+}
+
+const StyledButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex: 0 0 auto;
+ width: ${({ buttonSize }) => getSizeBy(buttonSize / 8)};
+ height: ${({ buttonSize, buttonHeight = buttonSize }) => getSizeBy(buttonHeight / 8)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ color: var(--dyncfg-text-secondary, ${getColor("textLite")});
+ transition:
+ background 120ms ease,
+ color 120ms ease;
+
+ svg {
+ fill: currentColor;
+ }
+
+ &:hover:not(:disabled):not([aria-disabled="true"]) {
+ color: ${({ tone }) =>
+ tone === "danger" ? "var(--dyncfg-error-text)" : getColor("textFocus")};
+ background: ${getColor("elementBackground")};
+ }
+
+ ${focusRingAt(1)}
+
+ &:disabled,
+ &[aria-disabled="true"] {
+ opacity: 0.4;
+ cursor: not-allowed;
+ }
+`
+
+export const IconAction = forwardRef(
+ (
+ {
+ icon,
+ label,
+ tooltip = label,
+ onClick,
+ size = 28,
+ height,
+ iconSize = "small",
+ tone,
+ disabled,
+ children,
+ ...props
+ },
+ ref
+ ) => {
+ const renderButton = ({ ref: tooltipRef, ...tooltipProps } = {}) => (
+
+ {children ?? }
+
+ )
+
+ return tooltip ? (
+
+ {renderButton}
+
+ ) : (
+ renderButton()
+ )
+ }
+)
+
+const keysByOrientation = {
+ horizontal: { previous: ["ArrowLeft"], next: ["ArrowRight"] },
+ both: { previous: ["ArrowLeft", "ArrowUp"], next: ["ArrowRight", "ArrowDown"] },
+}
+
+export const onRovingKeyDown = ({ event, index, count, orientation = "horizontal", onMove }) => {
+ const { previous, next } = keysByOrientation[orientation] || keysByOrientation.horizontal
+ let target = null
+ if (event.key === "Home") target = 0
+ else if (event.key === "End") target = count - 1
+ else if (previous.includes(event.key)) target = (index - 1 + count) % count
+ else if (next.includes(event.key)) target = (index + 1) % count
+ if (target === null) return
+
+ event.preventDefault()
+ onMove(target)
+ event.currentTarget.parentElement?.querySelectorAll(":scope > [data-roving]")?.[target]?.focus()
+}
diff --git a/src/proposals/pr5951/card.js b/src/proposals/pr5951/card.js
new file mode 100644
index 000000000..a4e2e206d
--- /dev/null
+++ b/src/proposals/pr5951/card.js
@@ -0,0 +1,181 @@
+// Copied from PR 5951: alertEditor/cardParts.js and configForm/templates/clampedDescription.js
+// (MarkdownParser replaced by plain text; the fit-to-width header logic is omitted).
+import React, { useId, useLayoutEffect, useRef, useState } from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRingAt } from "./tokens"
+import { Tooltip } from "./actions"
+
+const editorTextInset = getSizeBy(44 / 8)
+
+export const Card = styled(Box).attrs({ as: "section" })`
+ box-sizing: border-box;
+ border: 1px solid var(--dyncfg-paper-edge);
+ border-radius: var(--dyncfg-radius-md);
+ background: var(--dyncfg-paper);
+ padding: ${getSizeBy(1.75)} ${getSizeBy(2.5)} ${getSizeBy(2)} calc(${editorTextInset} - 1px);
+`
+
+export const CardHeader = styled(Box)`
+ display: flex;
+ align-items: center;
+ gap: ${getSizeBy(0.75)} ${getSizeBy(1.5)};
+ min-height: 28px;
+`
+
+export const CardTitle = styled(Box).attrs({ as: "h2" })`
+ margin: 0;
+ font-size: 13px;
+ line-height: 20px;
+ font-weight: 600;
+ color: var(--dyncfg-text-primary);
+ white-space: nowrap;
+`
+
+export const CardSub = styled(Box).attrs({ as: "span" })`
+ flex: 0 1 auto;
+ min-width: 0;
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--dyncfg-text-secondary);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+`
+
+export const CardGap = styled(Box).attrs({ as: "span", "aria-hidden": true })`
+ flex: 1 1 auto;
+`
+
+const Note = styled(Box)`
+ display: flex;
+ align-items: center;
+ gap: ${getSizeBy(1)};
+ margin-top: ${getSizeBy(0.75)};
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--dyncfg-text-secondary);
+`
+
+const AboutButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ flex: none;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: ${getSizeBy(2.5)};
+ height: ${getSizeBy(2.5)};
+ border-radius: 50%;
+ cursor: pointer;
+ color: var(--dyncfg-text-secondary);
+
+ &:hover {
+ color: var(--dyncfg-text-primary);
+ background: var(--dyncfg-row-hover);
+ }
+
+ ${focusRingAt(1)}
+`
+
+export const CardNote = ({ short, full }) => {
+ const id = useId()
+ return (
+
+ {short}
+
+ {(tooltipProps = {}) => (
+
+
+
+ )}
+
+
+ {full}
+
+
+ )
+}
+
+const Row = styled(Box)`
+ display: flex;
+ align-items: flex-start;
+ gap: ${getSizeBy(1)};
+ min-width: 0;
+`
+
+const ClampText = styled(Box)`
+ flex: 1 1 auto;
+ min-width: 0;
+
+ &[data-clamp] {
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: ${({ lines }) => lines};
+ overflow: hidden;
+ }
+`
+
+const MoreToggle = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ flex: 0 0 auto;
+ min-width: ${getSizeBy(3.5)};
+ text-align: right;
+ cursor: pointer;
+ font-size: 12px;
+ line-height: 16px;
+ color: var(--dyncfg-text-placeholder);
+ text-underline-offset: 2px;
+ border-radius: var(--dyncfg-radius-xs);
+
+ &:hover,
+ &:focus-visible {
+ color: ${getColor("textFocus")};
+ text-decoration: underline;
+ }
+
+ ${focusRingAt(2)}
+`
+
+export const ClampedDescription = ({ text, lines = 1 }) => {
+ const textId = useId()
+ const textRef = useRef(null)
+ const [expanded, setExpanded] = useState(false)
+ const [cut, setCut] = useState(false)
+
+ useLayoutEffect(() => {
+ const node = textRef.current
+ if (!node || expanded) return undefined
+ const measure = () => setCut(node.scrollHeight > node.clientHeight + 1)
+ measure()
+ if (typeof ResizeObserver === "undefined") return undefined
+ const observer = new ResizeObserver(measure)
+ observer.observe(node)
+ return () => observer.disconnect()
+ }, [expanded, text])
+
+ return (
+
+
+ {text}
+
+ {cut || expanded ? (
+ setExpanded(open => !open)}
+ >
+ {expanded ? "Less" : "More"}
+
+ ) : null}
+
+ )
+}
diff --git a/src/proposals/pr5951/controls.js b/src/proposals/pr5951/controls.js
new file mode 100644
index 000000000..7d5ed0631
--- /dev/null
+++ b/src/proposals/pr5951/controls.js
@@ -0,0 +1,300 @@
+// Copied from PR 5951 src/domains/configuration/components/controls.js and alertEditor/controls.js.
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRing, focusRingAt } from "./tokens"
+
+export const Segmented = styled(Box)`
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: ${getSizeBy(0.25)};
+ padding: ${getSizeBy(0.375)};
+ border-radius: var(--dyncfg-radius-md);
+ background: var(--dyncfg-segment-bg);
+ border: 1px solid ${getColor("borderSecondary")};
+`
+
+export const SegmentButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.875)};
+ height: ${getSizeBy(3.25)};
+ padding: 0 ${getSizeBy(1.25)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ white-space: nowrap;
+ font-size: 13px;
+ font-weight: ${({ isSelected }) => (isSelected ? 600 : 500)};
+ color: ${({ isSelected }) =>
+ isSelected ? getColor("textFocus") : "var(--dyncfg-text-secondary)"};
+ background: ${({ isSelected }) => (isSelected ? "var(--dyncfg-segment-active)" : "transparent")};
+ box-shadow: ${({ isSelected }) => (isSelected ? "var(--dyncfg-segment-shadow)" : "none")};
+ transition:
+ color 120ms ease,
+ background 120ms ease;
+
+ &:hover {
+ color: ${getColor("textFocus")};
+ }
+
+ ${focusRing}
+`
+
+export const CompactSegmented = styled(Segmented)`
+ padding: ${getSizeBy(0.25)};
+ border-radius: var(--dyncfg-radius-sm);
+`
+
+export const CompactSegment = styled(SegmentButton)`
+ gap: ${getSizeBy(0.625)};
+ height: ${getSizeBy(2.75)};
+ padding: 0 ${getSizeBy(1)};
+ border-radius: var(--dyncfg-radius-xs);
+ font-size: 12px;
+`
+
+export const Count = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.5)};
+ font-size: 12px;
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const Tick = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.5)};
+ font-size: 12px;
+ font-weight: 600;
+ font-variant-numeric: tabular-nums;
+ color: ${({ tone }) => (tone ? `var(--dyncfg-${tone}-text)` : "var(--dyncfg-text-secondary)")};
+
+ &::before {
+ content: "";
+ width: ${getSizeBy(0.375)};
+ height: ${getSizeBy(1.375)};
+ border-radius: var(--dyncfg-radius-xs);
+ background: ${({ tone }) =>
+ tone ? `var(--dyncfg-${tone}-text)` : "var(--dyncfg-text-secondary)"};
+ }
+`
+
+export const FilterChip = styled(Box).attrs({ as: "button", type: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.75)};
+ height: ${getSizeBy(3.25)};
+ padding: 0 ${getSizeBy(1.25)};
+ border: 1px solid var(--dyncfg-chip-border);
+ border-radius: var(--dyncfg-radius-xs);
+ background: ${getColor("mainBackground")};
+ color: ${getColor("textFocus")};
+ font-size: 13px;
+ line-height: 20px;
+ white-space: nowrap;
+ cursor: pointer;
+
+ &:hover:not([aria-disabled="true"]) {
+ border-color: var(--dyncfg-control-border);
+ }
+
+ &[aria-pressed="true"] {
+ border-color: var(--dyncfg-heading);
+ background: var(--dyncfg-row-selected);
+ }
+
+ &[aria-disabled="true"] {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
+ ${focusRingAt(1)}
+`
+
+export const OutlineButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.75)};
+ flex: 0 0 auto;
+ height: ${({ buttonHeight = 32 }) => getSizeBy(buttonHeight / 8)};
+ padding: 0 ${({ buttonHeight = 32 }) => getSizeBy(buttonHeight < 30 ? 1.125 : 1.375)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ white-space: nowrap;
+ font-size: ${({ buttonHeight = 32 }) => (buttonHeight < 30 ? 12 : 13)}px;
+ font-weight: 500;
+ color: ${getColor("textFocus")};
+ border: 1px solid var(--dyncfg-chip-border);
+ background: ${({ isActive }) => (isActive ? "var(--dyncfg-segment-active)" : "transparent")};
+ transition:
+ border-color 120ms ease,
+ background 120ms ease;
+
+ svg {
+ fill: currentColor;
+ }
+
+ &:hover:not(:disabled):not([aria-disabled="true"]) {
+ border-color: var(--dyncfg-control-border);
+ background: var(--dyncfg-segment-bg);
+ }
+
+ &:disabled,
+ &[aria-disabled="true"] {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
+ ${focusRing}
+`
+
+export const SmallButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ flex: 0 0 auto;
+ height: ${getSizeBy(3.25)};
+ padding: 0 ${getSizeBy(1.25)};
+ border-radius: var(--dyncfg-radius-sm);
+ border: 1px solid var(--dyncfg-chip-border);
+ cursor: pointer;
+ font-size: 12px;
+ color: ${getColor("textFocus")};
+
+ &:hover {
+ border-color: var(--dyncfg-control-border);
+ }
+
+ ${focusRingAt(2)}
+`
+
+export const MenuPanel = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ width: ${getSizeBy(32.5)};
+ padding: ${getSizeBy(0.75)};
+`
+
+export const MenuItem = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: flex;
+ align-items: center;
+ gap: ${getSizeBy(1.25)};
+ height: ${getSizeBy(4)};
+ padding: 0 ${getSizeBy(0.75)} 0 ${getSizeBy(1)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ font-size: 13px;
+ color: ${getColor("textFocus")};
+
+ span:first-child {
+ flex: 1 1 auto;
+ }
+
+ svg {
+ fill: var(--dyncfg-text-secondary);
+ }
+
+ &:hover {
+ background: var(--dyncfg-row-hover);
+ }
+
+ ${focusRing}
+`
+
+export const MenuText = styled(Box).attrs({ as: "span" })`
+ display: flex;
+ flex-direction: column;
+`
+
+export const MenuNote = styled(Box).attrs({ as: "span" })`
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const TextLink = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ height: 28px;
+ padding: 0 ${getSizeBy(0.5)};
+ border-radius: var(--dyncfg-radius-xs);
+ cursor: pointer;
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--dyncfg-text-primary);
+ text-decoration: underline;
+ text-decoration-color: var(--dyncfg-control-border);
+ text-underline-offset: 3px;
+ white-space: nowrap;
+
+ &[aria-disabled="true"] {
+ cursor: default;
+ color: var(--dyncfg-text-secondary);
+ text-decoration: none;
+ }
+
+ ${focusRingAt(0)}
+`
+
+export const TextButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.625)};
+ height: 28px;
+ border-radius: var(--dyncfg-radius-xs);
+ cursor: pointer;
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-primary);
+ white-space: nowrap;
+
+ svg {
+ fill: var(--dyncfg-text-secondary);
+ }
+
+ &:hover {
+ text-decoration: underline;
+ text-decoration-color: var(--dyncfg-control-border);
+ text-underline-offset: 3px;
+ }
+
+ ${focusRingAt(2)}
+`
+
+export const RowTextAction = styled(Box).attrs({ as: "button", type: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ flex: none;
+ display: inline-flex;
+ align-items: center;
+ height: ${getSizeBy(3.5)};
+ padding: 0 ${getSizeBy(1)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--dyncfg-text-secondary);
+ white-space: nowrap;
+
+ &:hover:not([aria-disabled="true"]) {
+ color: var(--dyncfg-text-primary);
+ background: var(--dyncfg-row-hover);
+ }
+
+ &[aria-disabled="true"] {
+ cursor: default;
+ }
+
+ ${focusRingAt(0)}
+`
diff --git a/src/proposals/pr5951/dialog.js b/src/proposals/pr5951/dialog.js
new file mode 100644
index 000000000..fe0459f24
--- /dev/null
+++ b/src/proposals/pr5951/dialog.js
@@ -0,0 +1,202 @@
+// Copied from PR 5951: components/confirmDialog.js. useDialogFocus (focus trap/return) is replaced by a
+// plain Escape listener; the markup and styles are unchanged.
+import React, { useEffect, useId } from "react"
+import { createPortal } from "react-dom"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRingAt } from "./tokens"
+
+const Backdrop = styled(Box)`
+ position: ${({ inline }) => (inline ? "relative" : "fixed")};
+ inset: 0;
+ z-index: 120;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: ${getSizeBy(2)};
+ background: var(--dyncfg-backdrop);
+ backdrop-filter: blur(2px);
+`
+
+const Panel = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ max-width: 100%;
+ max-height: calc(100vh - ${getSizeBy(4)});
+ overflow: hidden;
+ border-radius: var(--dyncfg-radius-lg);
+ border: 1px solid var(--dyncfg-dialog-border);
+ background: ${getColor("modalBackground")};
+ box-shadow: var(--dyncfg-dialog-shadow);
+ color: ${getColor("text")};
+ outline: none;
+`
+
+const DialogContent = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ gap: ${getSizeBy(1)};
+ padding: ${getSizeBy(3)} ${getSizeBy(3)} 0;
+`
+
+const DialogTitle = styled(Box).attrs({ as: "h2" })`
+ display: flex;
+ align-items: center;
+ gap: ${getSizeBy(1.25)};
+ margin: 0;
+ font-size: 16px;
+ line-height: 24px;
+ font-weight: 600;
+ color: ${getColor("textFocus")};
+`
+
+const DialogMessage = styled(Box)`
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-secondary);
+ overflow-wrap: anywhere;
+
+ strong {
+ font-weight: 600;
+ color: ${getColor("textFocus")};
+ }
+`
+
+const DialogActions = styled(Box)`
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: ${getSizeBy(1)};
+ padding: ${getSizeBy(3)};
+`
+
+const DialogButton = styled(Box).attrs({ as: "button" })`
+ min-width: ${getSizeBy(10)};
+ height: ${getSizeBy(4)};
+ padding: 0 ${getSizeBy(1.75)};
+ border-radius: var(--dyncfg-radius-sm);
+ font-family: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ white-space: nowrap;
+ cursor: pointer;
+ transition:
+ background 120ms ease,
+ border-color 120ms ease;
+
+ ${focusRingAt(2)}
+
+ &:disabled {
+ cursor: not-allowed;
+ }
+`
+
+export const NeutralButton = styled(DialogButton)`
+ border: 1px solid var(--dyncfg-control-border);
+ background: transparent;
+ color: ${getColor("textFocus")};
+
+ &:disabled {
+ border-color: var(--dyncfg-disabled-border);
+ color: var(--dyncfg-disabled-text);
+ }
+
+ &:hover:not(:disabled) {
+ background: var(--dyncfg-row-hover);
+ }
+`
+
+const filledDisabled = `
+ &:disabled {
+ border-color: var(--dyncfg-disabled-fill);
+ background: var(--dyncfg-disabled-fill);
+ color: var(--dyncfg-disabled-fill-text);
+ }
+`
+
+export const DangerButton = styled(DialogButton)`
+ border: 1px solid transparent;
+ background: var(--dyncfg-danger-fill);
+ color: var(--dyncfg-danger-label);
+
+ &:hover:not(:disabled) {
+ filter: brightness(1.08);
+ }
+
+ ${filledDisabled}
+`
+
+export const PrimaryButton = styled(DialogButton)`
+ border: 1px solid transparent;
+ background: var(--dyncfg-primary-fill);
+ color: var(--dyncfg-primary-label);
+
+ &:hover:not(:disabled) {
+ filter: brightness(1.08);
+ }
+
+ ${filledDisabled}
+`
+
+// `inline` renders the dialog in place (story preview); the PR always portals to document.body.
+export const ConfirmDialog = ({
+ title,
+ message,
+ confirmLabel = "Confirm",
+ declineLabel = "Cancel",
+ onConfirm,
+ onDecline,
+ destructive = true,
+ isConfirmDisabled = false,
+ inline = false,
+}) => {
+ const titleId = useId()
+ const messageId = useId()
+ const ConfirmButton = destructive ? DangerButton : PrimaryButton
+
+ useEffect(() => {
+ const onKey = event => event.key === "Escape" && onDecline?.()
+ document.addEventListener("keydown", onKey)
+ return () => document.removeEventListener("keydown", onKey)
+ }, [onDecline])
+
+ const dialog = (
+
+
+
+
+ {destructive ? (
+
+ ) : null}
+ {title}
+
+ {message ? {message} : null}
+
+
+
+ {declineLabel}
+
+
+ {confirmLabel}
+
+
+
+
+ )
+
+ return inline ? dialog : createPortal(dialog, document.body)
+}
diff --git a/src/proposals/pr5951/inputs.js b/src/proposals/pr5951/inputs.js
new file mode 100644
index 000000000..b59671563
--- /dev/null
+++ b/src/proposals/pr5951/inputs.js
@@ -0,0 +1,322 @@
+// Copied from PR 5951: switchTrack.js + widgets/switchWidget.js, configItem/rowCheckbox.js,
+// workspace/filterInput.js, filters/activeFilters.js, workspace/styled.js.
+import React, { useEffect, useRef } from "react"
+import styled, { css } from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { checkMarkPath, focusRingAt, monoFont } from "./tokens"
+
+const BORDER = 1.5
+
+const switchTrack = ({ width, height, knob }) => {
+ const inset = (height - BORDER * 2 - knob) / 2
+ const onLeft = width - BORDER * 2 - knob - inset
+
+ return css`
+ all: unset;
+ box-sizing: border-box;
+ position: relative;
+ flex: 0 0 auto;
+ width: ${getSizeBy(width / 8)};
+ height: ${getSizeBy(height / 8)};
+ border-radius: var(--dyncfg-radius-pill);
+ cursor: pointer;
+ border: ${BORDER}px solid
+ ${({ isOn }) => (isOn ? "var(--dyncfg-heading)" : "var(--dyncfg-control-border)")};
+ background: ${({ isOn }) => (isOn ? "var(--dyncfg-heading)" : "transparent")};
+ transition:
+ background 140ms ease,
+ border-color 140ms ease;
+
+ &::after {
+ content: "";
+ position: absolute;
+ top: ${getSizeBy(inset / 8)};
+ left: ${({ isOn }) => getSizeBy((isOn ? onLeft : inset) / 8)};
+ width: ${getSizeBy(knob / 8)};
+ height: ${getSizeBy(knob / 8)};
+ border-radius: 50%;
+ background: ${({ isOn }) =>
+ isOn ? "var(--dyncfg-check-mark)" : "var(--dyncfg-control-border)"};
+ transition: left 140ms ease;
+ }
+
+ &:hover:not(:disabled) {
+ border-color: ${({ isOn }) => (isOn ? "var(--dyncfg-heading)" : getColor("textFocus"))};
+ }
+
+ ${focusRingAt(2)}
+
+ &:disabled {
+ opacity: 0.4;
+ cursor: not-allowed;
+ }
+ `
+}
+
+const Track = styled(Box).attrs({ as: "button" })`
+ ${switchTrack({ width: 34, height: 20, knob: 13 })}
+`
+
+const SwitchControl = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(1)};
+`
+
+const Word = styled(Box).attrs({ as: "span", "aria-hidden": "true" })`
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const Switch = ({ value, disabled, onChange, label }) => (
+
+
+)
+
+const CheckboxInput = styled(Box).attrs({ as: "input" }).attrs({ type: "checkbox" })`
+ appearance: none;
+ flex: 0 0 auto;
+ display: grid;
+ place-content: center;
+ width: ${getSizeBy(2)};
+ height: ${getSizeBy(2)};
+ margin: 0;
+ border-radius: var(--dyncfg-radius-xs);
+ border: 1.5px solid var(--dyncfg-control-border, ${getColor("inputBorderHover")});
+ background: ${getColor("mainBackground")};
+ cursor: pointer;
+ transition:
+ background 120ms ease,
+ border-color 120ms ease;
+
+ &::after {
+ content: "";
+ width: ${getSizeBy(1.125)};
+ height: ${getSizeBy(1.125)};
+ background: var(--dyncfg-check-mark);
+ clip-path: ${checkMarkPath};
+ transform: scale(0);
+ transition: transform 100ms ease;
+ }
+
+ &:checked,
+ &:indeterminate {
+ background: var(--dyncfg-check-fill, ${getColor("primary")});
+ border-color: var(--dyncfg-check-fill, ${getColor("primary")});
+ }
+
+ &:checked::after {
+ transform: scale(1);
+ }
+
+ &:indeterminate::after {
+ height: ${getSizeBy(0.25)};
+ clip-path: none;
+ transform: scale(1);
+ }
+
+ &:hover:not(:disabled) {
+ border-color: var(--dyncfg-check-fill, ${getColor("primary")});
+ }
+
+ ${focusRingAt(2)}
+`
+
+export const RowCheckbox = ({ checked, indeterminate = false, onChange, label }) => {
+ const ref = useRef()
+
+ useEffect(() => {
+ if (ref.current) ref.current.indeterminate = !!indeterminate
+ }, [indeterminate])
+
+ return (
+
+ )
+}
+
+const FilterContainer = styled(Box).attrs({ as: "label" })`
+ position: relative;
+ display: flex;
+ align-items: center;
+ flex: 1 1 auto;
+ min-width: 0;
+
+ > svg {
+ position: absolute;
+ left: ${getSizeBy(1.25)};
+ fill: var(--dyncfg-text-secondary);
+ pointer-events: none;
+ }
+`
+
+const FilterField = styled(Box).attrs({ as: "input" })`
+ width: 100%;
+ height: ${getSizeBy(4)};
+ padding: 0 ${getSizeBy(3.75)} 0 ${getSizeBy(4)};
+ border-radius: var(--dyncfg-radius-sm);
+ border: 1px solid
+ ${({ hasValue }) => (hasValue ? "var(--dyncfg-control-border)" : "var(--dyncfg-chip-border)")};
+ background: var(--dyncfg-input-bg);
+ color: ${getColor("textFocus")};
+ font: inherit;
+ font-size: 13px;
+
+ &::placeholder {
+ color: var(--dyncfg-text-placeholder);
+ }
+
+ &::-webkit-search-cancel-button {
+ display: none;
+ }
+
+ ${focusRingAt(-1)}
+`
+
+const Clear = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ position: absolute;
+ right: ${getSizeBy(0.625)};
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: ${getSizeBy(2.75)};
+ height: ${getSizeBy(2.75)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ color: var(--dyncfg-text-secondary);
+
+ svg {
+ fill: currentColor;
+ }
+
+ &:hover {
+ color: ${getColor("textFocus")};
+ background: var(--dyncfg-segment-bg);
+ }
+
+ ${focusRingAt(0)}
+`
+
+export const FilterInput = ({ value, onChange, placeholder }) => {
+ const inputRef = useRef()
+
+ const onKeyDown = event => {
+ if (event.key === "Escape" && value) {
+ event.stopPropagation()
+ onChange("")
+ }
+ }
+
+ return (
+
+
+ onChange(event.target.value)}
+ onKeyDown={onKeyDown}
+ />
+ {value ? (
+ {
+ onChange("")
+ inputRef.current?.focus()
+ }}
+ >
+
+
+ ) : null}
+
+ )
+}
+
+export const RemovableChip = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.5)};
+ height: ${getSizeBy(3.25)};
+ padding: 0 ${getSizeBy(0.75)} 0 ${getSizeBy(1.25)};
+ border-radius: var(--dyncfg-radius-pill);
+ cursor: pointer;
+ font-size: 12px;
+ font-weight: 500;
+ color: ${getColor("textFocus")};
+ background: ${getColor("elementBackground")};
+ border: 1px solid var(--dyncfg-control-border);
+
+ svg {
+ fill: var(--dyncfg-text-secondary);
+ }
+
+ &:hover svg {
+ fill: ${getColor("textFocus")};
+ }
+
+ ${focusRingAt(1)}
+`
+
+export const Chip = styled(Box).attrs({ as: "span" })`
+ display: inline-block;
+ flex: 0 0 auto;
+ max-width: 100%;
+ height: ${getSizeBy(2.5)};
+ line-height: 18px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ padding: 0 ${getSizeBy(0.875)};
+ border-radius: var(--dyncfg-radius-sm);
+ font-size: 11px;
+ font-family: ${({ mono }) => (mono ? monoFont : "inherit")};
+ font-weight: 500;
+ white-space: nowrap;
+ color: var(--dyncfg-text-secondary);
+ border: 1px solid var(--dyncfg-chip-border);
+`
+
+const Mark = styled(Box).attrs({ as: "mark" })`
+ color: inherit;
+ font-weight: 600;
+ border-radius: var(--dyncfg-radius-xs);
+ background: var(--dyncfg-match-bg);
+ box-shadow: 0 0 0 1px var(--dyncfg-match-bg);
+`
+
+export const Highlight = ({ text = "", match }) =>
+ match ? (
+ <>
+ {text.slice(0, match.start)}
+ {text.slice(match.start, match.end)}
+ {text.slice(match.end)}
+ >
+ ) : (
+ {text}
+ )
diff --git a/src/proposals/pr5951/marks.js b/src/proposals/pr5951/marks.js
new file mode 100644
index 000000000..f738ea5e1
--- /dev/null
+++ b/src/proposals/pr5951/marks.js
@@ -0,0 +1,189 @@
+// Copied from PR 5951: configItem/collectorLogo.js, workspace/addItemButton.js, templates/disclosureButton.js,
+// requiredTag.js, validationIcon.js, alertEditor/silentSign.js.
+import React from "react"
+import styled, { css, keyframes } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRingAt, hitArea } from "./tokens"
+
+const looks = {
+ logo: css`
+ background: var(--dyncfg-logo-tile);
+ border: 1px solid ${getColor("borderSecondary")};
+ `,
+ letter: css`
+ background: var(--dyncfg-letter-tile);
+ border: 1px solid var(--dyncfg-letter-tile-edge);
+ color: var(--dyncfg-letter-tile-text);
+ `,
+ plain: css`
+ background: ${getColor("elementBackground")};
+ border: 1px solid ${getColor("borderSecondary")};
+ color: var(--dyncfg-text-secondary);
+ `,
+}
+
+export const Tile = styled(Box)`
+ flex: 0 0 auto;
+ width: ${({ tileSize }) => getSizeBy(tileSize / 8)};
+ height: ${({ tileSize }) => getSizeBy(tileSize / 8)};
+ border-radius: ${({ tileSize }) => getSizeBy(Math.round(tileSize / 4) / 8)};
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ ${({ look }) => looks[look]}
+ opacity: ${({ dimmed }) => (dimmed ? 0.5 : 1)};
+ filter: ${({ dimmed }) => (dimmed ? "grayscale(1)" : "none")};
+ font-size: ${({ tileSize }) => Math.round(tileSize * 0.42)}px;
+ font-weight: 600;
+ text-transform: uppercase;
+ user-select: none;
+
+ img {
+ width: 76%;
+ height: 76%;
+ object-fit: contain;
+ }
+`
+
+const glyph = (size, filled, paths) => (
+
+)
+
+export const PlugGlyph = ({ size = 13 }) =>
+ glyph(size, false, [
+ ,
+ ,
+ ,
+ ])
+
+export const BellGlyph = ({ size = 13 }) =>
+ glyph(size, false, [
+ ,
+ ,
+ ])
+
+const CircleButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex: 0 0 auto;
+ width: ${getSizeBy(2.5)};
+ height: ${getSizeBy(2.5)};
+ border-radius: 50%;
+ cursor: pointer;
+ color: var(--dyncfg-text-secondary);
+ transition: color 120ms ease;
+ ${hitArea}
+
+ &:hover:not([aria-disabled="true"]),
+ &:focus-visible {
+ color: ${getColor("primary")};
+ }
+
+ &[aria-disabled="true"] {
+ color: var(--dyncfg-control-border);
+ opacity: 0.6;
+ cursor: not-allowed;
+ }
+
+ ${focusRingAt(0)}
+`
+
+export const AddItemButton = ({ noun, disabled }) => (
+
+
+
+)
+
+const Disclosure = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: ${getSizeBy(2.5)};
+ height: ${getSizeBy(2.5)};
+ border-radius: var(--dyncfg-radius-xs);
+ cursor: pointer;
+
+ &:hover {
+ background: ${getColor("elementBackground")};
+ }
+
+ ${focusRingAt(0)}
+`
+
+export const DisclosureButton = ({ expanded, title, onToggle }) => (
+
+
+
+)
+
+const Tag = styled(Box).attrs({ as: "span", "aria-hidden": "true" })`
+ margin-left: ${getSizeBy(0.25)};
+ font-size: 11px;
+ line-height: 16px;
+ font-weight: 400;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const RequiredTag = ({ ifUsed = false }) => (
+ {ifUsed ? " required if used" : " required"}
+)
+
+const fadeIn = keyframes`
+ from { opacity: 0; transform: scale(0.8); }
+ to { opacity: 1; transform: scale(1); }
+`
+
+const IconWrapper = styled(Flex)`
+ animation: ${fadeIn} 0.2s ease-in-out;
+`
+
+export const ValidationIcon = () => (
+
+
+
+)
+
+const Sign = styled(Box).attrs({ as: "span", "aria-hidden": true })`
+ flex: none;
+ display: inline-flex;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const SilentSign = () => (
+
+
+
+)
diff --git a/src/proposals/pr5951/pr5951.stories.js b/src/proposals/pr5951/pr5951.stories.js
new file mode 100644
index 000000000..61c1cfe5a
--- /dev/null
+++ b/src/proposals/pr5951/pr5951.stories.js
@@ -0,0 +1,507 @@
+// Faithful copies of the custom elements added in cloud-frontend PR 5951 (Dyncfg rework). Raw hex/px values
+// in this folder are deliberate so the review shows the PR as written; do not reuse them as netdata-ui code.
+import React, { useState } from "react"
+import Flex from "@/components/templates/flex"
+import { Icon } from "@/components/icon"
+import { Text, TextSmall } from "@/components/typography"
+import { DyncfgVars } from "./tokens"
+import {
+ CompactSegment,
+ CompactSegmented,
+ FilterChip,
+ MenuItem,
+ MenuNote,
+ MenuPanel,
+ MenuText,
+ OutlineButton,
+ RowTextAction,
+ SegmentButton,
+ Segmented,
+ SmallButton,
+ TextButton,
+ TextLink,
+ Count,
+ Tick,
+} from "./controls"
+import { IconAction, Tooltip } from "./actions"
+import { PaneTabs, TabStrip } from "./tabs"
+import { AlertLevelPill, MarkCounts, StatePill, StatusWord, statusTones } from "./status"
+import { Chip, FilterInput, Highlight, RemovableChip, RowCheckbox, Switch } from "./inputs"
+import {
+ Empty,
+ EmptyActionButton,
+ EmptyActions,
+ EmptyContainer,
+ EmptyHint,
+ EmptyResultActions,
+ EmptyTitle,
+ JobStateBanner,
+} from "./surfaces"
+import { ConfirmDialog, NeutralButton, PrimaryButton } from "./dialog"
+import {
+ AddItemButton,
+ BellGlyph,
+ DisclosureButton,
+ PlugGlyph,
+ RequiredTag,
+ SilentSign,
+ Tile,
+ ValidationIcon,
+} from "./marks"
+import { Card, CardGap, CardHeader, CardNote, CardSub, CardTitle, ClampedDescription } from "./card"
+
+const PR = "src/domains/configuration/components/"
+
+export default {
+ title: "Proposals/PR 5951 elements",
+ parameters: { layout: "padded" },
+ decorators: [
+ Story => (
+ <>
+
+
+ >
+ ),
+ ],
+}
+
+const Caption = ({ source, overlaps, children }) => (
+
+
+ {`PR: ${PR}${source}`}
+ {`Closest netdata-ui: ${overlaps}`}
+
+ {children}
+
+)
+
+const Row = props =>
+
+export const Buttons = () => (
+
+
+
+
+ Add job
+
+
+ Active
+
+
+ 28px height
+
+
+ Disabled
+
+ Copy
+
+
+
+
+ Add a condition
+
+ every 10 seconds
+
+ disabled link
+
+ Reset
+ Reset (disabled)
+
+
+)
+
+export const IconActions = () => (
+
+
+
+
+
+
+
+
+
+)
+
+const SegmentedDemo = ({ Group, Segment, options }) => {
+ const [value, setValue] = useState(options[0])
+ return (
+
+ {options.map(option => (
+ setValue(option)}
+ >
+ {option}
+
+ ))}
+
+ )
+}
+
+export const SegmentedControls = () => (
+
+
+
+
+)
+
+export const FilterChips = () => {
+ const [pressed, setPressed] = useState(true)
+ return (
+
+
+ setPressed(p => !p)}>
+ Needs attention
+
+ Configured
+ Available
+
+
+
+ Failed
+
+
+
+ User
+
+
+
+
+ dyncfg
+ go.d:nginx:local
+
+
+
+
+
+ )
+}
+
+export const TabStrips = () => {
+ const [selected, setSelected] = useState(0)
+ const [pane, setPane] = useState("jobs")
+ const paneTabs = [
+ { key: "jobs", label: "Jobs", icon: "nodes", count: 12, tick: { tone: "error", count: 2 } },
+ { key: "alerts", label: "Alerts", icon: "alarm_bell", count: 48, of: 52 },
+ { key: "settings", label: "Settings", icon: "gear", tone: "ink" },
+ ]
+ return (
+
+
+
+
+ 1,204
+ 3
+ 7
+ 0
+
+
+ )
+}
+
+export const StatusMarks = () => (
+
+
+ {Object.entries(statusTones).map(([key, { label, tone, hollow }]) => (
+
+ {label}
+
+ ))}
+
+
+
+ Running
+
+
+ Failed
+
+
+
+ {Object.entries(statusTones).map(([key, { label, tone, hollow }]) => (
+
+ ))}
+
+
+
+ Critical
+ Warning
+ Clear
+ Not run yet
+
+
+
+)
+
+export const SwitchAndCheckbox = () => {
+ const [on, setOn] = useState(true)
+ const [checked, setChecked] = useState(false)
+ return (
+
+
+
+ {}} label="Off" />
+ {}} label="Disabled" />
+
+
+ setChecked(c => !c)} label="Select job" />
+ {}} label="Checked" />
+ {}} label="Some selected" />
+
+
+ )
+}
+
+export const Filter = () => {
+ const [value, setValue] = useState("nginx")
+ return (
+
+
+
+ {}} placeholder="Filter alerts" />
+
+
+ )
+}
+
+export const Menu = () => (
+
+
+
+
+
+
+
+
+
+)
+
+export const EmptyStates = () => (
+
+
+ No matches for “postgres”
+ Try another search term, or clear the search and filters.
+
+ Clear search
+ Clear filters
+
+
+
+ Nothing to configure here on this node.
+
+
+
+
+
+ No jobs yet
+ The nginx collector has no jobs on this node. Add one to start collecting metrics.
+
+ Add job
+
+
+
+)
+
+export const Banners = () => (
+
+ Restart job}
+ />
+ Enable}
+ />
+
+
+
+)
+
+export const Dialog = () => (
+
+
+ Cancel
+ Save
+
+ Save
+
+
+
+ The job nginx_local stops collecting and its configuration is removed
+ from this node.
+ >
+ }
+ confirmLabel="Delete"
+ onConfirm={() => {}}
+ onDecline={() => {}}
+ />
+ {}}
+ onDecline={() => {}}
+ />
+
+)
+
+export const SmallMarks = () => {
+ const [expanded, setExpanded] = useState(false)
+ return (
+
+
+
+ N
+
+
+ P
+
+
+
+
+
+
+
+
+
+ setExpanded(e => !e)} />
+
+
+
+ URL
+
+
+
+ Password
+
+
+
+
+
+
+ )
+}
+
+export const AlertCard = () => (
+
+
+
+
+ On this node
+ web_log_nginx.requests · last 10 minutes
+
+ Warning
+
+
+
+
+
+
+
+
+
+
+)
+
+export const TooltipPanel = () => (
+
+
+ Hover me
+
+
+)
diff --git a/src/proposals/pr5951/status.js b/src/proposals/pr5951/status.js
new file mode 100644
index 000000000..582134971
--- /dev/null
+++ b/src/proposals/pr5951/status.js
@@ -0,0 +1,171 @@
+// Copied from PR 5951: configItem/badges.js, alertEditor/cardParts.js (StatusPill), templates/changeMarks.js.
+import React from "react"
+import styled, { css } from "styled-components"
+import Box from "@/components/templates/box"
+import { getColor, getSizeBy } from "@/theme"
+import { VisuallyHidden, dot } from "./tokens"
+
+export const statusTones = {
+ running: { label: "Running", tone: "success" },
+ accepted: { label: "Accepted", tone: "neutral", hollow: true },
+ failed: { label: "Failed", tone: "error" },
+ disabled: { label: "Disabled", tone: "muted", hollow: true },
+ incomplete: { label: "Incomplete", tone: "warning" },
+ orphan: { label: "Orphan", tone: "warning" },
+}
+
+export const toneColors = {
+ success: "var(--dyncfg-success-text)",
+ error: "var(--dyncfg-error-text)",
+ warning: "var(--dyncfg-warning-text)",
+ neutral: "var(--dyncfg-text-secondary)",
+ muted: "var(--dyncfg-text-secondary)",
+}
+
+export const StatusDot = styled(Box).attrs({ as: "span" })`
+ flex: 0 0 auto;
+ width: ${({ dotSize = 8 }) => getSizeBy(dotSize / 8)};
+ height: ${({ dotSize = 8 }) => getSizeBy(dotSize / 8)};
+ border-radius: 50%;
+ ${({ tone = "muted", hollow }) =>
+ hollow
+ ? css`
+ border: 1.5px solid ${toneColors[tone]};
+ `
+ : css`
+ background: ${toneColors[tone]};
+ `}
+`
+
+const pillLook = css`
+ border-radius: var(--dyncfg-radius-pill);
+ line-height: 1;
+ font-weight: 500;
+ white-space: nowrap;
+ background: color-mix(in srgb, currentColor var(--dyncfg-pill-tint, 13%), transparent);
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 22%, transparent);
+`
+
+const PillContainer = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: ${({ pillSize }) => getSizeBy(pillSize === "small" ? 0.5 : 0.75)};
+ height: ${({ pillSize }) => getSizeBy(pillSize === "small" ? 2 : 2.75)};
+ padding: 0 ${({ pillSize }) => getSizeBy(pillSize === "small" ? 0.75 : 1.125)};
+ font-size: ${({ pillSize }) => (pillSize === "small" ? 11 : 12)}px;
+ color: ${({ tone }) => toneColors[tone] || toneColors.neutral};
+ ${pillLook}
+`
+
+export const StatePill = ({ tone = "neutral", hollow, dot: hasDot = true, small, children }) => (
+
+ {hasDot ? : null}
+ {children}
+
+)
+
+const WordContainer = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: ${getSizeBy(0.75)};
+ font-size: 13px;
+ font-weight: 500;
+ white-space: nowrap;
+ color: ${({ tone }) => toneColors[tone] || toneColors.neutral};
+`
+
+const StateDetail = styled(Box).attrs({ as: "span" })`
+ font-weight: 400;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const StatusWord = ({ tone, hollow, label, detail }) => (
+
+
+ {label}
+ {detail ? {`· ${detail}`} : null}
+
+)
+
+export const AlertLevelPill = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ height: 20px;
+ padding: 0 7px;
+ border-radius: var(--dyncfg-radius-sm);
+ font-size: 11px;
+ line-height: 18px;
+ font-weight: 600;
+ background: ${({ status }) =>
+ status === "critical"
+ ? getColor("errorBackground")
+ : status === "warning"
+ ? getColor("warningBackground")
+ : "var(--dyncfg-clear-pill-bg)"};
+ color: ${({ status }) =>
+ status === "critical"
+ ? "var(--dyncfg-critical-level-text)"
+ : status === "warning"
+ ? "var(--dyncfg-warning-level-text)"
+ : "var(--dyncfg-clear-pill-text)"};
+`
+
+const EditedDot = styled(Box).attrs({ as: "span" })`
+ flex: 0 0 auto;
+ ${dot({ color: "var(--dyncfg-info-text)" })}
+`
+const CustomizedDot = styled(Box).attrs({ as: "span" })`
+ flex: 0 0 auto;
+ ${dot({ color: "var(--dyncfg-text-secondary)", hollow: true })}
+`
+const ErrorDot = styled(Box).attrs({ as: "span" })`
+ flex: 0 0 auto;
+ ${dot({ color: "var(--dyncfg-error-text)" })}
+`
+const ToFillDot = styled(Box).attrs({ as: "span" })`
+ flex: 0 0 auto;
+ box-sizing: border-box;
+ width: 7px;
+ height: 7px;
+ border-radius: 50%;
+ border: 1.5px dashed var(--dyncfg-heading);
+`
+
+const Counts = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(1.25)};
+ font-size: 12px;
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+`
+
+const MarkCount = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.625)};
+ color: ${({ tone }) => tone};
+`
+
+const countParts = [
+ ["error", ErrorDot, "var(--dyncfg-error-text)", "to fix"],
+ ["toFill", ToFillDot, "var(--dyncfg-heading)", "to fill"],
+ ["edited", EditedDot, "var(--dyncfg-info-text)", "edited"],
+ ["customized", CustomizedDot, "var(--dyncfg-text-secondary)", "customized"],
+]
+
+export const MarkCounts = ({ counts }) => (
+
+ {countParts
+ .filter(([key]) => counts[key])
+ .map(([key, Dot, tone, label]) => (
+
+
+ {counts[key]}
+ {` ${label}`}
+
+ ))}
+
+)
diff --git a/src/proposals/pr5951/surfaces.js b/src/proposals/pr5951/surfaces.js
new file mode 100644
index 000000000..faa376c8b
--- /dev/null
+++ b/src/proposals/pr5951/surfaces.js
@@ -0,0 +1,160 @@
+// Copied from PR 5951: emptyResults.js, workspace/emptyState.js, configForm/jobStateBanner.js.
+import React from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRingAt } from "./tokens"
+import { toneColors } from "./status"
+
+export const EmptyContainer = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: ${getSizeBy(0.75)};
+ align-self: flex-start;
+ width: 100%;
+ padding: ${getSizeBy(6)} ${getSizeBy(3)};
+ text-align: center;
+ border: 1px solid ${getColor("borderSecondary")};
+ border-radius: var(--dyncfg-radius-md);
+ background: ${getColor("mainBackground")};
+`
+
+export const EmptyTitle = styled(Box)`
+ font-size: 14px;
+ font-weight: 600;
+ line-height: 20px;
+ color: ${getColor("textFocus")};
+ overflow-wrap: anywhere;
+`
+
+export const EmptyHint = styled(Box)`
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-secondary);
+`
+
+export const EmptyResultActions = styled(Box)`
+ display: flex;
+ gap: ${getSizeBy(1)};
+ margin-top: ${getSizeBy(1.25)};
+`
+
+export const EmptyActionButton = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ height: ${getSizeBy(4)};
+ padding: 0 ${getSizeBy(1.75)};
+ border-radius: var(--dyncfg-radius-sm);
+ cursor: pointer;
+ font-size: 13px;
+ font-weight: 500;
+ color: ${getColor("textFocus")};
+ border: 1px solid var(--dyncfg-control-border);
+
+ &:hover {
+ border-color: ${getColor("textFocus")};
+ }
+
+ ${focusRingAt(1)}
+`
+
+export const Empty = styled(Box)`
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: ${getSizeBy(1.25)};
+ flex: 1 1 auto;
+ min-height: 0;
+ padding: ${getSizeBy(9)} ${getSizeBy(3)} ${getSizeBy(5)};
+ text-align: center;
+
+ h3 {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 600;
+ color: ${getColor("textFocus")};
+ }
+
+ p {
+ margin: 0;
+ max-width: ${getSizeBy(52.5)};
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-secondary);
+ }
+`
+
+export const EmptyActions = styled(Box)`
+ display: flex;
+ gap: ${getSizeBy(1)};
+ margin-top: ${getSizeBy(0.75)};
+`
+
+const Banner = styled(Box)`
+ display: flex;
+ align-items: flex-start;
+ gap: ${getSizeBy(1.25)};
+ max-width: ${getSizeBy(102)};
+ padding: ${getSizeBy(1.25)} ${getSizeBy(1.75)};
+ border-radius: var(--dyncfg-radius-md);
+ font-size: 13px;
+ line-height: 20px;
+ color: ${getColor("textFocus")};
+ background: color-mix(in srgb, ${({ tone }) => toneColors[tone]} 10%, transparent);
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, ${({ tone }) => toneColors[tone]} 35%, transparent);
+
+ > svg {
+ flex: 0 0 auto;
+ margin-top: ${getSizeBy(0.25)};
+ }
+
+ strong {
+ font-weight: 600;
+ }
+`
+
+const BannerMessage = styled(Box).attrs({ as: "span" })`
+ flex: 1 1 auto;
+`
+
+const BannerActionSlot = styled(Box).attrs({ as: "span" })`
+ display: flex;
+ flex: 0 0 auto;
+ align-self: center;
+`
+
+const Hint = styled(Box).attrs({ as: "p" })`
+ display: flex;
+ align-items: flex-start;
+ gap: ${getSizeBy(1)};
+ max-width: ${getSizeBy(102)};
+ margin: 0 0 ${getSizeBy(0.5)};
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--dyncfg-text-secondary);
+
+ > svg {
+ flex: 0 0 auto;
+ margin-top: ${getSizeBy(0.25)};
+ }
+`
+
+export const JobStateBanner = ({ state, action }) =>
+ state.variant === "hint" ? (
+
+
+ {state.text}
+
+ ) : (
+
+
+
+ {state.title} {state.text}
+
+ {action ? {action} : null}
+
+ )
diff --git a/src/proposals/pr5951/tabs.js b/src/proposals/pr5951/tabs.js
new file mode 100644
index 000000000..eaac67874
--- /dev/null
+++ b/src/proposals/pr5951/tabs.js
@@ -0,0 +1,162 @@
+// Copied from PR 5951: components/tabStrip.js and workspace/paneTabs.js (+ TypeTab from typeTabs.js).
+import React from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import { Icon } from "@/components/icon"
+import { getColor, getSizeBy } from "@/theme"
+import { focusRingAt } from "./tokens"
+import { onRovingKeyDown } from "./actions"
+import { Count, Tick } from "./controls"
+import { toneColors } from "./status"
+
+const Strip = styled(Box)`
+ display: flex;
+ align-items: center;
+ flex: 0 0 auto;
+ gap: ${getSizeBy(0.25)};
+ overflow-x: auto;
+ scrollbar-width: none;
+ align-self: flex-start;
+ max-width: 100%;
+ padding: ${getSizeBy(0.375)};
+ border-radius: var(--dyncfg-radius-md);
+ background: ${getColor("mainBackground")};
+ border: 1px solid ${getColor("borderSecondary")};
+`
+
+const StripItem = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ cursor: pointer;
+ white-space: nowrap;
+ font-size: 13px;
+ line-height: 20px;
+ padding: ${getSizeBy(0.5)} ${getSizeBy(1.5)};
+ border-radius: var(--dyncfg-radius-sm);
+ font-weight: 500;
+ color: ${({ active }) => (active ? getColor("textFocus") : "var(--dyncfg-text-secondary)")};
+ background: ${({ active }) => (active ? getColor("elementBackground") : "transparent")};
+ box-shadow: ${({ active }) => (active ? "inset 0 0 0 1px var(--dyncfg-control-border)" : "none")};
+ transition:
+ color 120ms ease,
+ background 120ms ease;
+
+ &:hover {
+ color: ${getColor("textFocus")};
+ }
+
+ ${focusRingAt(-2)}
+`
+
+export const TabStrip = ({ tabs = [], selected = 0, onChange }) => (
+
+ {tabs.map(({ label }, index) => (
+ onChange(index)}
+ onKeyDown={event => onRovingKeyDown({ event, index, count: tabs.length, onMove: onChange })}
+ >
+ {label}
+
+ ))}
+
+)
+
+export const TypeTab = styled(Box).attrs({ as: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: ${getSizeBy(0.875)};
+ height: ${getSizeBy(4.25)};
+ padding: 0 ${getSizeBy(1.5)};
+ white-space: nowrap;
+ font-size: 13px;
+ line-height: 20px;
+ color: ${getColor("textFocus")};
+ cursor: pointer;
+ font-weight: ${({ isSelected }) => (isSelected ? 600 : 500)};
+ box-shadow: inset 0 -${getSizeBy(0.25)} 0
+ ${({ isSelected }) => (isSelected ? getColor("textFocus") : "transparent")};
+ transition: background 120ms ease;
+
+ svg {
+ fill: var(--dyncfg-text-secondary);
+ }
+
+ &:hover,
+ &[aria-expanded="true"] {
+ background: var(--dyncfg-row-hover);
+ }
+
+ ${focusRingAt(-4)}
+`
+
+const PaneStrip = styled(Box)`
+ display: flex;
+ align-items: stretch;
+ gap: ${getSizeBy(0.25)};
+ flex: 0 0 auto;
+ border-bottom: 1px solid ${getColor("borderSecondary")};
+`
+
+const Of = styled(Box).attrs({ as: "span" })`
+ margin-left: -${getSizeBy(0.5)};
+ font-size: 12px;
+ color: var(--dyncfg-text-secondary);
+`
+
+const IconMark = styled(Box).attrs({ as: "span" })`
+ display: inline-flex;
+ color: ${({ tone, theme }) =>
+ tone === "ink"
+ ? getColor("textFocus")({ theme })
+ : toneColors[tone] || "var(--dyncfg-text-secondary)"};
+
+ && svg {
+ fill: currentColor;
+ }
+`
+
+export const PaneTabs = ({ tabs, selectedKey, onSelect, label }) => (
+
+ {tabs.map((tab, index) => {
+ const isSelected = tab.key === selectedKey
+ return (
+ onSelect(tab.key)}
+ onKeyDown={event =>
+ onRovingKeyDown({
+ event,
+ index,
+ count: tabs.length,
+ onMove: t => onSelect(tabs[t].key),
+ })
+ }
+ >
+
+
+
+ {tab.label}
+ {tab.count !== undefined ? {tab.count.toLocaleString()} : null}
+ {tab.of ? {`of ${tab.of.toLocaleString()}`} : null}
+ {tab.tick ? {tab.tick.count.toLocaleString()} : null}
+
+ )
+ })}
+
+)
diff --git a/src/proposals/pr5951/tokens.js b/src/proposals/pr5951/tokens.js
new file mode 100644
index 000000000..f1e073617
--- /dev/null
+++ b/src/proposals/pr5951/tokens.js
@@ -0,0 +1,174 @@
+// Faithful copy of cloud-frontend PR 5951 (src/domains/configuration/styles/*). Raw hex/px values are
+// kept on purpose so the review shows the PR as written; they are not netdata-ui conventions.
+import styled, { css, createGlobalStyle } from "styled-components"
+import Box from "@/components/templates/box"
+import { getColor, getSizeBy } from "@/theme"
+
+export const monoFont = `ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`
+
+export const focusRingAt = (offset, radius) => css`
+ &:focus-visible {
+ outline: 2px solid var(--dyncfg-focus);
+ outline-offset: ${offset}px;
+ ${radius ? `border-radius: ${radius};` : ""}
+ }
+`
+
+export const focusRing = focusRingAt(-2)
+
+export const dot = ({ size = 6, color = "currentColor", hollow = false } = {}) => css`
+ box-sizing: border-box;
+ width: ${getSizeBy(size / 8)};
+ height: ${getSizeBy(size / 8)};
+ border-radius: 50%;
+ ${hollow ? `border: 1.5px solid ${color};` : `background: ${color};`}
+`
+
+export const checkMarkPath = "polygon(14% 44%, 0 59%, 40% 100%, 100% 22%, 86% 8%, 39% 70%)"
+
+export const hitArea = css`
+ position: relative;
+
+ &::after {
+ content: "";
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ width: max(100%, ${getSizeBy(3)});
+ height: max(100%, ${getSizeBy(3)});
+ transform: translate(-50%, -50%);
+ }
+`
+
+export const VisuallyHidden = styled(Box).attrs(({ as = "span" }) => ({ as }))`
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ white-space: nowrap;
+`
+
+export const eyebrow = css`
+ font-size: 11px;
+ line-height: 16px;
+ font-weight: 600;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--dyncfg-text-secondary);
+`
+
+// Subset of the PR's --dyncfg-* variables that the ported elements read (dyncfgStyles.js:39-213).
+const darkVars = css`
+ --dyncfg-text-primary: #e2e8e8;
+ --dyncfg-text-secondary: #8fa3a3;
+ --dyncfg-text-placeholder: #7a8e8e;
+ --dyncfg-control-border: #748888;
+ --dyncfg-success-text: #1fc463;
+ --dyncfg-error-text: #ff6b7a;
+ --dyncfg-warning-text: #f5b638;
+ --dyncfg-warning-level-text: #1f1300;
+ --dyncfg-critical-level-text: #ffdfe3;
+ --dyncfg-clear-pill-bg: #2e3737;
+ --dyncfg-clear-pill-text: #c9d3d3;
+ --dyncfg-row-hover: #262f2f;
+ --dyncfg-row-selected: #283333;
+ --dyncfg-check-fill: #dfe6e6;
+ --dyncfg-check-mark: #172020;
+ --dyncfg-info-text: #7ab8f5;
+ --dyncfg-chip-border: #445252;
+ --dyncfg-segment-bg: rgba(255, 255, 255, 0.04);
+ --dyncfg-segment-active: rgba(255, 255, 255, 0.11);
+ --dyncfg-segment-shadow: none;
+ --dyncfg-match-bg: rgba(232, 237, 237, 0.2);
+ --dyncfg-paper: #202626;
+ --dyncfg-paper-edge: #2e3737;
+ --dyncfg-heading: #93c9cb;
+ --dyncfg-backdrop: rgba(0, 0, 0, 0.5);
+ --dyncfg-dialog-border: rgba(255, 255, 255, 0.08);
+ --dyncfg-dialog-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
+ --dyncfg-danger-fill: #ff6b7a;
+ --dyncfg-danger-label: #172020;
+ --dyncfg-focus: #00cd51;
+ --dyncfg-primary-fill: #00ab44;
+ --dyncfg-primary-label: #0c0f0f;
+ --dyncfg-disabled-border: #2e3737;
+ --dyncfg-disabled-text: #627474;
+ --dyncfg-disabled-fill: #2b3232;
+ --dyncfg-disabled-fill-text: #7a8e8e;
+ --dyncfg-pill-tint: 13%;
+ --dyncfg-logo-tile: #c0caca;
+ --dyncfg-letter-tile: #1f2525;
+ --dyncfg-letter-tile-edge: #445252;
+ --dyncfg-letter-tile-text: #8fa3a3;
+ --dyncfg-popover-bg: #232929;
+ --dyncfg-popover-border: #2e3737;
+ --dyncfg-popover-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
+`
+
+const lightVars = css`
+ --dyncfg-text-primary: #1f2b2b;
+ --dyncfg-text-secondary: #566868;
+ --dyncfg-text-placeholder: #687a7a;
+ --dyncfg-control-border: #7f9090;
+ --dyncfg-success-text: #007a31;
+ --dyncfg-error-text: #c4122a;
+ --dyncfg-warning-text: #905d00;
+ --dyncfg-warning-level-text: #5a3500;
+ --dyncfg-critical-level-text: #4d0610;
+ --dyncfg-clear-pill-bg: #e6ebeb;
+ --dyncfg-clear-pill-text: #3f4d4d;
+ --dyncfg-row-hover: #f0f4f4;
+ --dyncfg-row-selected: #dce5e6;
+ --dyncfg-check-fill: #1f2a2a;
+ --dyncfg-check-mark: #ffffff;
+ --dyncfg-info-text: #2366b8;
+ --dyncfg-chip-border: #cfd8d8;
+ --dyncfg-segment-bg: #eef2f2;
+ --dyncfg-segment-active: #ffffff;
+ --dyncfg-segment-shadow: 0 0 0 1px #b7c3c3, 0 1px 2px rgba(23, 32, 32, 0.14);
+ --dyncfg-match-bg: rgba(23, 32, 32, 0.12);
+ --dyncfg-paper: #ffffff;
+ --dyncfg-paper-edge: #dde4e4;
+ --dyncfg-heading: #1d6470;
+ --dyncfg-backdrop: rgba(15, 24, 24, 0.28);
+ --dyncfg-dialog-border: rgba(23, 32, 32, 0.08);
+ --dyncfg-dialog-shadow: 0 16px 48px rgba(23, 32, 32, 0.2);
+ --dyncfg-danger-fill: #c4122a;
+ --dyncfg-danger-label: #ffffff;
+ --dyncfg-focus: #007830;
+ --dyncfg-primary-fill: #007830;
+ --dyncfg-primary-label: #ffffff;
+ --dyncfg-disabled-border: #cfd8d8;
+ --dyncfg-disabled-text: #8b9b9b;
+ --dyncfg-disabled-fill: #d3dbdb;
+ --dyncfg-disabled-fill-text: #6b7c7c;
+ --dyncfg-pill-tint: 8%;
+ --dyncfg-logo-tile: #f4f6f6;
+ --dyncfg-letter-tile: #f4f6f6;
+ --dyncfg-letter-tile-edge: #d2d9d9;
+ --dyncfg-letter-tile-text: #465252;
+ --dyncfg-popover-bg: #ffffff;
+ --dyncfg-popover-border: #dbe1e1;
+ --dyncfg-popover-shadow: 0 8px 24px rgba(23, 32, 32, 0.12);
+`
+
+// Mounted only while a PR 5951 story renders, so the variables never leak into other stories.
+export const DyncfgVars = createGlobalStyle`
+ :root {
+ ${({ theme }) => (theme?.name === "Default" ? lightVars : darkVars)}
+ --dyncfg-radius-xs: ${getSizeBy(0.5)};
+ --dyncfg-radius-sm: ${getSizeBy(0.75)};
+ --dyncfg-radius-md: ${getSizeBy(1)};
+ --dyncfg-radius-lg: ${getSizeBy(1.5)};
+ --dyncfg-radius-pill: 999px;
+ --dyncfg-input-bg: ${getColor("mainBackground")};
+ }
+
+ .dyncfg-popover.dyncfg-popover {
+ background: var(--dyncfg-popover-bg);
+ border: 1px solid var(--dyncfg-popover-border);
+ border-radius: var(--dyncfg-radius-md);
+ box-shadow: var(--dyncfg-popover-shadow);
+ }
+`
diff --git a/src/proposals/primitives/divider.js b/src/proposals/primitives/divider.js
new file mode 100644
index 000000000..43f563f24
--- /dev/null
+++ b/src/proposals/primitives/divider.js
@@ -0,0 +1,21 @@
+// Proposed Divider: a 1px theme-coloured rule. Spacing and inset come from the Box margin prop.
+import React from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+
+const Rule = styled(Box)`
+ flex: none;
+ border: 0;
+`
+
+const Divider = ({ vertical = false, color = "border", ...rest }) => (
+
+)
+
+export default Divider
diff --git a/src/proposals/primitives/dividerScenes.js b/src/proposals/primitives/dividerScenes.js
new file mode 100644
index 000000000..32471a548
--- /dev/null
+++ b/src/proposals/primitives/dividerScenes.js
@@ -0,0 +1,182 @@
+import React from "react"
+import Flex from "@/components/templates/flex"
+import { IconButton } from "@/components/button"
+import { Text, TextSmall } from "@/components/typography"
+import { Section, Stack } from "../refresh/layout"
+import { Card, CardTitle, Grid, Note, Sample, Strip } from "./frame"
+import Divider from "./divider"
+import {
+ CfBillingSeparator,
+ CfDotSeparator,
+ CfHudDivider,
+ CfMenuDivider,
+ CfNodeBadgesSeparator,
+ CfSeparator,
+ CfSidebarDivider,
+ CfSpacesSeparator,
+ ChLineSeparator,
+ ChMenuDivider,
+} from "./today"
+
+const Words = ({ children }) => {children}
+
+export const TodayDividers = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Plan
+
+ Usage
+
+
+
+
+ 12 nodes
+
+ 3 offline
+
+
+
+
+ Prev
+
+ Next
+
+
+
+
+ Legend
+
+ Units
+
+ Off
+
+
+
+
+ 4 anomalies
+
+ 2 nodes
+
+ last 15m
+
+
+
+
+
+)
+
+const menuItems = [["Edit", "Duplicate"], ["Move to room", "Share link"], ["Delete"]]
+
+const MenuContext = () => (
+
+ {menuItems.map((group, index) => (
+
+ {index ? : null}
+ {group.map(label => (
+
+ {label}
+
+ ))}
+
+ ))}
+
+)
+
+const ToolbarContext = () => (
+
+
+
+
+
+
+
+
+
+
+)
+
+const CardContext = () => (
+
+ Node overview
+ ip-10-0-1-12 · Ubuntu 24.04 · agent v2.3.0
+
+
+ Collected metrics
+ 2,431
+
+
+
+ Active alerts
+ 3
+
+
+)
+
+export const ProposedDividers = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12 nodes
+
+ 3 offline
+
+
+
+
+
+
+
+
+ Dot text separator not proposed: only anomalies/components/separator.js defines one (2
+ importers). Elsewhere the middle dot is joined inside strings, which a component would not
+ replace.
+
+
+)
diff --git a/src/proposals/primitives/frame.js b/src/proposals/primitives/frame.js
new file mode 100644
index 000000000..592e89db7
--- /dev/null
+++ b/src/proposals/primitives/frame.js
@@ -0,0 +1,59 @@
+// Story-only frames for the primitives proposal.
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Text, TextSmall } from "@/components/typography"
+import { getColor, getSizeBy } from "@/theme"
+
+const SampleFrame = styled(Flex).attrs({ column: true, gap: 1.5 })`
+ min-width: 0;
+`
+
+// One labelled specimen: name, exact values, then the rendering.
+export const Sample = ({ name, values, children }) => (
+
+
+ {name}
+ {values ? {values} : null}
+
+ {children}
+
+)
+
+// A card surface (8px radius, hairline border) to show primitives in context.
+export const Card = styled(Flex).attrs(props => ({
+ column: true,
+ padding: [3, 4],
+ gap: 3,
+ round: "8px",
+ border: { side: "all", color: "border" },
+ background: "mainBackground",
+ ...props,
+}))`
+ min-width: 0;
+`
+
+export const CardTitle = props =>
+
+// Specimen strip with a fixed height so vertical rules have something to stretch against.
+export const Strip = styled(Flex).attrs(props => ({
+ alignItems: "center",
+ gap: 2,
+ height: 8,
+ padding: [0, 2],
+ round: "4px",
+ border: { side: "all", color: "borderSecondary" },
+ ...props,
+}))``
+
+export const Grid = styled.div`
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(${getSizeBy(26)}, 1fr));
+ gap: ${getSizeBy(3)};
+`
+
+export const Note = styled(TextSmall).attrs({ color: "textLite" })`
+ max-width: ${getSizeBy(70)};
+ border-left: 2px solid ${getColor("border")};
+ padding-left: ${getSizeBy(1)};
+`
diff --git a/src/proposals/primitives/primitives.stories.js b/src/proposals/primitives/primitives.stories.js
new file mode 100644
index 000000000..ff07319b8
--- /dev/null
+++ b/src/proposals/primitives/primitives.stories.js
@@ -0,0 +1,37 @@
+import React from "react"
+import { Compare } from "../refresh/layout"
+import { ProposedDividers, TodayDividers } from "./dividerScenes"
+import { ProposedDots, TodayDots } from "./statusDotScenes"
+import { ProposedSkeletons, TodaySkeletons } from "./skeletonScenes"
+
+export default {
+ title: "Proposals/Primitives",
+ parameters: { layout: "padded" },
+}
+
+export const Divider = () => (
+ }
+ proposed={}
+ />
+)
+
+export const StatusDot = () => (
+ }
+ proposed={}
+ />
+)
+
+export const Skeleton = () => (
+ }
+ proposed={}
+ />
+)
diff --git a/src/proposals/primitives/skeleton.js b/src/proposals/primitives/skeleton.js
new file mode 100644
index 000000000..0cf224aba
--- /dev/null
+++ b/src/proposals/primitives/skeleton.js
@@ -0,0 +1,56 @@
+// Proposed Skeleton: one calm pulse on theme colours, radius by variant, still under reduced motion.
+import React from "react"
+import styled, { css, keyframes } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { getRgbColor } from "@/theme"
+
+const pulse = props => keyframes`
+ from { background-color: ${getRgbColor("borderSecondary", 0.5)(props)}; }
+ to { background-color: ${getRgbColor("borderSecondary", 1)(props)}; }
+`
+
+const Bone = styled(Box).attrs({ "aria-hidden": "true" })`
+ flex: none;
+ background-color: ${getRgbColor("borderSecondary", 1)};
+ animation: ${css`
+ ${pulse}`} 1.5s ease-in-out infinite alternate;
+ @media (prefers-reduced-motion: reduce) {
+ animation: none;
+ }
+`
+
+// Box units are 4px: text line 10px, box 32px, circle 32px.
+const variants = {
+ text: { width: "100%", height: 2.5, round: "2px" },
+ box: { width: "100%", height: 8, round: "4px" },
+ circle: { width: 8, height: 8, round: "50%" },
+}
+
+const lastLineWidth = "60%"
+
+const Skeleton = ({ variant = "box", width, height, lines = 1, ...rest }) => {
+ const base = variants[variant] || variants.box
+ const circleSide = width ?? height
+ const size =
+ variant === "circle"
+ ? { width: circleSide ?? base.width, height: circleSide ?? base.height }
+ : { width: width ?? base.width, height: height ?? base.height }
+
+ if (variant !== "text" || lines <= 1) return
+
+ return (
+
+ {Array.from({ length: lines }, (_, index) => (
+
+ ))}
+
+ )
+}
+
+export default Skeleton
diff --git a/src/proposals/primitives/skeletonScenes.js b/src/proposals/primitives/skeletonScenes.js
new file mode 100644
index 000000000..647f1e2ed
--- /dev/null
+++ b/src/proposals/primitives/skeletonScenes.js
@@ -0,0 +1,154 @@
+import React from "react"
+import Flex from "@/components/templates/flex"
+import { Section, Stack } from "../refresh/layout"
+import { Card, Grid, Note, Sample } from "./frame"
+import Divider from "./divider"
+import Skeleton from "./skeleton"
+import { AnomaliesBone, CfSkeletonBox, ChBone, ConfigShimmer } from "./todaySkeletons"
+
+export const TodaySkeletons = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+const rowWidths = ["62%", "48%", "70%", "54%", "40%"]
+
+const TableLayout = () => (
+
+
+
+
+
+
+
+
+ {rowWidths.map(width => (
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+
+)
+
+const ChartCard = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+const AvatarList = () => (
+
+ {["55%", "70%", "45%", "62%"].map(width => (
+
+
+
+
+
+
+
+ ))}
+
+)
+
+export const ProposedSkeletons = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Width and height take Box units (4px) or CSS strings. Containers should set aria-busy while
+ loading. CH keeps its SVG chart-shape skeletons; only Bone would move to this.
+
+
+)
diff --git a/src/proposals/primitives/statusDot.js b/src/proposals/primitives/statusDot.js
new file mode 100644
index 000000000..aa4135f74
--- /dev/null
+++ b/src/proposals/primitives/statusDot.js
@@ -0,0 +1,80 @@
+// Proposed StatusDot: the Pill dot (src/components/pill/dot.js) usable on its own.
+import React from "react"
+import styled, { css, keyframes } from "styled-components"
+import Box from "@/components/templates/box"
+import { getColor } from "@/theme"
+
+// Diameters in px mapped to 4px sub-units for the Box width/height props.
+export const dotSizes = { 6: 1.5, 7: 1.75, 8: 2, 10: 2.5 }
+
+const inkOf = ({ color, theme }) => getColor(color)({ theme })
+
+const DotBase = styled(Box).attrs({ as: "span" })`
+ position: relative;
+ display: inline-block;
+ flex: none;
+ vertical-align: middle;
+ border-radius: 50%;
+`
+
+const FilledDot = styled(DotBase)`
+ background-color: ${inkOf};
+`
+
+const HollowDot = styled(DotBase)`
+ border: 1.5px solid ${inkOf};
+`
+
+const ripple = keyframes`
+ from { transform: scale(1); opacity: 0.45; }
+ to { transform: scale(2.4); opacity: 0; }
+`
+
+const pulseRing = css`
+ &::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: 50%;
+ background-color: ${inkOf};
+ animation: ${ripple} 1.6s ease-out infinite;
+ }
+ @media (prefers-reduced-motion: reduce) {
+ &::after {
+ animation: none;
+ opacity: 0;
+ }
+ }
+`
+
+const PulsingFilledDot = styled(FilledDot)`
+ ${pulseRing}
+`
+
+const PulsingHollowDot = styled(HollowDot)`
+ ${pulseRing}
+`
+
+const pick = (hollow, pulse) => {
+ if (pulse) return hollow ? PulsingHollowDot : PulsingFilledDot
+ return hollow ? HollowDot : FilledDot
+}
+
+// Decorative by default; pass aria-label when the dot is the only carrier of the status.
+const StatusDot = ({ color = "text", size = 7, hollow = false, pulse = false, ...rest }) => {
+ const Dot = pick(hollow, pulse)
+ const side = dotSizes[size] || dotSizes[7]
+ const label = rest["aria-label"]
+
+ return (
+
+ )
+}
+
+export default StatusDot
diff --git a/src/proposals/primitives/statusDotScenes.js b/src/proposals/primitives/statusDotScenes.js
new file mode 100644
index 000000000..0cef10539
--- /dev/null
+++ b/src/proposals/primitives/statusDotScenes.js
@@ -0,0 +1,183 @@
+import React from "react"
+import Flex from "@/components/templates/flex"
+import { Text, TextSmall } from "@/components/typography"
+import { Row, Section, Stack } from "../refresh/layout"
+import { Card, Grid, Note, Sample } from "./frame"
+import StatusDot from "./statusDot"
+import {
+ CfAlertStatusDot,
+ CfErrorIndicator,
+ CfInlineDot,
+ CfMcpStatusDot,
+ CfReportStatusDot,
+ CfUnreachableIndicator,
+ CfWarningIndicator,
+ ChDot,
+} from "./today"
+
+const inlineGap = [0, 1, 0, 0]
+
+const Label = props =>
+
+export const TodayDots = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+const nodes = [
+ { name: "ip-10-0-1-12", color: "live", hollow: false, state: "Live" },
+ { name: "db-primary-02", color: "stale", hollow: true, state: "Stale" },
+ { name: "edge-cache-07", color: "offline", hollow: true, state: "Offline" },
+]
+
+const alerts = [
+ { name: "disk_space_usage", color: "error", state: "Critical" },
+ { name: "10min_cpu_usage", color: "warning", state: "Warning" },
+ { name: "ram_in_use", color: "success", state: "Clear" },
+]
+
+const ListRow = ({ children }) => (
+
+ {children}
+
+)
+
+const NodeList = () => (
+
+ {nodes.map(({ name, color, hollow, state }) => (
+
+
+ {name}
+
+ {state}
+
+ ))}
+
+)
+
+const AlertList = () => (
+
+ {alerts.map(({ name, color, state }) => (
+
+
+ {name}
+
+ {state}
+
+ ))}
+
+)
+
+export const ProposedDots = () => (
+
+
+
+
+
+ {[6, 7, 8, 10].map(size => (
+
+ ))}
+
+
+
+
+ {[6, 7, 8, 10].map(size => (
+
+ ))}
+
+
+
+
+ {["live", "stale", "offline", "error", "warning", "attention"].map(color => (
+
+ ))}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 128 nodes live, 4 stale,{" "}
+ 2 offline
+
+
+ 3 critical alerts in this room
+
+
+
+
+ Colour stays the caller's mapping (statusPropsByHealthStatus, alertPill colors). The kit only
+ takes a theme key. The Pill would render this same component for its dot.
+
+
+)
diff --git a/src/proposals/primitives/today.js b/src/proposals/primitives/today.js
new file mode 100644
index 000000000..77bf5b2d6
--- /dev/null
+++ b/src/proposals/primitives/today.js
@@ -0,0 +1,146 @@
+// Faithful copies of today's cloud-frontend (CF) and charts (CH) dividers, dots and skeletons.
+// Raw px values, local keyframes and ad-hoc colours are kept on purpose, for comparison only.
+// They live only in this proposal file and must not be copied into src/components.
+import React from "react"
+import styled, { css } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { TextSmall } from "@/components/typography"
+import { getColor, getSizeBy } from "@/theme"
+
+// CF components/separator/index.js:3
+export const CfSeparator = ({ vertical, color = "borderSecondary", ...props }) => (
+
+)
+
+// CF components/navigation/sidebar/divider.js:3
+export const CfSidebarDivider = props => (
+
+)
+
+// CF components/menus/styled.js:4
+export const CfMenuDivider = styled.div`
+ background: ${getColor("disabled")};
+ height: 1px;
+ width: auto;
+ margin: ${getSizeBy(1)} ${getSizeBy(2)};
+`
+
+// CF domains/spaces/components/billing/separator.js:3 (vertical)
+export const CfBillingSeparator = props => (
+
+)
+
+// CF domains/spaces/components/sidebar/spaces/components/separator.js:4
+export const CfSpacesSeparator = styled.div`
+ height: 1px;
+ width: ${getSizeBy(3)};
+ background: ${getColor("border")};
+`
+
+// CF domains/rooms/components/room-overview/header/nodeBadges/styled.js:4
+export const CfNodeBadgesSeparator = styled.div`
+ background: ${getColor("border")};
+ height: 20px;
+ width: 1px;
+`
+
+// CF domains/dashboards/components/playlists/player/hud.js:46
+export const CfHudDivider = styled(Box).attrs({
+ width: "1px",
+ height: "16px",
+ background: "separator",
+})``
+
+// CF domains/anomalies/components/separator.js:3
+export const CfDotSeparator = () => (
+
+ ·
+
+)
+
+// CH components/line/separator.js:4
+export const ChLineSeparator = ({ disabled }) => (
+
+)
+
+// CH components/modern/menu.js:80
+export const ChMenuDivider = () =>
+
+// CF domains/spaces/components/mcpConnections/listView/statusDot.js:5 (colour from statusPropsByHealthStatus)
+export const CfMcpStatusDot = ({ color }) => (
+
+)
+
+// CF alertsSelector/alertsList/statusDot.js:4 and alertNameCell.js:9 (colour from alertPill colors)
+export const CfAlertStatusDot = ({ color }) => (
+
+
+
+)
+
+// CF domains/alerts/components/indicators.js:4-21 (round: 1 on an 8px box = 4px radius)
+export const CfErrorIndicator = styled(Flex).attrs({
+ flex: { grow: 0, shrink: 0 },
+ width: 2,
+ height: 2,
+ margin: [0, 1, 0, 0],
+ round: 1,
+ background: "error",
+})``
+export const CfWarningIndicator = styled(CfErrorIndicator).attrs({ background: "warning" })``
+export const CfUnreachableIndicator = styled(CfErrorIndicator).attrs({ background: "textLite" })``
+
+// CF domains/insights/components/styled.js:145 (6px, optional 1.6s 0-1-0 opacity blink)
+const blinkingMixin = css`
+ animation: ${({ isBlinking }) => (isBlinking ? `cfBlinking 1.6s ease-in infinite` : "")};
+ @keyframes cfBlinking {
+ 0% {
+ opacity: 0;
+ }
+ 50% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0;
+ }
+ }
+`
+export const CfReportStatusDot = styled(Box).attrs(props => ({
+ width: "6px",
+ height: "6px",
+ round: "50%",
+ ...props,
+}))`
+ ${blinkingMixin}
+`
+
+// CF inline boxes, e.g.
+export const CfInlineDot = ({ px = 6, color }) => (
+
+)
+
+// CH components/modern/dot.js:5 (size 2 = 8px, radius.pill = 999px)
+export const ChDot = styled(Box).attrs(({ size = 2 }) => ({
+ as: "span",
+ width: size,
+ height: size,
+ round: "999px",
+}))`
+ flex: none;
+`
diff --git a/src/proposals/primitives/todaySkeletons.js b/src/proposals/primitives/todaySkeletons.js
new file mode 100644
index 000000000..ae169e8f1
--- /dev/null
+++ b/src/proposals/primitives/todaySkeletons.js
@@ -0,0 +1,114 @@
+// Faithful copies of today's skeletons: CF SkeletonBox, anomalies Bone + Shine, configuration
+// Shimmer and CH Bone. Raw px values and the CH raw hex track colours are kept on purpose, for
+// comparison only. They live only in this proposal file and must not be copied into src/components.
+import React from "react"
+import styled, { css, keyframes } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { getColor, getRgbColor } from "@/theme"
+
+// CF styles/skeleton.js:13 (pulse borderSecondary 50% -> 100%, 1.5s ease-in, reduced motion off)
+const cfPulse = props => keyframes`
+ from { background: ${getRgbColor("borderSecondary", 0.5)(props)}; }
+ to { background: ${getRgbColor("borderSecondary", 1)(props)}; }
+`
+
+export const CfSkeletonBox = styled(Box).attrs(props => ({
+ width: "100%",
+ height: "12px",
+ round: true,
+ ...props,
+}))`
+ animation: ${css`
+ ${cfPulse}`} 1.5s ease-in infinite;
+ @media (prefers-reduced-motion: reduce) {
+ animation: none;
+ }
+`
+
+// CF domains/anomalies/components/skeleton.js:94 (borderSecondary + 4.8s text-12% sweep)
+const anomaliesShine = keyframes`
+ from { transform: translateX(-100%); }
+ to { transform: translateX(100%); }
+`
+
+const shineStyles = css`
+ &::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background: linear-gradient(90deg, transparent, ${getRgbColor("text", 0.12)}, transparent);
+ transform: translateX(-100%);
+ animation: ${anomaliesShine} 4.8s ease-in-out infinite;
+ }
+ @media (prefers-reduced-motion: reduce) {
+ &::after {
+ animation: none;
+ opacity: 0;
+ }
+ }
+`
+
+export const AnomaliesBone = styled(Box).attrs(props => ({
+ "aria-hidden": true,
+ background: "borderSecondary",
+ round: true,
+ position: "relative",
+ overflow: "hidden",
+ ...props,
+}))`
+ flex-shrink: 0;
+ ${shineStyles}
+`
+
+// CF domains/configuration/components/virtualized/placeholder.js:21 (100x10, 5px radius,
+// -45deg border/generic gradient, 1s linear, no reduced-motion handling)
+export const ConfigShimmer = styled(Flex).attrs(props => ({
+ width: "100px",
+ height: "10px",
+ round: "5px",
+ ...props,
+}))`
+ @keyframes cfShimmer {
+ to {
+ background-position-x: 0%;
+ }
+ }
+
+ background: linear-gradient(
+ -45deg,
+ ${getColor("border")} 40%,
+ ${getColor("generic")} 50%,
+ ${getColor("border")} 60%
+ );
+ background-size: 300%;
+ background-position-x: 100%;
+ animation: cfShimmer 1s infinite linear;
+`
+
+// CH components/skeleton/index.js:242 (themeSkeleton #E8ECEC / #1E2424, white spark at 12%, 4.8s)
+const chSlide = keyframes`
+ from { transform: translateX(-100%); }
+ to { transform: translateX(100%); }
+`
+
+const ChShine = styled(Box).attrs({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 })`
+ pointer-events: none;
+ background: linear-gradient(90deg, transparent, #ffffff, transparent);
+ opacity: 0.12;
+ animation: ${chSlide} 4.8s ease-in-out infinite;
+ @media (prefers-reduced-motion: reduce) {
+ display: none;
+ }
+`
+
+const ChBoneBase = styled(Box).attrs({ position: "relative", overflow: "hidden" })`
+ flex: none;
+ background: ${({ theme }) => (theme.name === "Dark" ? "#1E2424" : "#E8ECEC")};
+`
+
+export const ChBone = ({ round = 1, ...rest }) => (
+
+
+
+)
diff --git a/src/proposals/refresh/density.js b/src/proposals/refresh/density.js
new file mode 100644
index 000000000..d322e884b
--- /dev/null
+++ b/src/proposals/refresh/density.js
@@ -0,0 +1,101 @@
+// Simulations: styled wrappers that override the real Button, IconButton, SearchInput and Select
+// metrics, so the proposed ladder can be judged before any component changes.
+import React from "react"
+import styled, { css } from "styled-components"
+import Box from "@/components/templates/box"
+import { Button, IconButton } from "@/components/button"
+import Search from "@/components/search"
+import Select from "@/components/select"
+import { getSizeBy } from "@/theme"
+
+// Sizes in 8px units; text in px because the typography scale has no 13px step.
+export const ladder = {
+ compact: { height: 3, text: 12, buttonPad: 1.5, fieldInset: 1, icon: 1.75 },
+ default: { height: 3.5, text: 13, buttonPad: 1.5, fieldInset: 1.25, icon: 2 },
+ large: { height: 4, text: 14, buttonPad: 2, fieldInset: 1.5, icon: 2 },
+}
+
+const metrics = ({ density = "default" }) => ladder[density] || ladder.default
+
+const buttonMetrics = css`
+ &&& {
+ min-height: ${props => getSizeBy(metrics(props).height)};
+ height: ${props => getSizeBy(metrics(props).height)};
+ font-size: ${props => metrics(props).text}px;
+ line-height: ${getSizeBy(2)};
+ padding: 0 ${props => getSizeBy(metrics(props).buttonPad)};
+ }
+`
+
+export const DensityButton = styled(Button)`
+ ${buttonMetrics}
+`
+
+export const DensityIconButton = styled(IconButton)`
+ &&& {
+ width: ${props => getSizeBy(metrics(props).height)};
+ min-width: ${props => getSizeBy(metrics(props).height)};
+ height: ${props => getSizeBy(metrics(props).height)};
+ min-height: ${props => getSizeBy(metrics(props).height)};
+ padding: 0;
+ }
+
+ &&& .button-icon {
+ width: ${props => getSizeBy(metrics(props).icon)};
+ height: ${props => getSizeBy(metrics(props).icon)};
+ }
+`
+
+// The search icon sits in the inset; text starts after icon + 6px gap, as today.
+const SearchFrame = styled(Box)`
+ && input {
+ height: ${props => getSizeBy(metrics(props).height)};
+ font-size: ${props => metrics(props).text}px;
+ padding-left: ${props => getSizeBy(metrics(props).fieldInset + 1.75 + 0.75)};
+ padding-right: ${props => getSizeBy(metrics(props).fieldInset + 1.75)};
+ }
+
+ && input::placeholder {
+ font-size: ${props => metrics(props).text}px;
+ }
+
+ && label > div > div:first-child {
+ left: ${props => getSizeBy(metrics(props).fieldInset)};
+ }
+`
+
+export const DensitySearch = ({ density, width = 48, ...props }) => (
+
+
+
+)
+
+const prefix = "refresh-select"
+
+const SelectFrame = styled(Box)`
+ && .${prefix}__control {
+ min-height: ${props => getSizeBy(metrics(props).height)};
+ height: ${props => getSizeBy(metrics(props).height)};
+ }
+
+ && .${prefix}__value-container {
+ min-height: 0;
+ height: 100%;
+ padding: 0 ${props => getSizeBy(metrics(props).fieldInset)};
+ }
+
+ && .${prefix}__indicators-container {
+ min-height: 0;
+ height: 100%;
+ }
+
+ && .${prefix}__single-value, && .${prefix}__placeholder, && .${prefix}__input-container {
+ font-size: ${props => metrics(props).text}px;
+ }
+`
+
+export const DensitySelect = ({ density, width = 40, ...props }) => (
+
+
+
+)
diff --git a/src/proposals/refresh/layout.js b/src/proposals/refresh/layout.js
new file mode 100644
index 000000000..5bc1cc3ad
--- /dev/null
+++ b/src/proposals/refresh/layout.js
@@ -0,0 +1,45 @@
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Text, TextSmall } from "@/components/typography"
+import { getColor, getSizeBy } from "@/theme"
+
+const Column = styled(Flex).attrs({ column: true, gap: 4, flex: "1 1 0" })`
+ min-width: ${getSizeBy(50)};
+`
+
+const Heading = styled(Flex).attrs({ column: true, gap: 0.5, padding: [0, 0, 2] })`
+ border-bottom: 1px solid ${getColor("border")};
+`
+
+export const Side = ({ title, note, children }) => (
+
+
+ {title}
+ {note ? {note} : null}
+
+ {children}
+
+)
+
+export const Compare = ({ today, proposed, todayNote, proposedNote }) => (
+
+
+ {today}
+
+
+ {proposed}
+
+
+)
+
+export const Section = ({ caption, children }) => (
+
+ {caption ? {caption} : null}
+ {children}
+
+)
+
+export const Row = props =>
+
+export const Stack = props =>
diff --git a/src/proposals/refresh/pills.js b/src/proposals/refresh/pills.js
new file mode 100644
index 000000000..52b4cfdaa
--- /dev/null
+++ b/src/proposals/refresh/pills.js
@@ -0,0 +1,128 @@
+// Proposed Pill additions (soft look, leading dot, status word, mark counts), adapted from the PR's
+// StatePill / StatusWord / MarkCounts onto netdata-ui flavours and theme tokens.
+import React from "react"
+import styled, { css } from "styled-components"
+import Flex from "@/components/templates/flex"
+import Box from "@/components/templates/box"
+import { getColor, getRgbColor, getSizeBy } from "@/theme"
+
+// ink: text and dot; fill: tint behind the text; ring: 1px inset edge.
+export const tones = {
+ success: { ink: "success", fill: getColor("successSemi"), ring: getRgbColor("success", 0.35) },
+ warning: { ink: "warning", fill: getColor("warningSemi"), ring: getRgbColor("warning", 0.35) },
+ error: { ink: "error", fill: getColor("errorSemi"), ring: getRgbColor("error", 0.35) },
+ neutral: { ink: "text", fill: getColor("neutralHighlight"), ring: getColor("border") },
+ stale: { ink: "stale", fill: getRgbColor("stale", 0.14), ring: getRgbColor("stale", 0.35) },
+ muted: { ink: "textLite", fill: getColor(["transparent", "full"]), ring: getColor("border") },
+}
+
+tones.clear = tones.success
+tones.critical = tones.error
+
+const toneOf = tone => tones[tone] || tones.neutral
+
+// Heights follow the D4 pill ladder (14/18/20/24) in 8px units.
+export const sizes = {
+ tiny: { height: 1.75, pad: 0.75, gap: 0.5, text: 10, dot: 0.75 },
+ small: { height: 2.25, pad: 1, gap: 0.5, text: 11, dot: 0.75 },
+ default: { height: 2.5, pad: 1.25, gap: 0.75, text: 12, dot: 0.875 },
+ large: { height: 3, pad: 1.5, gap: 0.75, text: 13, dot: 1 },
+}
+
+const sizeOf = size => sizes[size] || sizes.default
+
+export const Dot = styled(Box).attrs({ as: "span", "aria-hidden": "true" })`
+ flex: 0 0 auto;
+ box-sizing: border-box;
+ width: ${({ dotSize = 0.875 }) => getSizeBy(dotSize)};
+ height: ${({ dotSize = 0.875 }) => getSizeBy(dotSize)};
+ border-radius: 50%;
+ ${({ tone, hollow, theme }) => {
+ const ink = getColor(toneOf(tone).ink)({ theme })
+ return hollow ? `border: 1.5px solid ${ink};` : `background: ${ink};`
+ }}
+`
+
+const soft = css`
+ background: ${({ tone, theme }) => toneOf(tone).fill({ theme })};
+ box-shadow: inset 0 0 0 1px ${({ tone, theme }) => toneOf(tone).ring({ theme })};
+`
+
+const SoftContainer = styled(Flex).attrs({ as: "span", alignItems: "center" })`
+ display: inline-flex;
+ flex: 0 0 auto;
+ box-sizing: border-box;
+ gap: ${({ pillSize }) => getSizeBy(sizeOf(pillSize).gap)};
+ height: ${({ pillSize }) => getSizeBy(sizeOf(pillSize).height)};
+ padding: 0 ${({ pillSize }) => getSizeBy(sizeOf(pillSize).pad)};
+ border-radius: 999px;
+ font-size: ${({ pillSize }) => sizeOf(pillSize).text}px;
+ font-weight: 500;
+ line-height: 1;
+ white-space: nowrap;
+ font-variant-numeric: tabular-nums;
+ color: ${({ tone, theme }) => getColor(toneOf(tone).ink)({ theme })};
+ ${soft}
+`
+
+export const SoftPill = ({ tone = "neutral", size, dot, hollowDot, children }) => (
+
+ {dot ? : null}
+ {children}
+
+)
+
+const Word = styled(Flex).attrs({ as: "span", alignItems: "center", gap: 1.5 })`
+ display: inline-flex;
+ font-size: 13px;
+ font-weight: 500;
+ white-space: nowrap;
+ color: ${({ tone, theme }) => getColor(toneOf(tone).ink)({ theme })};
+`
+
+const Detail = styled.span`
+ font-weight: 400;
+ color: ${getColor("textLite")};
+ font-variant-numeric: tabular-nums;
+`
+
+export const StatusWord = ({ tone, hollow, label, detail }) => (
+
+
+ {label}
+ {detail ? {`· ${detail}`} : null}
+
+)
+
+const Counts = styled(Flex).attrs({ as: "span", alignItems: "center", gap: 2.5 })`
+ display: inline-flex;
+ font-size: 12px;
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+`
+
+const Count = styled(Flex).attrs({ as: "span", alignItems: "center", gap: 1.25 })`
+ display: inline-flex;
+ color: ${({ tone, theme }) => getColor(toneOf(tone).ink)({ theme })};
+`
+
+const Hidden = styled.span`
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ white-space: nowrap;
+`
+
+export const MarkCounts = ({ counts }) => (
+
+ {counts.map(({ tone, hollow, count, label }) => (
+
+
+ {count}
+ {` ${label}`}
+
+ ))}
+
+)
diff --git a/src/proposals/refresh/refresh.stories.js b/src/proposals/refresh/refresh.stories.js
new file mode 100644
index 000000000..0ac96b08f
--- /dev/null
+++ b/src/proposals/refresh/refresh.stories.js
@@ -0,0 +1,433 @@
+import React, { useState } from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import Box from "@/components/templates/box"
+import { Button, IconButton, ButtonGroup } from "@/components/button"
+import Search from "@/components/search"
+import Select from "@/components/select"
+import Pill from "@/components/pill"
+import { Tabs, Tab } from "@/components/tabs"
+import { Text, TextSmall } from "@/components/typography"
+import { getColor } from "@/theme"
+import { DyncfgVars } from "../pr5951/tokens"
+import { IconAction, onRovingKeyDown } from "../pr5951/actions"
+import { Compare, Row, Section, Stack } from "./layout"
+import { DensityButton, DensityIconButton, DensitySearch, DensitySelect } from "./density"
+import { MarkCounts, SoftPill, StatusWord } from "./pills"
+import { ContainedTabs, SegmentedPicker, slotLabel } from "./tabs"
+
+export default {
+ title: "Proposals/Refresh",
+ parameters: { layout: "padded" },
+}
+
+const statusOptions = [
+ { label: "All statuses", value: "all" },
+ { label: "Critical", value: "critical" },
+ { label: "Warning", value: "warning" },
+ { label: "Clear", value: "clear" },
+]
+
+const TodayToolbar = ({ large }) => (
+
+
+
+
+
+
+
+
+
+
+
+
+)
+
+const ProposedToolbar = ({ density }) => (
+
+
+
+
+
+
+
+
+)
+
+export const ControlDensity = () => (
+
+
+
+
+ }
+ proposed={
+
+
+
+
+
+ }
+ />
+)
+
+const flavours = [
+ ["success", "Clear"],
+ ["warning", "Warning"],
+ ["error", "Critical"],
+ ["neutral", "Silenced"],
+ ["stale", "Stale"],
+]
+
+const toneLabels = [...flavours, ["muted", "Disabled"]]
+
+const PillRow = props => (
+
+ {flavours.map(([flavour, label]) => (
+
+ {label}
+
+ ))}
+
+)
+
+const SoftRow = props => (
+
+ {toneLabels.map(([tone, label]) => (
+
+ {label}
+
+ ))}
+
+)
+
+const pillSizes = [
+ ["tiny", "14px · 10px text"],
+ ["small", "18px · 11px text"],
+ ["default", "20px · 12px text"],
+ ["large", "24px · 13px text"],
+]
+
+const NodeLine = ({ children }) => (
+
+ web-prod-01
+ system.cpu
+ {children}
+
+)
+
+export const PillTones = () => (
+
+
+
+
+
+
+
+ Critical
+
+
+ Critical
+
+ Critical
+
+ Critical
+
+
+
+
+ }
+ proposed={
+
+
+
+
+
+
+ {pillSizes.map(([size, note]) => (
+
+ {`Critical ${note.split(" ")[0]}`}
+
+ ))}
+
+
+
+
+
+ }
+ />
+)
+
+const sections = [
+ { label: "Overview", value: "overview" },
+ { label: "Nodes", value: "nodes" },
+ { label: "Alerts", value: "alerts" },
+ { label: "Anomalies", value: "anomalies" },
+]
+
+const ranges = [
+ { label: "15m", value: "15m" },
+ { label: "1h", value: "1h" },
+ { label: "6h", value: "6h" },
+ { label: "24h", value: "24h" },
+ { label: "7d", value: "7d" },
+]
+
+const TodayCounter = ({ label, count, active }) => (
+
+ {label}
+
+ {count}
+
+
+)
+
+export const TabsVariants = () => {
+ const [section, setSection] = useState("nodes")
+ const [range, setRange] = useState("1h")
+ const [todayRange, setTodayRange] = useState("1h")
+
+ return (
+
+
+
+ {sections.map(({ label }) => (
+
+ ))}
+
+
+
+
+ }
+ />
+ }
+ />
+ (
+
+ )}
+ />
+
+
+
+
+ }
+ proposed={
+
+
+
+
+
+
+ }
+ />
+ )
+}
+
+const toolbarActions = [
+ { icon: "refresh", label: "Refresh alerts" },
+ { icon: "filter", label: "Filter by node" },
+ { icon: "download", label: "Export alerts" },
+ { icon: "gear", label: "Alert settings" },
+]
+
+const RovingToolbar = () => {
+ const [focused, setFocused] = useState(0)
+ return (
+
+ {toolbarActions.map(({ icon, label }, index) => (
+
+ onRovingKeyDown({ event, index, count: toolbarActions.length, onMove: setFocused })
+ }
+ />
+ ))}
+
+ )
+}
+
+// Dashed frame marks the hit area, since both buttons are borderless at rest.
+const Bounds = styled(Flex)`
+ display: inline-flex;
+ outline: 1px dashed ${getColor("border")};
+`
+
+const Labeled = ({ note, children }) => (
+
+ {children}
+ {note}
+
+)
+
+export const IconButtonVsIconAction = () => (
+ <>
+
+
+
+
+
+
+
+
+ none
+ 28: not available
+
+
+
+
+
+
+
+
+
+ {toolbarActions.map(({ icon, label }) => (
+
+ ))}
+
+
+
+ }
+ proposed={
+
+
+
+ {[24, 28, 32].map(size => (
+
+
+
+ ))}
+
+
+
+
+
+
+
+
+ }
+ />
+ >
+)
diff --git a/src/proposals/refresh/tabs.js b/src/proposals/refresh/tabs.js
new file mode 100644
index 000000000..9919e7634
--- /dev/null
+++ b/src/proposals/refresh/tabs.js
@@ -0,0 +1,125 @@
+// Proposed contained track: one visual for contained tabs and segmented value pickers
+// (after the PR's TabStrip and Segmented), plus icon/count slots for our line tabs.
+import React from "react"
+import styled from "styled-components"
+import Flex from "@/components/templates/flex"
+import { Icon } from "@/components/icon"
+import { getColor, getRgbColor, getSizeBy } from "@/theme"
+import { focusRingOutline } from "@/mixins/focusRing"
+import { Dot } from "./pills"
+
+// Track 4px radius (control), raised item 2px (inner chip); 3px track padding.
+const Track = styled(Flex).attrs({ alignItems: "center" })`
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-self: flex-start;
+ gap: ${getSizeBy(0.25)};
+ padding: ${getSizeBy(0.375)};
+ border-radius: ${getSizeBy(0.5)};
+ border: 1px solid ${getColor("borderSecondary")};
+ background: ${getRgbColor("textLite", 0.12)};
+`
+
+const trackHeights = { small: 2.25, default: 2.75 }
+
+const Item = styled(Flex).attrs({ as: "button", type: "button" })`
+ all: unset;
+ box-sizing: border-box;
+ display: inline-flex;
+ gap: ${getSizeBy(0.75)};
+ align-items: center;
+ height: ${({ trackSize }) => getSizeBy(trackHeights[trackSize] || trackHeights.default)};
+ padding: 0 ${getSizeBy(1.25)};
+ border-radius: ${getSizeBy(0.25)};
+ font-size: ${({ trackSize }) => (trackSize === "small" ? 12 : 13)}px;
+ font-weight: ${({ active }) => (active ? 600 : 500)};
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+ cursor: pointer;
+ color: ${({ active }) => getColor(active ? "textFocus" : "textLite")};
+ background: ${({ active }) => getColor(active ? "dropdown" : ["transparent", "full"])};
+ box-shadow: ${({ active, theme }) =>
+ active ? `inset 0 0 0 1px ${getColor("border")({ theme })}` : "none"};
+ transition:
+ color 120ms ease-out,
+ background 120ms ease-out;
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+
+ &:hover {
+ color: ${getColor("textFocus")};
+ }
+
+ &:focus-visible {
+ ${focusRingOutline}
+ }
+
+ svg {
+ fill: currentColor;
+ }
+`
+
+const TrackList = ({ role, itemRole, items, value, onChange, size, label }) => (
+
+)
+
+export const ContainedTabs = props =>
+
+export const SegmentedPicker = props =>
+
+export const Count = styled.span`
+ font-size: 12px;
+ font-weight: 500;
+ font-variant-numeric: tabular-nums;
+ color: ${getColor("textLite")};
+`
+
+const Label = styled(Flex).attrs({ as: "span", alignItems: "center", gap: 1.5 })`
+ font-size: 13px;
+ font-weight: ${({ active }) => (active ? 600 : 500)};
+ color: ${({ active }) => getColor(active ? "textFocus" : "text")};
+
+ svg {
+ fill: ${({ active }) => getColor(active ? "textFocus" : "textLite")};
+ }
+`
+
+// A label render-prop for the real Tab: icon, text, muted count, optional "of N" and status tick.
+export const slotLabel =
+ ({ icon, label, count, of, tick }) =>
+ ({ active }) => (
+
+ )
diff --git a/src/proposals/tableActions/chip.js b/src/proposals/tableActions/chip.js
new file mode 100644
index 000000000..ce8f22909
--- /dev/null
+++ b/src/proposals/tableActions/chip.js
@@ -0,0 +1,130 @@
+// Proposal-only chip action for table rows and toolbars. Not wired into src/components.
+import React from "react"
+import styled, { css } from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import Tooltip from "@/components/drops/tooltip"
+import { Icon } from "@/components/icon"
+import { focusRing } from "@/mixins/focusRing"
+import { getColor, getRgbColor, getSizeBy } from "@/theme"
+
+const chipStylesByTone = {
+ neutral: {
+ rest: css`
+ color: ${getColor("textLite")};
+ background-color: transparent;
+ border-color: ${getColor("border")};
+ `,
+ hover: css`
+ color: ${getColor("primary")};
+ background-color: ${getRgbColor("primary", 0.1)};
+ border-color: ${getRgbColor("primary", 0.5)};
+ `,
+ },
+ ai: {
+ rest: css`
+ color: ${getColor("primaryAI")};
+ background-color: ${getRgbColor("primaryAI", 0.08)};
+ border-color: ${getRgbColor("primaryAI", 0.35)};
+ `,
+ hover: css`
+ color: ${getColor("primaryAI")};
+ background-color: ${getRgbColor("primaryAI", 0.16)};
+ border-color: ${getRgbColor("primaryAI", 0.7)};
+ `,
+ },
+ quiet: {
+ rest: css`
+ color: ${getColor("textLite")};
+ background-color: transparent;
+ border-color: transparent;
+ `,
+ hover: css`
+ color: ${getColor("primary")};
+ background-color: ${getRgbColor("primary", 0.1)};
+ border-color: ${getRgbColor("primary", 0.5)};
+ `,
+ },
+}
+
+const chipRadiusByShape = {
+ circle: "50%",
+ square: getSizeBy(0.75),
+}
+
+const chipSizeByDensity = {
+ default: getSizeBy(3.5),
+ compact: getSizeBy(3),
+}
+
+const ChipButton = styled(Box).attrs({ as: "button", type: "button" })`
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex: 0 0 auto;
+ margin: 0;
+ padding: 0;
+ width: ${({ density }) => chipSizeByDensity[density]};
+ height: ${({ density }) => chipSizeByDensity[density]};
+ border-width: 1px;
+ border-style: solid;
+ border-radius: ${({ shape }) => chipRadiusByShape[shape]};
+ font: inherit;
+ cursor: pointer;
+ transition:
+ color 140ms ease-out,
+ background-color 140ms ease-out,
+ border-color 140ms ease-out;
+
+ svg {
+ fill: currentColor;
+ }
+
+ ${({ tone }) => chipStylesByTone[tone].rest}
+ ${({ tone, preview }) => preview === "hover" && chipStylesByTone[tone].hover}
+
+ &:hover:not(:disabled) {
+ ${({ tone }) => chipStylesByTone[tone].hover}
+ }
+
+ ${focusRing}
+
+ &:disabled {
+ opacity: 0.4;
+ cursor: not-allowed;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`
+
+export const ActionChip = ({
+ icon,
+ label,
+ tone = "neutral",
+ shape = "circle",
+ density = "default",
+ preview,
+ ref,
+ ...rest
+}) => (
+
+
+
+
+
+)
+
+export const ChipCluster = props => (
+ e.stopPropagation()} {...props} />
+)
diff --git a/src/proposals/tableActions/fanStack.js b/src/proposals/tableActions/fanStack.js
new file mode 100644
index 000000000..54a69965b
--- /dev/null
+++ b/src/proposals/tableActions/fanStack.js
@@ -0,0 +1,130 @@
+// Proposal-only "more actions" trigger: the topbar Add new chip stack, reused as a row overflow.
+import React from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import Menu from "@/components/drops/menu"
+import { Icon } from "@/components/icon"
+import { TextSmall } from "@/components/typography"
+import { focusRingOutline } from "@/mixins/focusRing"
+import { getColor, getRgbColor, getSizeBy } from "@/theme"
+
+const fanEasing = "200ms cubic-bezier(0.2, 0.8, 0.2, 1)"
+
+const Trigger = styled(Box).attrs({ as: "button", type: "button" })`
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ gap: ${getSizeBy(0.75)};
+ height: ${getSizeBy(3.5)};
+ margin: 0;
+ padding: 0 ${getSizeBy(1)} 0 ${getSizeBy(0.5)};
+ border: 1px solid ${getColor("border")};
+ border-radius: ${getSizeBy(1.75)};
+ background-color: transparent;
+ color: ${getColor("textLite")};
+ font: inherit;
+ cursor: pointer;
+ transition:
+ background-color 140ms ease-out,
+ border-color 140ms ease-out,
+ color 140ms ease-out;
+
+ &:hover,
+ &[aria-expanded="true"] {
+ color: ${getColor("primary")};
+ background-color: ${getRgbColor("primary", 0.1)};
+ border-color: ${getRgbColor("primary", 0.5)};
+ }
+
+ &:focus {
+ outline: none;
+ }
+
+ &:focus-visible {
+ color: ${getColor("primary")};
+ ${focusRingOutline}
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`
+
+const fanSpread = 4
+const fanTilt = 6
+
+const StackChip = styled(Flex).attrs({ alignItems: "center", justifyContent: "center" })`
+ box-sizing: border-box;
+ width: ${getSizeBy(2.5)};
+ height: ${getSizeBy(2.5)};
+ border-radius: ${getSizeBy(1.25)};
+ border: 1px solid ${getRgbColor("primary", 0.55)};
+ background-color: ${getColor("mainBackground")};
+ color: ${getColor("textLite")};
+ transition:
+ transform ${fanEasing},
+ color 140ms ease-out;
+
+ & + & {
+ margin-left: -${getSizeBy(0.5)};
+ }
+
+ svg {
+ fill: currentColor;
+ }
+
+ ${Trigger}:hover &,
+ ${Trigger}:focus-visible &,
+ ${Trigger}[aria-expanded="true"] & {
+ color: ${getColor("primary")};
+ transform: ${({ index, count }) =>
+ `translateX(${index * fanSpread}px) rotate(${(index - (count - 1) / 2) * fanTilt}deg)`};
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+
+ ${Trigger}:hover &,
+ ${Trigger}:focus-visible &,
+ ${Trigger}[aria-expanded="true"] & {
+ transform: none;
+ }
+ }
+`
+
+const maxStackedChips = 3
+
+const FanTrigger = ({ actions, ref, ...rest }) => {
+ const stacked = actions.slice(0, maxStackedChips)
+
+ return (
+
+
+ {stacked.map(({ id, icon }, index) => (
+
+
+
+ ))}
+
+
+ +{actions.length}
+
+
+ )
+}
+
+export const OverflowActions = ({ actions }) => (
+
+)
diff --git a/src/proposals/tableActions/scenes.js b/src/proposals/tableActions/scenes.js
new file mode 100644
index 000000000..cc883e750
--- /dev/null
+++ b/src/proposals/tableActions/scenes.js
@@ -0,0 +1,285 @@
+// Story scenes: today's real Table + Action next to proposal-only chip renderings of the same rows.
+import React, { useState } from "react"
+import styled from "styled-components"
+import Box from "@/components/templates/box"
+import Flex from "@/components/templates/flex"
+import { Table } from "@/components/table"
+import { Text, TextSmall } from "@/components/typography"
+import { Row, Section, Stack } from "../refresh/layout"
+import { ActionChip, ChipCluster } from "./chip"
+import { ActionTrack } from "./track"
+import { OverflowActions } from "./fanStack"
+
+const noop = () => {}
+
+const alerts = [
+ { id: "a1", name: "disk_space_usage", node: "db-primary-01", value: "96.2%" },
+ { id: "a2", name: "10min_cpu_usage", node: "web-03", value: "84.1%" },
+ { id: "a3", name: "ram_in_use", node: "cache-02", value: "81.7%", locked: true },
+ { id: "a4", name: "net_packet_drops", node: "edge-gw-1", value: "1.2k/s" },
+]
+
+const getRowId = row => row.id
+
+const dataColumns = [
+ { id: "name", accessorKey: "name", header: "Alert", cell: ({ getValue }) => getValue() },
+ { id: "node", accessorKey: "node", header: "Node", cell: ({ getValue }) => getValue() },
+ {
+ id: "value",
+ accessorKey: "value",
+ header: "Value",
+ size: 90,
+ cell: ({ getValue }) => getValue(),
+ },
+]
+
+const rowActionDefs = [
+ { id: "acknowledge", icon: "checkmark_s", label: "Acknowledge and hide" },
+ { id: "edit", icon: "pencilOutline", label: "Edit this alert configuration" },
+ { id: "silence", icon: "alarm_off", label: "Add new silencing rule" },
+ {
+ id: "mark",
+ icon: "palette",
+ label: "Mark this alert",
+ isDisabled: row => !!row.locked,
+ },
+ { id: "troubleshoot", icon: "ai", label: "Ask AI to troubleshoot this alert", tone: "ai" },
+ {
+ id: "conversation",
+ icon: "conversationSubject",
+ label: "Add to an AI conversation",
+ tone: "ai",
+ },
+]
+
+const bulkActionDefs = [
+ { id: "acknowledge", icon: "checkmark_s", label: "Acknowledge selected" },
+ { id: "mark", icon: "palette", label: "Mark selected" },
+ { id: "download", icon: "download", label: "Download as CSV", alwaysEnabled: true },
+ { id: "columns", icon: "columns", label: "Columns", alwaysEnabled: true },
+]
+
+const todayRowActions = Object.fromEntries(
+ rowActionDefs.map(({ id, icon, label, tone, isDisabled }) => [
+ id,
+ {
+ icon,
+ tooltipText: label,
+ confirmation: false,
+ handleAction: noop,
+ isDisabled,
+ ...(tone === "ai" ? { iconColor: "primaryAI" } : {}),
+ },
+ ])
+)
+
+const todayBulkActions = Object.fromEntries(
+ bulkActionDefs
+ .filter(({ id }) => id !== "columns")
+ .map(({ id, icon, label, alwaysEnabled }) => [
+ id,
+ { icon, tooltipText: label, confirmation: false, handleAction: noop, alwaysEnabled },
+ ])
+)
+
+const TableFrame = props =>
+
+const chipActionsColumn = ({ renderCell, size }) => ({
+ id: "actions",
+ header: "Actions",
+ headerString: "Actions",
+ cell: ({ row }) => renderCell(row.original),
+ enableColumnFilter: false,
+ enableSorting: false,
+ enableResizing: false,
+ enableReordering: false,
+ size,
+ align: "end",
+ notFlex: true,
+ meta: { cellStyles: { justifyContent: "end" } },
+})
+
+const clusterWidth = count => count * 28 + (count - 1) * 4 + 32
+
+const renderChips = (row, actions, shape) =>
+ actions.map(({ id, isDisabled, ...action }) => (
+
+ ))
+
+const ProposedTable = ({ renderCell, size, ...rest }) => (
+
+
+
+)
+
+export const TodayRowActions = () => (
+
+
+
+)
+
+const ChipStates = ({ shape }) => (
+
+
+
+
+
+
+ rest · hover · disabled · AI rest · AI hover
+
+)
+
+export const ProposedRowActions = () => (
+
+
+
+ {renderChips(row, rowActionDefs, "circle")}}
+ />
+
+
+
+ {renderChips(row, rowActionDefs, "square")}}
+ />
+
+
+)
+
+const rowSelector = '[data-testid^="netdata-table-row"]'
+
+const Reveal = styled(Flex).attrs({ gap: 0.5, alignItems: "center" })`
+ opacity: 0;
+ transition: opacity 120ms ease-out;
+
+ ${rowSelector}:hover &,
+ ${rowSelector}:focus-within &,
+ &:focus-within {
+ opacity: 1;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`
+
+const [primaryRowAction, ...secondaryRowActions] = rowActionDefs
+
+export const ProposedRevealRowActions = () => (
+
+
+ (
+
+ {renderChips(row, secondaryRowActions, "circle")}
+ {renderChips(row, [primaryRowAction], "circle")}
+
+ )}
+ />
+
+
+)
+
+export const TodayBulkActions = () => (
+
+
+
+)
+
+export const ProposedBulkActions = () => {
+ const [selected, setSelected] = useState([])
+
+ return (
+
+
+
+
+ Active alerts
+
+
+ (
+ {renderChips(row, rowActionDefs, "circle")}
+ )}
+ />
+
+
+
+
+ )
+}
+
+const overflowOrder = ["acknowledge", "edit", "troubleshoot", "silence", "mark", "conversation"]
+const prioritisedRowActions = overflowOrder.map(id => rowActionDefs.find(a => a.id === id))
+const maxVisibleRowActions = 3
+const overflowThreshold = 4
+
+const OverflowCell = ({ row }) => {
+ const needsOverflow = prioritisedRowActions.length > overflowThreshold
+ const visible = needsOverflow
+ ? prioritisedRowActions.slice(0, maxVisibleRowActions)
+ : prioritisedRowActions
+ const hidden = needsOverflow ? prioritisedRowActions.slice(maxVisibleRowActions) : []
+
+ return (
+
+ {renderChips(row, visible, "circle")}
+ {hidden.length ? (
+ ({
+ ...action,
+ onClick: noop,
+ disabled: isDisabled ? isDisabled(row) : false,
+ }))}
+ />
+ ) : null}
+
+ )
+}
+
+export const ProposedOverflowRowActions = () => (
+
+
+
+)
diff --git a/src/proposals/tableActions/tableActions.stories.js b/src/proposals/tableActions/tableActions.stories.js
new file mode 100644
index 000000000..cbf1e4b2f
--- /dev/null
+++ b/src/proposals/tableActions/tableActions.stories.js
@@ -0,0 +1,51 @@
+import React from "react"
+import { Compare } from "../refresh/layout"
+import {
+ ProposedBulkActions,
+ ProposedOverflowRowActions,
+ ProposedRevealRowActions,
+ ProposedRowActions,
+ TodayBulkActions,
+ TodayRowActions,
+} from "./scenes"
+
+export default {
+ title: "Proposals/Table actions",
+ parameters: { layout: "padded" },
+}
+
+export const RowActions = () => (
+ }
+ proposed={}
+ />
+)
+
+export const RowActionsOnHover = () => (
+ }
+ proposed={}
+ />
+)
+
+export const HeaderAndBulkActions = () => (
+ }
+ proposed={}
+ />
+)
+
+export const GroupedLikeAddNew = () => (
+ }
+ proposed={}
+ />
+)
diff --git a/src/proposals/tableActions/track.js b/src/proposals/tableActions/track.js
new file mode 100644
index 000000000..28126a88e
--- /dev/null
+++ b/src/proposals/tableActions/track.js
@@ -0,0 +1,67 @@
+// Proposal-only pill track that groups header and bulk chips, after the topbar trigger.
+import React from "react"
+import styled, { css } from "styled-components"
+import Flex from "@/components/templates/flex"
+import Box from "@/components/templates/box"
+import { TextSmall } from "@/components/typography"
+import { getColor, getRgbColor, getSizeBy } from "@/theme"
+import { ActionChip } from "./chip"
+
+const trackStylesBySelection = {
+ idle: css`
+ background-color: ${getRgbColor("textLite", 0.06)};
+ border-color: ${getColor("borderSecondary")};
+ `,
+ active: css`
+ background-color: ${getRgbColor("primary", 0.06)};
+ border-color: ${getRgbColor("primary", 0.5)};
+ `,
+}
+
+const Track = styled(Flex).attrs({ alignItems: "center", gap: 0.25, role: "toolbar" })`
+ box-sizing: border-box;
+ height: ${getSizeBy(3.5)};
+ padding: 1px;
+ border-width: 1px;
+ border-style: solid;
+ border-radius: ${getSizeBy(1.75)};
+ transition:
+ background-color 140ms ease-out,
+ border-color 140ms ease-out;
+ ${({ selection }) => trackStylesBySelection[selection]}
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`
+
+const TrackDivider = styled(Box)`
+ width: 1px;
+ height: ${getSizeBy(2)};
+ margin: 0 ${getSizeBy(0.5)};
+ background-color: ${getRgbColor("primary", 0.5)};
+`
+
+const SelectionCount = ({ count }) => (
+
+
+ {count} selected
+
+
+
+)
+
+export const ActionTrack = ({ actions, selectedCount = 0, label = "Table actions" }) => (
+
+)
diff --git a/src/stories.test.js b/src/stories.test.js
index fcc199205..1554f5874 100644
--- a/src/stories.test.js
+++ b/src/stories.test.js
@@ -1,3 +1,4 @@
+import React from "react"
import fs from "fs"
import path from "path"
import { composeStories, setProjectAnnotations } from "@storybook/react"
diff --git a/src/theme/dark/colors.js b/src/theme/dark/colors.js
index bf783ba55..24b5eaf58 100644
--- a/src/theme/dark/colors.js
+++ b/src/theme/dark/colors.js
@@ -1,25 +1,35 @@
import rawColors from "../rawColors"
+const tableRowHover = "#29352D"
+
const appColors = {
primary: rawColors.green.green100,
accent: rawColors.green.chateau,
- main: rawColors.neutral.white,
- border: rawColors.neutral.grey45,
- borderSecondary: rawColors.neutral.grey35,
+ main: "#D5DDD7",
+ border: "#48584D",
+ borderSecondary: "#344239",
+ appSidebarBackground: "#1B231E",
+ appBackground: "#171D19",
+ workspaceSidebarBackground: "#202723",
+ workspaceBackground: "#171D19",
+ tableBorder: "#344239",
+ tableHeaderBackground: "#171D19",
disabled: rawColors.neutral.grey100,
- disabledBackground: rawColors.neutral.grey100,
- dropdown: rawColors.neutral.grey30,
+ disabledBackground: "#29312C",
+ dropdown: "#252D28",
dropdownShadow: rawColors.shadows.dropdownDark,
- elementBackground: rawColors.neutral.grey35,
- elementBackgroundHover: rawColors.neutral.tuna,
- mainBackground: rawColors.neutral.grey15,
- mainBackgroundDisabled: rawColors.neutral.outerSpace,
- modalHeaderBackground: rawColors.neutral.grey30,
- modalTabsBackground: rawColors.neutral.grey20,
- modalBackground: rawColors.neutral.grey30,
- modalInfoBackground: rawColors.neutral.grey50,
- menuItemSelected: rawColors.neutral.grey30,
- menuItemHover: rawColors.neutral.grey40,
+ elementBackground: "#29312C",
+ elementBackgroundHover: "#202723",
+ mainBackground: "#171D19",
+ mainBackgroundDisabled: "#202723",
+ modalHeaderBackground: "#29312C",
+ modalTabsBackground: "#29312C",
+ modalBackground: "#252D28",
+ modalInfoBackground: "#29312C",
+ menuItemHover: "#2C382F",
+ menuItemSelected: "#354439",
+ menuItemSelectedHover: "#3C4B40",
+ menuItemSelectedText: "#A4E3B2",
tabActiveBackground: rawColors.green.green30,
tabItem: rawColors.neutral.grey155,
scrollBarTrack: rawColors.neutral.grey25,
@@ -36,7 +46,30 @@ const appColors = {
primaryPressed: rawColors.green.green90,
secondaryColor: rawColors.green.green110,
secondaryHighlight: rawColors.green.green40,
- neutralHighlight: rawColors.neutral.grey50,
+ neutralHighlight: "#2C342F",
+ segmentedBackground: "#29312C",
+ segmentedSelectedBackground: "rgba(255,255,255,0.11)",
+ segmentedFocus: rawColors.green.green110,
+ segmentedAccentText: "#B0C5B5",
+ segmentedAccentBackground: "#2C342F",
+ segmentedBorder: "#1E2420",
+ controlBackground: "#222B25",
+ controlHoverBackground: "#2B352E",
+ controlPressedBackground: "#303B33",
+ controlText: "#BAC6BE",
+ controlHoverText: "#BAC6BE",
+ controlPressedText: "#BAC6BE",
+ buttonNeutralFill: "#B0C5B5",
+ buttonNeutralFillHover: "#C2CAC4",
+ buttonNeutralFillPressed: "#CBD1CD",
+ buttonNeutralText: "#171D19",
+ buttonNeutralBorder: "#728077",
+ buttonNeutralBorderHover: "#98A69D",
+ buttonNeutralHollowHover: "#2A332D",
+ buttonNeutralHollowPressed: "#344038",
+ buttonNeutralBorderlessHover: "#242D27",
+ buttonNeutralBorderlessPressed: "#2C362F",
+ actionContrastText: "#171D19",
// Buttons - AI
primaryAI: rawColors.blue.blue130,
accentAI: rawColors.blue.blue150,
@@ -60,6 +93,11 @@ const appColors = {
errorSoftText: rawColors.red.red120,
staleSoftText: rawColors.neutral.grey150,
+ statusSuccessText: "#1fc463",
+ statusErrorText: "#ff6b7a",
+ statusWarningText: "#f5b638",
+ statusMutedText: "#98A69D",
+
warning: rawColors.yellow.yellow60,
warningLite: rawColors.yellow.yellow190,
warningSemi: rawColors.yellow.yellow20,
@@ -88,41 +126,46 @@ const appColors = {
attention: rawColors.purple.mauve,
attentionSecondary: rawColors.purple.daisy,
- separator: rawColors.neutral.grey35,
- controlFocused: rawColors.neutral.white,
- selected: rawColors.neutral.grey55,
- highlight: rawColors.neutral.grey55,
- tooltip: rawColors.neutral.grey55,
- tooltipText: rawColors.neutral.grey185,
- tooltipBg: rawColors.neutral.grey55,
+ separator: "#344239",
+ controlFocused: "#B0C5B5",
+ selected: "#2C342F",
+ highlight: "#98A69D",
+ tooltip: "#344239",
+ tooltipText: "#F0F4F1",
+ tooltipBg: "#344239",
bright: rawColors.neutral.white,
- text: rawColors.neutral.grey150,
- textLite: rawColors.neutral.grey120,
- textNoFocus: rawColors.neutral.grey105,
- textFocus: rawColors.neutral.grey160,
- textDescription: rawColors.neutral.grey120,
- sectionHeaderBackground: rawColors.neutral.white,
- sectionTitle: rawColors.neutral.grey155,
- sectionDescription: rawColors.neutral.grey150,
- menuItem: rawColors.neutral.grey140,
- placeholder: rawColors.neutral.grey125,
- key: rawColors.neutral.iron,
- panel: rawColors.neutral.limedSpruce,
- panelBg: rawColors.neutral.grey25,
- panelBgGrad: `linear-gradient(to right, ${rawColors.neutral.grey25} 0%, ${rawColors.neutral.grey15} 50%, ${rawColors.neutral.grey25} 100%)`,
- mainChartBg: rawColors.neutral.grey25,
- mainChartHeaderBg: rawColors.neutral.grey35,
- mainChartBorder: rawColors.neutral.grey25,
- mainChartTboxHover: rawColors.neutral.grey50,
- sideBar: rawColors.neutral.grey25,
- sideBarMini: rawColors.neutral.grey05,
+ onColorDark: rawColors.neutral.black,
+ onColorLight: rawColors.neutral.white,
+ text: "#D5DDD7",
+ textLite: "#98A69D",
+ textNoFocus: "#98A69D",
+ textFocus: "#BAC6BE",
+ textDescription: "#98A69D",
+ sectionHeaderBackground: "#202723",
+ sectionTitle: "#D5DDD7",
+ sectionDescription: "#98A69D",
+ menuItem: "#98A69D",
+ placeholder: "#98A69D",
+ key: "#98A69D",
+ panel: "#202723",
+ cardBackground: "#202723",
+ cardNestedBackground: "#29312C",
+ popoverBackground: "#303A33",
+ panelBg: "#202723",
+ panelBgGrad: `linear-gradient(to right, #202723 0%, #171D19 50%, #202723 100%)`,
+ mainChartBg: "#202723",
+ mainChartHeaderBg: "#29312C",
+ mainChartBorder: "#344239",
+ mainChartTboxHover: "#2C342F",
+ sideBar: "#1B231E",
+ sideBarMini: "#1B231E",
spaceSelected: rawColors.neutral.grey85,
spaceIdle: rawColors.neutral.grey50,
spaceHovered: rawColors.neutral.grey65,
hoverHighlight: rawColors.green.green195,
- topBarBg: rawColors.neutral.grey35,
- elevationLevelOne: rawColors.neutral.grey60,
+ topBarBg: "#1B231E",
+ elevationLevelOne: "#29312C",
// Date picker
datePickerPausedBg: rawColors.neutral.grey35,
datePickerPlayBg: rawColors.green.green20,
@@ -130,21 +173,49 @@ const appColors = {
dateTimePickerChipAccent: rawColors.violet.violet120,
// Input colors
// Resting edge for fields: 3:1 against the page so the field is findable without hover.
- controlBorder: rawColors.neutral.grey120,
+ controlBorder: "#98A69D",
textInfo: rawColors.blue.blue150,
- inputBg: rawColors.neutral.grey55,
- inputBorder: rawColors.neutral.grey85,
- inputBorderHover: rawColors.neutral.grey100,
- inputBorderFocus: rawColors.neutral.grey100,
+ inputBg: "#222B25",
+ inputBorder: "#98A69D",
+ inputBorderHover: "#B0C5B5",
+ inputBorderFocus: "#B0C5B5",
// Badges
- nodeBadgeBackground: rawColors.neutral.grey90,
- nodeBadgeBorder: rawColors.neutral.bluebayoux,
- nodeBadgeColor: rawColors.neutral.white,
+ nodeBadgeBackground: "#2C342F",
+ nodeBadgeBorder: "#2C342F",
+ nodeBadgeColor: "#B0C5B5",
// Default pills
- neutralPillBg: rawColors.neutral.grey90,
- neutralPillBorder: rawColors.neutral.grey90,
- neutralPillColor: rawColors.neutral.grey120,
+ neutralPillBg: "#2C342F",
+ neutralPillBorder: "#2C342F",
+ neutralPillColor: "#B0C5B5",
+
+ labelTokenBackground: "#24393b",
+ labelTokenBorder: "#3f5a5b",
+ labelTokenText: "#a8d5d7",
+ patternTokenBackground: "#163a3c",
+ patternTokenBorder: "#2c6468",
+ patternTokenText: "#a8e1dc",
+ patternTokenMark: "#62d6ce",
+ negatedTokenBackground: "#30284b",
+ negatedTokenBorder: "#58498a",
+ negatedTokenText: "#d6c9fc",
+ negatedTokenMark: "#b6a0f8",
+
+ syntaxKey: "#93c9cb",
+ syntaxNumber: "#d79bf2",
+ syntaxParen1: "#f38bc0",
+ syntaxParen2: "#c8c86b",
+ syntaxParen3: "#a8b4dc",
+ linkedContentBackground: "#22393a",
+ errorContentBackground: "#3a1d22",
+ thresholdWarningText: "#1f1300",
+ thresholdCriticalText: "#ffdfe3",
+ chartSeries1: "#93c9cb",
+ chartSeries2: "#a58be0",
+ chartSeries3: "#b4c0cc",
+ chartSeries4: "#d58fb0",
+ chartWarningLine: "#bf7100",
+ chartMutedLine: "#4d5c5c",
// Alert MasterCard
alertIcon: rawColors.neutral.grey50,
@@ -153,14 +224,14 @@ const appColors = {
idleClear: rawColors.green.green20,
// Table
- tableRowBgHover: rawColors.neutral.grey30,
+ tableRowBgHover: tableRowHover,
tableRowBg: rawColors.neutral.grey25,
tableRowBg2: rawColors.neutral.grey25,
- tableRowBg2Hover: rawColors.neutral.grey25,
+ tableRowBg2Hover: tableRowHover,
columnHighlight: rawColors.neutral.grey35,
// Progress Bare
- progressBg: rawColors.neutral.bluebayoux,
+ progressBg: "#3D4A40",
// IconButton
iconColor: rawColors.neutral.grey160,
diff --git a/src/theme/dark/constants.js b/src/theme/dark/constants.js
new file mode 100644
index 000000000..7020aba70
--- /dev/null
+++ b/src/theme/dark/constants.js
@@ -0,0 +1,3 @@
+export * from "../default/constants"
+
+export const PILL_SUBTLE_TINT = "13%"
diff --git a/src/theme/dark/index.js b/src/theme/dark/index.js
index d5e9825eb..6cdf23791 100644
--- a/src/theme/dark/index.js
+++ b/src/theme/dark/index.js
@@ -1,5 +1,5 @@
import colors from "./colors"
-import * as constants from "../default/constants"
+import * as constants from "./constants"
const root = {
name: "Dark",
@@ -10,4 +10,8 @@ export const DarkTheme = {
...root,
constants,
colors,
+ shadows: {
+ segmentedSelected: "none",
+ segmentedAccentSelected: `inset 0 0 0 1px color-mix(in srgb, ${colors.segmentedAccentText} 30%, transparent)`,
+ },
}
diff --git a/src/theme/default/colors.js b/src/theme/default/colors.js
index 3afd36f6c..4be9d2cb2 100644
--- a/src/theme/default/colors.js
+++ b/src/theme/default/colors.js
@@ -3,23 +3,31 @@ import rawColors from "../rawColors"
const appColors = {
primary: rawColors.green.green70,
accent: rawColors.green.chateau,
- main: rawColors.neutral.limedSpruce,
- border: rawColors.neutral.grey180,
- borderSecondary: rawColors.neutral.grey175,
+ main: "#2D3E33",
+ border: "#C5D0C8",
+ borderSecondary: "#DEE6E0",
+ appSidebarBackground: "#F4F6F4",
+ appBackground: "#FFFFFF",
+ workspaceSidebarBackground: "#F2F5F2",
+ workspaceBackground: "#FFFFFF",
+ tableBorder: "#DEE6E0",
+ tableHeaderBackground: "#F6F8F6",
disabled: rawColors.neutral.grey160,
- disabledBackground: rawColors.neutral.grey160,
- dropdown: rawColors.neutral.white,
+ disabledBackground: "#EEF3EF",
+ dropdown: "#FFFFFF",
dropdownShadow: rawColors.shadows.dropdownLight,
- elementBackground: rawColors.neutral.grey195,
+ elementBackground: "#EEF3EF",
elementBackgroundHover: rawColors.neutral.white,
- mainBackground: rawColors.neutral.white,
- mainBackgroundDisabled: rawColors.neutral.grey195,
- modalHeaderBackground: rawColors.neutral.grey185,
- modalTabsBackground: rawColors.neutral.grey190,
- modalBackground: rawColors.neutral.grey195,
- modalInfoBackground: rawColors.neutral.grey195,
- menuItemSelected: rawColors.neutral.grey180,
- menuItemHover: rawColors.neutral.grey185,
+ mainBackground: "#F6F8F6",
+ mainBackgroundDisabled: "#EEF3EF",
+ modalHeaderBackground: "#EEF3EF",
+ modalTabsBackground: "#EEF3EF",
+ modalBackground: "#FFFFFF",
+ modalInfoBackground: "#EEF3EF",
+ menuItemHover: "#DEE7E0",
+ menuItemSelected: "#CFDED3",
+ menuItemSelectedHover: "#C0D4C6",
+ menuItemSelectedText: "#005E29",
tabActiveBackground: rawColors.transparent.full,
tabItem: rawColors.neutral.grey100,
scrollBarTrack: rawColors.neutral.grey190,
@@ -35,7 +43,30 @@ const appColors = {
primaryPressed: rawColors.green.green50,
secondaryColor: rawColors.green.green70,
secondaryHighlight: rawColors.green.green190,
- neutralHighlight: rawColors.neutral.grey180,
+ neutralHighlight: "#E0E7E2",
+ segmentedBackground: "#F0F3F0",
+ segmentedSelectedBackground: "#E0E7E2",
+ segmentedFocus: rawColors.green.green70,
+ segmentedAccentText: "#476453",
+ segmentedAccentBackground: "#E0E7E2",
+ segmentedBorder: "#D3DBD5",
+ controlBackground: "#EEF3EF",
+ controlHoverBackground: "#E8EFEA",
+ controlPressedBackground: "#E3ECE5",
+ controlText: "#4D5C52",
+ controlHoverText: "#4D5C52",
+ controlPressedText: "#4D5C52",
+ buttonNeutralFill: "#476453",
+ buttonNeutralFillHover: "#3C5746",
+ buttonNeutralFillPressed: "#334C3D",
+ buttonNeutralText: "#FFFFFF",
+ buttonNeutralBorder: "#718073",
+ buttonNeutralBorderHover: "#5C6A61",
+ buttonNeutralHollowHover: "#E6EEE8",
+ buttonNeutralHollowPressed: "#D9E4DC",
+ buttonNeutralBorderlessHover: "#EAF1EB",
+ buttonNeutralBorderlessPressed: "#DFE9E1",
+ actionContrastText: "#FFFFFF",
// Buttons - AI
primaryAI: rawColors.blue.blue130,
accentAI: rawColors.blue.blue140,
@@ -58,6 +89,11 @@ const appColors = {
errorSoftText: rawColors.red.red90,
staleSoftText: rawColors.neutral.grey100,
+ statusSuccessText: rawColors.green.green60,
+ statusErrorText: "#c4122a",
+ statusWarningText: rawColors.yellow.yellow40,
+ statusMutedText: rawColors.neutral.grey100,
+
warning: rawColors.yellow.yellow50,
warningLite: rawColors.yellow.yellow190,
warningSemi: rawColors.yellow.yellow190,
@@ -86,42 +122,47 @@ const appColors = {
attention: rawColors.purple.mauve,
attentionSecondary: rawColors.purple.daisy,
- separator: rawColors.neutral.grey185,
- controlFocused: rawColors.neutral.limedSpruce,
- selected: rawColors.neutral.grey180,
- highlight: rawColors.neutral.grey180,
-
- tooltip: rawColors.neutral.limedSpruce,
- tooltipText: rawColors.neutral.grey195,
- tooltipBg: rawColors.neutral.limedSpruce,
+ separator: "#DEE6E0",
+ controlFocused: "#4D5C52",
+ selected: "#E0E7E2",
+ highlight: "#718073",
+
+ tooltip: "#293A2F",
+ tooltipText: "#F0F4F1",
+ tooltipBg: "#293A2F",
bright: rawColors.neutral.white,
- text: rawColors.neutral.grey100,
- textLite: rawColors.neutral.grey120,
- textNoFocus: rawColors.neutral.grey140,
- textFocus: rawColors.neutral.grey90,
- textDescription: rawColors.neutral.grey120,
- sectionHeaderBackground: rawColors.neutral.limedSpruce,
- sectionTitle: rawColors.neutral.grey100,
- sectionDescription: rawColors.neutral.grey120,
- placeholder: rawColors.neutral.grey110,
- key: rawColors.neutral.regentgrey,
- panel: rawColors.neutral.limedSpruce,
- panelBg: rawColors.neutral.grey195,
+ onColorDark: rawColors.neutral.black,
+ onColorLight: rawColors.neutral.white,
+ text: "#2D3E33",
+ textLite: "#5C6A61",
+ textNoFocus: "#5C6A61",
+ textFocus: "#4D5C52",
+ textDescription: "#5C6A61",
+ sectionHeaderBackground: "#FFFFFF",
+ sectionTitle: "#2D3E33",
+ sectionDescription: "#5C6A61",
+ placeholder: "#5C6A61",
+ key: "#5C6A61",
+ panel: "#FFFFFF",
+ cardBackground: "#F5F7F5",
+ cardNestedBackground: "#F0F3F0",
+ popoverBackground: "#F2F5F2",
+ panelBg: "#FFFFFF",
// Flat on purpose: gradients made panels read as a second surface system.
- panelBgGrad: rawColors.neutral.grey195,
- mainChartBg: rawColors.neutral.grey195,
- mainChartHeaderBg: rawColors.neutral.grey190,
- mainChartBorder: rawColors.neutral.grey185,
- mainChartTboxHover: rawColors.neutral.grey180,
- sideBar: rawColors.neutral.grey190,
- sideBarMini: rawColors.neutral.grey190,
+ panelBgGrad: "#FFFFFF",
+ mainChartBg: "#FFFFFF",
+ mainChartHeaderBg: "#EEF3EF",
+ mainChartBorder: "#DEE6E0",
+ mainChartTboxHover: "#E0E7E2",
+ sideBar: "#F0F3F0",
+ sideBarMini: "#F0F3F0",
spaceSelected: rawColors.neutral.grey175,
spaceIdle: rawColors.neutral.grey195,
spaceHovered: rawColors.neutral.grey180,
hoverHighlight: rawColors.green.green70,
menuItem: rawColors.neutral.grey120,
- topBarBg: rawColors.neutral.grey195,
- elevationLevelOne: rawColors.neutral.grey185,
+ topBarBg: "#F0F3F0",
+ elevationLevelOne: "#EEF3EF",
// Date picker
datePickerPausedBg: rawColors.neutral.grey185,
@@ -131,22 +172,50 @@ const appColors = {
// Input colors
// Resting edge for fields: 3:1 against the page so the field is findable without hover.
- controlBorder: rawColors.neutral.grey130,
+ controlBorder: "#5C6A61",
textInfo: rawColors.blue.blue100,
- inputBg: rawColors.neutral.white,
- inputBorder: rawColors.neutral.grey130,
- inputBorderHover: rawColors.neutral.grey110,
- inputBorderFocus: rawColors.neutral.grey110,
+ inputBg: "#EEF3EF",
+ inputBorder: "#5C6A61",
+ inputBorderHover: "#4D5C52",
+ inputBorderFocus: "#4D5C52",
// Badges
- nodeBadgeBackground: rawColors.neutral.grey155,
- nodeBadgeBorder: rawColors.neutral.iron,
- nodeBadgeColor: rawColors.neutral.bluebayoux,
+ nodeBadgeBackground: "#E0E7E2",
+ nodeBadgeBorder: "#E0E7E2",
+ nodeBadgeColor: "#476453",
// Default pills
- neutralPillBg: rawColors.neutral.grey155,
- neutralPillBorder: rawColors.neutral.grey155,
- neutralPillColor: rawColors.neutral.grey100,
+ neutralPillBg: "#E0E7E2",
+ neutralPillBorder: "#E0E7E2",
+ neutralPillColor: "#476453",
+
+ labelTokenBackground: "#e2ecec",
+ labelTokenBorder: "#c4d4d4",
+ labelTokenText: "#1a5560",
+ patternTokenBackground: "#dcefec",
+ patternTokenBorder: "#a6d0ca",
+ patternTokenText: "#0e545a",
+ patternTokenMark: "#08767d",
+ negatedTokenBackground: "#ebe4f7",
+ negatedTokenBorder: "#cbbce9",
+ negatedTokenText: "#47307f",
+ negatedTokenMark: "#6544b0",
+
+ syntaxKey: "#1d6470",
+ syntaxNumber: "#8a2aa8",
+ syntaxParen1: "#b0306a",
+ syntaxParen2: "#6b6b00",
+ syntaxParen3: "#4f5f86",
+ linkedContentBackground: "#ebf4f4",
+ errorContentBackground: "#fceef0",
+ thresholdWarningText: "#5a3500",
+ thresholdCriticalText: "#4d0610",
+ chartSeries1: "#1d6470",
+ chartSeries2: "#6b4fbf",
+ chartSeries3: "#5b6b7a",
+ chartSeries4: "#9c4f78",
+ chartWarningLine: "#df8400",
+ chartMutedLine: "#bfc9c9",
// Alert MasterCard
alertIcon: rawColors.neutral.grey180,
@@ -166,7 +235,7 @@ const appColors = {
iconColor: rawColors.neutral.limedSpruce,
// Progress Bare
- progressBg: rawColors.neutral.chineseWhite,
+ progressBg: "#D7E1D9",
// table-resizer
resizerLine: rawColors.green.green100,
diff --git a/src/theme/default/constants.js b/src/theme/default/constants.js
index 478c19930..eabc30e79 100644
--- a/src/theme/default/constants.js
+++ b/src/theme/default/constants.js
@@ -5,9 +5,13 @@ export const SIZE_UNIT = 8
export const GUTTER_HEIGHT = 8
+export const FONT_MONOSPACE = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"
+
// One control ladder (px) shared by buttons, fields, selects and icon buttons, so rows always align.
export const CONTROL_SIZES = {
compact: { height: 24, fontSize: 12 },
- default: { height: 28, fontSize: 13 },
+ default: { height: 30, fontSize: 13 },
large: { height: 32, fontSize: 14 },
}
+
+export const PILL_SUBTLE_TINT = "8%"
diff --git a/src/theme/default/index.js b/src/theme/default/index.js
index 444c54c59..fc3e184c6 100644
--- a/src/theme/default/index.js
+++ b/src/theme/default/index.js
@@ -10,4 +10,8 @@ export const DefaultTheme = {
...root,
constants,
colors,
+ shadows: {
+ segmentedSelected: `0 0 0 1px ${colors.segmentedBorder}, 0 1px 2px rgba(23, 32, 32, 0.14)`,
+ segmentedAccentSelected: `inset 0 0 0 1px color-mix(in srgb, ${colors.segmentedAccentText} 30%, transparent)`,
+ },
}
diff --git a/src/theme/editorPalette.test.js b/src/theme/editorPalette.test.js
new file mode 100644
index 000000000..99febc943
--- /dev/null
+++ b/src/theme/editorPalette.test.js
@@ -0,0 +1,26 @@
+import { DarkTheme, DefaultTheme, getColor } from "./index"
+
+describe("editor syntax, threshold and chart palette", () => {
+ it.each([
+ ["syntaxKey", "#1d6470", "#93c9cb"],
+ ["syntaxNumber", "#8a2aa8", "#d79bf2"],
+ ["syntaxParen1", "#b0306a", "#f38bc0"],
+ ["syntaxParen2", "#6b6b00", "#c8c86b"],
+ ["syntaxParen3", "#4f5f86", "#a8b4dc"],
+ ["linkedContentBackground", "#ebf4f4", "#22393a"],
+ ["errorContentBackground", "#fceef0", "#3a1d22"],
+ ["thresholdWarningText", "#5a3500", "#1f1300"],
+ ["thresholdCriticalText", "#4d0610", "#ffdfe3"],
+ ["chartSeries1", "#1d6470", "#93c9cb"],
+ ["chartSeries2", "#6b4fbf", "#a58be0"],
+ ["chartSeries3", "#5b6b7a", "#b4c0cc"],
+ ["chartSeries4", "#9c4f78", "#d58fb0"],
+ ["chartWarningLine", "#df8400", "#bf7100"],
+ ["chartMutedLine", "#bfc9c9", "#4d5c5c"],
+ ])("resolves %s without changing either editor theme", (token, light, dark) => {
+ expect([DefaultTheme, DarkTheme].map(theme => getColor(token)({ theme }))).toEqual([
+ light,
+ dark,
+ ])
+ })
+})
diff --git a/src/theme/editorTokens.test.js b/src/theme/editorTokens.test.js
new file mode 100644
index 000000000..59e76503d
--- /dev/null
+++ b/src/theme/editorTokens.test.js
@@ -0,0 +1,20 @@
+import { DarkTheme, DefaultTheme, getColor } from "./index"
+
+describe("editor chip tokens", () => {
+ it.each([
+ ["labelTokenBackground", "#e2ecec", "#24393b"],
+ ["labelTokenBorder", "#c4d4d4", "#3f5a5b"],
+ ["labelTokenText", "#1a5560", "#a8d5d7"],
+ ["patternTokenBackground", "#dcefec", "#163a3c"],
+ ["patternTokenBorder", "#a6d0ca", "#2c6468"],
+ ["patternTokenText", "#0e545a", "#a8e1dc"],
+ ["patternTokenMark", "#08767d", "#62d6ce"],
+ ["negatedTokenBackground", "#ebe4f7", "#30284b"],
+ ["negatedTokenBorder", "#cbbce9", "#58498a"],
+ ["negatedTokenText", "#47307f", "#d6c9fc"],
+ ["negatedTokenMark", "#6544b0", "#b6a0f8"],
+ ])("resolves %s to the existing editor chip color in each theme", (token, light, dark) => {
+ expect(getColor(token)({ theme: DefaultTheme })).toBe(light)
+ expect(getColor(token)({ theme: DarkTheme })).toBe(dark)
+ })
+})
diff --git a/src/theme/index.d.ts b/src/theme/index.d.ts
index dd6b2a24a..cdff1e842 100644
--- a/src/theme/index.d.ts
+++ b/src/theme/index.d.ts
@@ -8,6 +8,41 @@ export type AppColorsT = {
main: string
border: string
borderSecondary: string
+ appSidebarBackground: string
+ appBackground: string
+ workspaceSidebarBackground: string
+ workspaceBackground: string
+ menuItemHover: string
+ menuItemSelected: string
+ menuItemSelectedHover: string
+ menuItemSelectedText: string
+ tableBorder: string
+ tableHeaderBackground: string
+ segmentedBackground: string
+ segmentedSelectedBackground: string
+ segmentedFocus: string
+ segmentedAccentText: string
+ segmentedAccentBackground: string
+ segmentedBorder: string
+ controlBackground: string
+ controlHoverBackground: string
+ controlPressedBackground: string
+ controlText: string
+ controlHoverText: string
+ controlPressedText: string
+ buttonNeutralFill: string
+ buttonNeutralFillHover: string
+ buttonNeutralFillPressed: string
+ buttonNeutralText: string
+ buttonNeutralBorder: string
+ buttonNeutralBorderHover: string
+ buttonNeutralHollowHover: string
+ buttonNeutralHollowPressed: string
+ buttonNeutralBorderlessHover: string
+ buttonNeutralBorderlessPressed: string
+ actionContrastText: string
+ onColorDark: string
+ onColorLight: string
tabsBorder: string
disabled: string
dropdown: string
@@ -17,6 +52,36 @@ export type AppColorsT = {
success: string
successLite: string
successBackground: string
+ statusSuccessText: string
+ statusErrorText: string
+ statusWarningText: string
+ statusMutedText: string
+ labelTokenBackground: string
+ labelTokenBorder: string
+ labelTokenText: string
+ patternTokenBackground: string
+ patternTokenBorder: string
+ patternTokenText: string
+ patternTokenMark: string
+ negatedTokenBackground: string
+ negatedTokenBorder: string
+ negatedTokenText: string
+ negatedTokenMark: string
+ syntaxKey: string
+ syntaxNumber: string
+ syntaxParen1: string
+ syntaxParen2: string
+ syntaxParen3: string
+ linkedContentBackground: string
+ errorContentBackground: string
+ thresholdWarningText: string
+ thresholdCriticalText: string
+ chartSeries1: string
+ chartSeries2: string
+ chartSeries3: string
+ chartSeries4: string
+ chartWarningLine: string
+ chartMutedLine: string
warning: string
warningLite: string
warningBackground: string
@@ -39,6 +104,9 @@ export type AppColorsT = {
sectionHeaderBackground: string
placeholder: string
key: string
+ cardBackground: string
+ cardNestedBackground: string
+ popoverBackground: string
panel: string
datePickerPausedBg: string
datePickerPlayBg: string
@@ -67,8 +135,14 @@ interface IDefaultTheme {
SIZE_SUB_UNIT: number
SIZE_UNIT: number
GUTTER_HEIGHT: number
+ FONT_MONOSPACE: string
+ PILL_SUBTLE_TINT: string
}
colors: AppColorsT
+ shadows: {
+ segmentedSelected: string
+ segmentedAccentSelected: string
+ }
}
interface IDarkTheme {
@@ -78,8 +152,14 @@ interface IDarkTheme {
SIZE_SUB_UNIT: number
SIZE_UNIT: number
GUTTER_HEIGHT: number
+ FONT_MONOSPACE: string
+ PILL_SUBTLE_TINT: string
}
colors: AppColorsT
+ shadows: {
+ segmentedSelected: string
+ segmentedAccentSelected: string
+ }
}
declare const DefaultTheme: IDefaultTheme
@@ -96,6 +176,11 @@ declare function getSizeUnit({ theme }: WrappedTheme): number | undefined
declare function getColor(colorPath: string[] | string): any
declare function getRgbColor(colorPath: string[] | string, opacity: number): any
+declare function getReadableColor(
+ backgroundPath: string[] | string,
+ darkColorPath?: string[] | string,
+ lightColorPath?: string[] | string
+): any
declare function getSizeBy(multiplier?: number): (props: WrappedTheme) => any
@@ -119,6 +204,7 @@ export {
getSizeUnit,
getColor,
getRgbColor,
+ getReadableColor,
getSizeBy,
getValidatedControlColor,
}
diff --git a/src/theme/index.test.js b/src/theme/index.test.js
index eb954103d..37da1b4ab 100644
--- a/src/theme/index.test.js
+++ b/src/theme/index.test.js
@@ -1,7 +1,65 @@
+import { getContrast, getLuminance } from "polished"
import { DarkTheme, DefaultTheme } from "./index"
import rawColors from "./rawColors"
describe("theme colors", () => {
+ it.each([DefaultTheme, DarkTheme])("separates menu interaction states in $name", ({ colors }) => {
+ const {
+ appSidebarBackground,
+ workspaceSidebarBackground,
+ menuItemHover,
+ menuItemSelected,
+ menuItemSelectedHover,
+ menuItemSelectedText,
+ primary,
+ text,
+ } = colors
+
+ for (const surface of [appSidebarBackground, workspaceSidebarBackground]) {
+ expect(getContrast(surface, menuItemHover)).toBeGreaterThanOrEqual(1.15)
+ expect(getContrast(surface, menuItemSelected)).toBeGreaterThanOrEqual(1.25)
+ }
+ expect(getContrast(menuItemSelected, menuItemSelectedHover)).toBeGreaterThanOrEqual(1.1)
+ expect(getContrast(text, menuItemHover)).toBeGreaterThanOrEqual(4.5)
+ expect(getContrast(menuItemSelectedText, menuItemSelectedHover)).toBeGreaterThanOrEqual(4.5)
+ expect(getContrast(primary, menuItemSelectedHover)).toBeGreaterThanOrEqual(3)
+ })
+
+ it("darkens light surfaces from the page to nested controls", () => {
+ const colors = DefaultTheme.colors
+ const luminance = role => getLuminance(colors[role])
+ expect(colors.workspaceBackground).toBe(colors.appBackground)
+ const steps = [
+ "appBackground",
+ "cardBackground",
+ "cardNestedBackground",
+ "controlBackground",
+ "controlHoverBackground",
+ "controlPressedBackground",
+ ]
+
+ steps.slice(1).forEach((role, i) => {
+ expect(luminance(role)).toBeLessThan(luminance(steps[i]))
+ })
+ expect(luminance("appSidebarBackground")).toBeLessThan(luminance("workspaceBackground"))
+ expect(luminance("workspaceSidebarBackground")).toBeLessThan(luminance("appSidebarBackground"))
+ expect(luminance("inputBg")).toBeLessThan(luminance("workspaceSidebarBackground"))
+ expect(luminance("segmentedSelectedBackground")).toBeLessThan(luminance("segmentedBackground"))
+ expect(luminance("popoverBackground")).toBeLessThan(luminance("workspaceBackground"))
+ })
+
+ it("separates Sage control and neutral-button state roles from surfaces", () => {
+ expect(DefaultTheme.colors.controlBackground).toBe("#EEF3EF")
+ expect(DefaultTheme.colors.controlHoverBackground).toBe("#E8EFEA")
+ expect(DefaultTheme.colors.buttonNeutralFill).toBe("#476453")
+ expect(DefaultTheme.colors.buttonNeutralText).toBe("#FFFFFF")
+ expect(DefaultTheme.colors.actionContrastText).toBe("#FFFFFF")
+ expect(DarkTheme.colors.controlBackground).toBe("#222B25")
+ expect(DarkTheme.colors.buttonNeutralFill).toBe("#B0C5B5")
+ expect(DarkTheme.colors.buttonNeutralText).toBe("#171D19")
+ expect(DarkTheme.colors.actionContrastText).toBe("#171D19")
+ })
+
it("owns metric gaps as a semantic color in both themes", () => {
expect(DefaultTheme.colors.metricGap).toBe(rawColors.neutral.metricGapLight)
expect(DarkTheme.colors.metricGap).toBe(rawColors.neutral.metricGapDark)
@@ -12,10 +70,10 @@ describe("theme colors", () => {
expect(DarkTheme.colors.mapSearchHighlight).toBe(rawColors.blue.blue150)
})
- it("keeps panelBgGrad flat in light so legacy panels follow the surface ladder", () => {
+ it("keeps panelBgGrad on the Sage panel and canvas ladder", () => {
expect(DefaultTheme.colors.panelBgGrad).toBe(DefaultTheme.colors.panelBg)
expect(DarkTheme.colors.panelBgGrad).toBe(
- `linear-gradient(to right, ${rawColors.neutral.grey25} 0%, ${rawColors.neutral.grey15} 50%, ${rawColors.neutral.grey25} 100%)`
+ "linear-gradient(to right, #202723 0%, #171D19 50%, #202723 100%)"
)
})
})
@@ -30,8 +88,8 @@ describe("visual refresh token values", () => {
})
it("gives dark input borders a visible edge", () => {
- expect(DarkTheme.colors.inputBorder).toBe(rawColors.neutral.grey85)
- expect(DarkTheme.colors.inputBorderHover).toBe(rawColors.neutral.grey100)
+ expect(DarkTheme.colors.inputBorder).toBe("#98A69D")
+ expect(DarkTheme.colors.inputBorderHover).toBe("#B0C5B5")
})
it("keeps dark focused input borders distinct from resting borders", () => {
@@ -39,15 +97,39 @@ describe("visual refresh token values", () => {
})
it("renders tooltips as an inverse surface", () => {
- expect(DefaultTheme.colors.tooltip).toBe(rawColors.neutral.limedSpruce)
- expect(DefaultTheme.colors.tooltipText).toBe(rawColors.neutral.grey195)
- expect(DarkTheme.colors.tooltip).toBe(rawColors.neutral.grey55)
- expect(DarkTheme.colors.tooltipText).toBe(rawColors.neutral.grey185)
+ expect(DefaultTheme.colors.tooltip).toBe("#293A2F")
+ expect(DefaultTheme.colors.tooltipText).toBe("#F0F4F1")
+ expect(DarkTheme.colors.tooltip).toBe("#344239")
+ expect(DarkTheme.colors.tooltipText).toBe("#F0F4F1")
})
it("keeps table row dividers visible under hover", () => {
expect(DefaultTheme.colors.tableRowBgHover).toBe(rawColors.neutral.grey190)
- expect(DarkTheme.colors.tableRowBgHover).toBe(rawColors.neutral.grey30)
+ const { workspaceBackground, cardBackground, tableBorder, tableRowBgHover, text } =
+ DarkTheme.colors
+ expect(getLuminance(tableRowBgHover)).toBeGreaterThan(getLuminance(cardBackground))
+ expect(getContrast(tableRowBgHover, workspaceBackground)).toBeGreaterThanOrEqual(1.25)
+ expect(getContrast(tableRowBgHover, cardBackground)).toBeGreaterThanOrEqual(1.15)
+ expect(getContrast(tableRowBgHover, tableBorder)).toBeGreaterThanOrEqual(1.15)
+ expect(getContrast(text, tableRowBgHover)).toBeGreaterThanOrEqual(4.5)
+ })
+
+ it("makes dark grouped-row hover visible on table and card surfaces", () => {
+ const { cardBackground, tableRowBg2, tableRowBg2Hover, textLite } = DarkTheme.colors
+ expect(getLuminance(tableRowBg2Hover)).toBeGreaterThan(getLuminance(cardBackground))
+ expect(getContrast(tableRowBg2Hover, tableRowBg2)).toBeGreaterThanOrEqual(1.25)
+ expect(getContrast(tableRowBg2Hover, cardBackground)).toBeGreaterThanOrEqual(1.15)
+ expect(getContrast(textLite, tableRowBg2Hover)).toBeGreaterThanOrEqual(4.5)
+ })
+
+ describe.each([DefaultTheme, DarkTheme])("grouped rows in $name theme", ({ colors }) => {
+ it.each(["statusSuccessText", "statusErrorText", "statusWarningText", "statusMutedText"])(
+ "%s stays readable at rest and on hover",
+ role => {
+ expect(getContrast(colors[role], colors.tableRowBg2)).toBeGreaterThanOrEqual(4.5)
+ expect(getContrast(colors[role], colors.tableRowBg2Hover)).toBeGreaterThanOrEqual(4.5)
+ }
+ )
})
it("draws the column resizer in primary green", () => {
@@ -56,7 +138,7 @@ describe("visual refresh token values", () => {
})
it("lifts the dark modal header above the page", () => {
- expect(DarkTheme.colors.modalHeaderBackground).toBe(rawColors.neutral.grey30)
+ expect(DarkTheme.colors.modalHeaderBackground).toBe("#29312C")
})
it("exposes hover and pressed steps for primary actions", () => {
@@ -81,8 +163,8 @@ describe("soft pill text keys", () => {
describe("approved colour proposal", () => {
it("adds controlBorder and textInfo to both themes", () => {
- expect(DefaultTheme.colors.controlBorder).toBe(rawColors.neutral.grey130)
- expect(DarkTheme.colors.controlBorder).toBe(rawColors.neutral.grey120)
+ expect(DefaultTheme.colors.controlBorder).toBe("#5C6A61")
+ expect(DarkTheme.colors.controlBorder).toBe("#98A69D")
expect(DefaultTheme.colors.textInfo).toBe(rawColors.blue.blue100)
expect(DarkTheme.colors.textInfo).toBe(rawColors.blue.blue150)
})
@@ -103,8 +185,8 @@ describe("approved colour proposal", () => {
it("raises warning text and placeholder contrast", () => {
expect(DefaultTheme.colors.warningText).toBe(rawColors.yellow.yellow40)
- expect(DefaultTheme.colors.placeholder).toBe(rawColors.neutral.grey110)
- expect(DarkTheme.colors.placeholder).toBe(rawColors.neutral.grey125)
+ expect(DefaultTheme.colors.placeholder).toBe("#5C6A61")
+ expect(DarkTheme.colors.placeholder).toBe("#98A69D")
})
})
@@ -122,27 +204,43 @@ it("paints dark tooltipBg like the drops tooltip", () => {
describe("light surface ladder and field edges (audit L1–L4)", () => {
const c = DefaultTheme.colors
const n = rawColors.neutral
- it("uses one lightest grey: blackhaze keys sit on grey195", () => {
- ;["elementBackground", "mainChartBg", "mainBackgroundDisabled", "modalInfoBackground"].forEach(key =>
- expect([key, c[key]]).toEqual([key, n.grey195])
- )
+ it("uses distinct Sage canvas, panel and subtle surface roles", () => {
+ expect(c.elementBackground).toBe("#EEF3EF")
+ expect(c.mainChartBg).toBe("#FFFFFF")
+ expect(c.mainBackgroundDisabled).toBe("#EEF3EF")
+ expect(c.modalInfoBackground).toBe("#EEF3EF")
})
- it("puts the sidebar on grey190 with hover one step darker", () => {
- expect(c.sideBarMini).toBe(n.grey190)
- expect(c.menuItemHover).toBe(n.grey185)
+ it("keeps the compact sidebar surface on its own Sage step", () => {
+ expect(c.sideBarMini).toBe("#F0F3F0")
})
it("keeps the time picker neutral; green stays for status", () => {
expect(c.datePickerPlayBg).toBe(n.grey190)
expect(c.datePickerPausedBg).toBe(n.grey185)
})
it("gives fields one softer edge that still reaches 3:1, and darkens it on hover", () => {
- expect(c.controlBorder).toBe(n.grey130)
- expect(c.inputBorder).toBe(n.grey130)
- expect(c.inputBorderHover).toBe(n.grey110)
- expect(c.inputBorderFocus).toBe(n.grey110)
+ expect(c.controlBorder).toBe("#5C6A61")
+ expect(c.inputBorder).toBe("#5C6A61")
+ expect(c.inputBorderHover).toBe("#4D5C52")
+ expect(c.inputBorderFocus).toBe("#4D5C52")
})
it("renders stale as a neutral grey", () => {
expect(c.stale).toBe(n.grey130)
expect(c.staleSemi).toBe(n.grey120)
})
})
+
+
+describe("Sage compact label contrast", () => {
+ it.each([
+ ["light", DefaultTheme],
+ ["dark", DarkTheme],
+ ])("keeps node badge labels readable on their neutral surface in %s theme", (_, theme) => {
+ const { nodeBadgeColor, nodeBadgeBackground } = theme.colors
+ expect(getContrast(nodeBadgeColor, nodeBadgeBackground)).toBeGreaterThanOrEqual(4.5)
+ })
+
+ it("keeps muted text readable on the dark pressed control surface", () => {
+ const { textLite, controlPressedBackground } = DarkTheme.colors
+ expect(getContrast(textLite, controlPressedBackground)).toBeGreaterThanOrEqual(4.5)
+ })
+})
diff --git a/src/theme/rawColors.js b/src/theme/rawColors.js
index d66c58f42..54eade04f 100644
--- a/src/theme/rawColors.js
+++ b/src/theme/rawColors.js
@@ -135,65 +135,65 @@ const rawColors = {
neutral: {
white: "#FFFFFF",
black: "#000000",
- limedSpruce: "#35414A",
- regentgrey: "#8F9EAA",
- blackhaze: "#F7F8F8",
- brightGrey: "#E9ECEC",
- chineseWhite: "#DEE3E3",
- iron: "#CFD5DA",
- porcelain: "#ECEEEF",
- bluebayoux: "#536775",
- shark: "#1C1E22",
- tuna: "#383B40",
- outerSpace: "#2B3136",
- ratsbane: "#3E4551",
- arsenic: "#353B45",
- gunmetal: "#282C34",
- darkGunmetal: "#21252B",
- eerieBlack: "#181c20",
+ limedSpruce: "#39413C",
+ regentgrey: "#959E98",
+ blackhaze: "#F7F8F7",
+ brightGrey: "#E9ECEA",
+ chineseWhite: "#DFE3E1",
+ iron: "#CFD6D1",
+ porcelain: "#ECEEED",
+ bluebayoux: "#5E6661",
+ shark: "#1B1F1C",
+ tuna: "#373C39",
+ outerSpace: "#2B312D",
+ ratsbane: "#3E4641",
+ arsenic: "#343C37",
+ gunmetal: "#262D29",
+ darkGunmetal: "#202622",
+ eerieBlack: "#171C19",
metricGapDark: "#312E27",
metricGapLight: "#E0DCD5",
// Grey shades
grey05: "#040505",
- grey10: "#080A0A",
- grey15: "#0C0F0F",
- grey20: "#101313",
- grey25: "#151818",
- grey30: "#191D1D",
- grey35: "#1D2222",
- grey40: "#212727",
- grey45: "#252C2C",
- grey50: "#293030",
- grey55: "#2D3535",
- grey60: "#313A3A",
- grey65: "#353F3F",
- grey70: "#394444",
- grey75: "#3D4949",
- grey80: "#424E4E",
- grey85: "#465252",
- grey90: "#4A5757",
- grey95: "#4E5C5C",
+ grey10: "#080A09",
+ grey15: "#0D0F0D",
+ grey20: "#101311",
+ grey25: "#161816",
+ grey30: "#1A1D1B",
+ grey35: "#1E2220",
+ grey40: "#222724",
+ grey45: "#262C28",
+ grey50: "#2A302C",
+ grey55: "#2E3531",
+ grey60: "#333A35",
+ grey65: "#373F3A",
+ grey70: "#3B443E",
+ grey75: "#404943",
+ grey80: "#454E48",
+ grey85: "#49514C",
+ grey90: "#4E5751",
+ grey95: "#535C56",
// Grey base
- grey100: "#526161",
+ grey100: "#58615B",
// Grey Tints
- grey105: "#5A6A6A",
- grey110: "#617373",
- grey115: "#697C7C",
- grey120: "#708585",
- grey125: "#788D8D",
- grey130: "#819595",
- grey135: "#8A9C9C",
- grey140: "#93A4A4",
- grey145: "#9CACAC",
- grey150: "#A5B3B3",
- grey155: "#AEBBBB",
- grey160: "#B7C2C2",
- grey165: "#C0CACA",
- grey170: "#C9D2D2",
- grey175: "#D2D9D9",
- grey180: "#DBE1E1",
- grey185: "#E4E8E8",
- grey190: "#EDF0F0",
+ grey105: "#606964",
+ grey110: "#69716C",
+ grey115: "#717A75",
+ grey120: "#7A847E",
+ grey125: "#828C85",
+ grey130: "#8A938D",
+ grey135: "#919B94",
+ grey140: "#9AA39D",
+ grey145: "#A2ACA5",
+ grey150: "#A9B2AC",
+ grey155: "#B1BBB4",
+ grey160: "#BAC2BC",
+ grey165: "#C2CAC4",
+ grey170: "#CBD1CD",
+ grey175: "#D3D9D5",
+ grey180: "#DDE1DE",
+ grey185: "#E5E8E6",
+ grey190: "#EEF0EE",
grey195: "#F6F7F7",
},
purple: {
diff --git a/src/theme/utils.js b/src/theme/utils.js
index 562089178..e84318f23 100644
--- a/src/theme/utils.js
+++ b/src/theme/utils.js
@@ -1,4 +1,5 @@
import get from "lodash/get"
+import { getContrast } from "polished"
export const propOrElse = (pathName, defaultValue) => props => get(props, pathName, defaultValue)
@@ -26,6 +27,19 @@ export const getRgbColor = (colorPath, opacity = 1) => {
}
}
+export const getReadableColor = (
+ backgroundPath,
+ darkColorPath = "onColorDark",
+ lightColorPath = "onColorLight"
+) => ({ theme }) => {
+ const background = getColor(backgroundPath)({ theme })
+ const dark = getColor(darkColorPath)({ theme })
+ const light = getColor(lightColorPath)({ theme })
+ return getContrast(dark, background) >= getContrast(light, background)
+ ? dark
+ : light
+}
+
export const getSizeBy =
(multiplier = 1) =>
props =>
diff --git a/src/theme/utils.test.js b/src/theme/utils.test.js
new file mode 100644
index 000000000..d337ccee2
--- /dev/null
+++ b/src/theme/utils.test.js
@@ -0,0 +1,25 @@
+import { getReadableColor } from "./utils"
+import { getContrast } from "polished"
+import { DefaultTheme } from "./default"
+import { DarkTheme } from "./dark"
+
+describe("getReadableColor", () => {
+ it("chooses the higher-contrast theme-owned ink for light and dark fills", () => {
+ expect(getReadableColor("onColorDark", "onColorDark", "onColorLight")({ theme: DefaultTheme })).toBe(
+ "#FFFFFF"
+ )
+ expect(getReadableColor("onColorLight", "onColorDark", "onColorLight")({ theme: DarkTheme })).toBe(
+ "#000000"
+ )
+ })
+
+ it("keeps the midpoint grey at AA contrast by choosing a true endpoint", () => {
+ const color = getReadableColor("#777777")({ theme: DefaultTheme })
+ expect(getContrast(color, "#777777")).toBeGreaterThanOrEqual(4.5)
+ expect(color).toBe("#000000")
+ })
+
+ it("accepts uppercase RGB background values from chart annotations", () => {
+ expect(getReadableColor("RGB(119, 119, 119)")({ theme: DefaultTheme })).toBe("#000000")
+ })
+})
diff --git a/src/utils/getScrollInset.d.ts b/src/utils/getScrollInset.d.ts
new file mode 100644
index 000000000..25cc42bb7
--- /dev/null
+++ b/src/utils/getScrollInset.d.ts
@@ -0,0 +1,4 @@
+export function getScrollInset(
+ element: HTMLElement,
+ options?: { dimension?: "width" | "height"; includeBorder?: boolean }
+): number
diff --git a/src/utils/getScrollInset.js b/src/utils/getScrollInset.js
new file mode 100644
index 000000000..397bee59b
--- /dev/null
+++ b/src/utils/getScrollInset.js
@@ -0,0 +1,12 @@
+export const getScrollInset = (element, { dimension = "width", includeBorder = false } = {}) => {
+ const isWidth = dimension === "width"
+ const inset = isWidth
+ ? element.offsetWidth - element.clientWidth
+ : element.offsetHeight - element.clientHeight
+ if (includeBorder) return inset
+
+ const style = getComputedStyle(element)
+ const start = isWidth ? style.borderLeftWidth : style.borderTopWidth
+ const end = isWidth ? style.borderRightWidth : style.borderBottomWidth
+ return Math.max(0, inset - ((parseFloat(start) || 0) + (parseFloat(end) || 0)))
+}
diff --git a/src/utils/getScrollInset.test.js b/src/utils/getScrollInset.test.js
new file mode 100644
index 000000000..9eb0c3ecd
--- /dev/null
+++ b/src/utils/getScrollInset.test.js
@@ -0,0 +1,40 @@
+import { getScrollInset } from "./getScrollInset"
+
+const scroller = () => {
+ const element = document.createElement("div")
+ element.style.border = "solid"
+ element.style.borderWidth = "3px 1px 4px 2px"
+ Object.defineProperties(element, {
+ offsetWidth: { value: 120 },
+ clientWidth: { value: 102 },
+ offsetHeight: { value: 100 },
+ clientHeight: { value: 88 },
+ })
+ return element
+}
+
+describe("getScrollInset", () => {
+ it("subtracts only inline borders from the default width measurement", () => {
+ expect(getScrollInset(scroller())).toBe(15)
+ })
+
+ it("uses block borders for the height measurement", () => {
+ expect(getScrollInset(scroller(), { dimension: "height" })).toBe(5)
+ })
+
+ it("can retain the full box difference for each dimension", () => {
+ const element = scroller()
+ expect([
+ getScrollInset(element, { includeBorder: true }),
+ getScrollInset(element, { dimension: "height", includeBorder: true }),
+ ]).toEqual([18, 12])
+ })
+
+ it("clamps negative scrollbar space caused by fractional borders", () => {
+ const element = scroller()
+ element.style.borderLeftWidth = "9.5px"
+ element.style.borderRightWidth = "9px"
+
+ expect(getScrollInset(element)).toBe(0)
+ })
+})
diff --git a/src/utils/mergeRefs.js b/src/utils/mergeRefs.js
index 521fadac5..e265932a7 100644
--- a/src/utils/mergeRefs.js
+++ b/src/utils/mergeRefs.js
@@ -10,7 +10,7 @@ export function assignRef(ref, value) {
try {
ref.current = value
- } catch (error) {
+ } catch {
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`)
}
}
diff --git a/src/utils/mergeRefs.test.js b/src/utils/mergeRefs.test.js
index a005cd125..f4b9adb46 100644
--- a/src/utils/mergeRefs.test.js
+++ b/src/utils/mergeRefs.test.js
@@ -120,11 +120,7 @@ describe("mergeRefs", () => {
expect(goodRef).toHaveBeenCalledWith("value")
})
- it("works with React component refs", () => {
- const Component = React.forwardRef((props, ref) => {
- return
- })
-
+ it("sets multiple React object refs to the same value", () => {
const ref1 = React.createRef()
const ref2 = React.createRef()
const merged = mergeRefs(ref1, ref2)
diff --git a/src/utils/virtualRangeWithIndex.d.ts b/src/utils/virtualRangeWithIndex.d.ts
new file mode 100644
index 000000000..95b5a0f01
--- /dev/null
+++ b/src/utils/virtualRangeWithIndex.d.ts
@@ -0,0 +1,3 @@
+import type { Range } from "@tanstack/react-virtual"
+
+export function virtualRangeWithIndex(range: Range, index: number): number[]
diff --git a/src/utils/virtualRangeWithIndex.js b/src/utils/virtualRangeWithIndex.js
new file mode 100644
index 000000000..1c44350c8
--- /dev/null
+++ b/src/utils/virtualRangeWithIndex.js
@@ -0,0 +1,8 @@
+import { defaultRangeExtractor } from "@tanstack/react-virtual"
+
+export const virtualRangeWithIndex = (range, index) => {
+ const visible = defaultRangeExtractor(range)
+ return index >= 0 && index < range.count && !visible.includes(index)
+ ? [...visible, index].sort((a, b) => a - b)
+ : visible
+}
diff --git a/yarn.lock b/yarn.lock
index e2a08bd16..677cb0132 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1437,45 +1437,65 @@
dependencies:
eslint-visitor-keys "^3.4.3"
-"@eslint-community/regexpp@^4.12.2":
+"@eslint-community/regexpp@^4.12.1":
version "4.12.2"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b"
integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==
-"@eslint/config-array@^0.23.0":
- version "0.23.1"
- resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.23.1.tgz#908223da7b9148f1af5bfb3144b77a9387a89446"
- integrity sha512-uVSdg/V4dfQmTjJzR0szNczjOH/J+FyUMMjYtr07xFRXR7EDf9i1qdxrD0VusZH9knj1/ecxzCQQxyic5NzAiA==
+"@eslint/config-array@^0.21.2":
+ version "0.21.2"
+ resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.21.2.tgz#f29e22057ad5316cf23836cee9a34c81fffcb7e6"
+ integrity sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==
dependencies:
- "@eslint/object-schema" "^3.0.1"
+ "@eslint/object-schema" "^2.1.7"
debug "^4.3.1"
- minimatch "^10.1.1"
+ minimatch "^3.1.5"
-"@eslint/config-helpers@^0.5.2":
- version "0.5.2"
- resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.5.2.tgz#314c7b03d02a371ad8c0a7f6821d5a8a8437ba9d"
- integrity sha512-a5MxrdDXEvqnIq+LisyCX6tQMPF/dSJpCfBgBauY+pNZ28yCtSsTvyTYrMhaI+LK26bVyCJfJkT0u8KIj2i1dQ==
+"@eslint/config-helpers@^0.4.2":
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.4.2.tgz#1bd006ceeb7e2e55b2b773ab318d300e1a66aeda"
+ integrity sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==
dependencies:
- "@eslint/core" "^1.1.0"
+ "@eslint/core" "^0.17.0"
-"@eslint/core@^1.1.0":
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/@eslint/core/-/core-1.1.0.tgz#51f5cd970e216fbdae6721ac84491f57f965836d"
- integrity sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==
+"@eslint/core@^0.17.0":
+ version "0.17.0"
+ resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.17.0.tgz#77225820413d9617509da9342190a2019e78761c"
+ integrity sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==
dependencies:
"@types/json-schema" "^7.0.15"
-"@eslint/object-schema@^3.0.1":
- version "3.0.1"
- resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-3.0.1.tgz#9a1dc9af00d790dc79a9bf57a756e3cb2740ddb9"
- integrity sha512-P9cq2dpr+LU8j3qbLygLcSZrl2/ds/pUpfnHNNuk5HW7mnngHs+6WSq5C9mO3rqRX8A1poxqLTC9cu0KOyJlBg==
+"@eslint/eslintrc@^3.3.6":
+ version "3.3.7"
+ resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.7.tgz#76d3dedec4a30ea32df797bf8a0085c1311b7316"
+ integrity sha512-F42g89Qd5oAWtp0k0nnSrjziAKza7w8SVT4mStc18LZMaRb4J1HQAHLCalEtDCxrTuksx7NU9qsmeLwpOfPqWw==
+ dependencies:
+ ajv "^6.14.0"
+ debug "^4.3.2"
+ espree "^10.0.1"
+ globals "^14.0.0"
+ ignore "^5.2.0"
+ import-fresh "^3.2.1"
+ js-yaml "^4.3.2"
+ minimatch "^3.1.5"
+ strip-json-comments "^3.1.1"
+
+"@eslint/js@9.39.5", "@eslint/js@^9.39.4":
+ version "9.39.5"
+ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.39.5.tgz#6f2fbcff75500d229d535e0a949ae13472c84787"
+ integrity sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==
+
+"@eslint/object-schema@^2.1.7":
+ version "2.1.7"
+ resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.7.tgz#6e2126a1347e86a4dedf8706ec67ff8e107ebbad"
+ integrity sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==
-"@eslint/plugin-kit@^0.6.0":
- version "0.6.0"
- resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.6.0.tgz#e0cb12ec66719cb2211ad36499fb516f2a63899d"
- integrity sha512-bIZEUzOI1jkhviX2cp5vNyXQc6olzb2ohewQubuYlMXZ2Q/XjBO0x0XhGPvc9fjSIiUN0vw+0hq53BJ4eQSJKQ==
+"@eslint/plugin-kit@^0.4.1":
+ version "0.4.1"
+ resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz#9779e3fd9b7ee33571a57435cf4335a1794a6cb2"
+ integrity sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==
dependencies:
- "@eslint/core" "^1.1.0"
+ "@eslint/core" "^0.17.0"
levn "^0.4.1"
"@exodus/bytes@^1.11.0", "@exodus/bytes@^1.6.0":
@@ -2265,11 +2285,6 @@
"@types/estree" "*"
"@types/json-schema" "*"
-"@types/esrecurse@^4.3.1":
- version "4.3.1"
- resolved "https://registry.yarnpkg.com/@types/esrecurse/-/esrecurse-4.3.1.tgz#6f636af962fbe6191b830bd676ba5986926bccec"
- integrity sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==
-
"@types/estree@*", "@types/estree@^1.0.6", "@types/estree@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e"
@@ -2768,7 +2783,7 @@ ajv-keywords@^5.1.0:
dependencies:
fast-deep-equal "^3.1.3"
-ajv@^6.12.4, ajv@^6.12.5:
+ajv@^6.12.5:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
@@ -2778,6 +2793,16 @@ ajv@^6.12.4, ajv@^6.12.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
+ajv@^6.14.0:
+ version "6.15.0"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.15.0.tgz#07e982c74626167aa7a2495c53817892d7139492"
+ integrity sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==
+ dependencies:
+ fast-deep-equal "^3.1.1"
+ fast-json-stable-stringify "^2.0.0"
+ json-schema-traverse "^0.4.1"
+ uri-js "^4.2.2"
+
ajv@^8.0.0, ajv@^8.9.0:
version "8.18.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.18.0.tgz#8864186b6738d003eb3a933172bb3833e10cefbc"
@@ -3388,7 +3413,7 @@ chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
-chalk@^4.1.2:
+chalk@^4.0.0, chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
@@ -4460,13 +4485,11 @@ eslint-scope@5.1.1:
esrecurse "^4.3.0"
estraverse "^4.1.1"
-eslint-scope@^9.1.0:
- version "9.1.0"
- resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-9.1.0.tgz#dfcb41d6c0d73df6b977a50cf3e91c41ddb4154e"
- integrity sha512-CkWE42hOJsNj9FJRaoMX9waUFYhqY4jmyLFdAdzZr6VaCg3ynLYx4WnOdkaIifGfH4gsUcBTn4OZbHXkpLD0FQ==
+eslint-scope@^8.4.0:
+ version "8.4.0"
+ resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.4.0.tgz#88e646a207fad61436ffa39eb505147200655c82"
+ integrity sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==
dependencies:
- "@types/esrecurse" "^4.3.1"
- "@types/estree" "^1.0.8"
esrecurse "^4.3.0"
estraverse "^5.2.0"
@@ -4480,34 +4503,42 @@ eslint-visitor-keys@^3.4.3:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==
+eslint-visitor-keys@^4.2.1:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz#4cfea60fe7dd0ad8e816e1ed026c1d5251b512c1"
+ integrity sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==
+
eslint-visitor-keys@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-5.0.0.tgz#b9aa1a74aa48c44b3ae46c1597ce7171246a94a9"
integrity sha512-A0XeIi7CXU7nPlfHS9loMYEKxUaONu/hTEzHTGba9Huu94Cq1hPivf+DE5erJozZOky0LfvXAyrV/tcswpLI0Q==
-eslint@^10.0.0:
- version "10.0.0"
- resolved "https://registry.yarnpkg.com/eslint/-/eslint-10.0.0.tgz#c93c36a96d91621d0fbb680db848ea11af56ab1e"
- integrity sha512-O0piBKY36YSJhlFSG8p9VUdPV/SxxS4FYDWVpr/9GJuMaepzwlf4J8I4ov1b+ySQfDTPhc3DtLaxcT1fN0yqCg==
+eslint@^9.39.4:
+ version "9.39.5"
+ resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.39.5.tgz#2a4e3c8b0f753196efae943c8ffaa8730fc6a3fa"
+ integrity sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==
dependencies:
"@eslint-community/eslint-utils" "^4.8.0"
- "@eslint-community/regexpp" "^4.12.2"
- "@eslint/config-array" "^0.23.0"
- "@eslint/config-helpers" "^0.5.2"
- "@eslint/core" "^1.1.0"
- "@eslint/plugin-kit" "^0.6.0"
+ "@eslint-community/regexpp" "^4.12.1"
+ "@eslint/config-array" "^0.21.2"
+ "@eslint/config-helpers" "^0.4.2"
+ "@eslint/core" "^0.17.0"
+ "@eslint/eslintrc" "^3.3.6"
+ "@eslint/js" "9.39.5"
+ "@eslint/plugin-kit" "^0.4.1"
"@humanfs/node" "^0.16.6"
"@humanwhocodes/module-importer" "^1.0.1"
"@humanwhocodes/retry" "^0.4.2"
"@types/estree" "^1.0.6"
- ajv "^6.12.4"
+ ajv "^6.14.0"
+ chalk "^4.0.0"
cross-spawn "^7.0.6"
debug "^4.3.2"
escape-string-regexp "^4.0.0"
- eslint-scope "^9.1.0"
- eslint-visitor-keys "^5.0.0"
- espree "^11.1.0"
- esquery "^1.7.0"
+ eslint-scope "^8.4.0"
+ eslint-visitor-keys "^4.2.1"
+ espree "^10.4.0"
+ esquery "^1.5.0"
esutils "^2.0.2"
fast-deep-equal "^3.1.3"
file-entry-cache "^8.0.0"
@@ -4517,25 +4548,26 @@ eslint@^10.0.0:
imurmurhash "^0.1.4"
is-glob "^4.0.0"
json-stable-stringify-without-jsonify "^1.0.1"
- minimatch "^10.1.1"
+ lodash.merge "^4.6.2"
+ minimatch "^3.1.5"
natural-compare "^1.4.0"
optionator "^0.9.3"
-espree@^11.1.0:
- version "11.1.0"
- resolved "https://registry.yarnpkg.com/espree/-/espree-11.1.0.tgz#7d0c82a69f8df670728dba256264b383fbf73e8f"
- integrity sha512-WFWYhO1fV4iYkqOOvq8FbqIhr2pYfoDY0kCotMkDeNtGpiGGkZ1iov2u8ydjtgM8yF8rzK7oaTbw2NAzbAbehw==
+espree@^10.0.1, espree@^10.4.0:
+ version "10.4.0"
+ resolved "https://registry.yarnpkg.com/espree/-/espree-10.4.0.tgz#d54f4949d4629005a1fa168d937c3ff1f7e2a837"
+ integrity sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==
dependencies:
acorn "^8.15.0"
acorn-jsx "^5.3.2"
- eslint-visitor-keys "^5.0.0"
+ eslint-visitor-keys "^4.2.1"
esprima@^4.0.0, esprima@~4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
-esquery@^1.7.0:
+esquery@^1.5.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.7.0.tgz#08d048f261f0ddedb5bae95f46809463d9c9496d"
integrity sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==
@@ -5034,6 +5066,11 @@ glob@^9.3.3:
minipass "^4.2.4"
path-scurry "^1.6.1"
+globals@^14.0.0:
+ version "14.0.0"
+ resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e"
+ integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==
+
globals@^17.3.0:
version "17.3.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-17.3.0.tgz#8b96544c2fa91afada02747cc9731c002a96f3b9"
@@ -6237,6 +6274,13 @@ js-yaml@^4.1.0:
dependencies:
argparse "^2.0.1"
+js-yaml@^4.3.2:
+ version "4.3.2"
+ resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.3.2.tgz#8e44fb14a2643c59726bb15787b5f1512cb3d3fb"
+ integrity sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==
+ dependencies:
+ argparse "^2.0.1"
+
jsdom@^26.1.0:
version "26.1.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-26.1.0.tgz#ab5f1c1cafc04bd878725490974ea5e8bf0c72b3"
@@ -6450,6 +6494,11 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==
+lodash.merge@^4.6.2:
+ version "4.6.2"
+ resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
+ integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
+
lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.23:
version "4.17.23"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.23.tgz#f113b0378386103be4f6893388c73d0bde7f2c5a"
@@ -6649,7 +6698,7 @@ min-indent@^1.0.0:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
-minimatch@*, minimatch@^10.1.1, minimatch@^10.2.1:
+minimatch@*, minimatch@^10.2.1:
version "10.2.1"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.1.tgz#9d82835834cdc85d5084dd055e9a4685fa56e5f0"
integrity sha512-MClCe8IL5nRRmawL6ib/eT4oLyeKMGCghibcDWK+J0hh0Q8kqSdia6BvbRMVk6mPa6WqUa5uR2oxt6C5jd533A==
@@ -6663,6 +6712,13 @@ minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"
+minimatch@^3.1.5:
+ version "3.1.5"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.5.tgz#580c88f8d5445f2bd6aa8f3cadefa0de79fbd69e"
+ integrity sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==
+ dependencies:
+ brace-expansion "^1.1.7"
+
minimatch@^8.0.2:
version "8.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-8.0.4.tgz#847c1b25c014d4e9a7f68aaf63dedd668a626229"