Skip to content

Commit b4f2a26

Browse files
refactor(web): unocss via vite plugin
1 parent c412a65 commit b4f2a26

10 files changed

+55
-133
lines changed

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ snapshot:
99
dev:
1010
air
1111

12-
dev-vite:
12+
dev-web:
1313
cd web && pnpm run dev
1414

15-
dev-uno:
16-
cd web && pnpm run dev-uno
17-
1815
clean:
1916
rm -rf smtpbridge_data
2017

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ smtp:
8888
disable: false # (false, true)
8989
host: ""
9090
port: 1025
91+
auth:
92+
username: username
93+
password: password
9194

9295
# Endpoints for envelopes
9396
endpoints:

web/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite dev",
8-
"dev-uno": "unocss --watch",
9-
"build": "tsc && unocss && vite build"
8+
"build": "tsc && vite build"
109
},
1110
"devDependencies": {
1211
"@iconify-json/ri": "^1.1.10",
1312
"@rollup/plugin-inject": "^5.0.3",
14-
"@unocss/cli": "^0.53.6",
1513
"@unocss/preset-icons": "^0.53.6",
1614
"typescript": "^5.1.6",
1715
"unocss": "^0.53.6",

web/pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "htmx.org"
22
import "htmx.org/dist/ext/loading-states.js"
33
import "@picocss/pico";
4-
import "./uno.css"
54
import "./pico.css"
5+
import 'uno.css'

web/src/uno.css

-70
This file was deleted.

web/uno.config.ts

-35
This file was deleted.

web/views/envelopes-show.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h2><a href="#endpoints">Endpoints</a></h2>
6666
<form method="post" action="/send" hx-post="/send">
6767
<input type="hidden" id="envelope" name="envelope" value="{{.Envelope.Message.ID}}">
6868
<label for="endpoint">
69-
Endpoints
69+
Endpoint
7070
<select id="endpoint" name="endpoint">
7171
{{range $val := .Endpoints}}
7272
<option value="{{$val.ID}}">{{$val.Name}}</option>

web/views/rules.html

+16-15
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,23 @@ <h2>Showing {{len .AggregateRules}} rules.</h2>
4040
</label>
4141
</div>
4242

43-
<h4>Endpoints</h4>
44-
45-
<div class="flex flex-col gap-4">
46-
{{range $end := $val.Endpoints}}
47-
<div class="flex justify-between gap-2">
48-
<div class="text-ellipsis truncate">
49-
<a href="/endpoints#endpoint-{{$end.ID}}">
50-
{{$end.Name}}
51-
</a>
43+
<fieldset>
44+
<legend>Endpoints</legend>
45+
<div class="flex flex-col gap-2">
46+
{{range $end := $val.Endpoints}}
47+
<div class="flex justify-between gap-2">
48+
<div class="text-ellipsis truncate">
49+
<a href="/endpoints#endpoint-{{$end.ID}}">
50+
{{$end.Name}}
51+
</a>
52+
</div>
53+
<div>
54+
<input {{if $val.Rule.Internal}}disabled{{end}} {{if $end.Enable}}checked{{end}} type="checkbox"
55+
role="switch" />
56+
</div>
5257
</div>
53-
<div>
54-
<input {{if $val.Rule.Internal}}disabled{{end}} {{if $end.Enable}}checked{{end}} type="checkbox"
55-
role="switch" />
56-
</div>
57-
</div>
58-
{{end}}
58+
{{end}}
59+
</fieldset>
5960
</div>
6061
</article>
6162
</details>

web/vite.config.ts

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { defineConfig } from "vite"
22
import FullReload from 'vite-plugin-full-reload'
33
import inject from '@rollup/plugin-inject'
4+
import UnoCSS from 'unocss/vite'
5+
import { presetUno } from 'unocss'
6+
import presetIcons from '@unocss/preset-icons'
47

58
export default defineConfig({
69
plugins: [
@@ -9,13 +12,41 @@ export default defineConfig({
912
htmx: 'htmx.org',
1013
htmx_loading_states: "htmx.org/dist/ext/loading-states.js"
1114
}),
15+
UnoCSS({
16+
content: {
17+
filesystem: ["views/**/*"]
18+
},
19+
rules: [
20+
[/^bg-(.*)$/, ([, c], { theme }) => {
21+
//@ts-ignore
22+
if (theme.colors[c]) {
23+
return {
24+
//@ts-ignore
25+
color: theme.colors[c],
26+
}
27+
}
28+
}],
29+
],
30+
theme: {
31+
colors: {
32+
'pico': {
33+
'card': 'var(--card-background-color)',
34+
'background': 'var(--background-color)',
35+
}
36+
},
37+
},
38+
presets: [
39+
presetUno(),
40+
presetIcons(),
41+
],
42+
}),
1243
],
1344
build: {
1445
// generate manifest.json in outDir
1546
manifest: true,
1647
rollupOptions: {
1748
// overwrite default .html entry
18-
// also change in ./views/layouts/index.html
49+
// DEPS: ./views/layouts/index.html
1950
input: 'src/main.ts',
2051
},
2152
},

0 commit comments

Comments
 (0)