Use bootstrap components for up- and downloads

This commit is contained in:
Søren L. Hansen
2022-04-09 10:10:03 +00:00
parent 736ad294e7
commit 7f05f2fe17
22 changed files with 6840 additions and 1717 deletions

64
js/src/MyModal.tsx Normal file
View File

@@ -0,0 +1,64 @@
import { createRef, Component, ComponentChildren } from "preact";
import { Modal } from "bootstrap";
import 'bootstrap/dist/css/bootstrap.min.css';
//import './bootstrap.scss';
interface ModalProps {
children: ComponentChildren;
buttons?: ComponentChildren;
title: string;
dismissHandler?: (hideModal?: () => void) => void;
}
export class MyModal extends Component<ModalProps, {}> {
ref = createRef<HTMLDivElement>();
constructor() {
super();
}
componentDidMount() {
Modal.getOrCreateInstance(this.ref.current!).show();
this.ref.current?.addEventListener('hide.bs.modal', () => { this.props.dismissHandler && this.props.dismissHandler(); });
}
componentWillUnmount() {
this.hide()
}
hide(): void {
Modal.getOrCreateInstance(this.ref.current!).hide();
}
render() {
return <div class="modal fade" ref={this.ref} tabIndex={-1} aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{this.props.title}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{this.props.children}
</div>
<div class="modal-footer">
{this.props.buttons}
</div>
</div>
</div>
</div>;
}
}
interface ButtonProps {
priority: "primary" | "secondary" | "danger"
clickHandler?: () => void
children: ComponentChildren
disabled?: boolean;
}
export function Button(props:ButtonProps) {
let classes: string = "btn btn-" + props.priority
return <button type="button" disabled={props.disabled} class={classes} onClick={ () => { props.clickHandler ? props.clickHandler() : null; }}>{ props.children}</button>
}