Params Input Placeholders (#627)

* add `placeholder?: string;` to `StringField` & `NumberField`

* add `placeholder` to inputs

* move values from `defaultValue` to `placeholder`
This commit is contained in:
asharonbaltazar
2023-11-27 18:25:46 -05:00
committed by GitHub
parent 11db39ee73
commit 4cbc09864c
3 changed files with 35 additions and 28 deletions
@@ -42,24 +42,31 @@ export default function ParamInput(props: EditFormInputProps) {
} }
if (type === 'number') { if (type === 'number') {
const { prefix } = paramField; const { prefix, placeholder } = paramField;
const defaultNumberValue = searchParams.get(id) ?? defaultValue; const defaultNumberValue = searchParams.get(id) ?? defaultValue;
return ( return (
<InputGroup variant='ontime-filled'> <InputGroup variant='ontime-filled'>
{prefix && <InputLeftElement pointerEvents='none'>{prefix}</InputLeftElement>} {prefix && <InputLeftElement pointerEvents='none'>{prefix}</InputLeftElement>}
<Input type='number' step='any' variant='ontime-filled' name={id} defaultValue={defaultNumberValue} /> <Input
type='number'
step='any'
variant='ontime-filled'
name={id}
defaultValue={defaultNumberValue}
placeholder={placeholder}
/>
</InputGroup> </InputGroup>
); );
} }
const defaultStringValue = searchParams.get(id) ?? defaultValue; const defaultStringValue = searchParams.get(id) ?? defaultValue;
const { prefix } = paramField; const { prefix, placeholder } = paramField;
return ( return (
<InputGroup variant='ontime-filled'> <InputGroup variant='ontime-filled'>
{prefix && <InputLeftElement pointerEvents='none'>{prefix}</InputLeftElement>} {prefix && <InputLeftElement pointerEvents='none'>{prefix}</InputLeftElement>}
<Input name={id} defaultValue={defaultStringValue} /> <Input name={id} defaultValue={defaultStringValue} placeholder={placeholder} />
</InputGroup> </InputGroup>
); );
} }
@@ -20,7 +20,7 @@ export const getClockOptions = (timeFormat: TimeFormat): ParamField[] => [
description: 'Background colour in hexadecimal', description: 'Background colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000000', placeholder: '00000000 (default)',
}, },
{ {
id: 'text', id: 'text',
@@ -28,7 +28,7 @@ export const getClockOptions = (timeFormat: TimeFormat): ParamField[] => [
description: 'Text colour in hexadecimal', description: 'Text colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: 'fffff', placeholder: 'fffff (default)',
}, },
{ {
id: 'textbg', id: 'textbg',
@@ -36,21 +36,21 @@ export const getClockOptions = (timeFormat: TimeFormat): ParamField[] => [
description: 'Colour of text background in hexadecimal', description: 'Colour of text background in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000000', placeholder: '00000000 (default)',
}, },
{ {
id: 'font', id: 'font',
title: 'Font', title: 'Font',
description: 'Font family, will use the fonts available in the system', description: 'Font family, will use the fonts available in the system',
type: 'string', type: 'string',
defaultValue: 'Arial Black', placeholder: 'Arial Black (default)',
}, },
{ {
id: 'size', id: 'size',
title: 'Text Size', title: 'Text Size',
description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)', description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)',
type: 'number', type: 'number',
defaultValue: 1, placeholder: '1 (default)',
}, },
{ {
id: 'alignx', id: 'alignx',
@@ -65,7 +65,7 @@ export const getClockOptions = (timeFormat: TimeFormat): ParamField[] => [
title: 'Offset Horizontal', title: 'Offset Horizontal',
description: 'Offsets the timer horizontal position by a given amount in pixels', description: 'Offsets the timer horizontal position by a given amount in pixels',
type: 'number', type: 'number',
defaultValue: 0, placeholder: '0 (default)',
}, },
{ {
id: 'aligny', id: 'aligny',
@@ -80,7 +80,7 @@ export const getClockOptions = (timeFormat: TimeFormat): ParamField[] => [
title: 'Offset Vertical', title: 'Offset Vertical',
description: 'Offsets the timer vertical position by a given amount in pixels', description: 'Offsets the timer vertical position by a given amount in pixels',
type: 'number', type: 'number',
defaultValue: 0, placeholder: '0 (default)',
}, },
]; ];
@@ -130,7 +130,7 @@ export const MINIMAL_TIMER_OPTIONS: ParamField[] = [
description: 'Background colour in hexadecimal', description: 'Background colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000000', placeholder: '00000000 (default)',
}, },
{ {
id: 'text', id: 'text',
@@ -138,7 +138,7 @@ export const MINIMAL_TIMER_OPTIONS: ParamField[] = [
description: 'Text colour in hexadecimal', description: 'Text colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: 'fffff', placeholder: 'fffff (default)',
}, },
{ {
id: 'textbg', id: 'textbg',
@@ -146,21 +146,21 @@ export const MINIMAL_TIMER_OPTIONS: ParamField[] = [
description: 'Colour of text background in hexadecimal', description: 'Colour of text background in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000000', placeholder: '00000000 (default)',
}, },
{ {
id: 'font', id: 'font',
title: 'Font', title: 'Font',
description: 'Font family, will use the fonts available in the system', description: 'Font family, will use the fonts available in the system',
type: 'string', type: 'string',
defaultValue: 'Arial Black', placeholder: 'Arial Black (default)',
}, },
{ {
id: 'size', id: 'size',
title: 'Text Size', title: 'Text Size',
description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)', description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)',
type: 'number', type: 'number',
defaultValue: 1, placeholder: '1 (default)',
}, },
{ {
id: 'alignx', id: 'alignx',
@@ -175,7 +175,7 @@ export const MINIMAL_TIMER_OPTIONS: ParamField[] = [
title: 'Offset Horizontal', title: 'Offset Horizontal',
description: 'Offsets the timer horizontal position by a given amount in pixels', description: 'Offsets the timer horizontal position by a given amount in pixels',
type: 'number', type: 'number',
defaultValue: 0, placeholder: '0 (default)',
}, },
{ {
id: 'aligny', id: 'aligny',
@@ -190,7 +190,7 @@ export const MINIMAL_TIMER_OPTIONS: ParamField[] = [
title: 'Offset Vertical', title: 'Offset Vertical',
description: 'Offsets the timer vertical position by a given amount in pixels', description: 'Offsets the timer vertical position by a given amount in pixels',
type: 'number', type: 'number',
defaultValue: 0, placeholder: '0 (default)',
}, },
{ {
id: 'hideovertime', id: 'hideovertime',
@@ -221,14 +221,14 @@ export const LOWER_THIRDS_OPTIONS: ParamField[] = [
title: 'Size', title: 'Size',
description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)', description: 'Scales the current style (0.5 = 50% 1 = 100% 2 = 200%)',
type: 'number', type: 'number',
defaultValue: 1, placeholder: '1 (default)',
}, },
{ {
id: 'transition', id: 'transition',
title: 'Transition', title: 'Transition',
description: 'Transition in time in seconds (default 3)', description: 'Transition in time in seconds (default 3)',
type: 'number', type: 'number',
defaultValue: 3, placeholder: '3 (default)',
}, },
{ {
id: 'text', id: 'text',
@@ -236,7 +236,7 @@ export const LOWER_THIRDS_OPTIONS: ParamField[] = [
description: 'Text colour in hexadecimal', description: 'Text colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '#fffffa', placeholder: 'fffffa (default)',
}, },
{ {
id: 'bg', id: 'bg',
@@ -244,7 +244,7 @@ export const LOWER_THIRDS_OPTIONS: ParamField[] = [
description: 'Text background colour in hexadecimal', description: 'Text background colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000033', placeholder: '00000033 (default)',
}, },
{ {
id: 'key', id: 'key',
@@ -252,14 +252,14 @@ export const LOWER_THIRDS_OPTIONS: ParamField[] = [
description: 'Screen background colour in hexadecimal', description: 'Screen background colour in hexadecimal',
prefix: '#', prefix: '#',
type: 'string', type: 'string',
defaultValue: '00000033', placeholder: '00000033 (default)',
}, },
{ {
id: 'fadeout', id: 'fadeout',
title: 'Fadeout', title: 'Fadeout',
description: 'Time (in seconds) the lower third displays before fading out', description: 'Time (in seconds) the lower third displays before fading out',
type: 'number', type: 'number',
defaultValue: 3, placeholder: '3 (default)',
}, },
]; ];
@@ -284,7 +284,7 @@ export const getBackstageOptions = (timeFormat: TimeFormat): ParamField[] => [
title: 'Events per page', title: 'Events per page',
description: 'Sets the number of events on the page, can cause overlow', description: 'Sets the number of events on the page, can cause overlow',
type: 'number', type: 'number',
defaultValue: 7, placeholder: '7 (default)',
}, },
]; ];
@@ -309,7 +309,7 @@ export const getPublicOptions = (timeFormat: TimeFormat): ParamField[] => [
title: 'Events per page', title: 'Events per page',
description: 'Sets the number of events on the page, can cause overlow', description: 'Sets the number of events on the page, can cause overlow',
type: 'number', type: 'number',
defaultValue: 7, placeholder: '7 (default)',
}, },
]; ];
export const getStudioClockOptions = (timeFormat: TimeFormat): ParamField[] => [ export const getStudioClockOptions = (timeFormat: TimeFormat): ParamField[] => [
@@ -9,8 +9,8 @@ type OptionsField = {
values: Record<string, string>; values: Record<string, string>;
defaultValue?: string; defaultValue?: string;
}; };
type StringField = { type: 'string'; defaultValue: string; prefix?: string }; type StringField = { type: 'string'; defaultValue?: string; prefix?: string; placeholder?: string };
type NumberField = { type: 'number'; defaultValue: number; prefix?: string }; type NumberField = { type: 'number'; defaultValue?: number; prefix?: string; placeholder?: string };
type BooleanField = { type: 'boolean'; defaultValue: boolean }; type BooleanField = { type: 'boolean'; defaultValue: boolean };
export type ParamField = BaseField & (StringField | BooleanField | NumberField | OptionsField); export type ParamField = BaseField & (StringField | BooleanField | NumberField | OptionsField);