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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/administration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { noAutofill } from "./no-autofill.js";
authoritative. */
import React, { useEffect, useState } from "react";
import { createRoot } from "react-dom/client";
import { Badge, Box, Button, Paper } from "../tools/webui/mantine.js";
import { Badge, Box, Button, NativeSelect, Paper, TextInput } from "../tools/webui/mantine.js";

const h = React.createElement;
// Access, snapshot freshness and mutation activity are independent dimensions.
Expand Down Expand Up @@ -297,7 +297,7 @@ function ComponentCard({ record, revision }) {
h("fieldset", { className: "fieldset administration-policy", disabled: (ui.getSnapshot().activity === "busy") || (ui.getSnapshot().freshness === "stale") },
h("legend", { className: "fieldset-legend" }, "Release policy"),
h("label", { className: "fieldset field" }, h("span", { className: "fieldset-legend" }, "Release channel"),
h(Box, { component: "select", className: "select select-sm", "aria-label": `${record.component} release channel`, value: channel,
h(NativeSelect, { size: "sm", "aria-label": `${record.component} release channel`, value: channel,
onChange: event => {
const value = event.target.value; setChannel(value);
return mutate(record, "Save release channel", () => {
Expand All @@ -306,7 +306,7 @@ function ComponentCard({ record, revision }) {
});
} }, ...["latest", "stable", "nightly"].map(value => h("option", { key: value, value }, value === "latest" ? "Latest published build" : value === "stable" ? "Stable releases" : "Nightly releases")))),
h("label", { className: "fieldset field" }, h("span", { className: "fieldset-legend" }, "Automatic installation"),
h(Box, { component: "select", className: "select select-sm", "aria-label": `${record.component} automatic installation cadence`, value: cadence,
h(NativeSelect, { size: "sm", "aria-label": `${record.component} automatic installation cadence`, value: cadence,
onChange: event => {
const value = event.target.value; setCadence(value);
return mutate(record, "Save automatic installation", () => {
Expand All @@ -328,7 +328,7 @@ function AlertChannelCard({ revision }) {
h("p", { className: "muted" }, "The bot posts here once when boot repair can't restore the recorded bot or API release."),
!saved && h("p", { id: "alert-channel-unset", className: "muted" }, "No alert channel is set. Mismatches are logged and shown on the component cards."),
h("label", { className: "fieldset field" }, h("span", { className: "fieldset-legend" }, "Alert channel ID"),
h(Box, noAutofill({ component: "input", id: "alert-channel-id", className: "input input-sm", inputMode: "numeric", value, disabled: blocked,
h(TextInput, noAutofill({ id: "alert-channel-id", size: "sm", inputMode: "numeric", value, disabled: blocked,
onChange: event => setValue(event.target.value) }))),
h("div", { className: "card-actions" },
h(Button, { id: "save-alert-channel", type: "button", size: "sm", variant: "default", disabled: blocked || value.trim() === saved,
Expand Down
400 changes: 184 additions & 216 deletions frontend/app.js

Large diffs are not rendered by default.

31 changes: 28 additions & 3 deletions frontend/appearance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { Box, MantineProvider, Notifications } from "../tools/webui/mantine.js";
import { MantineProvider, NativeSelect, Notifications } from "../tools/webui/mantine.js";

const colorSchemeManager = {
get: fallback => fallback,
Expand Down Expand Up @@ -100,13 +100,38 @@ const webuiTheme = {
components: {
Paper: { defaultProps: { radius: "md" } },
Input: {
defaultProps: { size: "md" },
styles: (_theme, { variant, error, success }) => variant === "unstyled" ? {} : {
wrapper: {
"--input-bg": variant === "filled" ? "var(--panel2)" : "var(--input)",
...(error || success ? {} : { "--input-bd": variant === "filled" ? "transparent" : "var(--input-border)" }),
},
},
},
TextInput: { defaultProps: { size: "md" } },
Textarea: { defaultProps: { size: "md" } },
NativeSelect: { defaultProps: { size: "md" } },
Checkbox: {
defaultProps: { size: "md" },
vars: () => ({
root: {
"--checkbox-size": "var(--target-min)",
"--checkbox-color": "var(--accent)",
"--checkbox-icon-color": "var(--accent-text)",
},
}),
},
Switch: {
defaultProps: { size: "md", withThumbIndicator: false },
vars: () => ({
root: {
"--switch-height": "var(--target-min)",
"--switch-width": "2.5rem",
"--switch-thumb-size": ".875rem",
"--switch-color": "var(--accent)",
},
}),
},
Button: {
defaultProps: { variant: "default", size: "md" },
vars: (_theme, { variant = "default", color }) => {
Expand Down Expand Up @@ -298,8 +323,8 @@ export function useAppearance() {

export function Appearance({ preference, setPreference }) {
return React.createElement("label", { className: "theme-picker" }, "Appearance ",
React.createElement(Box, { component: "select",
className: "select select-sm", "aria-label": "Appearance", value: preference,
React.createElement(NativeSelect, {
size: "sm", "aria-label": "Appearance", value: preference,
onChange: event => {
const value = event.target.value;
setPreference(value);
Expand Down
99 changes: 77 additions & 22 deletions frontend/controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ html { font-size: 106.25%; }
a:where(:not(.mantine-Button-root, .mantine-ActionIcon-root)) { color: inherit; text-decoration: none; }
.link { text-decoration: underline; text-underline-offset: .16em; }
:where(button, select) { cursor: pointer; }
:where(button, input, select, textarea):disabled { opacity: .65; }
:where(button, input:not(.mantine-Switch-input), select, textarea):disabled { opacity: .65; }

.mantine-Button-root {
--button-height-md: var(--control-height);
Expand Down Expand Up @@ -57,31 +57,86 @@ a:where(:not(.mantine-Button-root, .mantine-ActionIcon-root)) { color: inherit;
.mantine-Button-root .mantine-Button-section[data-position="left"] { margin-inline-end: .375rem; }
.mantine-Button-root .mantine-Button-section[data-position="right"] { margin-inline-start: .375rem; }

.input, .select, .textarea {
.mantine-Input-wrapper {
--input-height-md: var(--control-height);
--input-height-sm: var(--compact-height);
--input-height-xs: var(--target-min);
--input-height: var(--control-height);
--input-radius: var(--radius-field);
--input-padding: .625rem;
--input-color: var(--text);
--input-bd-focus: var(--accent);
}
.mantine-Input-wrapper[data-size="sm"] { --input-height: var(--compact-height); --input-fz: var(--ui-font-size-sm); }
.mantine-Input-wrapper[data-size="xs"] { --input-height: var(--target-min); --input-fz: var(--ui-font-size-sm); }
.mantine-Input-wrapper:not([data-variant="unstyled"]):not([data-error]):not([data-success]) {
--input-bg: var(--input);
--input-bd: var(--input-border);
}
.mantine-Input-wrapper[data-error]:not([data-variant="unstyled"]) { --input-bd: var(--bad); }
.mantine-Input-input {
max-width: 100%;
min-height: var(--control-height);
padding: .125rem .625rem;
border: 1px solid var(--input-border);
border-radius: var(--radius-field);
height: var(--input-height, var(--control-height));
min-height: var(--input-height, var(--control-height));
border: 1px solid var(--input-bd, var(--input-border));
border-radius: var(--input-radius, var(--radius-field));
background-color: var(--input-bg, var(--input));
color: var(--input-color, var(--text));
}
.mantine-Textarea-input { height: auto; min-height: 4rem; padding-block: .375rem; }

.mantine-Checkbox-root {
--checkbox-size-xs: var(--target-min);
--checkbox-size-sm: var(--target-min);
--checkbox-size-md: var(--target-min);
--checkbox-size: var(--target-min);
--checkbox-color: var(--accent);
--checkbox-icon-color: var(--accent-text);
--label-offset-start: .5rem;
}
.mantine-Checkbox-body, .mantine-Switch-body { align-items: center; }
.mantine-Checkbox-input {
width: var(--checkbox-size, var(--target-min));
height: var(--checkbox-size, var(--target-min));
background-color: var(--input);
color: var(--text);
border: 1px solid var(--input-border);
cursor: pointer;
}
.input-sm, .select-sm, .textarea-sm { min-height: var(--compact-height); font-size: var(--ui-font-size-sm); }
.select:not(select) { display: inline-flex; align-items: center; gap: .375rem; }
.select:not(select)::after {
content: "";
width: .375rem;
height: .375rem;
border-bottom: 1px solid currentColor;
border-inline-end: 1px solid currentColor;
transform: translateY(-.125rem) rotate(45deg);
.mantine-Checkbox-input:checked { background-color: var(--accent); border-color: var(--accent); }
.mantine-Checkbox-input:disabled { cursor: not-allowed; background-color: var(--panel2); border-color: var(--shell-border); }
.mantine-Checkbox-label, .mantine-Switch-label { font-size: .75rem; font-weight: 650; color: var(--text); }

.mantine-Switch-root {
--switch-height-xs: var(--target-min);
--switch-height-sm: var(--target-min);
--switch-height-md: var(--target-min);
--switch-height: var(--target-min);
--switch-width-xs: 2.5rem;
--switch-width-sm: 2.5rem;
--switch-width-md: 2.5rem;
--switch-width: 2.5rem;
--switch-thumb-size-xs: .875rem;
--switch-thumb-size-sm: .875rem;
--switch-thumb-size-md: .875rem;
--switch-thumb-size: .875rem;
--switch-track-label-padding-xs: .1875rem;
--switch-track-label-padding-sm: .1875rem;
--switch-track-label-padding-md: .1875rem;
--switch-track-label-padding: .1875rem;
--switch-color: var(--accent);
--label-offset-start: .5rem;
}
.mantine-Switch-track {
min-height: var(--switch-height, var(--target-min));
min-width: var(--switch-width, 2.5rem);
border: 1px solid var(--input-border);
background-color: var(--panel2);
}
.textarea { min-height: 4rem; padding-block: .375rem; }
.checkbox, .toggle { width: var(--target-min); height: var(--target-min); margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.toggle { appearance: none; display: inline-grid; place-items: center start; height: var(--target-min); width: 2.5rem; padding: .1875rem; border: 1px solid var(--input-border); border-radius: 1rem; background: var(--panel2); }
.toggle::before { content: ""; width: .875rem; height: .875rem; border-radius: 50%; background: var(--muted); }
.toggle:checked { background: var(--accent); border-color: var(--accent); justify-items: end; }
.toggle:checked::before { background: var(--accent-text); }
.mantine-Switch-thumb { background-color: var(--muted); }
.mantine-Switch-input:checked + .mantine-Switch-track { background-color: var(--accent); border-color: var(--accent); }
.mantine-Switch-input:checked + .mantine-Switch-track > .mantine-Switch-thumb { background-color: var(--accent-text); }
.mantine-Switch-input:disabled { opacity: 0; }
.mantine-Switch-input:disabled + .mantine-Switch-track { opacity: .65; cursor: not-allowed; }
Comment thread
jatmn marked this conversation as resolved.
Resolved
:is(button, input, select, textarea):disabled { cursor: not-allowed; }

.card { min-width: 0; background: var(--panel); border-radius: var(--radius-box); }
Expand Down
18 changes: 9 additions & 9 deletions frontend/list-controls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Button, Table, UnstyledButton } from "../tools/webui/mantine.js";
import { Button, NativeSelect, Table, TextInput, UnstyledButton } from "../tools/webui/mantine.js";
import React, { useEffect, useRef, useState } from "react";
import { Icon } from "./icons.js";
import { noAutofill } from "./no-autofill.js";
Expand Down Expand Up @@ -244,8 +244,8 @@ function ListField({ label, children }) {

export function ListPageSize({ controls }) {
return h(ListField, { label: "Rows per page" },
h(Box, { component: "select",
className: "select select-sm",
h(NativeSelect, {
size: "sm",
value: controls.view.pageSize,
onChange: (event) => controls.setPageSize(event.target.value),
}, ...PAGE_SIZES.map((size) => h("option", { key: size, value: size }, size === "all" ? "All" : size))),
Expand All @@ -257,17 +257,17 @@ export function ListControls({ controls, UserPicker, userPickerProps, filterOpti
const { filters } = view;
const { from: fromLabel = "From", to: toLabel = "To" } = config.dateLabels ?? {};
const date = (key, label, bounds) => h(ListField, { label },
h(Box, noAutofill({ component: "input",
className: "input input-sm",
h(TextInput, noAutofill({
size: "sm",
type: "date",
value: filters[key],
...bounds,
onChange: (event) => setFilter(key, event.target.value),
})),
);
const text = (key, label, placeholder, type = "text") => h(ListField, { key, label },
h(Box, noAutofill({ component: "input",
className: "input input-sm",
h(TextInput, noAutofill({
size: "sm",
type,
value: drafts[key] ?? filters[key],
placeholder,
Expand Down Expand Up @@ -304,8 +304,8 @@ export function ListControls({ controls, UserPicker, userPickerProps, filterOpti
if (kind === "text") return text(key, label, placeholder);
if (render) return h(ListField, { key, label }, render(filters[key], (value) => setFilter(key, value)));
return h(ListField, { key, label },
h(Box, { component: "select",
className: "select select-sm",
h(NativeSelect, {
size: "sm",
value: filters[key],
onChange: (event) => setFilter(key, event.target.value),
},
Expand Down
Loading
Loading