mirror of
https://github.com/pyscript/pyscript.git
synced 2026-04-19 02:00:21 -04:00
add pybutton and pytitle
This commit is contained in:
37
pyscriptjs/src/components/pytitle.ts
Normal file
37
pyscriptjs/src/components/pytitle.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { BaseEvalElement } from './base';
|
||||
import { addClasses, ltrim, htmlDecode } from '../utils';
|
||||
|
||||
export class PyTitle extends BaseEvalElement {
|
||||
shadow: ShadowRoot;
|
||||
wrapper: HTMLElement;
|
||||
theme: string;
|
||||
widths: Array<string>;
|
||||
label: string;
|
||||
mount_name: string;
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
connectedCallback() {
|
||||
this.label = htmlDecode(this.innerHTML);
|
||||
this.mount_name = this.id.split("-").join("_");
|
||||
this.innerHTML = '';
|
||||
|
||||
let mainDiv = document.createElement('div');
|
||||
let divContent = document.createElement('h1')
|
||||
|
||||
addClasses(mainDiv, ["text-center", "w-full", "mb-8"]);
|
||||
addClasses(divContent, ["text-3xl", "font-bold", "text-gray-800", "uppercase", "tracking-tight"]);
|
||||
divContent.innerHTML = this.label;
|
||||
|
||||
mainDiv.id = this.id;
|
||||
this.id = `${this.id}-container`;
|
||||
mainDiv.appendChild(divContent);
|
||||
this.appendChild(mainDiv);
|
||||
|
||||
console.log('py-title connected');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user