Skip to content

Commit 7323fa9

Browse files
authored
style(site): 添加官网主题样式 (Tencent#800)
style(site): 添加主题样式 - 添加全局品牌颜色 CSS 变量定义 - 支持浅色和深色两种主题模式 - 定义完整的品牌色彩体系 (1-10级)
1 parent 0c257b8 commit 7323fa9

1 file changed

Lines changed: 45 additions & 4 deletions

File tree

tdesign-site/site/app.vue

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { defineComponent } from 'vue';
1616
1717
const { docs: routerList } = JSON.parse(JSON.stringify(siteConfig).replace(/component:.+/g, ''));
1818
19-
routerList.forEach(item => {
19+
routerList.forEach((item) => {
2020
if (item.type === 'component') {
2121
item.children = item.children.sort((a, b) => {
2222
const nameA = a.name.toUpperCase();
@@ -26,7 +26,7 @@ routerList.forEach(item => {
2626
return 0;
2727
});
2828
}
29-
})
29+
});
3030
3131
export default defineComponent({
3232
data() {
@@ -48,7 +48,7 @@ export default defineComponent({
4848
this.$refs.tdHeader.framework = 'flutter';
4949
this.$refs.tdDocAside.routerList = routerList;
5050
this.$refs.tdDocAside.onchange = ({ detail }) => {
51-
console.log("detail: " + JSON.stringify(detail));
51+
console.log('detail: ' + JSON.stringify(detail));
5252
if (this.$route.path === detail) return;
5353
this.loaded = false;
5454
this.$router.push({ path: detail });
@@ -61,7 +61,7 @@ export default defineComponent({
6161
$route(route) {
6262
if (!route.meta.docType) return;
6363
this.docType = route.meta.docType;
64-
}
64+
},
6565
},
6666
6767
methods: {
@@ -74,3 +74,44 @@ export default defineComponent({
7474
},
7575
});
7676
</script>
77+
78+
<style lang="less">
79+
:root,
80+
:root[theme-mode='light'] {
81+
--td-brand-color-1: #f2f3ff;
82+
--td-brand-color-2: #d9e1ff;
83+
--td-brand-color-3: #b5c7ff;
84+
--td-brand-color-4: #8eabff;
85+
--td-brand-color-5: #618dff;
86+
--td-brand-color-6: #366ef4;
87+
--td-brand-color-7: #0052d9;
88+
--td-brand-color-8: #003cab;
89+
--td-brand-color-9: #002a7c;
90+
--td-brand-color-10: #001a57;
91+
--td-brand-color: var(--td-brand-color-7);
92+
--td-brand-color-focus: var(--td-brand-color-1);
93+
--td-brand-color-active: var(--td-brand-color-8);
94+
--td-brand-color-disabled: var(--td-brand-color-3) #b5c7ff;
95+
--td-brand-color-light: var(--td-brand-color-1);
96+
--td-brand-color-light-active: var(--td-brand-color-2);
97+
}
98+
99+
:root[theme-mode='dark'] {
100+
--td-brand-color-1: #1b2f51;
101+
--td-brand-color-2: #173463;
102+
--td-brand-color-3: #143975;
103+
--td-brand-color-4: #103d88;
104+
--td-brand-color-5: #0d429a;
105+
--td-brand-color-6: #054bbe;
106+
--td-brand-color-7: #2667d4;
107+
--td-brand-color-8: #4582e6;
108+
--td-brand-color-9: #699ef5;
109+
--td-brand-color-10: #96bbf8;
110+
--td-brand-color: var(--td-brand-color-8);
111+
--td-brand-color-focus: var(--td-brand-color-1);
112+
--td-brand-color-active: var(--td-brand-color-9);
113+
--td-brand-color-disabled: var(--td-brand-color-3);
114+
--td-brand-color-light: var(--td-brand-color-1);
115+
--td-brand-color-light-active: var(--td-brand-color-2);
116+
}
117+
</style>

0 commit comments

Comments
 (0)