feat: alert & discord components

This commit is contained in:
iCrawl
2022-10-07 17:49:03 +02:00
parent 9f68d73706
commit 5730866073
27 changed files with 113 additions and 123 deletions

View File

@@ -72,6 +72,7 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "^16.11.64",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@types/react-syntax-highlighter": "^15.5.5",
"@unocss/cli": "^0.45.26",

View File

@@ -1,6 +1,6 @@
import { Alert } from '@discordjs/ui';
import { StandardTags } from '@microsoft/tsdoc';
import type { PropsWithChildren } from 'react';
import { VscWarning } from 'react-icons/vsc';
export function Block({ children, title }: PropsWithChildren<{ title: string }>) {
return (
@@ -18,26 +18,6 @@ export function ExampleBlock({
return <Block title={`Example ${exampleIndex ? exampleIndex : ''}`}>{children}</Block>;
}
export function DeprecatedBlock({ children }: PropsWithChildren): JSX.Element {
return (
<div className="my-4">
<div className="relative flex">
<div className="p-4">{children}</div>
<div className="absolute flex h-full w-full">
<div className="rounded-tl-1.5 rounded-bl-1.5 w-4 shrink-0 border-t-2 border-b-2 border-l-2 border-red-500" />
<div className="relative border-b-2 border-red-500">
<div className="-translate-y-50% flex place-items-center gap-2 px-2 text-red-500">
<VscWarning size={20} />
<span className="font-semibold text-red-500">Deprecated</span>
</div>
</div>
<div className="rounded-tr-1.5 rounded-br-1.5 flex-1 border-t-2 border-b-2 border-r-2 border-red-500" />
</div>
</div>
</div>
);
}
export function DefaultValueBlock({ children }: PropsWithChildren): JSX.Element {
return <Block title="Default value">{children}</Block>;
}
@@ -58,7 +38,11 @@ export function BlockComment({
case StandardTags.example.tagNameWithUpperCase:
return <ExampleBlock exampleIndex={index}>{children}</ExampleBlock>;
case StandardTags.deprecated.tagNameWithUpperCase:
return <DeprecatedBlock>{children}</DeprecatedBlock>;
return (
<Alert title="Deprecated" type="danger">
{children}
</Alert>
);
case StandardTags.remarks.tagNameWithUpperCase:
return <RemarksBlock>{children}</RemarksBlock>;
case StandardTags.defaultValue.tagNameWithUpperCase: