Skip to content

Commit ba6e59a

Browse files
committed
feat: theme colors
1 parent e7f9a20 commit ba6e59a

File tree

6 files changed

+47
-19
lines changed

6 files changed

+47
-19
lines changed

app.vue

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,10 @@ const mode = computed(() => color.value as ConfigProviderTheme)
1313
<template>
1414
<VanConfigProvider :theme="mode">
1515
<ColorScheme tag="div">
16+
<NuxtLoadingIndicator />
1617
<NuxtLayout>
1718
<NuxtPage />
1819
</NuxtLayout>
1920
</ColorScheme>
2021
</VanConfigProvider>
2122
</template>
22-
23-
<style>
24-
#__nuxt {
25-
height: 100vh;
26-
margin: 0;
27-
padding: 0;
28-
}
29-
30-
html {
31-
background: var(--van-gray-1);
32-
color-scheme: light;
33-
}
34-
35-
html.dark {
36-
background: #222;
37-
color-scheme: dark;
38-
}
39-
</style>

nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export default defineNuxtConfig({
1212

1313
css: [
1414
'@unocss/reset/tailwind.css',
15+
'~/styles/vars.css',
16+
'~/styles/global.css',
17+
'~/styles/default-theme.css',
1518
],
1619

1720
postcss: {

styles/default-theme.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:root:root {
2+
--van-primary-color: var(--c-primary);
3+
}

styles/global.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#__nuxt {
2+
height: 100vh;
3+
margin: 0;
4+
padding: 0;
5+
}
6+
7+
html {
8+
background: var(--van-gray-1);
9+
color-scheme: light;
10+
}
11+
12+
html.dark {
13+
background: #222;
14+
color-scheme: dark;
15+
}

styles/vars.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:root {
2+
--c-primary: rgb(var(--c-primary-500));
3+
--c-primary-active: rgb(var(--c-primary-600));
4+
5+
/* main color ratio */
6+
--c-primary-100: 217 251 232;
7+
--c-primary-200: 179 245 209;
8+
--c-primary-300: 117 237 174;
9+
--c-primary-400: 0 220 130;
10+
--c-primary-500: 0 193 106;
11+
--c-primary-600: 0 161 85;
12+
--c-primary-700: 0 127 69;
13+
--c-primary-800: 1 101 56;
14+
--c-primary-900: 10 83 49;
15+
}

uno.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import presetRemToPx from '@unocss/preset-rem-to-px'
1515
export default defineConfig({
1616
shortcuts: [
1717
// shortcuts to multiple utilities
18-
['btn', 'px-6 py-3 rounded-3 border-none inline-block bg-green-400 text-white cursor-pointer hover:bg-green-600 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
18+
['btn', 'px-6 py-3 rounded-3 inline-block bg-primary text-white cursor-pointer hover:bg-primary-hover disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
1919
],
2020

2121
presets: [
@@ -33,4 +33,13 @@ export default defineConfig({
3333
transformerDirectives(),
3434
transformerVariantGroup(),
3535
],
36+
37+
theme: {
38+
colors: {
39+
primary: {
40+
DEFAULT: 'var(--c-primary)',
41+
hover: 'var(--c-primary-active)',
42+
},
43+
},
44+
},
3645
})

0 commit comments

Comments
 (0)