generated from garrettmills/template-npm-typescript
Start modal, page, form, form fields, logical components, session service, login page
This commit is contained in:
15
src/logical/Logical.component.ts
Normal file
15
src/logical/Logical.component.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {ExComponent} from '../ExComponent.js'
|
||||
|
||||
export abstract class LogicalComponent extends ExComponent {
|
||||
protected static styles = `
|
||||
<style>
|
||||
:host {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
`
|
||||
|
||||
public value(): string {
|
||||
return this.innerText.trim()
|
||||
}
|
||||
}
|
||||
19
src/logical/Session.component.ts
Normal file
19
src/logical/Session.component.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import {LogicalComponent} from './Logical.component.js'
|
||||
import {Component} from '../decorators.js'
|
||||
|
||||
@Component('ex-session')
|
||||
export class SessionComponent extends LogicalComponent {
|
||||
mount() {
|
||||
super.mount()
|
||||
|
||||
;(window as any).session = this.session()
|
||||
|
||||
try {
|
||||
const data = JSON.parse(this.value())
|
||||
this.session().populate(data)
|
||||
} catch (e) {
|
||||
console.error('Error parsing JSON session data!', this.value()) // eslint-disable-line no-console
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user