Skip to content

Commit 284b3d8

Browse files
committed
update styles
1 parent d49aa6e commit 284b3d8

File tree

2 files changed

+43
-40
lines changed

2 files changed

+43
-40
lines changed

frontend/src/utils/form.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
padding: 2px;
66
padding-left: var(--mantine-spacing-xs);
77
border-radius: var(--mantine-radius-sm);
8+
9+
background-color: var(--bg-color);
10+
color: var(--text-color);
11+
12+
button {
13+
color: var(--text-color);
14+
}
815
}
916

1017
.valueComponentInnerBox {

frontend/src/utils/formGeneration.tsx

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
2-
import { css } from '@emotion/react'
3-
import type { EmotionJSX, ReactJSXElement } from '@emotion/react/types/jsx-namespace'
42
import {
53
Group,
64
TextInput,
@@ -38,6 +36,7 @@ import {
3836
InputBaseProps,
3937
List,
4038
} from '@mantine/core'
39+
import cx from 'clsx'
4140
import classes from './form.module.css'
4241
import { DateInput, DateTimePicker } from '@mantine/dates'
4342
import { useFocusWithin } from '@mantine/hooks'
@@ -77,7 +76,6 @@ import {
7776
type UseFormSetError,
7877
} from 'react-hook-form'
7978
import { json } from 'react-router-dom'
80-
import { ApiError } from 'src/api/mutator'
8179
import DynamicFormErrorCallout from 'src/components/Callout/DynamicFormErrorCallout'
8280
import PageTemplate from 'src/components/PageTemplate'
8381
import useRenders from 'src/hooks/utils/useRenders'
@@ -332,9 +330,9 @@ export default function DynamicForm<Form extends object, IgnoredFormKeys extends
332330
setHasClickedSubmit(true)
333331
onSubmit(e)
334332
}}
335-
css={css`
336-
min-width: 100%;
337-
`}
333+
style={{
334+
minWidth: '100%',
335+
}}
338336
data-testid={formName}
339337
>
340338
<Button type="submit">Submit</Button>
@@ -362,9 +360,9 @@ type GeneratedInputsProps = {
362360
}
363361

364362
const containerProps = {
365-
css: css`
366-
width: 100%;
367-
`,
363+
style: {
364+
width: '100%',
365+
},
368366
}
369367

370368
function GeneratedInputs({ parentSchemaKey, parentFormField }: GeneratedInputsProps) {
@@ -391,9 +389,9 @@ function GeneratedInputs({ parentSchemaKey, parentFormField }: GeneratedInputsPr
391389
const itemName = singularize(options.labels[schemaKey] || '')
392390

393391
const inputProps = {
394-
css: css`
395-
width: 100%;
396-
`,
392+
style: {
393+
minWidth: '100%',
394+
},
397395
...(!field.isArray && { label: options.labels[schemaKey] }),
398396
required: field.required,
399397
'data-testid': `${formName}-${formField}`,
@@ -418,9 +416,9 @@ function GeneratedInputs({ parentSchemaKey, parentFormField }: GeneratedInputsPr
418416
mt={12}
419417
mb={12}
420418
withBorder
421-
css={css`
422-
width: 100%;
423-
`}
419+
style={{
420+
minWidth: '100%',
421+
}}
424422
>
425423
{/* existing array fields, if any */}
426424
{
@@ -466,9 +464,9 @@ function GeneratedInputs({ parentSchemaKey, parentFormField }: GeneratedInputsPr
466464
<Group
467465
key={schemaKey}
468466
align="center"
469-
css={css`
470-
width: 100%;
471-
`}
467+
style={{
468+
minWidth: '100%',
469+
}}
472470
>
473471
{field.type !== 'object' ? (
474472
<>
@@ -584,9 +582,9 @@ const ArrayOfObjectsChild = ({ index, formField, itemName, schemaKey }) => {
584582
return (
585583
<div
586584
key={index}
587-
css={css`
588-
min-width: 100%;
589-
`}
585+
style={{
586+
minWidth: '100%',
587+
}}
590588
>
591589
<Card mt={12} mb={12} withBorder radius={cardRadius} className={classes.childCard}>
592590
<Flex justify={'space-between'} direction={'row-reverse'} mb={10}>
@@ -618,9 +616,9 @@ function ArrayChildren({ formField, schemaKey, inputProps }: ArrayChildrenProps)
618616
if (options.selectOptions?.[schemaKey]?.type === 'multiselect') {
619617
return (
620618
<Flex
621-
css={css`
622-
width: 100%;
623-
`}
619+
style={{
620+
minWidth: '100%',
621+
}}
624622
>
625623
<GeneratedInput
626624
schemaKey={schemaKey}
@@ -646,9 +644,9 @@ function ArrayChildren({ formField, schemaKey, inputProps }: ArrayChildrenProps)
646644
// IMPORTANT: https://react-hook-form.com/docs/usefieldarray Does not support flat field array.
647645
// if reordering needed change spec to use object. since it's all generated its the easiest way to not mess up validation, etc.
648646
key={k}
649-
css={css`
650-
width: 100%;
651-
`}
647+
style={{
648+
minWidth: '100%',
649+
}}
652650
>
653651
<GeneratedInput
654652
schemaKey={schemaKey}
@@ -670,9 +668,9 @@ function ArrayChildren({ formField, schemaKey, inputProps }: ArrayChildrenProps)
670668
gap={6}
671669
align="left"
672670
direction="column"
673-
css={css`
674-
width: 100%;
675-
`}
671+
style={{
672+
minWidth: '100%',
673+
}}
676674
>
677675
<Card radius={cardRadius} p={6} withBorder className={classes.arrayChildCard}>
678676
{children}
@@ -745,10 +743,10 @@ const GeneratedInput = ({ schemaKey, props, formField, index }: GeneratedInputPr
745743
? // TODO: use convertValueByType
746744
{ valueAsDate: true, setValueAs: (v) => (v === '' ? undefined : new Date(v)) }
747745
: type === 'integer'
748-
? { valueAsNumber: true, setValueAs: (v) => (v === '' ? undefined : parseInt(v, 10)) }
749-
: type === 'number'
750-
? { valueAsNumber: true, setValueAs: (v) => (v === '' ? undefined : parseFloat(v)) }
751-
: null),
746+
? { valueAsNumber: true, setValueAs: (v) => (v === '' ? undefined : parseInt(v, 10)) }
747+
: type === 'number'
748+
? { valueAsNumber: true, setValueAs: (v) => (v === '' ? undefined : parseFloat(v)) }
749+
: null),
752750
})
753751

754752
const fieldState = form.getFieldState(formField)
@@ -1490,12 +1488,10 @@ function CustomPill({
14901488
return (
14911489
<Box
14921490
className={classes.valueComponentOuterBox}
1493-
css={css`
1494-
background-color: ${color};
1495-
* {
1496-
color: ${getContrastYIQ(color) === 'black' ? 'whitesmoke' : '#131313'};
1497-
}
1498-
`}
1491+
style={{
1492+
'--bg-color': color,
1493+
'--text-color': getContrastYIQ(color) === 'black' ? 'whitesmoke' : '#131313',
1494+
}}
14991495
{...props}
15001496
>
15011497
<Box className={classes.valueComponentInnerBox}>{invalidValue || transformer(option)}</Box>

0 commit comments

Comments
 (0)