Skip to content

Commit

Permalink
vanilla extract setup & basic layout components
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Oct 14, 2023
1 parent 07c384a commit b6cc529
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/components/header/header.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const header = style({

})
6 changes: 6 additions & 0 deletions src/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { component$ } from "@builder.io/qwik";
import { header } from "./header.css";

export const Header = component$(() => {
return <div class={header}></div>;
});
6 changes: 6 additions & 0 deletions src/components/sidenav/sidenav.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const sidenav = style({

})
6 changes: 6 additions & 0 deletions src/components/sidenav/sidenav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { component$ } from "@builder.io/qwik";
import { sidenav } from "./sidenav.css";

export const SideNav = component$(() => {
return <div class={sidenav}></div>;
});
3 changes: 2 additions & 1 deletion src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { RouterHead } from "./components/router-head/router-head";

import "./global.css";
import { darkTheme, lightTheme } from "./theme.css";

export default component$(() => {
/**
Expand All @@ -24,7 +25,7 @@ export default component$(() => {
<RouterHead />
<ServiceWorkerRegister />
</head>
<body lang="en">
<body lang="en" class={darkTheme}>
<RouterOutlet />
</body>
</QwikCityProvider>
Expand Down
6 changes: 6 additions & 0 deletions src/routes/header.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const header = style({
backgroundColor: vars.color.background
})
18 changes: 18 additions & 0 deletions src/routes/layout.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const layoutRow = style({
width: "100vw",
height: "100vh",
display: "grid",
gridTemplateRows: "36px 1fr",
backgroundColor: vars.color.backgroundHighlight,
gap: "1px",
})

export const layoutColumn = style({
display: "grid",
gridTemplateColumns: "36px 1fr",
gap: "1px",
backgroundColor: vars.color.backgroundHighlight,
})
25 changes: 16 additions & 9 deletions src/routes/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { component$, Slot, useStyles$ } from "@builder.io/qwik";
import { routeLoader$ } from "@builder.io/qwik-city";
import type { RequestHandler } from "@builder.io/qwik-city";

import styles from "./styles.css?inline";
import { layoutColumn, layoutRow } from "./layout.css";
import { SideNav } from "~/components/sidenav/sidenav";
import { Header } from "~/components/header/header";
import { header } from "./header.css";
import { nav } from "./nav.css";
import { main } from "./main.css";

export const onGet: RequestHandler = async ({ cacheControl }) => {
// Control caching for this request for best performance and to reduce hosting costs:
Expand All @@ -22,14 +27,16 @@ export const useServerTimeLoader = routeLoader$(() => {
});

export default component$(() => {
useStyles$(styles);
// useStyles$(styles);
return (
<>
{/* <Header /> */}
<main>
<Slot />
</main>
{/* <Footer /> */}
</>
<div class={layoutRow}>
<header class={header}><Header></Header></header>
<div class={layoutColumn}>
<nav class={nav}><SideNav></SideNav></nav>
<main class={main}>
<Slot />
</main>
</div>
</div>
);
});
6 changes: 6 additions & 0 deletions src/routes/main.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const main = style({
backgroundColor: vars.color.background
})
6 changes: 6 additions & 0 deletions src/routes/nav.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from "@vanilla-extract/css";
import { vars } from "~/theme.css";

export const nav = style({
backgroundColor: vars.color.background
})
Empty file removed src/routes/styles.css
Empty file.
27 changes: 27 additions & 0 deletions src/theme.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createTheme } from "@vanilla-extract/css";

export const [darkTheme, vars] = createTheme({
color: {
background: '#2b2f3a', // Background (Dark Grayish Bluish)
backgroundHighlight: '#3c3f4a', // Background Highlighted (Dark Grayish Bluish)
red: '#d43f4a', // Muted Red
green: '#3d8e5d', // Muted Green
blue: '#2f6d99', // Muted Blue
text: '#e0e0e0', // Text (For light text against dark backgrounds)
subtext: '#a0a0a0', // Subtext (For lesser important text)
divider: '#42465b', // Border/Divider Color
},
});

export const lightTheme = createTheme(vars, {
color: {
background: '#e6eaf0', // Background (Light Grayish Bluish)
backgroundHighlight: '#d5d8e0', // Background Highlighted (Dark Grayish Bluish)
red: '#e05a67', // Muted Red
green: '#59a883', // Muted Green
blue: '#508db3', // Muted Blue
text: '#2c2f3b', // Text (For dark text against light backgrounds)
subtext: '#6c6f7f', // Subtext (For lesser important text)
divider: '#b2b5c3', // Border/Divider Color
},
});

0 comments on commit b6cc529

Please sign in to comment.