2025-01-05 12:21:01 +02:00
|
|
|
import { TypedComponent } from "../../components/component.js";
|
2020-12-27 22:19:27 +01:00
|
|
|
import Container from "./container.js";
|
2020-02-06 21:16:02 +01:00
|
|
|
|
2025-01-04 12:44:40 +02:00
|
|
|
export type FlexDirection = "row" | "column";
|
|
|
|
|
2025-01-05 12:21:01 +02:00
|
|
|
export default class FlexContainer<T extends TypedComponent<any>> extends Container<T> {
|
2025-01-04 12:44:40 +02:00
|
|
|
constructor(direction: FlexDirection) {
|
2020-02-27 00:58:10 +01:00
|
|
|
super();
|
2020-02-06 21:16:02 +01:00
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
if (!direction || !["row", "column"].includes(direction)) {
|
2023-05-04 22:16:18 +02:00
|
|
|
throw new Error(`Direction argument given as '${direction}', use either 'row' or 'column'`);
|
2020-02-27 00:58:10 +01:00
|
|
|
}
|
|
|
|
|
2020-03-01 18:57:13 +01:00
|
|
|
this.attrs.style = `display: flex; flex-direction: ${direction};`;
|
2020-02-06 21:16:02 +01:00
|
|
|
}
|
2020-07-03 22:27:45 +02:00
|
|
|
}
|