Skip to content

Commit 84fb4b4

Browse files
authored
docs: github icon support hover tips and optimized the background (#6899)
* docs: github icon support hover tips and optimized the background color under hover * refactor: modify icon to `icon` export * style: optimize githubIcon style
1 parent 106750e commit 84fb4b4

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

site/src/layouts/header/Github.vue

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
<template>
2-
<span id="github-btn" class="github-btn">
3-
<a class="gh-btn" href="https://github.com/vueComponent/ant-design-vue" target="_blank">
4-
<span class="gh-ico" aria-hidden="true"></span>
5-
<span class="gh-text">Star</span>
6-
</a>
7-
</span>
2+
<a-tooltip placement="bottom">
3+
<template #title>Github</template>
4+
<span id="github-btn" class="github-btn" :style="githubIconStyles">
5+
<a class="gh-btn" href="https://github.com/vueComponent/ant-design-vue" target="_blank">
6+
<GithubOutlined class="github-icon" />
7+
</a>
8+
</span>
9+
</a-tooltip>
810
</template>
11+
12+
<script lang="ts">
13+
import { defineComponent, inject, computed } from 'vue';
14+
import { GithubOutlined } from '@ant-design/icons-vue';
15+
export default defineComponent({
16+
components: {
17+
GithubOutlined,
18+
},
19+
setup() {
20+
const themeMode = inject('themeMode');
21+
const githubIconStyles = computed(() => {
22+
let iconBackgroundColor = 'rgba(0,0,0,0.06)';
23+
if ((themeMode as any).theme.value === 'dark') {
24+
iconBackgroundColor = 'rgba(255,255,255,0.12)';
25+
}
26+
return {
27+
'--github-icon-background-color': iconBackgroundColor,
28+
};
29+
});
30+
return {
31+
githubIconStyles,
32+
};
33+
},
34+
});
35+
</script>
36+
937
<style lang="less" scoped>
1038
@import './Github.less';
1139
#github-btn {
@@ -14,10 +42,16 @@
1442
height: auto;
1543
1644
.gh-btn {
45+
color: currentColor;
1746
height: auto;
18-
padding: 1px 4px;
47+
padding: 6px;
1948
background: transparent;
2049
border: 0;
50+
transition: all 0.2s;
51+
52+
&:hover {
53+
background: var(--github-icon-background-color);
54+
}
2155
2256
.gh-ico {
2357
width: 20px;
@@ -30,6 +64,11 @@
3064
}
3165
}
3266
67+
.github-icon {
68+
font-size: 18px;
69+
color: var(--text-color);
70+
}
71+
3372
.gh-count {
3473
height: auto;
3574
padding: 4px 8px;

0 commit comments

Comments
 (0)