tweb/src/components/divAndCaption.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-01-06 20:27:29 +01:00
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
2023-01-16 18:26:51 +01:00
import {setDirection} from '../helpers/dom/setInnerHTML';
2023-01-06 20:27:29 +01:00
export default class DivAndCaption<T> {
public container: HTMLElement;
public border: HTMLElement;
public content: HTMLElement;
public title: HTMLElement;
public subtitle: HTMLElement;
constructor(protected className: string, public fill?: T) {
this.container = document.createElement('div');
this.container.className = className;
this.border = document.createElement('div');
this.border.classList.add(className + '-border');
this.content = document.createElement('div');
this.content.classList.add(className + '-content');
this.title = document.createElement('div');
this.title.classList.add(className + '-title');
2023-01-16 18:26:51 +01:00
setDirection(this.title);
2023-01-06 20:27:29 +01:00
this.subtitle = document.createElement('div');
this.subtitle.classList.add(className + '-subtitle');
2023-01-16 18:26:51 +01:00
setDirection(this.subtitle);
2023-01-06 20:27:29 +01:00
this.content.append(this.title, this.subtitle);
this.container.append(this.border, this.content);
}
}