mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 11:15:36 -05:00
add app loading splash screen and AppConfig (#279)
* add PyLoader class * create global loader during app creation time and remove it when pyscript loading operations are done * make the loader global and open/close when apps is starting. Also add concept of app config so users can set if they want to autoclose the loader of handle it themselves * add pyconfig file * auto add global config if there's no config set in the page * remove changes to simple_clock example
This commit is contained in:
55
pyscriptjs/src/components/pyconfig.ts
Normal file
55
pyscriptjs/src/components/pyconfig.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import * as jsyaml from 'js-yaml';
|
||||
import { BaseEvalElement } from './base';
|
||||
import { appConfig } from '../stores';
|
||||
|
||||
let appConfig_;
|
||||
|
||||
appConfig.subscribe(value => {
|
||||
appConfig_ = value;
|
||||
});
|
||||
|
||||
export type AppConfig = {
|
||||
autoclose_loader: boolean;
|
||||
name?: string;
|
||||
version?: string;
|
||||
};
|
||||
|
||||
export class PyConfig extends BaseEvalElement {
|
||||
shadow: ShadowRoot;
|
||||
wrapper: HTMLElement;
|
||||
theme: string;
|
||||
widths: Array<string>;
|
||||
label: string;
|
||||
mount_name: string;
|
||||
details: HTMLElement;
|
||||
operation: HTMLElement;
|
||||
code: string;
|
||||
values: AppConfig;
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.code = this.innerHTML;
|
||||
this.innerHTML = '';
|
||||
|
||||
this.values = jsyaml.load(this.code);
|
||||
if (this.values === undefined){
|
||||
this.values = {
|
||||
autoclose_loader: true,
|
||||
};
|
||||
}
|
||||
appConfig.set(this.values);
|
||||
console.log("config set", this.values);
|
||||
}
|
||||
|
||||
log(msg: string){
|
||||
const newLog = document.createElement('p');
|
||||
newLog.innerText = msg;
|
||||
this.details.appendChild(newLog);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user