File: src/components/Header.ts

Recommend this page to a friend!
  Classes of Dom Hastings   JS Webdav Client   src/components/Header.ts   Download  
File: src/components/Header.ts
Role: Class source
Content type: text/plain
Description: Class source
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 1 year ago
Size: 649 bytes
 

Contents

Class file image Download
import Element, { s } from '@dom111/element'; import State from '../lib/State'; const getPath = (state: State): string => decodeURIComponent(state.getPath()); export class Header extends Element { #state: State; constructor(state: State) { super( s(`<header> <h1>${getPath(state)}</h1> </header>`) ); this.#state = state; this.bindEvents(); } private bindEvents(): void { this.#state.on('updated', (): void => { if (this.#state.isDirectory()) { this.update(); } }); } private update(): void { this.query('h1').innerHTML = getPath(this.#state); } } export default Header;