Add button, dialog positioning

file-group-page
bat 3 years ago
parent 2cf4d75d1e
commit 348e38a810

@ -32,7 +32,7 @@ export class Dialog extends HTMLElement {
style.textContent = ` style.textContent = `
dialog { dialog {
margin-top: 120px; margin-top: 120px;
min-width: 80%; min-width: 200px;
border: 1px solid rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 6px; border-radius: 6px;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);

@ -4,7 +4,6 @@ export class Layout extends HTMLElement {
this.attachShadow({mode: 'open'}) this.attachShadow({mode: 'open'})
this.csp = "default-src 'self' 'unsafe-inline' 'unsafe-eval'" this.csp = "default-src 'self' 'unsafe-inline' 'unsafe-eval'"
this.header = document.createElement('m-header') this.header = document.createElement('m-header')
this.editing = false
} }
connectedCallback() { connectedCallback() {
@ -45,14 +44,19 @@ export class Layout extends HTMLElement {
} }
get path() { get path() {
return new URL( const hash = (
window.location.hash.slice(1) || '/', window.location.hash.slice(1) || '/'
)
return hash.startsWith('/') ? new URL(
hash,
window.location window.location
).pathname.replace(/^%23/, '#') ).pathname : hash
} }
set editing(value) { set editing(value) {
this._editing = value sessionStorage.setItem(
'editing', value ? 'true' : 'false'
)
this.header.editing = this.editing this.header.editing = this.editing
if (this.page) { if (this.page) {
this.page.editing = this.editing this.page.editing = this.editing
@ -60,6 +64,12 @@ export class Layout extends HTMLElement {
} }
get editing() { get editing() {
return this._editing try {
return (
sessionStorage.getItem('editing') === 'true'
)
} catch (e) {
return false
}
} }
} }

@ -29,7 +29,7 @@ export class NavMenu extends HTMLElement {
} }
a { a {
display: block; display: block;
margin: 5px 10px; margin: 8px 10px;
} }
` `
this.shadowRoot.append(style) this.shadowRoot.append(style)
@ -79,7 +79,7 @@ export class NavMenu extends HTMLElement {
renderPageList() { renderPageList() {
const els = this.pages.map(page => { const els = this.pages.map(page => {
const el = document.createElement('a') const el = document.createElement('a')
el.href = `#${page}` el.href = `#${page.replace(/^#/, '%23')}`
el.innerText = page el.innerText = page
el.classList.add('page') el.classList.add('page')
return el return el

@ -154,6 +154,7 @@ export class Page extends HTMLElement {
if (this.editing) { if (this.editing) {
classes.add('editing') classes.add('editing')
classes.remove('viewing') classes.remove('viewing')
this.textArea.focus()
} else { } else {
classes.add('viewing') classes.add('viewing')
classes.remove('editing') classes.remove('editing')

Loading…
Cancel
Save