8000 Merge remote-tracking branch 'origin/main' into add-testing-to-ci · pyscript/pyscript@07033ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 07033ea

Browse files
committed
Merge remote-tracking branch 'origin/main' into add-testing-to-ci
2 parents 7cace13 + 508a7d8 commit 07033ea

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

docs/tutorials/getting-started.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,44 @@ fig
211211

212212
The `<py-repl>` tag creates a REPL component that is rendered to the page as a code editor, allowing you to write executable code inline.
213213

214-
## Visual components
214+
## The py-config tag
215215

216-
The following tags control visual attributes of your HTML page.
216+
Use the `<py-config>` tag to set and configure general metadata about your PyScript application in YAML format. If you are unfamiliar with YAML, consider reading [Red Hat's YAML for beginners](https://www.redhat.com/sysadmin/yaml-beginners) guide for more information.
217+
218+
The `<py-config>` tag can be used as follows:
219+
220+
```
221+
<py-config>
222+
- autoclose_loader: false
223+
- runtimes:
224+
-
225+
src: "https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"
226+
name: pyodide-0.20
227+
lang: python
228+
</py-config>
229+
```
230+
231+
The following optional values are supported by `<py-config>`:
232+
233+
* autoclose_loader (boolean): If false, PyScript will not close the loading splash screen when the startup operations finish.
234+
* name (string): Name of the user application. This field can be any string and is to be used by the application author for their own customization purposes.
235+
* version (string): Version of the user application. This field can be any string and is to be used by the application author for their own customization purposes. It is not related to the PyScript version.
236+
* runtimes (List of Runtimes): List of runtime configurations. Each Runtime expects the following fields:
237+
* src (string, Required): URL to the runtime source.
238+
* name (string): Name of the runtime. This field can be any string and is to be used by the application author for their own customization purposes.
239+
* name (string): Programming language supported by the runtime. This field can by used by the application author to provide clarify. It currently has no implications on how PyScript behaves.
240+
241+
## Visual component tags
242+
243+
The following tags can be used to add visual attributes to your HTML page.
217244

218245
| Tag | Description |
219246
| --- | ----------- |
220-
| `<py-inputbox>` | TBD |
221-
| `<py-box>` | TBD |
222-
| `<py-button>` | TBD |
223-
| `<py-list>` | TBD |
224-
| `<py-title>` | TBD |
247+
| `<py-inputbox>` | Adds an input box that can be used to prompt users to enter input values. |
248+
| `<py-box>` | Creates a container object that can be used to host one or more visual components that define how elements of `<py-box>` should align and show on the page. |
249+
| `<py-button>` | Adds a button to which authors can add labels and event handlers for actions on the button, such as `on_focus` or `on_click`. |
250+
| `<py-title>` | Adds a static text title component that styles the text inside the tag as a page title. |
251+
252+
```{note}
253+
All the elements above are experimental and not implemented at their full functionality. Use them with the understanding that the APIs or full support might change or be removed until the visual components are more mature.
254+
```

pyscriptjs/src/components/pyrepl.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,35 @@ export class PyRepl extends BaseEvalElement {
9494
const mainDiv = document.createElement('div');
9595
addClasses(mainDiv, ['parentBox', 'flex', 'flex-col', 'mt-2', 'mx-8', 'relative']);
9696

97+
// Styles that we use to hide the labels whilst also keeping it accessible for screen readers
98+
const labelStyle = 'overflow:hidden; display:block; width:1px; height:1px';
99+
100+
// Code editor Label
101+
this.editorNode.id = 'code-editor';
102+
const editorLabel = document.createElement('label');
103+
editorLabel.innerHTML = 'Python Script Area';
104+
editorLabel.setAttribute('style', labelStyle);
105+
editorLabel.htmlFor = 'code-editor';
106+
107+
mainDiv.append(editorLabel);
108+
97109
// add Editor to main PyScript div
98110
mainDiv.appendChild(this.editorNode);
99111

100112
// Play Button
101113
this.btnRun = document.createElement('button');
114+
this.btnRun.id = 'btnRun';
102115
this.btnRun.innerHTML =
103116
'<svg id="" class="svelte-fa svelte-ps5qeg" style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>';
104117
addClasses(this.btnRun, ['absolute', 'right-1', 'bottom-1', 'opacity-0', 'group-hover:opacity-100']);
118+
119+
// Play Button Label
120+
const btnLabel = document.createElement('label');
121+
btnLabel.innerHTML = 'Python Script Run Button';
122+
btnLabel.setAttribute('style', labelStyle);
123+
btnLabel.htmlFor = 'btnRun';
124+
125+
this.editorNode.appendChild(btnLabel);
105126
this.editorNode.appendChild(this.btnRun);
106127

107128
this.btnRun.addEventListener('click', () => {

0 commit comments

Comments
 (0)
0