diff --git a/packages/ui-components/Common/DataTag/index.module.css b/packages/ui-components/Common/DataTag/index.module.css new file mode 100644 index 0000000000000..1cf2a76d0d094 --- /dev/null +++ b/packages/ui-components/Common/DataTag/index.module.css @@ -0,0 +1,52 @@ +@reference "../../styles/index.css"; + +.dataTag { + @apply flex + items-center + justify-center + rounded-full + font-semibold + text-white; + + &.lg { + @apply size-12 + text-2xl; + } + + &.md { + @apply size-10 + text-xl; + } + + &.sm { + @apply size-8; + } + + &.event { + @apply bg-accent1-600; + } + + &.method { + @apply bg-info-600; + } + + &.property { + @apply bg-green-600; + } + + &.class { + @apply bg-warning-600; + } + + &.module { + @apply bg-red-600; + } + + &.classMethod { + @apply bg-blue-600; + } + + &.ctor { + @apply bg-accent2-600; + } +} diff --git a/packages/ui-components/Common/DataTag/index.stories.tsx b/packages/ui-components/Common/DataTag/index.stories.tsx new file mode 100644 index 0000000000000..2cbbf3f7f4364 --- /dev/null +++ b/packages/ui-components/Common/DataTag/index.stories.tsx @@ -0,0 +1,31 @@ +import type { Meta as MetaObj, StoryObj } from '@storybook/react'; + +import DataTag, { type DataTagProps } from '#ui/Common/DataTag'; + +type Story = StoryObj; +type Meta = MetaObj; + +export const DataTags: Story = { + render: () => ( +
+ {['event', 'method', 'property', 'class', 'module', 'classMethod', 'ctor'] + .map(kind => + ['sm', 'md', 'lg'].map(size => ( +
+ +
+ )) + ) + .flat()} +
+ ), +}; + +export default { component: DataTag } as Meta; diff --git a/packages/ui-components/Common/DataTag/index.tsx b/packages/ui-components/Common/DataTag/index.tsx new file mode 100644 index 0000000000000..ad616fe9009e7 --- /dev/null +++ b/packages/ui-components/Common/DataTag/index.tsx @@ -0,0 +1,37 @@ +import classNames from 'classnames'; +import type { FC } from 'react'; + +import styles from './index.module.css'; + +export type DataTagProps = { + kind: + | 'event' + | 'method' + | 'property' + | 'class' + | 'module' + | 'classMethod' + | 'ctor'; + size?: 'lg' | 'md' | 'sm'; +}; + +// These symbols match up with the types used in +// node core, and the ones defined at +// https://github.com/nodejs/api-docs-tooling/blob/main/src/types.d.ts#L22 (`HeadingMetadataEntry['type']`) +const symbolMap = { + event: 'E', + method: 'M', + property: 'P', + class: 'C', + module: 'M', + classMethod: 'S', + ctor: 'C', +} as const; + +const DataTag: FC = ({ kind, size = 'md' }) => ( +
+ {symbolMap[kind]} +
+); + +export default DataTag;