Skip to content

Commit 3469232

Browse files
committed
Migrate to tailwind 4
1 parent 92fe4b5 commit 3469232

25 files changed

+776
-748
lines changed

app.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tsconfig from "./tsconfig.json";
66
import { linariaVitePlugin } from "./vite/linariaVitePlugin";
77
import { viteMarkdownPlugin } from "./vite/markdown/viteMarkdownPlugin";
88
import { viteImagePlugin } from "./vite/viteImagePlugin";
9+
import tailwindcss from "@tailwindcss/vite";
910
// @ts-ignore
1011
import babelPluginLazyPlus from "solid-lazy-plus/babel";
1112

@@ -38,7 +39,7 @@ export default defineConfig({
3839

3940
vite(options) {
4041
return {
41-
css: { postcss: "./postcss.config.js" },
42+
// css: { postcss: "./postcss.config.js" },
4243
server: {
4344
port: 3000,
4445
warmup: { clientFiles: ["./src/app.tsx"] },
@@ -49,7 +50,7 @@ export default defineConfig({
4950
Object.entries(tsconfig.compilerOptions.paths).map(([key, value]) => [
5051
key.replace(/\/\*$/, ""),
5152
path.join(process.cwd(), value[0].replace(/\/\*$/, "")),
52-
])
53+
]),
5354
),
5455
},
5556
plugins: [
@@ -61,6 +62,7 @@ export default defineConfig({
6162
include: [/\/src\//],
6263
exclude: [/solid-refresh/, /\/@babel\/runtime\//, /\.import\./],
6364
}) as any,
65+
tailwindcss(),
6466
],
6567
};
6668
},

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "example-basic",
2+
"name": "blog",
33
"license": "MIT",
44
"type": "module",
55
"scripts": {
@@ -18,23 +18,28 @@
1818
"@solidjs/meta": "0.29.4",
1919
"@solidjs/router": "0.15.3",
2020
"@solidjs/start": "1.0.11",
21+
"@tailwindcss/node": "^4.0.3",
22+
"@tailwindcss/postcss": "^4.0.3",
23+
"@tailwindcss/vite": "4.0.3",
2124
"@vinxi/plugin-mdx": "3.7.2",
2225
"@wyw-in-js/transform": "0.5.5",
2326
"@wyw-in-js/vite": "0.5.5",
2427
"babel-plugin-transform-remove-imports": "1.8.0",
2528
"classnames": "2.5.1",
2629
"cssnano": "6.1.2",
30+
"lightningcss": "^1.29.1",
2731
"postcss-preset-env": "10.0.3",
2832
"postcss-pxtorem": "6.1.0",
2933
"rehype-raw": "7.0.0",
3034
"remark-shiki-twoslash": "3.1.3",
31-
"sass": "1.77.8",
35+
"sass": "1.84.0",
3236
"solid-js": "1.9.4",
3337
"solid-labels": "0.16.0",
3438
"solid-mdx": "0.0.7",
35-
"tailwindcss": "3.4.10",
39+
"tailwindcss": "4.0.3",
3640
"typescript": "5.7.3",
3741
"vinxi": "0.5.1",
42+
"vite": "6.0.11",
3843
"vite-plugin-compile-time": "0.4.6"
3944
},
4045
"engines": {

pnpm-lock.yaml

Lines changed: 244 additions & 264 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postcss.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cssnano from "cssnano";
2-
import tailwindcss from "tailwindcss";
2+
import tailwindcss from "@tailwindcss/postcss";
33
import postcssPresentEnv from "postcss-preset-env";
44
import pxtorem from "postcss-pxtorem";
55

@@ -9,7 +9,7 @@ export default {
99
replace: true,
1010
propList: ["*"],
1111
}),
12-
postcssPresentEnv(),
12+
// postcssPresentEnv(),
1313
tailwindcss,
1414
...(process.env.NODE_ENV === "production" ? [cssnano] : []),
1515
],

src/Article.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const isValidArticle = (name: string) => !!getArticleComponent(name);
2020

2121
interface Props {
2222
name: string;
23+
className?: string;
2324
}
2425

2526
const Article: Component<Props> = (props) => {
@@ -28,7 +29,7 @@ const Article: Component<Props> = (props) => {
2829
const meta = articles.find((x: any) => x.slug == name)!;
2930

3031
return (
31-
<div class={_Article}>
32+
<div class={cn(_Article, props.className)}>
3233
<Meta name="description" content={meta.description} />
3334
<span class="mb-2">
3435
<a href="/">Articles</a>{" "}
@@ -100,13 +101,13 @@ const Article: Component<Props> = (props) => {
100101
);
101102
},
102103
h1: (props: any) => (
103-
<h2 {...props} class="text-h2 text-colors-text-900a" />
104+
<h2 {...props} class="text-heading2 text-colors-text-900a" />
104105
),
105106
h2: (props: any) => (
106-
<h3 {...props} class="text-h3 text-colors-text-900a" />
107+
<h3 {...props} class="text-heading3 text-colors-text-900a" />
107108
),
108109
h3: (props: any) => (
109-
<h4 {...props} class="text-h4 text-colors-text-900a" />
110+
<h4 {...props} class="text-heading4 text-colors-text-900a" />
110111
),
111112

112113
ul: (props: any) => (
@@ -170,7 +171,7 @@ const Article: Component<Props> = (props) => {
170171
class="ml-8 mr-8 h-full w-16 flex-shrink-0"
171172
/>
172173
<div class="flex flex-1 flex-col gap-2 bg-colors-primary-200 pl-4 pr-4 shadow">
173-
<span class="mt-6 text-h2">
174+
<span class="text-heading2 mt-6">
174175
<span class="text-colors-text-300a">{username}/</span>
175176
<span class="text-colors-text-900a">{projectName}</span>
176177
</span>

src/BlogIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const BlogIndex: Component = () => {
2020
<a
2121
href={`${config.base}${item.url}`}
2222
class="flex flex-col p-4 no-underline">
23-
<span class="text-h2 text-colors-primary-800">
23+
<span class="text-heading2 text-colors-primary-800">
2424
{item.title}
2525
</span>
2626
<span class="textbody mb-4 mt-1 text-colors-text-300a !no-underline">

src/Header.tsx

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,54 @@ import { heading1TextHeight } from "~/style/textStylesTS";
88
import LogoSVG from "../assets/logo.svg?component-solid";
99

1010
interface Props {
11-
children?: JSX.Element;
11+
children?: JSX.Element;
1212
}
1313

1414
const Header: Component<Props> = (props) => {
15-
const location = useLocation();
15+
const location = useLocation();
1616

17-
const activeSection = $derefMemo(
18-
createMemo(() => {
19-
if (location.pathname.startsWith(`${config.base}/gallery`))
20-
return "gallery";
21-
if (location.pathname.startsWith(`${config.base}/about`)) return "about";
22-
return "blog";
23-
})
24-
);
17+
const activeSection = $derefMemo(
18+
createMemo(() => {
19+
if (location.pathname.startsWith(`${config.base}/gallery`))
20+
return "gallery";
21+
if (location.pathname.startsWith(`${config.base}/about`)) return "about";
22+
return "blog";
23+
})
24+
);
2525

26-
return (
27-
<nav
28-
class={cn(
29-
_Header,
30-
"content-container mb-4 mt-4 flex items-center gap-8"
31-
)}>
32-
<a href={`${config.base}/`}>
33-
<LogoSVG class={cn(Logo, "w-12")} viewBox="0 0 60 94.564" />
34-
</a>
35-
<NavLink href={`${config.base}/`} active={activeSection == "blog"}>
36-
Blog
37-
</NavLink>
38-
<NavLink
39-
href={`${config.base}/gallery`}
40-
active={activeSection == "gallery"}>
41-
Gallery
42-
</NavLink>
43-
<NavLink href={`${config.base}/about`} active={activeSection == "about"}>
44-
About
45-
</NavLink>
46-
</nav>
47-
);
26+
return (
27+
<nav
28+
class={cn(
29+
_Header,
30+
"content-container mb-4 mt-4 flex items-center gap-8"
31+
)}>
32+
<a href={`${config.base}/`}>
33+
<LogoSVG class={cn(Logo, "w-12")} viewBox="0 0 60 94.564" />
34+
</a>
35+
<NavLink href={`${config.base}/`} active={activeSection == "blog"}>
36+
Blog
37+
</NavLink>
38+
<NavLink
39+
href={`${config.base}/gallery`}
40+
active={activeSection == "gallery"}>
41+
Gallery
42+
</NavLink>
43+
<NavLink href={`${config.base}/about`} active={activeSection == "about"}>
44+
About
45+
</NavLink>
46+
</nav>
47+
);
4848
};
4949

5050
const NavLink: Component<any> = (props: any) => {
51-
const { children, href, active } = $destructure(props);
52-
return (
53-
<a
54-
class={cn("text-h1", { "text-colors-text-900a underline": active })}
55-
href={href}>
56-
{children}
57-
</a>
58-
);
51+
const { children, href, active } = $destructure(props);
52+
return (
53+
<a
54+
class={cn("text-heading1", { "text-colors-text-900a underline": active })}
55+
href={href}>
56+
{children}
57+
</a>
58+
);
5959
};
6060

6161
const _Header = css``;

src/LazyImage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const LazyImage: (meta: LazyImageMeta) => Component<Props> =
4040
<img
4141
ref={imageRef}
4242
class={cn({ hasJS, loaded })}
43-
onLoad={() => { loaded = true; }}
43+
onLoad={() => {
44+
loaded = true;
45+
}}
4446
src={meta.url}
4547
{...rest}
4648
/>
@@ -67,7 +69,9 @@ const _LazyImage = css`
6769
6870
img {
6971
width: 100%;
70-
height: 100%;
72+
@layer components {
73+
height: 100%;
74+
}
7175
object-fit: inherit;
7276
// hide text when loading image
7377
font-size: 0;

src/about/AboutSite.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ interface Props {
1818
const AboutSite: Component<Props> = (props) => {
1919
return (
2020
<div class={cn(_AboutSite, "mb-8 grid gap-4")}>
21-
<div class="flex flex-col gap-2 " style={{ "grid-area": "picture" }}>
22-
<div class="flex h-[192px] w-[192px] items-center justify-center rounded border-4 border-colors-primary-500">
21+
<div class="flex flex-col gap-2" style={{ "grid-area": "picture" }}>
22+
<div class="flex h-[192px] w-[192px] items-center justify-center overflow-hidden rounded border-4 border-colors-primary-500">
2323
<ProfilePicture
2424
alt="Profile picture showing an manga-style face with glasses"
2525
class="h-full w-full"
2626
/>
2727
</div>
2828
</div>
2929

30-
<div class="flex flex-col gap-2 " style={{ "grid-area": "stats" }}>
30+
<div class="flex flex-col gap-2" style={{ "grid-area": "stats" }}>
3131
<StatsBar icon="heart" progress={28} type="secondary" label="HP">
3232
12/85
3333
</StatsBar>
@@ -39,34 +39,34 @@ const AboutSite: Component<Props> = (props) => {
3939
<div
4040
class="flex flex-col gap-2 text-center"
4141
style={{ "grid-area": "name" }}>
42-
<div class="bg-colors-primary-500 pl-8 pr-8 text-h1 text-colors-text-900a">
42+
<div class="text-heading1 bg-colors-primary-500 pl-8 pr-8 text-colors-text-900a">
4343
Matic Utsumi Gačar
4444
</div>
4545
</div>
4646

4747
<div
48-
class="flex flex-col gap-2 s:flex-row"
48+
class="text-heading3 flex gap-2 s:flex-row"
4949
style={{ "grid-area": "title" }}>
50-
<div class="text-nowrap text-h3">Level 21</div>
51-
<div class="text-nowrap text-h3 xs:text-h3">
50+
<div class="text-nowrap">Level 21</div>
51+
<div class="xs:text-heading3 text-nowrap">
5252
Enthusiastic Software Engineer
5353
</div>
5454
</div>
5555
<LabeledBox label="general" style={{ "grid-area": "general" }}>
5656
<ul class="flex min-h-full flex-col gap-1">
57-
<li class="flex gap-2 text-nowrap xs:text-h3 s:text-body">
57+
<li class="xs:text-heading3 flex gap-2 text-nowrap s:text-body">
5858
<IconText icon="github" />
5959
<a href="https://github.com/shiro">github.com/shiro</a>
6060
</li>
61-
<li class="flex gap-2 text-nowrap xs:text-h3 s:text-body">
61+
<li class="xs:text-heading3 flex gap-2 text-nowrap s:text-body">
6262
<IconText icon="email" />
6363
<a href="mailto:matic@usagi.io">matic@usagi.io</a>
6464
</li>
65-
<li class="flex gap-2 text-nowrap xs:text-h3 s:text-body">
65+
<li class="xs:text-heading3 flex gap-2 text-nowrap s:text-body">
6666
<IconText icon="globe" />
6767
<a href="https://usagi.io">usagi.io</a>
6868
</li>
69-
<li class="flex gap-2 text-nowrap xs:text-h3 s:text-body">
69+
<li class="xs:text-heading3 flex gap-2 text-nowrap s:text-body">
7070
<IconText icon="house" />
7171
<span>Tokyo</span>
7272
</li>

src/about/ProjectsSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ const Project: Component<any> = (props: any) => {
152152
return (
153153
<div>
154154
<div class="mb-8 flex xs:flex-col xs:gap-1 s:flex-row s:gap-4">
155-
<span class="text-nowrap text-h3 text-colors-text-900a">{name}</span>
156-
<span class="text-nowrap text-h3 text-colors-text-300a">
155+
<span class="text-nowrap text-heading3 text-colors-text-900a">{name}</span>
156+
<span class="text-nowrap text-heading3 text-colors-text-300a">
157157
{descripton}
158158
</span>
159159
</div>

0 commit comments

Comments
 (0)