Skip to content

Commit 636cca0

Browse files
userquinbrc-dd
andauthored
perf(theme): move svg icons to css (#3537)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent b63e0a0 commit 636cca0

22 files changed

+210
-253
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0-rc.42",
44
"description": "Vite & Vue powered static site generator",
55
"type": "module",
6-
"packageManager": "[email protected].1",
6+
"packageManager": "[email protected].3",
77
"main": "dist/node/index.js",
88
"types": "types/index.d.ts",
99
"exports": {

Diff for: src/client/theme-default/components/VPDocFooter.vue

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { computed } from 'vue'
33
import { useData } from '../composables/data'
44
import { useEditLink } from '../composables/edit-link'
55
import { usePrevNext } from '../composables/prev-next'
6-
import VPIconEdit from './icons/VPIconEdit.vue'
76
import VPLink from './VPLink.vue'
87
import VPDocFooterLastUpdated from './VPDocFooterLastUpdated.vue'
98
@@ -30,7 +29,7 @@ const showFooter = computed(() => {
3029
<div v-if="hasEditLink || hasLastUpdated" class="edit-info">
3130
<div v-if="hasEditLink" class="edit-link">
3231
<VPLink class="edit-link-button" :href="editLink.url" :no-icon="true">
33-
<VPIconEdit class="edit-link-icon" aria-label="edit icon"/>
32+
<span class="vpi-square-pen edit-link-icon" />
3433
{{ editLink.text }}
3534
</VPLink>
3635
</div>
@@ -92,9 +91,6 @@ const showFooter = computed(() => {
9291
9392
.edit-link-icon {
9493
margin-right: 8px;
95-
width: 14px;
96-
height: 14px;
97-
fill: currentColor;
9894
}
9995
10096
.prev-next {

Diff for: src/client/theme-default/components/VPFeature.vue

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import type { DefaultTheme } from 'vitepress/theme'
33
import VPImage from './VPImage.vue'
44
import VPLink from './VPLink.vue'
5-
import VPIconArrowRight from './icons/VPIconArrowRight.vue'
65
76
defineProps<{
87
icon?: DefaultTheme.FeatureIcon
@@ -46,7 +45,7 @@ defineProps<{
4645

4746
<div v-if="linkText" class="link-text">
4847
<p class="link-text-value">
49-
{{ linkText }} <VPIconArrowRight class="link-text-icon" />
48+
{{ linkText }} <span class="vpi-arrow-right link-text-icon" />
5049
</p>
5150
</div>
5251
</article>
@@ -119,10 +118,6 @@ defineProps<{
119118
}
120119
121120
.link-text-icon {
122-
display: inline-block;
123121
margin-left: 6px;
124-
width: 14px;
125-
height: 14px;
126-
fill: currentColor;
127122
}
128123
</style>

Diff for: src/client/theme-default/components/VPFlyout.vue

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<script lang="ts" setup>
22
import { ref } from 'vue'
33
import { useFlyout } from '../composables/flyout'
4-
import VPIconChevronDown from './icons/VPIconChevronDown.vue'
5-
import VPIconMoreHorizontal from './icons/VPIconMoreHorizontal.vue'
64
import VPMenu from './VPMenu.vue'
75
86
defineProps<{
9-
icon?: any
7+
icon?: string
108
button?: string
119
label?: string
1210
items?: any[]
@@ -38,12 +36,12 @@ function onBlur() {
3836
@click="open = !open"
3937
>
4038
<span v-if="button || icon" class="text">
41-
<component v-if="icon" :is="icon" class="option-icon" />
39+
<span v-if="icon" :class="[icon, 'option-icon']" />
4240
<span v-if="button" v-html="button"></span>
43-
<VPIconChevronDown class="text-icon" />
41+
<span class="vpi-chevron-down text-icon" />
4442
</span>
4543

46-
<VPIconMoreHorizontal v-else class="icon" />
44+
<span v-else class="vpi-more-horizontal icon" />
4745
</button>
4846

4947
<div class="menu">
@@ -114,22 +112,16 @@ function onBlur() {
114112
115113
.option-icon {
116114
margin-right: 0px;
117-
width: 16px;
118-
height: 16px;
119-
fill: currentColor;
115+
font-size: 16px;
120116
}
121117
122118
.text-icon {
123119
margin-left: 4px;
124-
width: 14px;
125-
height: 14px;
126-
fill: currentColor;
120+
font-size: 14px;
127121
}
128122
129123
.icon {
130-
width: 20px;
131-
height: 20px;
132-
fill: currentColor;
124+
font-size: 20px;
133125
transition: fill 0.25s;
134126
}
135127

Diff for: src/client/theme-default/components/VPHomeSponsors.vue

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
import VPIconHeart from './icons/VPIconHeart.vue'
32
import VPButton from './VPButton.vue'
43
import VPSponsors from './VPSponsors.vue'
54
@@ -30,7 +29,9 @@ withDefaults(defineProps<Props>(), {
3029
<section class="VPHomeSponsors">
3130
<div class="container">
3231
<div class="header">
33-
<div class="love"><VPIconHeart class="icon" /></div>
32+
<div class="love">
33+
<span class="vpi-heart icon" />
34+
</div>
3435
<h2 v-if="message" class="message">{{ message }}</h2>
3536
</div>
3637

@@ -59,15 +60,13 @@ withDefaults(defineProps<Props>(), {
5960
6061
.love {
6162
margin: 0 auto;
62-
width: 28px;
63-
height: 28px;
63+
width: fit-content;
64+
font-size: 28px;
6465
color: var(--vp-c-text-3);
6566
}
6667
6768
.icon {
68-
width: 28px;
69-
height: 28px;
70-
fill: currentColor;
69+
display: inline-block;
7170
}
7271
7372
.message {

Diff for: src/client/theme-default/components/VPLocalNav.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useLocalNav } from '../composables/local-nav'
77
import { getHeaders } from '../composables/outline'
88
import { useSidebar } from '../composables/sidebar'
99
import VPLocalNavOutlineDropdown from './VPLocalNavOutlineDropdown.vue'
10-
import VPIconAlignLeft from './icons/VPIconAlignLeft.vue'
1110
1211
defineProps<{
1312
open: boolean
@@ -67,7 +66,7 @@ const classes = computed(() => {
6766
aria-controls="VPSidebarNav"
6867
@click="$emit('open-menu')"
6968
>
70-
<VPIconAlignLeft class="menu-icon" />
69+
<span class="vpi-align-left menu-icon"></span>
7170
<span class="menu-text">
7271
{{ theme.sidebarMenuLabel || 'Menu' }}
7372
</span>
@@ -157,9 +156,7 @@ const classes = computed(() => {
157156
158157
.menu-icon {
159158
margin-right: 8px;
160-
width: 16px;
161-
height: 16px;
162-
fill: currentColor;
159+
font-size: 14px;
163160
}
164161
165162
.VPOutlineDropdown {

Diff for: src/client/theme-default/components/VPLocalNavOutlineDropdown.vue

+13-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { nextTick, ref } from 'vue'
55
import { useData } from '../composables/data'
66
import { resolveTitle, type MenuItem } from '../composables/outline'
77
import VPDocOutlineItem from './VPDocOutlineItem.vue'
8-
import VPIconChevronRight from './icons/VPIconChevronRight.vue'
98
109
const props = defineProps<{
1110
headers: MenuItem[]
@@ -61,7 +60,7 @@ function scrollToTop() {
6160
>
6261
<button @click="toggle" :class="{ open }" v-if="headers.length > 0">
6362
{{ resolveTitle(theme) }}
64-
<VPIconChevronRight class="icon" />
63+
<span class="vpi-chevron-right icon" />
6564
</button>
6665
<button @click="scrollToTop" v-else>
6766
{{ theme.returnToTopLabel || 'Return to top' }}
@@ -111,19 +110,23 @@ function scrollToTop() {
111110
color: var(--vp-c-text-1);
112111
}
113112
113+
.icon {
114+
display: inline-block;
115+
vertical-align: middle;
116+
margin-left: 2px;
117+
font-size: 14px;
118+
transform: rotate(0deg);
119+
transition: transform 0.25s;
120+
}
121+
114122
@media (min-width: 960px) {
115123
.VPLocalNavOutlineDropdown button {
116124
font-size: 14px;
117125
}
118-
}
119126
120-
.icon {
121-
display: inline-block;
122-
vertical-align: middle;
123-
margin-left: 2px;
124-
width: 14px;
125-
height: 14px;
126-
fill: currentColor;
127+
.icon {
128+
font-size: 16px;
129+
}
127130
}
128131
129132
.open > .icon {

0 commit comments

Comments
 (0)