Actualizar 'components/project.js'

file-group-page
bat 3 years ago
parent a4b05fc757
commit ce795855b2

@ -1,27 +1,28 @@
export class Project extends HTMLElement { export class Project extends HTMLElement {
constructor() { constructor() {
super() super()
const path = this.getAttribute('path')
const shadow = this.attachShadow({mode: 'open'}) const shadow = this.attachShadow({mode: 'open'})
const textArea = document.createElement('textarea') this.textArea = document.createElement('textarea')
const header = document.createElement('h1') this.header = document.createElement('h1')
header.innerText = path this.textArea.addEventListener('input', e => {
textArea.value = localStorage.getItem( const path = this.getAttribute('path')
path
) ?? ''
textArea.addEventListener('input', e => {
localStorage.setItem( localStorage.setItem(
path, path,
e.target.value e.target.value
) )
}) })
const div = document.createElement('div') const div = document.createElement('div')
div.appendChild(header) div.appendChild(this.header)
div.appendChild(textArea) div.appendChild(this.textArea)
shadow.appendChild(div) shadow.appendChild(div)
} }
connectedCallback() { connectedCallback() {
const path = this.getAttribute('path')
this.header.innerText = path
this.textArea.value = localStorage.getItem(
path
) ?? ''
const style = document.createElement('style') const style = document.createElement('style')
style.textContent = ` style.textContent = `
textarea { textarea {

Loading…
Cancel
Save