Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing Grid control #36

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions src/Components/Flex.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<script lang="ts">
import { getStyles } from '../utils';
import type { GapType } from '../Models/Gap';
import { Breakpoint } from '../Models/Breakpoint';
import type { JustifyContent, JustifySelf } from '../Models/Justify';
import type { AlignContent, AlignItems, AlignSelf } from '../Models/Align';
import type { PlaceContent, PlaceItems, PlaceSelf } from '../Models/Place';
import type {
FlexSize,
FlexDirection,
FlexGrow,
FlexShrink,
FlexWrap,
IFlexLayout,
Order,
} from '../Models/Flex';
import { flexToStyle } from '../Models/Flex';
import type {
ColumnSpan,
ColumnStartEnd,
RowSpan,
RowStartEnd,
} from '../Models/Grid';

export let css = '';
export let gap: GapType = undefined;
export let justify: JustifyContent = undefined;
export let alignContent: AlignContent = undefined;
export let align: AlignItems = undefined;
export let placeContent: PlaceContent = undefined;
export let placeItems: PlaceItems = undefined;
export let dir: FlexDirection = undefined;
export let wrap: FlexWrap = undefined;
export let size: FlexSize = undefined;
export let grow: FlexGrow = undefined;
export let shrink: FlexShrink = undefined;
export let order: Order = undefined;
export let colSpan: ColumnSpan = undefined;
export let colStart: ColumnStartEnd = undefined;
export let colEnd: ColumnStartEnd = undefined;
export let rowSpan: RowSpan = undefined;
export let rowStart: RowStartEnd = undefined;
export let rowEnd: RowStartEnd = undefined;
export let justifySelf: JustifySelf = undefined;
export let alignSelf: AlignSelf = undefined;
export let placeSelf: PlaceSelf = undefined;
export let container: boolean = undefined;

let classes: string = '';
export let sm: IFlexLayout = undefined;
export let md: IFlexLayout = undefined;
export let lg: IFlexLayout = undefined;
export let xl: IFlexLayout = undefined;
export let xxl: IFlexLayout = undefined;

$: {
classes = getStyles([
flexToStyle({
dir,
wrap,
size,
grow,
shrink,
gap,
justify,
alignContent,
align,
placeContent,
placeItems,
order,
colSpan,
colStart,
colEnd,
rowSpan,
rowStart,
rowEnd,
justifySelf,
alignSelf,
placeSelf,
}),
flexToStyle(sm, Breakpoint.Sm),
flexToStyle(md, Breakpoint.Md),
flexToStyle(lg, Breakpoint.Lg),
flexToStyle(xl, Breakpoint.Xl),
flexToStyle(xxl, Breakpoint.Xxl),
container ? 'container mx-auto' : '',
css,
]);
}
</script>

<div class={classes}>
<slot />
</div>
101 changes: 101 additions & 0 deletions src/Components/Grid.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<script lang="ts">
import { getStyles } from '../utils';
import type {
Column,
ColumnSpan,
ColumnStartEnd,
Row,
Flow,
RowSpan,
RowStartEnd,
GapType,
Order,
JustifyContent,
JustifyItems,
AlignContent,
AlignItems,
PlaceContent,
PlaceItems,
IGrid,
} from '../Models/Grid';
import { gridToStyle } from '../Models/Grid';
import { Breakpoint } from '../Models/Breakpoint';
import type { FlexGrow, FlexShrink, FlexSize } from '../Models/Flex';
import type { JustifySelf } from '../Models/Justify';
import type { AlignSelf } from '../Models/Align';
import type { PlaceSelf } from '../Models/Place';

export let css: string = '';
export let rows: Row = undefined;
export let cols: Column = undefined;
export let colSpan: ColumnSpan = undefined;
export let colStart: ColumnStartEnd = undefined;
export let colEnd: ColumnStartEnd = undefined;
export let rowSpan: RowSpan = undefined;
export let rowStart: RowStartEnd = undefined;
export let rowEnd: RowStartEnd = undefined;
export let flow: Flow = undefined;
export let gap: GapType = undefined;
export let justify: JustifyContent = undefined;
export let justifyItems: JustifyItems = undefined;
export let alignContent: AlignContent = undefined;
export let align: AlignItems = undefined;
export let placeContent: PlaceContent = undefined;
export let placeItems: PlaceItems = undefined;
export let flexSize: FlexSize = undefined;
export let flexGrow: FlexGrow = undefined;
export let flexShrink: FlexShrink = undefined;
export let order: Order = undefined;
export let justifySelf: JustifySelf = undefined;
export let alignSelf: AlignSelf = undefined;
export let placeSelf: PlaceSelf = undefined;
export let sm: IGrid = undefined;
export let md: IGrid = undefined;
export let lg: IGrid = undefined;
export let xl: IGrid = undefined;
export let xxl: IGrid = undefined;
export let container: boolean = undefined;

let classes = '';

