@sodacore/ui
Version:
Sodacore UI is a powerful JSON-based DSL for describing web pages that can be rendered by a frontend JavaScript framework.
46 lines (45 loc) • 900 B
JavaScript
export default class Layout {
constructor() {
this.areas = [];
this.columns = '1fr';
this.rows = '1fr';
this.gap = 0;
}
setAreas(areas) {
this.areas = areas;
return this;
}
getAreas() {
return this.areas;
}
setColumns(columns) {
this.columns = columns;
return this;
}
getColumns() {
return this.columns;
}
setRows(rows) {
this.rows = rows;
return this;
}
getRows() {
return this.rows;
}
setGap(gap) {
this.gap = gap;
return this;
}
getGap() {
return this.gap;
}
toJSON() {
return {
areas: this.areas,
uniqueAreas: Array.from(new Set(this.areas.flat())),
columns: this.columns,
rows: this.rows,
gap: this.gap,
};
}
}