From 0c276eeef989954e20758db03160c6ea606d3bb0 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Fri, 21 Feb 2025 01:39:46 +0800 Subject: [PATCH] feat(styles): add mdx.css for improved code styling and line numbering --- src/style/mdx.css | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/style/mdx.css diff --git a/src/style/mdx.css b/src/style/mdx.css new file mode 100644 index 0000000..054d3bc --- /dev/null +++ b/src/style/mdx.css @@ -0,0 +1,35 @@ +[data-rehype-pretty-code-figure] pre { + @apply px-0; +} + +[data-rehype-pretty-code-figure] code { + @apply text-sm !leading-loose md:text-base border-0 p-0; +} + +[data-rehype-pretty-code-figure] code[data-line-numbers] { + counter-reset: line; +} + +[data-rehype-pretty-code-figure] code[data-line-numbers]>[data-line]::before { + counter-increment: line; + content: counter(line); + @apply mr-4 inline-block w-4 text-right text-gray-500; +} + +[data-rehype-pretty-code-figure] [data-line] { + @apply border-l-2 border-l-transparent px-3; +} + +[data-rehype-pretty-code-figure] [data-highlighted-line] { + background: rgba(200, 200, 255, 0.1); + @apply border-l-blue-400; +} + +[data-rehype-pretty-code-figure] [data-highlighted-chars] { + @apply rounded bg-zinc-600/50; + box-shadow: 0 0 0 4px rgb(82 82 91 / 0.5); +} + +[data-rehype-pretty-code-figure] [data-chars-id] { + @apply border-b-2 p-1 shadow-none; +}