$: {
classes = getStyles([
gridToStyle({
rows,
cols,
flow,
gap,
justify,
justifyItems,
alignContent,
align,
placeContent,
placeItems,
flexGrow,
flexShrink,
flexSize,
order,
colSpan,
colStart,
colEnd,
rowStart,
rowEnd,
rowSpan,
justifySelf,
alignSelf,
placeSelf,
}),
gridToStyle(sm, Breakpoint.Sm),
gridToStyle(md, Breakpoint.Md),
gridToStyle(lg, Breakpoint.Lg),
gridToStyle(xl, Breakpoint.Xl),
gridToStyle(xxl, Breakpoint.Xxl),
container ? 'container mx-auto' : '',
css,
]);
}
</script>

<div class={classes}>
<slot />
</div>
92 changes: 47 additions & 45 deletions src/Components/Page/Page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,88 +18,90 @@
import TextField from '../TextField/TextField.svelte';
import Tooltip from '../Tooltip/Tooltip.svelte';
import Table from './Table.svelte';
import Flex from '../Flex.svelte';
import Grid from '../Grid.svelte';

let select: Select;
let petType: string;
</script>

<div class={`flex-grow flex flex-col ${$pageStyles.toStyles()}`}>
<Flex dir="col" css={$pageStyles.toStyles()}>
<Header styles={$headerStyles}>
<div slot="icon">
<SmartHome
size={$headerStyles.icon.size}
strokeWidth={$headerStyles.icon.stroke} />
strokeWidth={$headerStyles.icon.stroke}
/>
</div>
<div slot="brand">Pet Finder</div>
<div slot="menu" class="hover:underline cursor-pointer">Account</div>
</Header>
<div class="px-4 pb-4">
<div class="flex flex-row gap-3">
<div class="flex flex-1 flex-col gap-3">
<div class="grid grid-cols-2 md:grid-cols-3 gap-3 ">
<TextField styles={$textFieldStyles} placeholder="Pet's Name">
<span slot="trailingIcon">
<Search
size={$textFieldStyles.icon.size}
strokeWidth={$textFieldStyles.icon.stroke} />
</span>
</TextField>
<Flex dir="col" gap={3}>
<Grid gap={3} rows={2} cols={1} md={{ cols: 2, rows: 1 }}>
<TextField styles={$textFieldStyles} placeholder="Pet's Name">
<span slot="trailingIcon">
<Search
size={$textFieldStyles.icon.size}
strokeWidth={$textFieldStyles.icon.stroke}
/>
</span>
</TextField>
<Flex dir="row" gap={3}>
<Select
bind:this={select}
bind:value={petType}
isMenuOpen
placeholder="Pet Type"
mustHaveValue
styles={$selectStyles}>
styles={$selectStyles}
>
<SelectOption {select} value="Dog">Dog</SelectOption>
<SelectOption {select} value="Cat">Cat</SelectOption>
<SelectOption {select} value="Bird">Bird</SelectOption>
</Select>
<div>
<Tooltip styles={$tooltipStyles} visible>
<Button styles={$primaryButtonStyles}>
Search
<span slot="icon">
<Search
size={$primaryButtonStyles.icon.size}
strokeWidth={$primaryButtonStyles.icon.stroke} />
</span>
</Button>
<div slot="tooltip">I'm a tooltip!!!</div>
</Tooltip>
</div>
</div>
<div class="text-2xl mt-28">Found Dogs:</div>
<Table />
</div>
</div>

<Tooltip styles={$tooltipStyles} visible>
<Button styles={$primaryButtonStyles}>
Search
<span slot="icon">
<Search
size={$primaryButtonStyles.icon.size}
strokeWidth={$primaryButtonStyles.icon.stroke}
/>
</span>
</Button>
<div slot="tooltip">I'm a tooltip!!!</div>
</Tooltip>
</Flex>
</Grid>
<div class="text-2xl mt-28">Found Dogs:</div>
<Table />
</Flex>
<div>
<Card styles={$cardStyles}>
<div slot="header">Dog Profile</div>

<div class="flex md:flex-row md:gap-2 flex-col ">
<Flex md={{ dir: 'row', gap: 2 }} dir="col">
<img alt="Doge" class="h-40 w-40" src="/shiba.jpg" />
<div class="flex flex-col gap-1">
<div class="flex flex-row gap-1"><b>Name:</b> Doge</div>
<div class="flex flex-row gap-1"><b>Gender:</b> Female</div>
<div class="flex flex-row gap-1"><b>DOB:</b> Nov, 2 2005</div>
<div class="flex flex-row gap-1">
<Flex dir="col" gap={1}>
<Flex dir="row" gap={1}><b>Name:</b> Doge</Flex>
<Flex dir="row" gap={1}><b>Gender:</b> Female</Flex>
<Flex dir="row" gap={1}><b>DOB:</b> Nov, 2 2005</Flex>
<Flex dir="row" gap={1}>
<b>Bio:</b>
<p>
An Internet meme that became popular in 2013. The meme typically
consists of a picture of a Shiba Inu dog accompanied by
multicolored text in Comic Sans font in the foreground.
</p>
</div>
</div>
</div>
</Flex>
</Flex>
</Flex>
<div slot="footer">
<div class="flex flex-row justify-end">
<Flex dir="row" justify="end">
<Button styles={$secondaryButtonStyles}>Adopt Me</Button>
</div>
</Flex>
</div>
</Card>
</div>
</div>
</div>
</Flex>
Loading