Commit 09ddc180 by Moorthy G

feat(shared/markdown): create Markdown component with tailwind typography plugin

parent efdb114d
import type { Meta, StoryObj } from '@storybook/nextjs';
import { Markdown as Component } from './Markdown';
const meta: Meta<typeof Component> = {
title: 'Shared/Markdown',
component: Component
};
export default meta;
type Story = StoryObj<typeof meta>;
const sample =
`# Heading One\n\n` +
`This is a paragraph with **bold** and *italic* text, as well as a [link](https://example.com).\n\n` +
`## Heading Two\n\n` +
`- List item 1\n- List item 2\n- List item 3\n\n` +
'```ts\n' +
'type User = { id: string; name: string }\n' +
'```\n\n' +
`> Blockquote example.`;
export const Markdown: Story = {
args: {
children: sample
}
};
import MarkdownToJsx, { type MarkdownToJSX } from 'markdown-to-jsx';
import { cn } from '@heroui/theme';
export type MarkdownProps = {
children: string;
options?: MarkdownToJSX.Options;
className?: string;
};
export const Markdown = ({ children, options, className }: MarkdownProps) => {
return (
<MarkdownToJsx
options={options}
className={cn(
'text-start prose prose-headings:font-semibold prose-headings:mb-4',
className
)}>
{children}
</MarkdownToJsx>
);
};
export * from './Markdown';
......@@ -15,9 +15,11 @@
"@heroui/react": "2.8.2",
"@storybook/nextjs": "^9.1.2",
"@tailwindcss/postcss": "^4.1.12",
"@tailwindcss/typography": "^0.5.16",
"@types/node": "^24.3.0",
"@types/react": "^19.1.10",
"autoprefixer": "^10.4.21",
"markdown-to-jsx": "^7.7.13",
"next": "^15.4.6",
"postcss": "^8.5.6",
"react": "^19.1.1",
......
......@@ -17,6 +17,9 @@ importers:
'@tailwindcss/postcss':
specifier: ^4.1.12
version: 4.1.12
'@tailwindcss/typography':
specifier: ^0.5.16
version: 0.5.16(tailwindcss@4.1.12)
'@types/node':
specifier: ^24.3.0
version: 24.3.0
......@@ -26,6 +29,9 @@ importers:
autoprefixer:
specifier: ^10.4.21
version: 10.4.21(postcss@8.5.6)
markdown-to-jsx:
specifier: ^7.7.13
version: 7.7.13(react@19.1.1)
next:
specifier: ^15.4.6
version: 15.4.6(@babel/core@7.28.3)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
......@@ -2446,6 +2452,11 @@ packages:
'@tailwindcss/postcss@4.1.12':
resolution: {integrity: sha512-5PpLYhCAwf9SJEeIsSmCDLgyVfdBhdBpzX1OJ87anT9IVR0Z9pjM0FNixCAUAHGnMBGB8K99SwAheXrT0Kh6QQ==}
'@tailwindcss/typography@0.5.16':
resolution: {integrity: sha512-0wDLwCVF5V3x3b1SGXPCDcdsbDHMBe+lkFzBRaHeLvNi+nrrnZ1lA18u+OTWO8iSWU2GxUOCvlXtDuqftc1oiA==}
peerDependencies:
tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1'
'@tanstack/react-virtual@3.11.3':
resolution: {integrity: sha512-vCU+OTylXN3hdC8RKg68tPlBPjjxtzon7Ys46MgrSLE+JhSjSTPvoQifV6DQJeJmA8Q3KT6CphJbejupx85vFw==}
peerDependencies:
......@@ -4454,6 +4465,9 @@ packages:
lodash.camelcase@4.3.0:
resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==}
lodash.castarray@4.4.0:
resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==}
lodash.debounce@4.0.8:
resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==}
......@@ -4519,6 +4533,12 @@ packages:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'}
markdown-to-jsx@7.7.13:
resolution: {integrity: sha512-DiueEq2bttFcSxUs85GJcQVrOr0+VVsPfj9AEUPqmExJ3f8P/iQNvZHltV4tm1XVhu1kl0vWBZWT3l99izRMaA==}
engines: {node: '>= 10'}
peerDependencies:
react: '>= 0.14.0'
math-intrinsics@1.1.0:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
......@@ -4903,6 +4923,10 @@ packages:
peerDependencies:
postcss: ^8.1.0
postcss-selector-parser@6.0.10:
resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
engines: {node: '>=4'}
postcss-selector-parser@7.1.0:
resolution: {integrity: sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==}
engines: {node: '>=4'}
......@@ -9093,6 +9117,14 @@ snapshots:
postcss: 8.5.6
tailwindcss: 4.1.12
'@tailwindcss/typography@0.5.16(tailwindcss@4.1.12)':
dependencies:
lodash.castarray: 4.4.0
lodash.isplainobject: 4.0.6
lodash.merge: 4.6.2
postcss-selector-parser: 6.0.10
tailwindcss: 4.1.12
'@tanstack/react-virtual@3.11.3(react-dom@19.1.1(react@19.1.1))(react@19.1.1)':
dependencies:
'@tanstack/virtual-core': 3.11.3
......@@ -11406,6 +11438,8 @@ snapshots:
lodash.camelcase@4.3.0: {}
lodash.castarray@4.4.0: {}
lodash.debounce@4.0.8: {}
lodash.isplainobject@4.0.6: {}
......@@ -11459,6 +11493,10 @@ snapshots:
dependencies:
semver: 6.3.1
markdown-to-jsx@7.7.13(react@19.1.1):
dependencies:
react: 19.1.1
math-intrinsics@1.1.0: {}
md5.js@1.3.5:
......@@ -11843,6 +11881,11 @@ snapshots:
icss-utils: 5.1.0(postcss@8.5.6)
postcss: 8.5.6
postcss-selector-parser@6.0.10:
dependencies:
cssesc: 3.0.0
util-deprecate: 1.0.2
postcss-selector-parser@7.1.0:
dependencies:
cssesc: 3.0.0
......
@import 'tailwindcss';
@plugin './hero.ts';
@source '../node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}';
@plugin '@tailwindcss/typography';
@custom-variant dark (&:is(.dark *));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment