Skip to content

Commit

Permalink
spaces/qwik: add daisyui
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed Mar 30, 2024
1 parent 46814f1 commit b9ff364
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 11 deletions.
1 change: 1 addition & 0 deletions spaces/qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"autoprefixer": "^10.4.14",
"daisyui": "^4.9.0",
"eslint": "^8.57.0",
"eslint-plugin-qwik": "^1.5.1",
"postcss": "^8.4.31",
Expand Down
31 changes: 31 additions & 0 deletions spaces/qwik/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions spaces/qwik/src/routes/daisyui/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
$,
component$,
Signal,
useOnWindow,
useSignal,
} from "@builder.io/qwik";


export default component$(() => {
return (
<>
<h1>tailwind breakpoints</h1>
<button type="button" class={"btn"}>hello daisy</button>
</>
);
});
54 changes: 46 additions & 8 deletions spaces/qwik/src/routes/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { component$, Slot } from "@builder.io/qwik";
import type { RequestHandler } from "@builder.io/qwik-city";
import {component$, Slot} from "@builder.io/qwik";
import type {RequestHandler} from "@builder.io/qwik-city";
import {Link} from "@builder.io/qwik-city";

export const onGet: RequestHandler = async ({ cacheControl }) => {
export const onGet: RequestHandler = async ({cacheControl}) => {
// Control caching for this request for best performance and to reduce hosting costs:
// https://qwik.builder.io/docs/caching/
cacheControl({
Expand All @@ -14,10 +14,48 @@ export const onGet: RequestHandler = async ({ cacheControl }) => {
};

export default component$(() => {
return <div>
<div>
<Link href="/tailwind/breakpoint">tailwind/breakpoint</Link>
return <main class="">
<div class="sticky top-0 navbar bg-blue-950 text-neutral-content">
<div class="navbar-start">
<Link class="link link-hover text-xl">Study Web</Link>
</div>
<div class="navbar-end">
<Link class="link link-hover text-xl" target="_blank" href="https://github.com/chen56/kou">
{/* <MdiGithub class="hover:text-red-400" width="32" height="32"/>*/}
</Link>
</div>
</div>
<Slot />
</div>;

<div class="flex h-dvh">
{/* --h-dvh 使左边栏占满viewport所有有效高度 */}
<div class="min-w-48 bg-base-200 h-dvh">
<ul class="menu">
<li><Link class="link link-hover" href="/tailwind/breakpoint">tailwind/breakpoint</Link></li>
<li><Link class="link link-hover" href="/daisyui">daisyui</Link></li>
</ul>
</div>
{/*
设置内容区域单独滚动,必须要让内容区域实际高度小于可显示高度:
比如:
<div style="height:500px;overflow-y: scroll;" class="bg-red-100">
<div style="height:1000px;" class="bg-blue-100">很长的内容。。。</div>
</div>
所以设置下列class:
h-dvh 高度viewport最大(y轴必须)
overflow-y-scroll y轴滚动(y轴必须)
scroll-smooth 平滑滚动(可选)
style="overflow-y: unset;height: 600px" "overflow-y: scroll ;"
*/}

<div class="w-dvw h-dvh overflow-y-scroll scroll-smooth" style={{overflowY: "scroll"}}>
<Slot></Slot>
</div>
{/*<span class="flex-none min-w-48 bg-base-200 ">nav right</span>*/}
</div>
</main>
;
});


4 changes: 2 additions & 2 deletions spaces/qwik/src/routes/tailwind/breakpoint/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {

import resolveConfig from "tailwindcss/resolveConfig";
import tailwindConfig from "../../../../tailwind.config";
import React from "react"; // Your tailwind config
import {Config} from "tailwindcss";


// https://tailwindcss.com/docs/configuration#using-esm-or-type-script
// 因为tailwindcss/resolveConfig没有提供ts版本的接口,所以ts模式下会编译失败,所以转any
let fullConfig = resolveConfig(tailwindConfig) as any;
let fullConfig = resolveConfig(tailwindConfig as Config) as any;
fullConfig.theme.screens.md
// => '768px'

Expand Down
6 changes: 5 additions & 1 deletion spaces/qwik/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import daisyui from "daisyui"

/** @type {import('tailwindcss').Config} */


export default {
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
theme: {
extend: {},
},
plugins: [],
plugins: [daisyui],
};

0 comments on commit b9ff364

Please sign in to comment.