Settings style (#808)

This commit is contained in:
Carlos Valente
2024-03-09 10:56:14 +01:00
committed by GitHub
parent ad71793cf3
commit 78b386742e
10 changed files with 170 additions and 152 deletions
@@ -32,10 +32,10 @@ export default function AppSettings() {
<PanelContent onClose={closeSettings}> <PanelContent onClose={closeSettings}>
{selectedPanel === 'project' && <ProjectPanel />} {selectedPanel === 'project' && <ProjectPanel />}
{selectedPanel === 'general' && <GeneralPanel />} {selectedPanel === 'general' && <GeneralPanel />}
{selectedPanel === 'project_settings' && <ProjectSettingsPanel />}
{selectedPanel === 'sources' && <SourcesPanel />} {selectedPanel === 'sources' && <SourcesPanel />}
{selectedPanel === 'interface' && <InterfacePanel />} {selectedPanel === 'interface' && <InterfacePanel />}
{selectedPanel === 'integrations' && <IntegrationsPanel />} {selectedPanel === 'integrations' && <IntegrationsPanel />}
{selectedPanel === 'project_settings' && <ProjectSettingsPanel />}
{selectedPanel === 'about' && <AboutPanel />} {selectedPanel === 'about' && <AboutPanel />}
{selectedPanel === 'log' && <LogPanel />} {selectedPanel === 'log' && <LogPanel />}
</PanelContent> </PanelContent>
@@ -98,7 +98,7 @@ $inner-padding: 1rem;
} }
.listGroup { .listGroup {
padding: 1rem 2rem 0 2rem; padding: 0 2rem;
> li:not(:last-child) { > li:not(:last-child) {
border-bottom: 1px solid $white-10; border-bottom: 1px solid $white-10;
@@ -130,23 +130,22 @@ $inner-padding: 1rem;
.divider { .divider {
border-top: 1px solid $white-10; border-top: 1px solid $white-10;
margin: 1rem -2rem; margin: 1rem -2rem;
z-index: 999;
} }
$loader-size: 4rem;
.overlay { .overlay {
position: absolute; position: absolute;
z-index: 10; z-index: 10;
width: calc(100% - 2rem); width: 100%;
left: 1rem; height: 100%;
height: calc(80% - 1rem); backdrop-filter: blur(2px);
display: grid; display: grid;
place-content: center; place-content: center;
backdrop-filter: blur(5px); background-color: $black-10;
background-color: rgba(0, 0, 0, 0.01);
} }
.loader { .loader {
$loader-size: 4rem;
width: $loader-size; width: $loader-size;
height: $loader-size; height: $loader-size;
background: $blue-500; background: $blue-500;
@@ -82,10 +82,13 @@ export function Divider() {
return <hr className={style.divider} />; return <hr className={style.divider} />;
} }
export function Loader() { export function Loader({ isLoading }: { isLoading: boolean }) {
if (!isLoading) {
return null;
}
return ( return (
<div className={style.overlay}> <div className={style.overlay}>
<span className={style.loader} /> <div className={style.loader} />
</div> </div>
); );
} }
@@ -59,6 +59,8 @@ export default function GeneralPanelForm() {
reset(data); reset(data);
}; };
const isLoading = status === 'pending';
return ( return (
<Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} id='app-settings'> <Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} id='app-settings'>
<Panel.Card> <Panel.Card>
@@ -82,6 +84,8 @@ export default function GeneralPanelForm() {
</Panel.SubHeader> </Panel.SubHeader>
{submitError && <Panel.Error>{submitError}</Panel.Error>} {submitError && <Panel.Error>{submitError}</Panel.Error>}
<Panel.Divider /> <Panel.Divider />
<Panel.Section>
<Panel.Loader isLoading={isLoading} />
<Panel.ListGroup> <Panel.ListGroup>
<Panel.ListItem> <Panel.ListItem>
<Panel.Field <Panel.Field
@@ -152,6 +156,7 @@ export default function GeneralPanelForm() {
</Select> </Select>
</Panel.ListItem> </Panel.ListItem>
</Panel.ListGroup> </Panel.ListGroup>
</Panel.Section>
</Panel.Card> </Panel.Card>
</Panel.Section> </Panel.Section>
); );
@@ -84,11 +84,11 @@ export default function UrlPresetsForm() {
}); });
}; };
const isPending = status === 'pending'; const isLoading = status === 'pending';
const canSubmit = !isSubmitting && isDirty && isValid; const canSubmit = !isSubmitting && isDirty && isValid;
return ( return (
<Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} data-testId='url-preset-form'> <Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} data-testid='url-preset-form'>
<Panel.Card> <Panel.Card>
<Panel.SubHeader> <Panel.SubHeader>
URL Presets URL Presets
@@ -102,8 +102,6 @@ export default function UrlPresetsForm() {
</div> </div>
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
{isPending && <Panel.Loader />}
<Panel.Section>
<Alert status='info' variant='ontime-on-dark-info'> <Alert status='info' variant='ontime-on-dark-info'>
<AlertIcon /> <AlertIcon />
<AlertDescription> <AlertDescription>
@@ -117,6 +115,8 @@ export default function UrlPresetsForm() {
<ExternalLink href={urlPresetsDocs}>See the docs</ExternalLink> <ExternalLink href={urlPresetsDocs}>See the docs</ExternalLink>
</AlertDescription> </AlertDescription>
</Alert> </Alert>
<Panel.Section>
<Panel.Loader isLoading={isLoading} />
<Panel.Title> <Panel.Title>
Manage presets Manage presets
<Button variant='ontime-subtle' rightIcon={<IoAdd />} size='sm' onClick={addNew}> <Button variant='ontime-subtle' rightIcon={<IoAdd />} size='sm' onClick={addNew}>
@@ -16,8 +16,8 @@ import style from './GeneralPanel.module.scss';
const cssOverrideDocsUrl = 'https://docs.getontime.no/features/custom-styling/'; const cssOverrideDocsUrl = 'https://docs.getontime.no/features/custom-styling/';
export default function ViewSettingsForm() { export default function ViewSettingsForm() {
const { data, status, refetch, isFetching } = useViewSettings(); const { data, status, refetch } = useViewSettings();
const { data: info, isFetching: isFetchingInfo } = useInfo(); const { data: info, status: infoStatus } = useInfo();
const { const {
control, control,
@@ -64,7 +64,7 @@ export default function ViewSettingsForm() {
return null; return null;
} }
const disableInputs = status === 'pending'; const isLoading = status === 'pending' || infoStatus === 'pending';
return ( return (
<Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} id='view-settings'> <Panel.Section as='form' onSubmit={handleSubmit(onSubmit)} id='view-settings'>
@@ -81,8 +81,6 @@ export default function ViewSettingsForm() {
</div> </div>
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
{isFetching || isFetchingInfo ? <Panel.Loader /> : null}
<Panel.ListGroup>
<Alert status='info' variant='ontime-on-dark-info'> <Alert status='info' variant='ontime-on-dark-info'>
<AlertIcon /> <AlertIcon />
<AlertDescription> <AlertDescription>
@@ -93,6 +91,9 @@ export default function ViewSettingsForm() {
<ExternalLink href={cssOverrideDocsUrl}>See the docs</ExternalLink> <ExternalLink href={cssOverrideDocsUrl}>See the docs</ExternalLink>
</AlertDescription> </AlertDescription>
</Alert> </Alert>
<Panel.Section>
<Panel.Loader isLoading={isLoading} />
<Panel.ListGroup>
<Panel.ListItem> <Panel.ListItem>
<Panel.Field <Panel.Field
title='Override CSS styles' title='Override CSS styles'
@@ -125,11 +126,11 @@ export default function ViewSettingsForm() {
maxLength={150} maxLength={150}
width='275px' width='275px'
placeholder='Message shown when timer reaches end' placeholder='Message shown when timer reaches end'
isDisabled={disableInputs}
{...register('endMessage')} {...register('endMessage')}
/> />
</Panel.ListItem> </Panel.ListItem>
</Panel.ListGroup> </Panel.ListGroup>
</Panel.Section>
</Panel.Card> </Panel.Card>
</Panel.Section> </Panel.Section>
); );
@@ -16,7 +16,7 @@ import { cycles } from './integrationUtils';
import style from './IntegrationsPanel.module.css'; import style from './IntegrationsPanel.module.css';
export default function HttpIntegrations() { export default function HttpIntegrations() {
const { data } = useHttpSettings(); const { data, status } = useHttpSettings();
const { mutateAsync } = usePostHttpSettings(); const { mutateAsync } = usePostHttpSettings();
const { const {
@@ -69,6 +69,7 @@ export default function HttpIntegrations() {
}; };
const canSubmit = !isSubmitting && isDirty && isValid; const canSubmit = !isSubmitting && isDirty && isValid;
const isLoading = status === 'pending';
return ( return (
<Panel.Section> <Panel.Section>
@@ -93,6 +94,7 @@ export default function HttpIntegrations() {
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Panel.Section as='form' id='http-form' onSubmit={handleSubmit(onSubmit)} onKeyDown={preventEscape}> <Panel.Section as='form' id='http-form' onSubmit={handleSubmit(onSubmit)} onKeyDown={preventEscape}>
<Panel.Loader isLoading={isLoading} />
{errors?.root && <Panel.Error>{errors.root.message}</Panel.Error>} {errors?.root && <Panel.Error>{errors.root.message}</Panel.Error>}
<Panel.ListGroup> <Panel.ListGroup>
<Panel.ListItem> <Panel.ListItem>
@@ -16,7 +16,7 @@ import { cycles } from './integrationUtils';
import style from './IntegrationsPanel.module.css'; import style from './IntegrationsPanel.module.css';
export default function OscIntegrations() { export default function OscIntegrations() {
const { data } = useOscSettings(); const { data, status } = useOscSettings();
const { mutateAsync } = useOscSettingsMutation(); const { mutateAsync } = useOscSettingsMutation();
const { const {
@@ -75,6 +75,7 @@ export default function OscIntegrations() {
}; };
const canSubmit = !isSubmitting && isDirty && isValid; const canSubmit = !isSubmitting && isDirty && isValid;
const isLoading = status === 'pending';
return ( return (
<Panel.Card> <Panel.Card>
@@ -100,6 +101,7 @@ export default function OscIntegrations() {
<Panel.Divider /> <Panel.Divider />
<Panel.Section as='form' id='osc-form' onSubmit={handleSubmit(onSubmit)} onKeyDown={preventEscape}> <Panel.Section as='form' id='osc-form' onSubmit={handleSubmit(onSubmit)} onKeyDown={preventEscape}>
<Panel.Loader isLoading={isLoading} />
<Panel.Title>OSC Settings</Panel.Title> <Panel.Title>OSC Settings</Panel.Title>
{errors?.root && <Panel.Error>{errors.root.message}</Panel.Error>} {errors?.root && <Panel.Error>{errors.root.message}</Panel.Error>}
<Panel.ListGroup> <Panel.ListGroup>
@@ -51,6 +51,7 @@ export default function ManageProjects() {
const handleCloseForm = () => { const handleCloseForm = () => {
setIsCreatingProject(false); setIsCreatingProject(false);
}; };
return ( return (
<Panel.Section> <Panel.Section>
<Input <Input
@@ -11,7 +11,7 @@ import * as Panel from '../PanelUtils';
import style from './ProjectPanel.module.scss'; import style from './ProjectPanel.module.scss';
export default function ProjectData() { export default function ProjectData() {
const { data, refetch } = useProjectData(); const { data, status, refetch } = useProjectData();
const { const {
handleSubmit, handleSubmit,
@@ -45,9 +45,13 @@ export default function ProjectData() {
} }
}; };
// populate with new data if we get an update
const onReset = () => { const onReset = () => {
reset(data); reset(data);
}; };
const isLoading = status === 'pending';
return ( return (
<Panel.Section as='form' onSubmit={handleSubmit(onSubmit)}> <Panel.Section as='form' onSubmit={handleSubmit(onSubmit)}>
<Panel.Card> <Panel.Card>
@@ -70,6 +74,7 @@ export default function ProjectData() {
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Panel.Section> <Panel.Section>
<Panel.Loader isLoading={isLoading} />
<label> <label>
Project title Project title
<Input <Input