Skip to content

Commit 255a0ba

Browse files
committed
fix gear idea styles
1 parent 10e0122 commit 255a0ba

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

idea/gear/frontend/src/features/sails/ui/payload-form/payload-form.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Fields, ISailsFuncArg } from '@gear-js/sails-payload-form';
22
import { InputProps, InputWrapper, Select } from '@gear-js/ui';
3+
import { ComponentProps } from 'react';
34
import { Sails } from 'sails-js';
45

56
import { Checkbox, Fieldset, Input, Textarea } from '@/shared/ui';
@@ -24,21 +25,35 @@ type ServiceProps = BaseProps & {
2425

2526
type Props = ConstructorProps | ServiceProps;
2627

28+
function PayloadSelect(props: Omit<ComponentProps<typeof Select>, 'direction' | 'gap'>) {
29+
// eslint-disable-next-line react/no-children-prop
30+
return <Select {...props} direction="y" children="" />;
31+
}
32+
33+
function PayloadInput(props: Omit<ComponentProps<typeof Input>, 'direction' | 'gap'>) {
34+
return <Input {...props} direction="y" />;
35+
}
36+
37+
function PayloadTextarea(props: Omit<ComponentProps<typeof Textarea>, 'direction' | 'gap'>) {
38+
return <Textarea {...props} direction="y" />;
39+
}
40+
2741
function PayloadForm({ sails, select, args, gap, direction = 'x', ...props }: Props) {
2842
const isFunction = 'functionSelect' in props;
2943

3044
return (
3145
<InputWrapper id="payload" label="Payload" size="normal" gap={gap} direction={direction} className={styles.form}>
32-
<Select direction="y" {...select} />
33-
{isFunction && <Select direction="y" {...props.functionSelect} />}
46+
<PayloadSelect {...select} />
47+
{isFunction && <PayloadSelect {...props.functionSelect} />}
3448

3549
<Fields
3650
sails={sails}
3751
args={args}
3852
render={{
39-
ui: { fieldset: Fieldset, select: Select },
40-
rhf: { input: Input, textarea: Textarea, checkbox: Checkbox },
53+
ui: { fieldset: Fieldset, select: PayloadSelect },
54+
rhf: { input: PayloadInput, textarea: PayloadTextarea, checkbox: Checkbox },
4155
}}
56+
renderContainer={Fieldset}
4257
/>
4358
</InputWrapper>
4459
);

utils/sails-payload-form/src/components/fields.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { JSX, PropsWithChildren } from 'react';
12
import { Sails } from 'sails-js';
23
import { ISailsTypeDef } from 'sails-js-types';
34

@@ -18,9 +19,10 @@ type Props = {
1819
sails: Sails;
1920
args: ISailsFuncArg[];
2021
render: FieldProps['render'];
22+
renderContainer?: (props: PropsWithChildren) => JSX.Element;
2123
};
2224

23-
function Fields({ sails, args, render }: Props) {
25+
function Fields({ sails, args, render, renderContainer }: Props) {
2426
const getFieldComponent = (def: ISailsTypeDef) => {
2527
if (def.isEnum) return EnumField;
2628
if (def.isStruct) return StructField;
@@ -45,7 +47,10 @@ function Fields({ sails, args, render }: Props) {
4547
);
4648
};
4749

48-
return args.map(({ typeDef, name }, index) => renderField(typeDef, name, getNestedName('payload', index.toString())));
50+
const renderFields = () =>
51+
args.map(({ typeDef, name }, index) => renderField(typeDef, name, getNestedName('payload', index.toString())));
52+
53+
return args.length && renderContainer ? renderContainer({ children: renderFields() }) : renderFields();
4954
}
5055

5156
export { Fields };

utils/sails-payload-form/src/types/field-props.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ISailsTypeDef } from 'sails-js-types';
66
type FieldsetProps = PropsWithChildren & { legend: string };
77

88
type SelectProps = Pick<SelectHTMLAttributes<HTMLSelectElement>, 'value' | 'onChange'> & {
9-
label?: string;
109
options: readonly OptionHTMLAttributes<HTMLOptionElement>[];
1110
};
1211

0 commit comments

Comments
 (0)