From ec1915e55ba933445554a91d81b08ccd3858b236 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 8 Oct 2026 19:45:26 +0200 Subject: [PATCH] Improve the Code block demo page Equal-height cards, more realistic snippets, and new cards for header variants, markup and long lines. --- preview/pages/code-block.astro | 83 +++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/preview/pages/code-block.astro b/preview/pages/code-block.astro index 9706251b2..a1d237929 100644 --- a/preview/pages/code-block.astro +++ b/preview/pages/code-block.astro @@ -7,20 +7,37 @@ import CardSubtitle from '@ui/CardSubtitle.astro' import DocsLink from '@ui/DocsLink.astro' import CodeBlock from '@ui/CodeBlock.astro' -const js = `import { Clipboard } from '@tabler/core' +const install = `npm install @tabler/core +pnpm add @tabler/core +yarn add @tabler/core` + +const config = `{ + "name": "my-dashboard", + "dependencies": { + "@tabler/core": "^1.6.0" + } +}` + +const script = `import { Clipboard } from '@tabler/core' const button = document.querySelector('#share') + const clipboard = Clipboard.getOrCreateInstance(button, { text: window.location.href, }) button.addEventListener('copied.bs.clipboard', () => { - console.log('copied') + console.log('Link copied') }) clipboard.copy()` -const shell = 'npm install @tabler/core' +const markup = `` + +const command = 'curl -X POST https://api.example.com/v1/projects/42/deployments -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d \'{"branch": "main", "environment": "production"}\'' --- @@ -28,41 +45,75 @@ const shell = 'npm install @tabler/core'
- + Basic - A .code-block with the copy button in the corner. - + A .code-block around a pre. The copy button sits in the top right corner. +
- + With header - A title or a file name and a language label. - + A title or a file name and a language label. The copy button moves into the header. +
- + Line numbers and highlighted lines - Add .code-block-numbered and mark lines with .code-line-highlight. - + Add .code-block-numbered and mark the lines to point out with .code-line-highlight. +
- + Max height - Add .code-block-scroll to scroll long code vertically. - + Add .code-block-scroll to scroll long code vertically. Change the height with --tblr-code-block-max-height. + + + +
+ +
+ + + Header variants + The header can hold only a title, only a language, or both. +
+ + + +
+
+
+
+ +
+ + + Markup + Any text works, also HTML. The copy button copies the code as written. + + + +
+ +
+ + + Long lines + Lines that do not fit scroll horizontally with the themed scrollbar. The page does not scroll. +
@@ -72,7 +123,7 @@ const shell = 'npm install @tabler/core' Without copy button Set copy={'{false}'} on the component, or leave the button out of the markup. - +