Skip to content

Commit aa3ee53

Browse files
committed
right align tetiary label and remove extra div
1 parent 25f8a9a commit aa3ee53

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

packages/react/src/auto/shadcn/inputs/relationships/ShadcnAutoHasManyForm.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ export const makeShadcnAutoHasManyForm = ({
120120
>
121121
<AccordionTrigger onClick={(e) => e.preventDefault()}>
122122
{option.label ? (
123-
<div className="flex justify-between">
124-
<div className="flex flex-col gap-2">
125-
{renderOptionLabel(option.label, "primary")}
123+
<div className="flex justify-between w-full items-center">
124+
<div className="flex flex-col gap-1 items-start">
125+
{option.label && renderOptionLabel(option.label, "primary")}
126126
{option.secondaryLabel && renderOptionLabel(option.secondaryLabel, "secondary")}
127127
</div>
128-
{option.tertiaryLabel && renderOptionLabel(option.tertiaryLabel, "tertiary")}
128+
129+
{option.tertiaryLabel && (
130+
<div className="flex items-center">{renderOptionLabel(option.tertiaryLabel, "tertiary")}</div>
131+
)}
129132
</div>
130133
) : (
131134
<Label>Click to edit...</Label>
@@ -146,20 +149,18 @@ export const makeShadcnAutoHasManyForm = ({
146149
);
147150
})}
148151
</Accordion>
149-
<div>
150-
<Button
151-
type="button"
152-
variant="default"
153-
className="flex gap-1 border border-gray-300 rounded-md p-2 cursor-pointer"
154-
onClick={() => {
155-
append({});
156-
setEditingIndex(fields.length);
157-
}}
158-
>
159-
<PlusCircleIcon className="w-4 h-4" />
160-
<Label className="text-sm font-semibold">Add {modelName}</Label>
161-
</Button>
162-
</div>
152+
<Button
153+
type="button"
154+
variant="default"
155+
className="flex gap-1 border border-gray-300 rounded-md p-2 cursor-pointer"
156+
onClick={() => {
157+
append({});
158+
setEditingIndex(fields.length);
159+
}}
160+
>
161+
<PlusCircleIcon className="w-4 h-4" />
162+
<Label className="text-sm font-semibold">Add {modelName}</Label>
163+
</Button>
163164
</div>
164165
</div>
165166
);

packages/react/src/auto/shadcn/utils.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export const makeShadcnRenderOptionLabel = ({ Label, Badge, Button }: Pick<Shadc
1111
case "secondary":
1212
return <Label className="text-sm text-gray-500">{label}</Label>;
1313
case "tertiary":
14-
return <Badge variant={"outline"}>{label}</Badge>;
14+
return (
15+
<Badge className="text-xs px-3 py-1 inline-flex items-center justify-center" variant={"outline"}>
16+
{label}
17+
</Badge>
18+
);
1519
default:
1620
throw new Error("Invalid option type");
1721
}

0 commit comments

Comments
 (0)