Skip to content

Commit 088d316

Browse files
author
Guillaume Chau
committed
feat(ui): plugin logo
1 parent b9a714c commit 088d316

File tree

14 files changed

+68
-2
lines changed

14 files changed

+68
-2
lines changed
2.07 KB
Loading
1.35 KB
Loading
2.24 KB
Loading
1.77 KB
Loading

packages/@vue/cli-plugin-pwa/logo.png

2.33 KB
Loading
1.22 KB
Loading
2.28 KB
Loading
1.6 KB
Loading

packages/@vue/cli-ui/src/components/ProjectPluginItem.vue

+41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<template>
22
<div class="project-plugin-item list-item">
3+
<div class="logo">
4+
<div class="wrapper">
5+
<img
6+
v-if="plugin.logo"
7+
class="image"
8+
:src="plugin.logo"
9+
>
10+
<VueIcon
11+
v-else
12+
icon="widgets"
13+
/>
14+
</div>
15+
</div>
16+
317
<ListItemInfo
418
:name="plugin.id"
519
:link="plugin.website"
@@ -61,6 +75,12 @@ export default {
6175
6276
.project-plugin-item
6377
padding $padding-item
78+
h-box()
79+
box-center()
80+
81+
.list-item-info
82+
flex 100% 1 1
83+
width 0
6484
6585
.plugin-description
6686
margin-right $padding-item
@@ -69,11 +89,32 @@ export default {
6989
opacity .7
7090
7191
.info
92+
display inline-block
7293
space-between-x($padding-item)
7394
>>> > *
7495
space-between-x(4px)
7596
7697
.package-description
7798
font-style italic
7899
opacity .7
100+
101+
.logo
102+
margin-right $padding-item
103+
.wrapper
104+
h-box()
105+
box-center()
106+
width 42px
107+
height @width
108+
background rgba(black, .03)
109+
border-radius 50%
110+
overflow hidden
111+
.image
112+
width 100%
113+
height @width
114+
.vue-icon
115+
width 24px
116+
height @width
117+
>>> svg
118+
fill rgba($color-text-light, .3)
119+
79120
</style>

packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const metadataCache = new LRU({
1212
maxAge: 1000 * 60 * 30
1313
})
1414

15+
const logoCache = new LRU({
16+
max: 50
17+
})
18+
1519
function getPath (id) {
1620
return path.join(cwd.get(), 'node_modules', id)
1721
}
@@ -89,8 +93,24 @@ async function getDescription ({ id }, context) {
8993
return null
9094
}
9195

96+
async function getLogo ({ id }, context) {
97+
const cached = logoCache.get(id)
98+
if (cached) {
99+
return `data:image/png;base64,${cached}`
100+
}
101+
const folder = getPath(id)
102+
const file = path.join(folder, 'logo.png')
103+
if (fs.existsSync(file)) {
104+
const data = fs.readFileSync(file, { encoding: 'base64' })
105+
logoCache.set(id, data)
106+
return `data:image/png;base64,${data}`
107+
}
108+
return null
109+
}
110+
92111
module.exports = {
93112
list,
94113
getVersion,
95-
getDescription
114+
getDescription,
115+
getLogo
96116
}

packages/@vue/cli-ui/src/graphql-api/resolvers.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module.exports = {
2929

3030
Plugin: {
3131
version: (plugin, args, context) => plugins.getVersion(plugin, context),
32-
description: (plugin, args, context) => plugins.getDescription(plugin, context)
32+
description: (plugin, args, context) => plugins.getDescription(plugin, context),
33+
logo: (plugin, args, context) => plugins.getLogo(plugin, context)
3334
},
3435

3536
Query: {

packages/@vue/cli-ui/src/graphql-api/type-defs.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Plugin {
8585
description: String
8686
githubStats: GitHubStats
8787
prompts: [Prompt]
88+
logo: String
8889
}
8990
9091
type Feature {

packages/@vue/cli-ui/src/graphql/pluginFragment.gql

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ fragment plugin on Plugin {
99
installed
1010
website
1111
description
12+
logo
1213
}

packages/@vue/cli-ui/src/views/ProjectPlugins.vue

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
fetch-policy="cache-and-network"
1717
>
1818
<template slot-scope="{ result: { data, loading } }">
19+
<div class="cta-text">Installed plugins</div>
20+
1921
<VueLoadingIndicator
2022
v-if="loading"
2123
class="overlay"

0 commit comments

Comments
 (0)