Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
dark:bg-neutral-900/40;
}

/*
* A top-level return (not nested inside a `.children` group) attaches to the
* items above it as a full-bleed footer: it bleeds past the container padding
* and is separated by a divider rather than floating on its own.
*/
.return:not(:first-child, .children .return) {
@apply -mx-4
-mb-3
rounded-t-none
border-t
border-neutral-200
dark:border-neutral-900;
}

.children {
@apply relative
flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ const SignatureRoot: FC<PropsWithChildren<SignatureRootProps>> = ({
const titleId = useId();

return (
<section className={styles.container} aria-labelledby={titleId}>
<div className={styles.title} id={titleId}>
{title}
</div>
<section
className={styles.container}
aria-labelledby={title ? titleId : undefined}
>
{title && (
<div className={styles.title} id={titleId}>
{title}
</div>
)}
<div className={styles.root}>{children}</div>
</section>
);
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-components/src/Common/Signature/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const Signature: FC<PropsWithChildren<SignatureProps>> = ({
title,
children,
}) => {
if (title) {
// A Signature without its own name or type is the grouping container, with
// an optional title. Everything else renders as an individual item.
if (!name && !type) {
Comment thread
avivkeller marked this conversation as resolved.
Comment thread
avivkeller marked this conversation as resolved.
return <SignatureRoot title={title}>{children}</SignatureRoot>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,10 @@ const renderSignature = (param: SignatureDefinition, index: number) => (
</Signature>
);

const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => {
if (title) {
const attributes: Array<SignatureDefinition> = [];
const returnTypes: Array<SignatureDefinition> = [];

for (const item of items) {
const target = item.kind === 'return' ? returnTypes : attributes;

target.push(item);
}

return (
<>
<Signature title={title}>
{attributes.map((param, i) => renderSignature(param, i))}
</Signature>

{returnTypes.length > 0 &&
returnTypes.map((param, i) =>
renderSignature(param, attributes.length + i)
)}
</>
);
}

return items.map((param, i) => renderSignature(param, i));
};
const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => (
<Signature title={title}>
{items.map((param, i) => renderSignature(param, i))}
</Signature>
Comment thread
avivkeller marked this conversation as resolved.
);

export default FunctionSignature;
Loading