add edit icon

file-group-page
bat 3 years ago
parent d86a44c543
commit e9525ab15c

@ -5,11 +5,19 @@ export class Header extends HTMLElement {
</svg>`,
dot: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-three-dots" viewBox="0 0 16 16">
<path d="M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"/>
</svg>`,
edit: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>`,
check: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-lg" viewBox="0 0 16 16">
<path d="M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z"/>
</svg>`,
}
constructor() {
super()
this.editing = false
this.attachShadow({mode: 'open'})
this.addButton(this.icons.menu, 'nav', () => {
this.menu.pages = this.getPages()
@ -17,6 +25,11 @@ export class Header extends HTMLElement {
this.overlay.classList.add('open')
})
this.addDivider()
this.editBtn = this.addButton(this.editIcon, 'edit', () => {
this.dispatchEvent(new CustomEvent(
'click-edit', {bubbles: true}
))
})
this.addButton(this.icons.dot, 'page', () => {
this.pageMenuPanel.classList.add('open')
this.overlay.classList.add('open')
@ -33,6 +46,7 @@ export class Header extends HTMLElement {
if (onClick) {
b.addEventListener('click', onClick)
}
return b
}
addDivider() {
@ -53,7 +67,7 @@ export class Header extends HTMLElement {
this.overlay.addEventListener('click', () => {
this.close()
})
this.menu.addEventListener('close', () => {
this.menu.addEventListener('close-menu', () => {
this.close()
})
}
@ -76,7 +90,7 @@ export class Header extends HTMLElement {
el.click()
this.shadowRoot.removeChild(el)
})
this.pageMenu.addEventListener('close', () => {
this.pageMenu.addEventListener('close-menu', () => {
this.close()
})
this.pageMenuPanel = document.createElement('div')
@ -166,4 +180,19 @@ export class Header extends HTMLElement {
getPages() {
return Object.keys(localStorage).slice().sort()
}
set editing(value) {
this._editing = value
if (this.editBtn) {
this.editBtn.innerHTML = this.editIcon
}
}
get editing() {
return this._editing
}
get editIcon() {
return this.editing ? this.icons.check : this.icons.edit
}
}
Loading…
Cancel
Save