Skip to content

Commit 973cfd6

Browse files
committed
chore: more styles
1 parent 5df5f44 commit 973cfd6

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

packages/carbon/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
} from '@rjsf/utils';
1212
import { LayerBackground } from '../components/Layer';
1313
import getCarbonOptions from '../utils';
14+
import { useNestDepth } from '../contexts';
15+
// @ts-expect-error miss types for `@carbon/layout`
16+
import { spacing } from '@carbon/layout';
1417

1518
/** Implement `ArrayFieldTemplate`
1619
*/
@@ -50,6 +53,7 @@ export default function ArrayFieldTemplate<
5053
registry,
5154
uiOptions
5255
);
56+
const depth = useNestDepth();
5357
// Button templates are not overridden in the uiSchema
5458
const {
5559
ButtonTemplates: { AddButton },
@@ -71,6 +75,10 @@ export default function ArrayFieldTemplate<
7175
uiSchema={uiSchema}
7276
registry={registry}
7377
/>
78+
{/* If this object is the very top one, add margin after title section */}
79+
{!depth && (uiOptions.title || title || uiOptions.description || schema.description) && (
80+
<div style={{ height: `calc(${spacing[carbonOptions.gap - 1]} - 0.5rem)` }} />
81+
)}
7482
<LayerBackground padding={carbonOptions.padding}>
7583
<Stack gap={carbonOptions.gap}>
7684
{items.length > 0 && (

packages/carbon/src/RangeWidget/RangeWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
3838
} = props;
3939
const inputProps = getInputProps<T, S, F>(schema, type, options);
4040

41-
const _onChange = (value: string | number) => onChange(value);
41+
const _onChange = ({ value }: { value: string | number }) => onChange(value);
4242
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onBlur(id, value);
4343
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onFocus(id, value);
4444

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
22
import { LabelValue } from '../components/LabelValue';
33
import { FormGroup } from '@carbon/react';
4+
import { useNestDepth } from '../contexts';
45

56
/** Implement `TitleFieldTemplate`
67
*/
@@ -9,11 +10,18 @@ export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSch
910
title,
1011
required,
1112
}: TitleFieldProps<T, S, F>) {
13+
const depth = useNestDepth();
14+
const text = <LabelValue label={title} required={required} hide={false} />;
1215
return (
1316
<div className='title-field'>
14-
<FormGroup legendId={id} legendText={<LabelValue label={title} required={required} hide={false} />}>
15-
{null}
16-
</FormGroup>
17+
{/* show larger text if it's a form title */}
18+
{depth ? (
19+
<FormGroup legendId={id} legendText={text}>
20+
{null}
21+
</FormGroup>
22+
) : (
23+
text
24+
)}
1725
</div>
1826
);
1927
}

packages/carbon/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// @ts-expect-error missing types for `Stack`
2-
import { FormGroup, Stack, TextInput } from '@carbon/react';
1+
import { FormGroup, TextInput } from '@carbon/react';
32
import {
43
ADDITIONAL_PROPERTY_FLAG,
54
FormContextType,
@@ -12,6 +11,8 @@ import {
1211
import { LayerBackground } from '../components/Layer';
1312
import { LabelValue } from '../components/LabelValue';
1413
import getCarbonOptions from '../utils';
14+
// @ts-expect-error miss types for `@carbon/layout`
15+
import { spacing } from '@carbon/layout';
1516

1617
export default function WrapIfAdditionalTemplate<
1718
T = any,
@@ -55,16 +56,18 @@ export default function WrapIfAdditionalTemplate<
5556
<div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'center' }}>
5657
<div style={{ flex: 1 }}>
5758
<LayerBackground padding={carbonOptions.padding}>
58-
<Stack gap={carbonOptions.gap}>
59-
<TextInput
60-
labelText={keyLabel}
61-
type='text'
62-
id={`${id}-key`}
63-
onBlur={(event) => onKeyChange(event.target.value)}
64-
defaultValue={label}
65-
/>
66-
{children}
67-
</Stack>
59+
<div style={{ display: 'flex' }}>
60+
<div style={{ flex: 1, marginInlineEnd: spacing[carbonOptions.padding - 1] }}>
61+
<TextInput
62+
labelText={keyLabel}
63+
type='text'
64+
id={`${id}-key`}
65+
onBlur={(event) => onKeyChange(event.target.value)}
66+
defaultValue={label}
67+
/>
68+
</div>
69+
<div style={{ flex: 1 }}>{children}</div>
70+
</div>
6871
</LayerBackground>
6972
</div>
7073
<div

packages/carbon/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface CarbonOptions {
2222
*/
2323
const defaultCarbonOptions: CarbonOptions = {
2424
gap: 7,
25-
padding: 3,
25+
padding: 5,
2626
};
2727

2828
/** Get carbon theme options from `formContext` and `ui:carbon` uiSchema options.

0 commit comments

Comments
 (0)