Skip to content

Commit 64ee995

Browse files
committed
refactor: function return type container
1 parent 62a66aa commit 64ee995

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
}
1313

1414
.root {
15-
@apply flex
15+
@apply mb-1
16+
flex
1617
flex-col
1718
gap-4
1819
rounded-sm

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ export const Nested: Story = {
118118
},
119119
],
120120
},
121+
{
122+
name: 'Returns',
123+
kind: 'return',
124+
description: 'description',
125+
type: (
126+
<>
127+
<a href="#">&lt;Promise&gt;</a>|
128+
<a href="#">&lt;AsyncIterable&gt;</a>
129+
</>
130+
),
131+
},
121132
],
122133
},
123134
};

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,24 @@ const renderSignature = (param: SignatureDefinition, index: number) => (
2929

3030
const FunctionSignature: FC<FunctionSignatureProps> = ({ title, items }) => {
3131
if (title) {
32+
const attributes: Array<SignatureDefinition> = [];
33+
const returnTypes: Array<SignatureDefinition> = [];
34+
35+
for (const item of items) {
36+
(item.kind === 'return' ? returnTypes : attributes).push(item);
37+
}
38+
3239
return (
33-
<Signature title={title}>
34-
{items.map((param, i) => renderSignature(param, i))}
35-
</Signature>
40+
<>
41+
<Signature title={title}>
42+
{attributes.map((param, i) => renderSignature(param, i))}
43+
</Signature>
44+
{returnTypes.length > 0 && (
45+
<Signature>
46+
{returnTypes.map((param, i) => renderSignature(param, i))}
47+
</Signature>
48+
)}
49+
</>
3650
);
3751
}
3852

0 commit comments

Comments
 (0)