Skip to content

Commit bc10063

Browse files
committed
chore: glue "Returns" to siblings
1 parent c582f6e commit bc10063

4 files changed

Lines changed: 31 additions & 32 deletions

File tree

packages/ui-components/src/Common/Signature/SignatureItem/index.module.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
dark:bg-neutral-900/40;
1515
}
1616

17+
/*
18+
* A top-level return (not nested inside a `.children` group) attaches to the
19+
* items above it as a full-bleed footer: it bleeds past the container padding
20+
* and is separated by a divider rather than floating on its own.
21+
*/
22+
.return:not(:first-child, .children .return) {
23+
@apply -mx-4
24+
-mb-3
25+
rounded-t-none
26+
border-t
27+
border-neutral-200
28+
dark:border-neutral-900;
29+
}
30+
1731
.children {
1832
@apply relative
1933
flex

packages/ui-components/src/Common/Signature/SignatureRoot/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ const SignatureRoot: FC<PropsWithChildren<SignatureRootProps>> = ({
1414
const titleId = useId();
1515

1616
return (
17-
<section className={styles.container} aria-labelledby={titleId}>
18-
<div className={styles.title} id={titleId}>
19-
{title}
20-
</div>
17+
<section
18+
className={styles.container}
19+
aria-labelledby={title ? titleId : undefined}
20+
>
21+
{title && (
22+
<div className={styles.title} id={titleId}>
23+
{title}
24+
</div>
25+
)}
2126
<div className={styles.root}>{children}</div>
2227
</section>
2328
);

packages/ui-components/src/Common/Signature/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const Signature: FC<PropsWithChildren<SignatureProps>> = ({
2121
title,
2222
children,
2323
}) => {
24-
if (title) {
24+
// A Signature without its own name or type is the grouping container, with
25+
// an optional title. Everything else renders as an individual item.
26+
if (!name && !type) {
2527
return <SignatureRoot title={title}>{children}</SignatureRoot>;
2628
}
2729

packages/ui-components/src/Containers/FunctionSignature/index.tsx

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,10 @@ const renderSignature = (param: SignatureDefinition, index: number) => (
2727
</Signature>
2828
);
2929

30-
const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => {
31-
if (title) {
32-
const attributes: Array<SignatureDefinition> = [];
33-
const returnTypes: Array<SignatureDefinition> = [];
34-
35-
for (const item of items) {
36-
const target = item.kind === 'return' ? returnTypes : attributes;
37-
38-
target.push(item);
39-
}
40-
41-
return (
42-
<>
43-
<Signature title={title}>
44-
{attributes.map((param, i) => renderSignature(param, i))}
45-
</Signature>
46-
47-
{returnTypes.length > 0 &&
48-
returnTypes.map((param, i) =>
49-
renderSignature(param, attributes.length + i)
50-
)}
51-
</>
52-
);
53-
}
54-
55-
return items.map((param, i) => renderSignature(param, i));
56-
};
30+
const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => (
31+
<Signature title={title}>
32+
{items.map((param, i) => renderSignature(param, i))}
33+
</Signature>
34+
);
5735

5836
export default FunctionSignature;

0 commit comments

Comments
 (0)