Skip to content

Commit 97261a2

Browse files
updated docs
1 parent 00f7fdc commit 97261a2

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

README.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,42 @@ npm i @vanillawc/wc-code
2626
<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-code/index.js"></script>
2727
```
2828

29-
## Demo
30-
31-
TODO: Try it on [WebComponents.dev]({{link}})
32-
33-
3429
## Usage
3530

36-
<!--
3731
Attributes
3832

39-
- title - the title that displays on the card
40-
- type - the content type ()
41-
-->
4233

43-
<!--
44-
Properties
34+
- `src` - load an external source file
35+
- `style` - CSS styling (default `height:100%;width:100%;`)
36+
- `mode` - the language you want to use
37+
- `viewport-margin`<sup>1</sup> - sets the `viewportMargin` option of the CodeMirrror editor instance (default `10`)
38+
- `readonly` - sets the codemirror's "readOnly" configuration attribute to true, you may set `readonly="nocursor"` if you want to disable the cursor and not let the user copy the text inside
4539

46-
- title - the title that displays on the card
47-
- type - the content type ()
48-
-->
40+
*<sup>1</sup>Setting `viewport-margin` to `infinity` will auto-resize the editor to its contents. To see this in action, check out the [CodeMirror Auto-Resize Demo](https://codemirror.net/demo/resize.html).*
4941

5042
### Basic Usage
5143

52-
<!-- description -->
44+
all language modes are dynamically loaded, and the css is dynamically loaded, you don't need to add any additional files for them
45+
46+
```html
47+
<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-code/index.js"></script>
48+
<wc-code mode="javascript">
49+
<script type="wc-content">
50+
const resp = await fetch("https://sv443.net/jokeapi/v2/joke/Any?blacklistFlags=nsfw,racist,sexist&format=txt");
51+
const text = await resp.text();
52+
console.log(text);
53+
</script>
54+
</wc-code>
55+
```
5356

5457
```html
55-
<!-- code sample -->
58+
<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-code/index.js"></script>
59+
<p>Python code example here</p>
60+
<wc-code mode="python">
61+
<script type="wc-content">
62+
a = 1
63+
b = 5
64+
print(a, b, a+b)
65+
</script>
66+
</wc-code>
5667
```

0 commit comments

Comments
 (0)