Skip to content

Commit 6c4d673

Browse files
feat: update to unocss (#290)
* feat: first pass to go to unocss * feat: full transition to unocss is complete * feat(playwright): enhance snapshot approval workflow with patch creation and commit automation * fix(playwright): remove unnecessary pull request permissions and comment step from snapshot approval workflow * feat(playwright): update snapshot patch creation to include staged changes * test: update Playwright snapshots * fix: do not commit the patch file * test: update Playwright snapshots --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent aec4055 commit 6c4d673

36 files changed

Lines changed: 569 additions & 184 deletions

.github/workflows/playwright.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ jobs:
5555
echo "No file changes after update-snapshots."
5656
fi
5757
58+
- name: Create snapshot patch
59+
if: steps.detect_changes.outputs.changed == 'true'
60+
shell: bash
61+
run: |
62+
git add -A
63+
git diff --cached --binary > playwright-snapshots.patch
64+
65+
- name: Upload snapshot patch
66+
if: steps.detect_changes.outputs.changed == 'true'
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: playwright-snapshot-patch
70+
path: playwright-snapshots.patch
71+
retention-days: 14
72+
5873
- name: Upload Playwright report
5974
if: always()
6075
uses: actions/upload-artifact@v4
@@ -75,8 +90,59 @@ jobs:
7590
needs: visual-check
7691
if: needs.visual-check.outputs.snapshots_changed == 'true'
7792
runs-on: ubuntu-latest
93+
permissions:
94+
contents: write
7895
environment:
7996
name: playwright-snapshot-approval
8097
steps:
81-
- name: Approved snapshot updates
82-
run: echo "Snapshot updates approved."
98+
- name: Resolve target branch
99+
id: resolve_branch
100+
shell: bash
101+
run: |
102+
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
103+
104+
if [[ -z "$branch_name" ]]; then
105+
echo "Unable to determine target branch."
106+
exit 1
107+
fi
108+
109+
if [[ "$branch_name" == "main" ]]; then
110+
echo "Snapshot updates cannot be auto-committed to main."
111+
exit 1
112+
fi
113+
114+
echo "branch_name=$branch_name" >> "$GITHUB_OUTPUT"
115+
echo "Snapshot updates approved for branch: $branch_name"
116+
117+
- name: Checkout target branch
118+
uses: actions/checkout@v4
119+
with:
120+
ref: ${{ steps.resolve_branch.outputs.branch_name }}
121+
122+
- name: Download snapshot patch
123+
uses: actions/download-artifact@v4
124+
with:
125+
name: playwright-snapshot-patch
126+
path: ${{ runner.temp }}/playwright-snapshot-patch
127+
128+
- name: Apply snapshot patch
129+
shell: bash
130+
run: git apply --index --reject --whitespace=nowarn "$RUNNER_TEMP/playwright-snapshot-patch/playwright-snapshots.patch"
131+
132+
- name: Commit snapshot updates
133+
id: commit_snapshot_updates
134+
shell: bash
135+
run: |
136+
if [[ -z "$(git status --porcelain)" ]]; then
137+
echo "No snapshot changes to commit after approval."
138+
echo "committed=false" >> "$GITHUB_OUTPUT"
139+
exit 0
140+
fi
141+
142+
git config user.name "github-actions[bot]"
143+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
144+
git add -A
145+
git commit -m "test: update Playwright snapshots"
146+
git push origin "HEAD:${{ steps.resolve_branch.outputs.branch_name }}"
147+
echo "committed=true" >> "$GITHUB_OUTPUT"
148+
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bun run dev
2222
- [vitest](https://vitest.dev/) for unit testing
2323
- [@testing-library/preact](https://preactjs.com/guide/v10/preact-testing-library/) for testing-library
2424
- [mermaid](https://mermaid-js.github.io/mermaid/#/) for mermaid diagrams for markdown
25-
- [tailwindcss](https://tailwindcss.com/) for CSS
25+
- [unocss](https://unocss.dev/) for utility-first CSS
2626
- [Vercel](https://vercel.com/) for Build Previews
2727
- [Github Pages](https://pages.github.com/) for Production
2828

astro.config.mjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineConfig } from "astro/config";
2-
import tailwind from "@astrojs/tailwind";
32
import preact from "@astrojs/preact";
3+
import unoCss from "@unocss/astro";
44
import tsconfigPaths from "vite-tsconfig-paths";
55
import remarkMermaid from "./utils/remark-mermaid/index.mjs";
66

@@ -12,12 +12,5 @@ export default defineConfig({
1212
markdown: {
1313
remarkPlugins: ["remark-gfm", "remark-smartypants", remarkMermaid],
1414
},
15-
integrations: [
16-
tailwind({
17-
config: {
18-
applyBaseStyles: false,
19-
},
20-
}),
21-
preact(),
22-
],
15+
integrations: [unoCss(), preact()],
2316
});

bun.lockb

-24.7 KB
Binary file not shown.
683 KB
Loading
569 KB
Loading
460 KB
Loading

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
},
1818
"devDependencies": {
1919
"@astrojs/preact": "5.0.2",
20-
"@astrojs/tailwind": "6.0.2",
2120
"@eslint/compat": "^1.2.6",
2221
"@eslint/eslintrc": "^3.2.0",
2322
"@eslint/js": "^9.20.0",
2423
"@netlify/classnames-template-literals": "^1.0.3",
2524
"@playwright/test": "^1.50.1",
2625
"@preact/preset-vite": "^2.10.1",
27-
"@tailwindcss/typography": "^0.5.16",
2826
"@testing-library/jest-dom": "^6.6.3",
2927
"@testing-library/preact": "^3.2.4",
3028
"@testing-library/user-event": "^14.6.1",
3129
"@types/node": "^22.13.4",
3230
"@typescript-eslint/eslint-plugin": "^8.24.0",
3331
"@typescript-eslint/parser": "^8.24.0",
32+
"@unocss/astro": "^66.6.7",
33+
"@unocss/preset-typography": "^66.6.7",
34+
"@unocss/preset-wind3": "^66.6.7",
3435
"@vitejs/plugin-react": "^4.3.4",
3536
"@vitest/coverage-v8": "^2.1.9",
3637
"@vitest/ui": "^2.1.9",
@@ -56,11 +57,10 @@
5657
"preact": "^10.25.4",
5758
"prettier": "^3.5.1",
5859
"prettier-plugin-astro": "^0.14.1",
59-
"tailwind-merge": "^2.6.0",
60-
"tailwindcss": "^3.4.17",
6160
"ts-essentials": "^10.0.4",
6261
"typescript": "^5.9.3",
6362
"unist-util-visit": "^5.0.0",
63+
"unocss": "^66.6.7",
6464
"vite-tsconfig-paths": "^6.1.1",
6565
"vitest": "^4.1.0"
6666
},

postcss.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
plugins: {
3-
tailwindcss: {},
43
autoprefixer: {},
54
},
6-
}
5+
};

src/components/app/AppSocialMedia.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { twMerge } from "tailwind-merge";
1+
import classNames from "classnames";
22

33
import Github from "~/components/icons/Github";
44
import LinkedIn from "~/components/icons/LinkedIn";
@@ -10,7 +10,7 @@ type Props = {
1010

1111
const AppSocialMedia = ({ className }: Props) => {
1212
return (
13-
<div className={twMerge("flex gap-2", className)}>
13+
<div className={classNames("flex gap-2", className)}>
1414
<a
1515
title="View My Github Profile"
1616
href={GITHUB_URL}

0 commit comments

Comments
 (0)