ISSUE-005 - Initial work commit. Have some basic routing done and some mocked-up design of how the pay may look.
Made improvements to the LayoutGrid component, supporting richer definition of grid columns and rows.
This commit is contained in:
1 parent
262aca9d73
commit
02132bdbe2
13 files changed
+122
-39
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
type SizeProp = number | Array<number | string>;
|
||||
|
||||
/**
|
||||
* Slickly handle different values
|
||||
* @param prop a number will use 1fr repeated. An array will interpret numbers
|
||||
* as fractions. Else you can define anything with strings (such as "100px").
|
||||
* @returns
|
||||
*/
|
||||
const parseSize = (prop: SizeProp): string => {
|
||||
if (typeof prop === "number") {
|
||||
return `repeat(${prop}, 1fr)`;
|
||||
}
|
||||
if (Array.isArray(prop)) {
|
||||
return prop.map(value => {
|
||||
if (typeof value === "number") {
|
||||
return value + "fr";
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}).join(" ");
|
||||
}
|
||||
return "1";
|
||||
};
|
||||
|
||||
type LayoutGridProps = {
|
||||
columns?: SizeProp,
|
||||
rows?: SizeProp,
|
||||
headerOffset?: number,
|
||||
};
|
||||
export const LayoutGrid = styled.div<LayoutGridProps>`
|
||||
display: grid;
|
||||
grid-template-columns: ${({ columns = 1 }) => parseSize(columns)};
|
||||
grid-template-rows: ${({ rows = 1 }) => parseSize(rows)};
|
||||
height: calc(100% - ${({ headerOffset = 0 }) => headerOffset}px);
|
||||
width: 100%;
|
||||
`;
|
||||
LayoutGrid.displayName = "LayoutGrid";
|
||||
|
||||
type LayoutGridItemProps = {
|
||||
column: number,
|
||||
columnSpan?: number,
|
||||
row: number,
|
||||
rowSpan?: number,
|
||||
};
|
||||
export const LayoutGridItem = styled.div<LayoutGridItemProps>`
|
||||
grid-column: ${({ column }) => column}
|
||||
/ span ${({ columnSpan = 1 }) => columnSpan};
|
||||
grid-row: ${({ row }) => row}
|
||||
/ span ${({ rowSpan = 1 }) => rowSpan};;
|
||||
`;
|
||||
LayoutGridItem.displayName = "LayoutGridItem";
|
||||
Reference in new issue
Block a user