Skip to content

Commit d6f5ff6

Browse files
hhfrancoisclaude
andcommitted
docs: update README with new controls (JSON, button, fold markers, download) [skip ci]
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1239ec5 commit d6f5ff6

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ A Web Component for displaying syntax-highlighted code with interactive bindings
44

55
## Features
66

7-
- **Syntax Highlighting**: HTML, SCSS, TypeScript, and Shell
7+
- **Syntax Highlighting**: HTML, SCSS, TypeScript, Shell, and JSON
88
- **Interactive Bindings**: Click to edit values directly in the code
9-
- **Multiple Types**: boolean, number, string, select, color, comment, attribute
9+
- **Multiple Types**: boolean, number, string, select, color, comment, attribute, button
10+
- **Collapsible Sections**: Fold non-interactive line ranges with `${fold}` markers (copy/download stay complete)
1011
- **Theme System**: Built-in IntelliJ default + 4 external CSS themes (vscode, github, solarized, catppuccin) with light/dark variants
1112
- **Mixed Content Highlighting**: HTML with embedded `<style>` (SCSS) and `<script>` (TypeScript) blocks
12-
- **Copy to Clipboard**: Optional copy button with visual feedback
13+
- **Copy & Download**: Optional copy and download buttons (valid JSON export)
1314
- **Line Numbers**: Optional gutter line numbers
1415
- **Accessibility**: ARIA attributes, keyboard navigation (Enter/Space, ArrowUp/Down)
1516
- **Framework Agnostic**: Works with Angular, React, Vue, or vanilla JS
@@ -54,6 +55,8 @@ No build step required — the custom elements `<interactive-code>` and `<code-b
5455
</interactive-code>
5556
```
5657

58+
> **Escaping**: write `\${...}` to display a literal `${...}` in the code instead of interpreting it as a binding or fold marker.
59+
5760
## Binding Types
5861

5962
| Type | Description | Interaction |
@@ -65,6 +68,7 @@ No build step required — the custom elements `<interactive-code>` and `<code-b
6568
| `color` | Color value | Click to open color picker |
6669
| `comment` | Line/block toggle | Click indicator to comment/uncomment (`//`, `#`, `<!-- -->`, `/* */`) |
6770
| `attribute` | HTML attribute toggle | Click to toggle (strikethrough when disabled) |
71+
| `button` | Action token (`value` = label) | Click to fire a `change` event (`e.detail` = `value`); no value edit, no re-render |
6872
| `readonly` | Display only | No interaction |
6973

7074
## API
@@ -73,10 +77,12 @@ No build step required — the custom elements `<interactive-code>` and `<code-b
7377

7478
| Attribute | Type | Description |
7579
|-----------|------|-------------|
76-
| `language` | `'html' \| 'scss' \| 'typescript' \| 'shell'` | Syntax highlighting language |
80+
| `language` | `'html' \| 'scss' \| 'typescript' \| 'shell' \| 'json'` | Syntax highlighting language |
7781
| `color-scheme` | `'light' \| 'dark'` | Color scheme override (inherits from parent by default) |
7882
| `show-separators` | `boolean` | Show visual separators between textarea sections |
7983
| `show-copy` | `boolean` | Show copy-to-clipboard button (top-right corner) |
84+
| `show-download` | `boolean` | Show download button (exports the full content as a file) |
85+
| `download` | `string` | File name for the download button (defaults to `snippet.<ext>`) |
8086
| `show-line-numbers` | `boolean` | Show line numbers in the gutter |
8187

8288
| Property | Type | Description |
@@ -229,6 +235,39 @@ console.log(result.groups);</textarea>
229235
- `condition="!key=value"` - Show when binding value does NOT equal a specific value
230236
- `show-separators` - Add visual separators between sections (customizable via `--code-separator-color`)
231237

238+
### Collapsible Sections
239+
240+
Wrap a range of lines in `${fold}``${/fold}` markers to make it foldable (GitHub-diff style). Collapsed by default; use `${fold:open}` to start expanded. The marker lines are removed from the output — folding is purely visual, and copy/download still export the full content. Works inside a `<textarea>` or via the `code` property, in any language.
241+
242+
```html
243+
<interactive-code language="json" show-download download="config.json">
244+
<textarea>{
245+
"name": "${name}",
246+
${fold}
247+
"_internal": {
248+
"trace": true,
249+
"buffer": 4096
250+
},
251+
${/fold}
252+
"enabled": ${enabled}
253+
}</textarea>
254+
<code-binding key="name" type="string" value="app"></code-binding>
255+
<code-binding key="enabled" type="boolean" value="true"></code-binding>
256+
</interactive-code>
257+
```
258+
259+
### Action Button
260+
261+
A `button` binding is a clickable token that fires a `change` event on every click (no value to edit, no re-render), with `e.detail` set to its `value` — handy for a hub of actions.
262+
263+
```html
264+
<interactive-code language="typescript">
265+
<textarea>await provider.${refresh}();</textarea>
266+
<code-binding key="refresh" type="button" value="refresh()"
267+
onchange="runAction(e.detail)"></code-binding>
268+
</interactive-code>
269+
```
270+
232271
## Themes
233272

234273
The built-in default is IntelliJ (Light/Darcula). Four external CSS themes are available as separate stylesheets:
@@ -266,6 +305,7 @@ The component exposes CSS custom properties for styling. Themes and custom overr
266305
| `--code-text` | Foreground text color |
267306
| `--code-border-radius` | Border radius |
268307
| `--code-line-number` | Line number color |
308+
| `--code-gutter-width` | Width of the left gutter control column |
269309
| `--code-separator-color` | Separator color between textarea sections |
270310
| `--code-focus-outline` | Focus ring color |
271311
| `--code-input-bg` | Inline input background |

0 commit comments

Comments
 (0)