mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
refactor: migrate edit to custom component
This commit is contained in:
committed by
Carlos Valente
parent
629204810f
commit
e090bde8bb
@@ -3,6 +3,7 @@
|
|||||||
.baseButton {
|
.baseButton {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
|
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtle {
|
.subtle {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
background-color: $gray-1250;
|
background-color: $gray-1250;
|
||||||
color: $ui-white;
|
color: $ui-white;
|
||||||
|
border-left: 1px solid $gray-1200;
|
||||||
|
|
||||||
&[data-open] {
|
&[data-open] {
|
||||||
transform: translateX(0%);
|
transform: translateX(0%);
|
||||||
|
|||||||
@@ -1,27 +1,53 @@
|
|||||||
.editModal {
|
.editModal {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
z-index: 2;
|
top: 10%;
|
||||||
margin: 0 auto;
|
|
||||||
top: 20%;
|
|
||||||
left: 50%;
|
left: 50%;
|
||||||
|
|
||||||
|
z-index: 2;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
|
|
||||||
padding: 1rem;
|
padding-inline: 1rem;
|
||||||
|
min-width: min(720px, 90vw);
|
||||||
|
|
||||||
background-color: $gray-1250;
|
background-color: $gray-1250;
|
||||||
|
color: $ui-white;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: $box-shadow-l1;
|
||||||
|
border: 1px solid $gray-1200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding-block: 1rem;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
max-height: min(80vh, 600px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
background-color: var(--user-bg);
|
||||||
|
width: fit-content;
|
||||||
|
padding-inline: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
padding-block: 1rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
min-width: min(400px, 90vw);
|
|
||||||
box-shadow: $box-shadow-l1;
|
|
||||||
|
|
||||||
.buttonRow {
|
button {
|
||||||
margin-top: auto;
|
width: 100%;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 1rem;
|
|
||||||
|
|
||||||
button {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { useRef, useState } from 'react';
|
import { Fragment, useRef, useState } from 'react';
|
||||||
import { Button, Textarea } from '@chakra-ui/react';
|
import { IoClose } from 'react-icons/io5';
|
||||||
|
import { Dialog } from '@base-ui-components/react/dialog';
|
||||||
|
import { Textarea } from '@chakra-ui/react';
|
||||||
import { OntimeEvent } from 'ontime-types';
|
import { OntimeEvent } from 'ontime-types';
|
||||||
|
|
||||||
|
import Button from '../../../common/components/buttons/Button';
|
||||||
|
import IconButton from '../../../common/components/buttons/IconButton';
|
||||||
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
||||||
import type { EditEvent } from '../Operator';
|
import { EditEvent } from '../operator.types';
|
||||||
|
|
||||||
import style from './EditModal.module.scss';
|
import style from './EditModal.module.scss';
|
||||||
|
|
||||||
@@ -44,34 +48,55 @@ export default function EditModal(props: EditModalProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.editModal}>
|
<Dialog.Root
|
||||||
<div>{`Editing fields in cue ${event.cue}`}</div>
|
open
|
||||||
{event.subscriptions.map((field) => {
|
onOpenChange={(isOpen) => {
|
||||||
return (
|
if (!isOpen) onClose();
|
||||||
<div key={field.label}>
|
}}
|
||||||
<label>{field.label}</label>
|
>
|
||||||
<Textarea
|
<Dialog.Portal>
|
||||||
ref={(element) => {
|
<Dialog.Popup className={style.editModal}>
|
||||||
if (element) inputRef.current.push(element);
|
<div className={style.title}>
|
||||||
}}
|
{`Editing fields in cue ${event.cue}`}
|
||||||
variant='ontime-filled'
|
<IconButton variant='subtle-white' onClick={onClose} disabled={loading}>
|
||||||
placeholder={`Add value for ${field.label} field`}
|
<IoClose />
|
||||||
defaultValue={field.value}
|
</IconButton>
|
||||||
data-field={field.id}
|
|
||||||
isDisabled={loading}
|
|
||||||
resize='none'
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
<div className={style.body}>
|
||||||
})}
|
{event.subscriptions.map((field) => {
|
||||||
<div className={style.buttonRow}>
|
return (
|
||||||
<Button variant='ontime-subtle' onClick={onClose} isDisabled={loading}>
|
<Fragment key={field.id}>
|
||||||
Cancel
|
<label htmlFor={field.id} className={style.label} style={{ '--user-bg': field.colour }}>
|
||||||
</Button>
|
{field.label}
|
||||||
<Button variant='ontime-filled' onClick={handleSave} isDisabled={loading}>
|
</label>
|
||||||
Save
|
<Textarea
|
||||||
</Button>
|
name={field.id}
|
||||||
</div>
|
ref={(element) => {
|
||||||
</div>
|
if (element) inputRef.current.push(element);
|
||||||
|
}}
|
||||||
|
variant='ontime-filled'
|
||||||
|
placeholder={`Add value for ${field.label} field`}
|
||||||
|
defaultValue={field.value}
|
||||||
|
data-field={field.id}
|
||||||
|
isDisabled={loading}
|
||||||
|
resize='none'
|
||||||
|
rows={5}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.footer}>
|
||||||
|
<Button variant='subtle' size='large' onClick={onClose} disabled={loading}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button variant='primary' size='large' onClick={handleSave} disabled={loading}>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Dialog.Popup>
|
||||||
|
</Dialog.Portal>
|
||||||
|
</Dialog.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user