From a518dc48820dfc1549ad44a56c40680cf1ddd149 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Fri, 22 Nov 2024 21:42:27 +0100 Subject: [PATCH] refactor: consolidate event editor styles --- .../components/input/time-input/TimeInput.tsx | 4 +- .../editor-utils/EditorUtils.module.scss | 17 +++++++ .../editors/editor-utils/EditorUtils.tsx | 14 ++++++ .../event-editor/EventEditor.module.scss | 10 ---- .../rundown/event-editor/EventEditor.tsx | 3 +- .../composite/EventEditorTimes.tsx | 47 +++++++++++++------ .../composite/EventEditorTitles.tsx | 7 ++- .../event-editor/composite/EventTextArea.tsx | 11 ++--- .../event-editor/composite/EventTextInput.tsx | 7 +-- 9 files changed, 77 insertions(+), 43 deletions(-) diff --git a/apps/client/src/common/components/input/time-input/TimeInput.tsx b/apps/client/src/common/components/input/time-input/TimeInput.tsx index ef3789286..502bee511 100644 --- a/apps/client/src/common/components/input/time-input/TimeInput.tsx +++ b/apps/client/src/common/components/input/time-input/TimeInput.tsx @@ -5,6 +5,7 @@ import { millisToString, parseUserTime } from 'ontime-utils'; import { useEmitLog } from '../../../stores/logger'; interface TimeInputProps { + id?: T; name: T; submitHandler: (field: T, value: string) => void; time?: number; @@ -15,7 +16,7 @@ interface TimeInputProps { } export default function TimeInput(props: TimeInputProps) { - const { name, submitHandler, time = 0, placeholder, disabled, align = 'center', className } = props; + const { id, name, submitHandler, time = 0, placeholder, disabled, align = 'center', className } = props; const { emitError } = useEmitLog(); const inputRef = useRef(null); const [value, setValue] = useState(''); @@ -117,6 +118,7 @@ export default function TimeInput(props: TimeInputProps) { return ( ; } + +export function Title({ children }: { children: ReactNode }) { + return

{children}

; +} + +export function Label({ children, className, ...elementProps }: LabelHTMLAttributes) { + const classes = cx([style.label, className]); + return ( + + ); +} diff --git a/apps/client/src/features/rundown/event-editor/EventEditor.module.scss b/apps/client/src/features/rundown/event-editor/EventEditor.module.scss index 33e7a09ab..99d5b4edc 100644 --- a/apps/client/src/features/rundown/event-editor/EventEditor.module.scss +++ b/apps/client/src/features/rundown/event-editor/EventEditor.module.scss @@ -40,13 +40,6 @@ gap: 1rem; } -.inputLabel { - display: block; - font-size: calc(1rem - 3px); - color: $label-gray; - margin-bottom: 0.25rem; -} - .decorated { color: var(--decorator-color, $ui-white); background-color: var(--decorator-bg, $gray-1100); @@ -58,7 +51,6 @@ .delayLabel { font-size: calc(1rem - 3px); color: $ontime-delay-text; - margin-top: 0.25rem; &::after { content: '\200b'; @@ -66,8 +58,6 @@ } .switchLabel { - font-size: calc(1rem - 3px); - color: $label-gray; display: flex; align-items: center; gap: 0.5rem; diff --git a/apps/client/src/features/rundown/event-editor/EventEditor.tsx b/apps/client/src/features/rundown/event-editor/EventEditor.tsx index 64513ee03..7cb180669 100644 --- a/apps/client/src/features/rundown/event-editor/EventEditor.tsx +++ b/apps/client/src/features/rundown/event-editor/EventEditor.tsx @@ -8,6 +8,7 @@ import { useEventAction } from '../../../common/hooks/useEventAction'; import useCustomFields from '../../../common/hooks-query/useCustomFields'; import useRundown from '../../../common/hooks-query/useRundown'; import { getAccessibleColour } from '../../../common/utils/styleUtils'; +import * as Editor from '../../editors/editor-utils/EditorUtils'; import { useEventSelection } from '../useEventSelection'; import EventEditorTimes from './composite/EventEditorTimes'; @@ -100,7 +101,7 @@ export default function EventEditor() { />
- Custom Fields + Custom Fields diff --git a/apps/client/src/features/rundown/event-editor/composite/EventEditorTimes.tsx b/apps/client/src/features/rundown/event-editor/composite/EventEditorTimes.tsx index 5090223aa..671db1883 100644 --- a/apps/client/src/features/rundown/event-editor/composite/EventEditorTimes.tsx +++ b/apps/client/src/features/rundown/event-editor/composite/EventEditorTimes.tsx @@ -6,6 +6,7 @@ import { millisToString, parseUserTime } from 'ontime-utils'; import TimeInput from '../../../../common/components/input/time-input/TimeInput'; import { useEventAction } from '../../../../common/hooks/useEventAction'; import { millisToDelayString } from '../../../../common/utils/dateConfig'; +import * as Editor from '../../../editors/editor-utils/EditorUtils'; import TimeInputFlow from '../../time-input-flow/TimeInputFlow'; import style from '../EventEditor.module.scss'; @@ -72,7 +73,7 @@ const EventEditorTimes = (props: EventEditorTimesProps) => { return (
-
Event schedule
+ Event schedule
{
- - + Warning Time +
- + Timer Type
- - + Danger Time +
- + End Action {
- + Colour
diff --git a/apps/client/src/features/rundown/event-editor/composite/EventTextArea.tsx b/apps/client/src/features/rundown/event-editor/composite/EventTextArea.tsx index 50ae550df..7f566e148 100644 --- a/apps/client/src/features/rundown/event-editor/composite/EventTextArea.tsx +++ b/apps/client/src/features/rundown/event-editor/composite/EventTextArea.tsx @@ -1,12 +1,10 @@ -import { CSSProperties, useCallback, useRef } from 'react'; +import { type CSSProperties, useCallback, useRef } from 'react'; import { AutoTextArea } from '../../../../common/components/input/auto-text-area/AutoTextArea'; import useReactiveTextInput from '../../../../common/components/input/text-input/useReactiveTextInput'; -import { cx } from '../../../../common/utils/styleUtils'; +import * as Editor from '../../../editors/editor-utils/EditorUtils'; import { EditorUpdateFields } from '../EventEditor'; -import style from '../EventEditor.module.scss'; - interface CountedTextAreaProps { className?: string; field: EditorUpdateFields; @@ -24,13 +22,12 @@ export default function EventTextArea(props: CountedTextAreaProps) { const { value, onChange, onBlur, onKeyDown } = useReactiveTextInput(initialValue, submitCallback, ref, { submitOnCtrlEnter: true, }); - const classes = cx([style.inputLabel, className]); return (
- + - + {label}