Skip to content

Commit

Permalink
improve styling of form inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dphuang2 committed Oct 10, 2023
1 parent 6cc5fd7 commit 020c111
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions generator/konfig-next-app/src/components/OperationParameter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Box, Code, Flex, Group, Stack, Text, rem } from '@mantine/core'
import {
Box,
Code,
Flex,
Stack,
Text,
rem,
useMantineTheme,
} from '@mantine/core'
import type { ParameterObject, SchemaObject } from 'konfig-lib'
import { ParameterInput } from './ParameterInput'
import { schemaTypeLabel } from '@/utils/schema-type-label'
Expand Down Expand Up @@ -34,8 +42,9 @@ export function OperationParameter({
noLabel?: boolean
}) {
const description = getDescription(param)
const theme = useMantineTheme()
return (
<Stack>
<Stack pb="lg">
{noLabel ? (
<ParameterInput
owner={owner}
Expand All @@ -47,18 +56,48 @@ export function OperationParameter({
<Flex justify="space-between">
<Box maw="50%" key={param.name}>
<Flex align="center" wrap="wrap">
<Code>{param.name}</Code>
<Text ml={rem(5)} fz="sm">
<Code
style={{
color: theme.colorScheme === 'dark' ? 'white' : 'black',
backgroundColor:
theme.colorScheme === 'dark'
? theme.colors.gray[9]
: theme.colors.gray[0],
border: `1px solid ${
theme.colorScheme === 'dark'
? theme.colors.gray[8]
: theme.colors.gray[4]
}`,
}}
>
{param.name}
</Code>
<Code
style={{
color: theme.colors.gray[6],
}}
ml={rem(5)}
bg="unset"
fz={12}
>
{schemaTypeLabel({ schema: param.schema })}
</Text>
</Code>
{param.required && (
<Text ml={rem(5)} fz="xs" color="red">
<Code style={{ color: 'red' }} bg="unset" ml={rem(5)} fz={12}>
{'required'}
</Text>
</Code>
)}
</Flex>
{description && (
<Text c="dimmed" fz="sm">
<Text
mt="xs"
c={
theme.colorScheme === 'dark'
? theme.colors.gray[5]
: theme.colors.gray[7]
}
fz="sm"
>
{description}
</Text>
)}
Expand Down

0 comments on commit 020c111

Please sign in to comment.