mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
refactor: properly handling spacing
This commit is contained in:
@@ -16,7 +16,7 @@ export function CommentSection({ node, textClassName }: RemarksBlockProps): JSX.
|
|||||||
const createNode = (node: ReturnType<CommentNode['toJSON']>, idx?: number): ReactNode => {
|
const createNode = (node: ReturnType<CommentNode['toJSON']>, idx?: number): ReactNode => {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case 'PlainText':
|
case 'PlainText':
|
||||||
return <span>{(node as ReturnType<PlainTextCommentNode['toJSON']>).text}</span>;
|
return <span key={idx}>{(node as ReturnType<PlainTextCommentNode['toJSON']>).text}</span>;
|
||||||
case 'Paragraph':
|
case 'Paragraph':
|
||||||
return (
|
return (
|
||||||
<p key={idx} className={textClassName}>
|
<p key={idx} className={textClassName}>
|
||||||
@@ -24,7 +24,7 @@ export function CommentSection({ node, textClassName }: RemarksBlockProps): JSX.
|
|||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
case 'SoftBreak':
|
case 'SoftBreak':
|
||||||
return <br />;
|
return <br key={idx} />;
|
||||||
case 'LinkTag': {
|
case 'LinkTag': {
|
||||||
const { codeDestination, urlDestination, text } = node as ReturnType<LinkTagCommentNode['toJSON']>;
|
const { codeDestination, urlDestination, text } = node as ReturnType<LinkTagCommentNode['toJSON']>;
|
||||||
|
|
||||||
|
|||||||
@@ -42,24 +42,28 @@ export function DocContainer({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-h-full overflow-y-auto overflow-x-clip px-10 pt-5 pb-10">
|
<div className="min-h-full overflow-y-auto overflow-x-clip px-10 pt-5 pb-10">
|
||||||
<Section iconElement={<VscListSelection />} title="Summary" className="dark:text-white">
|
<Section iconElement={<VscListSelection />} title="Summary" className="dark:text-white mb-5">
|
||||||
{summary ? (
|
{summary ? (
|
||||||
<CommentSection textClassName="text-dark-100 dark:text-gray-300" node={summary} />
|
<CommentSection textClassName="text-dark-100 dark:text-gray-300" node={summary} />
|
||||||
) : (
|
) : (
|
||||||
<p className="text-dark-100 dark:text-gray-300">No summary provided.</p>
|
<p className="text-dark-100 dark:text-gray-300">No summary provided.</p>
|
||||||
)}
|
)}
|
||||||
</Section>
|
</Section>
|
||||||
<SyntaxHighlighter
|
<div className={extendsTokens?.length ? 'mb-2' : 'mb-10'}>
|
||||||
wrapLines
|
<SyntaxHighlighter
|
||||||
wrapLongLines
|
wrapLines
|
||||||
language="typescript"
|
wrapLongLines
|
||||||
style={vscDarkPlus}
|
language="typescript"
|
||||||
codeTagProps={{ style: { fontFamily: 'JetBrains Mono' } }}
|
style={vscDarkPlus}
|
||||||
>
|
codeTagProps={{ style: { fontFamily: 'JetBrains Mono' } }}
|
||||||
{excerpt}
|
>
|
||||||
</SyntaxHighlighter>
|
{excerpt}
|
||||||
|
</SyntaxHighlighter>
|
||||||
|
</div>
|
||||||
{extendsTokens?.length ? (
|
{extendsTokens?.length ? (
|
||||||
<div className="flex flex-row items-center dark:text-white gap-3">
|
<div
|
||||||
|
className={`flex flex-row items-center dark:text-white gap-3 ${implementsTokens?.length ? '' : 'mb-10'}`}
|
||||||
|
>
|
||||||
<h3 className="m-0">Extends</h3>
|
<h3 className="m-0">Extends</h3>
|
||||||
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
|
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
|
||||||
<p className="font-mono break-all">
|
<p className="font-mono break-all">
|
||||||
@@ -68,7 +72,7 @@ export function DocContainer({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{implementsTokens?.length ? (
|
{implementsTokens?.length ? (
|
||||||
<div className="flex flex-row items-center dark:text-white gap-3">
|
<div className={`flex flex-row items-center dark:text-white gap-3 mb-10`}>
|
||||||
<h3 className="m-0">Implements</h3>
|
<h3 className="m-0">Implements</h3>
|
||||||
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
|
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
|
||||||
<p className="font-mono break-all">
|
<p className="font-mono break-all">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface SectionProps {
|
|||||||
defaultClosed?: boolean;
|
defaultClosed?: boolean;
|
||||||
iconElement?: JSX.Element;
|
iconElement?: JSX.Element;
|
||||||
showSeparator?: boolean;
|
showSeparator?: boolean;
|
||||||
|
margin?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Section({
|
export function Section({
|
||||||
@@ -19,6 +20,7 @@ export function Section({
|
|||||||
defaultClosed,
|
defaultClosed,
|
||||||
iconElement,
|
iconElement,
|
||||||
showSeparator = true,
|
showSeparator = true,
|
||||||
|
margin = true,
|
||||||
}: SectionProps) {
|
}: SectionProps) {
|
||||||
const [collapsed, setCollapsed] = useState(defaultClosed ?? false);
|
const [collapsed, setCollapsed] = useState(defaultClosed ?? false);
|
||||||
|
|
||||||
@@ -47,8 +49,16 @@ export function Section({
|
|||||||
height: 'auto',
|
height: 'auto',
|
||||||
paddingLeft: '1.75rem',
|
paddingLeft: '1.75rem',
|
||||||
paddingRight: '1.75rem',
|
paddingRight: '1.75rem',
|
||||||
|
marginBottom: margin ? '1.25rem' : 0,
|
||||||
|
},
|
||||||
|
collapsed: {
|
||||||
|
opacity: 0,
|
||||||
|
height: 0,
|
||||||
|
paddingLeft: '1.75rem',
|
||||||
|
paddingRight: '1.75rem',
|
||||||
|
paddingBottom: 0,
|
||||||
|
marginBottom: 0,
|
||||||
},
|
},
|
||||||
collapsed: { opacity: 0, height: 0, paddingLeft: '1.75rem', paddingRight: '1.75rem', paddingBottom: 0 },
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user