move heading to parent component

pages
bat 3 years ago
parent b6309210a3
commit 3f39582900

@ -1,10 +1,10 @@
export class NetworkSettings extends HTMLElement { export class NetworkSettings extends HTMLElement {
textEn = { textEn = {
access: 'Direct network access (Content Security Policy)', csp: 'Content Security Policy',
} }
textEs = { textEs = {
access: 'Acceso directo a la red (Política de Seguridad del Contenido)', csp: 'Política de Seguridad de Contenido',
} }
accessOptions = { accessOptions = {
@ -56,9 +56,6 @@ export class NetworkSettings extends HTMLElement {
super() super()
this.attachShadow({mode: 'open'}) this.attachShadow({mode: 'open'})
this.language = navigator.language this.language = navigator.language
const netSelectLabel = document.createElement('div')
netSelectLabel.classList.add('label')
netSelectLabel.innerText = this.text.access
const netSelectField = document.createElement('div') const netSelectField = document.createElement('div')
netSelectField.classList.add('field') netSelectField.classList.add('field')
this.netSelect = document.createElement('select') this.netSelect = document.createElement('select')
@ -77,13 +74,20 @@ export class NetworkSettings extends HTMLElement {
this.netSelect.append(...netOptions) this.netSelect.append(...netOptions)
this.netHeading = document.createElement('h3') this.netHeading = document.createElement('h3')
this.netText = document.createElement('p') this.netText = document.createElement('p')
this.cspLabel = document.createElement(
'div'
)
this.cspLabel.classList.add('csp-label')
this.cspLabel.innerText = (
this.text.csp + ' (CSP):'
)
this.netCsp = document.createElement('div') this.netCsp = document.createElement('div')
this.netCsp.classList.add('csp') this.netCsp.classList.add('csp')
this.shadowRoot.append( this.shadowRoot.append(
netSelectLabel,
netSelectField, netSelectField,
this.netHeading, this.netHeading,
this.netText, this.netText,
this.cspLabel,
this.netCsp, this.netCsp,
) )
} }
@ -96,14 +100,6 @@ export class NetworkSettings extends HTMLElement {
flex-direction: column; flex-direction: column;
align-items: stretch; align-items: stretch;
} }
div.label {
display: flex;
flex-direction: row;
justify-content: flex-start;
background: #eee;
padding: 3px;
margin-bottom: 5px;
}
div.field { div.field {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -111,6 +107,9 @@ export class NetworkSettings extends HTMLElement {
h1, h2, h3, p { h1, h2, h3, p {
margin: 3px 0; margin: 3px 0;
} }
.csp-label {
font-weight: bold;
}
.csp { .csp {
font-family: monospace; font-family: monospace;
} }

@ -1,12 +1,26 @@
export class PageSettings extends HTMLElement { export class PageSettings extends HTMLElement {
textEn = {
netAccess: 'Direct network access (CSP)',
}
textEs = {
netAccess: 'Acceso directo a la red (CSP)',
}
constructor() { constructor() {
super() super()
this.attachShadow({mode: 'open'}) this.attachShadow({mode: 'open'})
this.language = navigator.language this.language = navigator.language
const netSelectHeading = document.createElement('div')
netSelectHeading.classList.add('heading')
netSelectHeading.innerText = this.text.netAccess
this.network = document.createElement( this.network = document.createElement(
'm-settings-network-settings' 'm-settings-network-settings'
) )
this.shadowRoot.append(this.network) this.shadowRoot.append(
netSelectHeading,
this.network,
)
} }
connectedCallback() { connectedCallback() {
@ -19,6 +33,18 @@ export class PageSettings extends HTMLElement {
align-items: stretch; align-items: stretch;
overflow-y: auto; overflow-y: auto;
} }
* {
padding-left: 10px;
}
div.heading {
display: flex;
flex-direction: row;
justify-content: flex-start;
background: #f2dbd8;
padding: 3px;
margin-bottom: 5px;
font-weight: bold;
}
` `
this.shadowRoot.append(style) this.shadowRoot.append(style)
} }
@ -38,4 +64,21 @@ export class PageSettings extends HTMLElement {
set cspProfiles(value) { set cspProfiles(value) {
this.network.cspProfiles = value this.network.cspProfiles = value
} }
get language() {
return this._language
}
set language(language) {
this._language = language
this.text = this.langEs ? this.textEs : this.textEn
}
get langEs() {
return /^es\b/.test(this.language)
}
get lang() {
return this.language.split('-')[0]
}
} }
Loading…
Cancel
Save