adding "unkown" color to swatch

This commit is contained in:
Bianca Procopio
2024-04-08 09:34:29 -06:00
parent 997be35815
commit 7577f307bf
5 changed files with 25 additions and 10 deletions
@@ -25,5 +25,11 @@ export default function Swatch(props: SwatchProps) {
</div> </div>
); );
} }
if (color === 'unkown') {
<div className={`${classes} ${style.center}`} onClick={handleClick}>
?
</div>;
}
return <div className={classes} style={{ backgroundColor: `${color}` }} onClick={handleClick} />; return <div className={classes} style={{ backgroundColor: `${color}` }} onClick={handleClick} />;
} }
@@ -8,10 +8,12 @@ interface ColourInputProps {
value: string; value: string;
name: 'colour'; name: 'colour';
handleChange: (newValue: 'colour', name: string) => void; handleChange: (newValue: 'colour', name: string) => void;
isMultiple?: boolean;
} }
const colours = [ const colours = [
'', '',
'unkown',
'#FFCC78', // $orange-400 '#FFCC78', // $orange-400
'#FFAB33', // $orange-600 '#FFAB33', // $orange-600
'#77C785', // $green-400 '#77C785', // $green-400
@@ -27,7 +29,7 @@ const colours = [
]; ];
export default function SwatchSelect(props: ColourInputProps) { export default function SwatchSelect(props: ColourInputProps) {
const { value, name, handleChange } = props; const { value, name, handleChange, isMultiple } = props;
const setColour = useCallback( const setColour = useCallback(
(newValue: string) => { (newValue: string) => {
@@ -40,9 +42,15 @@ export default function SwatchSelect(props: ColourInputProps) {
return ( return (
<div className={style.list}> <div className={style.list}>
{colours.map((colour) => ( {colours
<Swatch key={colour} color={colour} onClick={setColour} isSelected={value === colour} /> .filter((colour) => {
))} // Only include unkown if it is multiple
if (!isMultiple && colour === 'unkown') return false;
return true;
})
.map((colour) => (
<Swatch key={colour} color={colour} onClick={setColour} isSelected={value === colour} />
))}
</div> </div>
); );
} }
@@ -65,6 +65,7 @@ export default function EventEditor({ event, handleSubmit, isMultiple }: EventEd
note={event.note} note={event.note}
colour={event.colour} colour={event.colour}
handleSubmit={handleSubmit} handleSubmit={handleSubmit}
isMultiple={isMultiple}
/> />
<div className={style.column}> <div className={style.column}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}> <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
@@ -15,7 +15,7 @@ import useRundown from '../../../common/hooks-query/useRundown';
import { useEventSelection } from '../useEventSelection'; import { useEventSelection } from '../useEventSelection';
import style from './EventEditor.module.scss'; import style from './EventEditor.module.scss';
import EventEditorTest from './EventEditor'; import EventEditor from './EventEditor';
export type EventEditorSubmitActions = keyof OntimeEvent; export type EventEditorSubmitActions = keyof OntimeEvent;
@@ -27,7 +27,6 @@ export default function EventEditorWrapper() {
const { order, rundown } = data; const { order, rundown } = data;
const { updateEvent } = useEventAction(); const { updateEvent } = useEventAction();
const [_searchParams] = useSearchParams(); const [_searchParams] = useSearchParams();
console.log({ selectedEvents, order }, 'size: ', selectedEvents.size);
const [event, setEvent] = useState<OntimeEvent | null>(null); const [event, setEvent] = useState<OntimeEvent | null>(null);
@@ -132,9 +131,9 @@ export default function EventEditorWrapper() {
return ( return (
<div className={style.eventEditor} data-testid='editor-container'> <div className={style.eventEditor} data-testid='editor-container'>
{selectedEvents.size <= 1 ? ( {selectedEvents.size <= 1 ? (
<EventEditorTest event={event} handleSubmit={handleSingleSubmit} isMultiple={false} /> <EventEditor event={event} handleSubmit={handleSingleSubmit} isMultiple={false} />
) : ( ) : (
<EventEditorTest event={getMultipleEvent()} handleSubmit={handleMultipleSubmits} isMultiple={true} /> <EventEditor event={getMultipleEvent()} handleSubmit={handleMultipleSubmits} isMultiple={true} />
)} )}
</div> </div>
); );
@@ -17,10 +17,11 @@ interface EventEditorTitlesProps {
note: string; note: string;
colour: string; colour: string;
handleSubmit: (field: EditorUpdateFields, value: string) => void; handleSubmit: (field: EditorUpdateFields, value: string) => void;
isMultiple?: boolean;
} }
const EventEditorTitles = (props: EventEditorTitlesProps) => { const EventEditorTitles = (props: EventEditorTitlesProps) => {
const { eventId, cue, title, note, colour, handleSubmit } = props; const { eventId, cue, title, note, colour, handleSubmit, isMultiple } = props;
const cueSubmitHandler = (_field: string, newValue: string) => { const cueSubmitHandler = (_field: string, newValue: string) => {
handleSubmit('cue', sanitiseCue(newValue)); handleSubmit('cue', sanitiseCue(newValue));
@@ -46,7 +47,7 @@ const EventEditorTitles = (props: EventEditorTitlesProps) => {
</div> </div>
<div> <div>
<label className={style.inputLabel}>Colour</label> <label className={style.inputLabel}>Colour</label>
<SwatchSelect name='colour' value={colour} handleChange={handleSubmit} /> <SwatchSelect name='colour' value={colour} handleChange={handleSubmit} isMultiple={isMultiple} />
</div> </div>
<EventTextInput field='title' label='Title' initialValue={title} submitHandler={handleSubmit} /> <EventTextInput field='title' label='Title' initialValue={title} submitHandler={handleSubmit} />
<EventTextArea field='note' label='Note' initialValue={note} submitHandler={handleSubmit} /> <EventTextArea field='note' label='Note' initialValue={note} submitHandler={handleSubmit} />