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,28 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
type FullScreenContainerProps = {
|
||||
minHeight?: number,
|
||||
minWidth?: number,
|
||||
heightCutoff?: number,
|
||||
widthCutoff?: number,
|
||||
};
|
||||
|
||||
export const FullScreenContainer = styled.div<FullScreenContainerProps>`
|
||||
--minHeight: ${({ minHeight = 0 }) => `${minHeight}px`};
|
||||
--minWidth: ${({ minWidth = 0 }) => `${minWidth}px`};
|
||||
--overflowY: ${({ minHeight }) => minHeight ? "scroll" : "hidden"};
|
||||
--overflowX: ${({ minWidth }) => minWidth ? "scroll" : "hidden"};
|
||||
--heightCutoff: ${({ heightCutoff = 0 }) => `${heightCutoff}px`};
|
||||
--widthCutoff: ${({ widthCutoff = 0 }) => `${widthCutoff}px`};
|
||||
|
||||
position: relative;
|
||||
height: calc(100vh - var(--heightCutoff));
|
||||
width: calc(100vw - var(--widthCutoff));
|
||||
|
||||
/* Demand a minimum width/height and scroll to support them. */
|
||||
min-height: var(--minHeight);
|
||||
min-width: var(--minWidth);
|
||||
overflow-y: var(--overflowY);
|
||||
overflow-x: var(--overflowX);
|
||||
`;
|
||||
FullScreenContainer.displayName = "FullScreenContainer";
|
||||
@@ -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