From 02e2864abf0ca8391dc767628076b784285b087b Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sun, 17 Aug 2025 10:51:56 +0200 Subject: [PATCH 01/11] refactor: align header columns --- .../views/cuesheet/cuesheet-table/CuesheetTable.module.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/client/src/views/cuesheet/cuesheet-table/CuesheetTable.module.scss b/apps/client/src/views/cuesheet/cuesheet-table/CuesheetTable.module.scss index 152f663105..ffc4e86195 100644 --- a/apps/client/src/views/cuesheet/cuesheet-table/CuesheetTable.module.scss +++ b/apps/client/src/views/cuesheet/cuesheet-table/CuesheetTable.module.scss @@ -32,7 +32,10 @@ $table-header-font-size: calc(1rem - 2px); } &:first-of-type { - margin-left: 4px; // compensate left border + box-sizing: content-box; + border-left: 4px solid $gray-1200; // compensate left border + margin-left: 0px; + padding-inline: 0px; } } From 52c5f23b575b13bc2b7bb69d4618b374d891e2f4 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sun, 17 Aug 2025 10:58:06 +0200 Subject: [PATCH 02/11] refactor: improve scrollbar visibility --- apps/client/src/index.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/client/src/index.scss b/apps/client/src/index.scss index 9c58b90847..af9d5b5642 100644 --- a/apps/client/src/index.scss +++ b/apps/client/src/index.scss @@ -40,8 +40,8 @@ } $track-color: $white-1; -$thumb-color: $gray-1100; -$thumb-color-hover: $gray-900; +$thumb-color: $white-20; +$thumb-color-hover: $white-60; /* Apply a natural box layout model to all elements */ html { @@ -157,7 +157,7 @@ input[type='number'] { /* Track */ ::-webkit-scrollbar-track { - background: $white-1; + background: $track-color; border-radius: 2px; } From c4dadacf9179897d2dac95b70c8fc884dc26234a Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sun, 17 Aug 2025 20:15:16 +0200 Subject: [PATCH 03/11] refactor: center align table elements --- .../src/features/app-settings/panel-utils/PanelUtils.module.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/client/src/features/app-settings/panel-utils/PanelUtils.module.scss b/apps/client/src/features/app-settings/panel-utils/PanelUtils.module.scss index 0f1c458c4c..65258cb03a 100644 --- a/apps/client/src/features/app-settings/panel-utils/PanelUtils.module.scss +++ b/apps/client/src/features/app-settings/panel-utils/PanelUtils.module.scss @@ -106,7 +106,6 @@ $inner-padding: 1rem; th, td { padding: 0.5rem; - vertical-align: top; } tr:nth-child(even) { From ce8d4f4eb340218299ecd21aa5620384911571cd Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Mon, 18 Aug 2025 06:24:23 +0200 Subject: [PATCH 04/11] refactor: make param elements stateful --- .../view-params-editor/InlineColourPicker.tsx | 9 ++- .../view-params-editor/ParamInput.tsx | 70 ++++++++++++++++--- .../view-params-editor/ViewParamPresets.tsx | 0 .../view-params-editor/ViewParamsEditor.tsx | 11 +-- ...ule.scss => ViewParamsPresets.module.scss} | 0 ...ewParamShare.tsx => ViewParamsPresets.tsx} | 6 +- .../view-params-editor/viewParams.types.ts | 2 +- 7 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 apps/client/src/common/components/view-params-editor/ViewParamPresets.tsx rename apps/client/src/common/components/view-params-editor/{ViewParamsShare.module.scss => ViewParamsPresets.module.scss} (100%) rename apps/client/src/common/components/view-params-editor/{ViewParamShare.tsx => ViewParamsPresets.tsx} (86%) diff --git a/apps/client/src/common/components/view-params-editor/InlineColourPicker.tsx b/apps/client/src/common/components/view-params-editor/InlineColourPicker.tsx index 705d591296..208dc543d4 100644 --- a/apps/client/src/common/components/view-params-editor/InlineColourPicker.tsx +++ b/apps/client/src/common/components/view-params-editor/InlineColourPicker.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import SwatchPicker from '../input/colour-input/SwatchPicker'; @@ -16,10 +16,13 @@ const ensureHex = (value: string) => { return value; }; -export default function InlineColourPicker(props: InlineColourPickerProps) { - const { name, value } = props; +export default function InlineColourPicker({ name, value }: InlineColourPickerProps) { const [colour, setColour] = useState(() => ensureHex(value)); + useEffect(() => { + setColour(ensureHex(value)); + }, [value]); + return (
diff --git a/apps/client/src/common/components/view-params-editor/ParamInput.tsx b/apps/client/src/common/components/view-params-editor/ParamInput.tsx index 8d673665a6..f335d9a2ef 100644 --- a/apps/client/src/common/components/view-params-editor/ParamInput.tsx +++ b/apps/client/src/common/components/view-params-editor/ParamInput.tsx @@ -1,10 +1,10 @@ -import { useState } from 'react'; +import { ComponentProps, useEffect, useState } from 'react'; import { useSearchParams } from 'react-router'; import { isStringBoolean } from '../../../features/viewers/common/viewUtils'; import Checkbox from '../checkbox/Checkbox'; import Input from '../input/input/Input'; -import Select from '../select/Select'; +import Select, { SelectOption } from '../select/Select'; import Switch from '../switch/Switch'; import InlineColourPicker from './InlineColourPicker'; @@ -35,7 +35,7 @@ export default function ParamInput({ paramField }: ParamInputProps) { return No options available; } - return ; + return ; } interface EditFormMultiOptionProps { @@ -83,7 +81,12 @@ function MultiOption({ paramField }: EditFormMultiOptionProps) { const { id, values, defaultValue = [''] } = paramField; const optionFromParams = searchParams.getAll(id); - const [paramState, setParamState] = useState(optionFromParams || defaultValue); + const [paramState, setParamState] = useState(optionFromParams.length ? optionFromParams : defaultValue); + + useEffect(() => { + const params = searchParams.getAll(id); + setParamState(params.length ? params : defaultValue); + }, [searchParams, id, defaultValue]); const toggleValue = (value: string, checked: boolean) => { if (checked) { @@ -129,5 +132,52 @@ interface ControlledSwitchProps { } function ControlledSwitch({ id, initialValue }: ControlledSwitchProps) { const [checked, setChecked] = useState(initialValue); + + // synchronise checked state + useEffect(() => { + setChecked(initialValue); + }, [initialValue]); + return ; } + +interface ControlledSelectProps { + id: string; + initialValue?: string; + options: SelectOption[]; +} +function ControlledSelect({ id, initialValue, options }: ControlledSelectProps) { + const [selected, setSelected] = useState(initialValue); + + // synchronise selected state + useEffect(() => { + setSelected(initialValue); + }, [initialValue]); + + return ( + setValue(event.target.value as T)} + {...inputProps} + /> + ); +} diff --git a/apps/client/src/common/components/view-params-editor/ViewParamPresets.tsx b/apps/client/src/common/components/view-params-editor/ViewParamPresets.tsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/client/src/common/components/view-params-editor/ViewParamsEditor.tsx b/apps/client/src/common/components/view-params-editor/ViewParamsEditor.tsx index e771c8bb11..83c5193c9e 100644 --- a/apps/client/src/common/components/view-params-editor/ViewParamsEditor.tsx +++ b/apps/client/src/common/components/view-params-editor/ViewParamsEditor.tsx @@ -1,4 +1,4 @@ -import { FormEvent, memo, useReducer } from 'react'; +import { FormEvent, memo } from 'react'; import { IoClose } from 'react-icons/io5'; import { useSearchParams } from 'react-router'; import { Dialog } from '@base-ui-components/react/dialog'; @@ -12,7 +12,7 @@ import Info from '../info/Info'; import { ViewOption } from './viewParams.types'; import { getURLSearchParamsFromObj } from './viewParams.utils'; import { useViewParamsEditorStore } from './viewParamsEditor.store'; -import { ViewParamsShare } from './ViewParamShare'; +import { ViewParamsPresets } from './ViewParamsPresets'; import ViewParamsSection from './ViewParamsSection'; import style from './ViewParamsEditor.module.scss'; @@ -24,12 +24,9 @@ interface EditFormDrawerProps { export default memo(ViewParamsEditor); function ViewParamsEditor({ target, viewOptions }: EditFormDrawerProps) { - // TODO: can we ensure that the options update when the user loads an alias? const [_, setSearchParams] = useSearchParams(); const { data: viewSettings } = useViewSettings(); const { isOpen, close } = useViewParamsEditorStore(); - // TODO: we dont want this as a permanent option - const forceRender = useReducer((x) => x + 1, 0)[1]; const handleClose = () => { close(); @@ -37,7 +34,6 @@ function ViewParamsEditor({ target, viewOptions }: EditFormDrawerProps) { const resetParams = () => { setSearchParams(); - forceRender(); }; const onParamsFormSubmit = (formEvent: FormEvent) => { @@ -46,7 +42,6 @@ function ViewParamsEditor({ target, viewOptions }: EditFormDrawerProps) { const newParamsObject = Object.fromEntries(new FormData(formEvent.currentTarget)); const newSearchParams = getURLSearchParamsFromObj(newParamsObject, viewOptions); setSearchParams(newSearchParams); - forceRender(); }; return ( @@ -71,7 +66,7 @@ function ViewParamsEditor({ target, viewOptions }: EditFormDrawerProps) { {viewSettings.overrideStyles && ( This view style is being modified by a custom CSS file. )} - +
{viewOptions.map((section) => (
{preset.alias}