Skip to content

Commit 88ea842

Browse files
committed
add one/many tag to cardinality options
1 parent 49d480a commit 88ea842

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

packages/compass-data-modeling/src/components/relationship-drawer-content.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,26 @@ function useRelationshipFormFields(
128128
};
129129
}
130130

131-
const CARDINALITY_OPTIONS = [1, 10, 100, 1000];
131+
const cardinalityTagStyle = css({
132+
color: palette.gray.base,
133+
fontWeight: 'bold',
134+
});
135+
136+
const CardinalityLabel: React.FunctionComponent<{
137+
value: number;
138+
tag: string;
139+
}> = ({ value, tag }) => (
140+
<>
141+
<span className={cardinalityTagStyle}>{tag}</span>&nbsp;{value}
142+
</>
143+
);
144+
145+
const CARDINALITY_OPTIONS = [
146+
{ tag: 'One', value: 1 },
147+
{ tag: 'Many', value: 10 },
148+
{ tag: 'Many', value: 100 },
149+
{ tag: 'Many', value: 1000 },
150+
];
132151

133152
const RelationshipDrawerContent: React.FunctionComponent<
134153
RelationshipDrawerContentProps
@@ -320,10 +339,10 @@ const RelationshipDrawerContent: React.FunctionComponent<
320339
}
321340
}}
322341
>
323-
{CARDINALITY_OPTIONS.map((option) => {
342+
{CARDINALITY_OPTIONS.map(({ tag, value }) => {
324343
return (
325-
<Option key={option} value={String(option)}>
326-
{option}
344+
<Option key={value} value={String(value)}>
345+
<CardinalityLabel value={value} tag={tag} />
327346
</Option>
328347
);
329348
})}
@@ -341,10 +360,10 @@ const RelationshipDrawerContent: React.FunctionComponent<
341360
}
342361
}}
343362
>
344-
{CARDINALITY_OPTIONS.map((option) => {
363+
{CARDINALITY_OPTIONS.map(({ tag, value }) => {
345364
return (
346-
<Option key={option} value={String(option)}>
347-
{option}
365+
<Option key={value} value={String(value)}>
366+
<CardinalityLabel value={value} tag={tag} />
348367
</Option>
349368
);
350369
})}

0 commit comments

Comments
 (0)