Skip to content

Commit 11b703e

Browse files
authored
chore: update docs to include info for embedding (#42)
1 parent 42aac2a commit 11b703e

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

README.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Testing-Playground ([demo])
1+
# Testing-Playground ([demo][playground])
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
44

@@ -14,8 +14,60 @@ Testing-Library makes it easy to get started with testing. But even then, it can
1414

1515
Testing-Playground provides you with direct feedback. Trying to visualize the direct impact of adding and removing specific (aria) attributes. All to give you some visual support while learning about the importance of aria roles, labels, and attributes.
1616

17-
[testing-library/dom]: https://testing-library.com/docs/dom-testing-library/example-intro
18-
[demo]: https://testing-playground.com
17+
## Embedding
18+
19+
[Testing-Playground][playground] can also be embedded. There is are two embed modes. Manual integration, and `oembed`.
20+
21+
### Oembed
22+
23+
To get started with `oembed`, you'll simply need to copy / paste your direct playground links into a supporting platform.
24+
25+
### Manual integration ([demo][embed-demo])
26+
27+
Follow the following steps if you wish to have an interactive playground on your website.
28+
29+
Add the following snippet directly before your closing `</body>` tag:
30+
31+
```html
32+
<script async src="https://testing-playground.com/embed.js"></script>
33+
```
34+
35+
Create a template element, in which you add to `script` tags. One for `html` and one for `javascript`. Make sure to type them correctly, as that's the what that our embedder uses to populate the different panes.
36+
37+
Note that the `data-testing-playground` attribute is required as well.
38+
39+
```html
40+
<template data-testing-playground>
41+
<script type="text/html"></script>
42+
43+
<script type="text/javascript"></script>
44+
</template>
45+
```
46+
47+
Now, you can populate the `html` and `javascript` elements:
48+
49+
```html
50+
<template data-testing-playground>
51+
<script type="text/html">
52+
<button>one</button>
53+
</script>
54+
55+
<script type="text/javascript">
56+
screen.getByRole('button');
57+
</script>
58+
</template>
59+
```
60+
61+
#### options
62+
63+
To configure your playground even further, add one or more of the following attributes to your opening `<template>` tag. Note, don't remove the `data-testing-playground` attribute!
64+
65+
| attribute | type | default | description |
66+
| ------------ | -------------------------------------------------- | ---------------------------------------- | ----------------------------------------------- |
67+
| data-panes | [markup &#124; preview &#124; query &#124; result] | ['markup', 'preview', 'query', 'result'] | which panes to show, and in what order |
68+
| data-height | number &#124; string | 300 | height of the element |
69+
| data-width | number &#124; string | '100% ' | width of the element |
70+
| data-loading | eager &#124; lazy | 'lazy' | load the frame eager or lazy (see iframe specs) |
1971

2072
## Roadmap
2173

@@ -58,6 +110,9 @@ Thanks goes to these people ([emoji key][emojis]):
58110
This project follows the [all-contributors][all-contributors] specification.
59111
Contributions of any kind welcome!
60112

113+
[testing-library/dom]: https://testing-library.com/docs/dom-testing-library/example-intro
114+
[playground]: https://testing-playground.com
115+
[embed-demo]: https://codepen.io/smeijer/pen/yLYWZmK
61116
[roadmap.md]: https://github.com/smeijer/testing-playground/blob/master/ROADMAP.md
62117
[contributing.md]: https://github.com/smeijer/testing-playground/blob/master/ONTRIBUTING.md
63118
[issue tracker]: https://github.com/smeijer/testing-playground/issues

0 commit comments

Comments
 (0)