Skip to content

Commit 3da7427

Browse files
author
Guillaume Chau
committed
refactor(ui): Suggestion from modal to dropdown
1 parent 29c1ce5 commit 3da7427

File tree

3 files changed

+69
-65
lines changed

3 files changed

+69
-65
lines changed

packages/@vue/cli-ui/locales/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@
353353
"suggestions": {
354354
"vue-router-add": {
355355
"label": "Add vue-router",
356-
"message": "Add support for multiple pages into the app."
356+
"message": "Official library to support multiple virtual pages in a Single-Page App. Each route renders a different component."
357357
},
358358
"vuex-add": {
359359
"label": "Add vuex",
360-
"message": "Centralized State Management solution for large-scale apps."
360+
"message": "Official centralized State Management solution for large-scale apps. Very useful if multiple components need to access the same data."
361361
},
362362
"progress": "Installing {arg0}..."
363363
}

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

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,78 +27,66 @@
2727
/>
2828

2929
<template slot-scope="{ result: { data } }" v-if="data">
30-
<VueButton
30+
<VueDropdown
3131
v-for="suggestion of data.suggestions"
3232
:key="suggestion.id"
33-
:label="$t(suggestion.label)"
34-
:loading="suggestion.busy"
35-
class="suggestion round"
36-
v-tooltip="$t('components.suggestion-bar.suggestion')"
37-
@click="select(suggestion)"
38-
/>
39-
</template>
40-
41-
<VueModal
42-
v-if="showDetails"
43-
:title="$t(currentSuggestion.label)"
44-
class="medium"
45-
@close="showDetails = false"
46-
>
47-
<div class="default-body">
48-
<div
49-
v-if="currentSuggestion.message"
50-
class="info message"
51-
v-html="$t(currentSuggestion.message)"
52-
/>
53-
<div
54-
v-if="currentSuggestion.link"
55-
class="info links"
56-
>
57-
<a :href="currentSuggestion.link" target="_blank">
58-
{{ $t('components.list-item-info.more-info') }}
59-
</a>
60-
</div>
61-
</div>
62-
63-
<div slot="footer" class="actions">
33+
:disabled="!suggestion.message && !suggestion.link"
34+
class="suggestion"
35+
placement="bottom-end"
36+
>
6437
<VueButton
65-
class="big"
66-
:label="$t('components.suggestion-bar.modal.cancel')"
67-
icon="close"
68-
@click="showDetails = false"
38+
slot="trigger"
39+
:label="$t(suggestion.label)"
40+
:loading="suggestion.busy"
41+
class="round"
42+
v-tooltip="$t('components.suggestion-bar.suggestion')"
43+
@click="if (!suggestion.message && !suggestion.link) activate(suggestion)"
6944
/>
70-
<VueButton
71-
class="primary big"
72-
:label="$t('components.suggestion-bar.modal.continue')"
73-
icon="done"
74-
@click="activate(currentSuggestion)"
75-
/>
76-
</div>
77-
</VueModal>
45+
46+
<div class="suggestion-details">
47+
<div class="info label">
48+
{{ $t(suggestion.label) }}
49+
</div>
50+
51+
<div
52+
v-if="suggestion.message"
53+
class="info message"
54+
v-html="$t(suggestion.message)"
55+
/>
56+
57+
<div class="actions-bar">
58+
<VueButton
59+
:href="suggestion.link"
60+
:label="$t('components.list-item-info.more-info')"
61+
target="_blank"
62+
class="flat"
63+
icon-right="open_in_new"
64+
/>
65+
<div class="vue-ui-spacer"/>
66+
<VueButton
67+
:label="$t('components.suggestion-bar.modal.cancel')"
68+
icon-left="close"
69+
v-close-popover
70+
/>
71+
<VueButton
72+
class="primary"
73+
:label="$t('components.suggestion-bar.modal.continue')"
74+
icon-left="done"
75+
v-close-popover
76+
@click="activate(suggestion)"
77+
/>
78+
</div>
79+
</div>
80+
</VueDropdown>
81+
</template>
7882
</ApolloQuery>
7983
</template>
8084

8185
<script>
8286
import SUGGESTION_ACTIVATE from '../graphql/suggestionActivate.gql'
8387
8488
export default {
85-
data () {
86-
return {
87-
currentSuggestion: null,
88-
showDetails: false
89-
}
90-
},
91-
9289
methods: {
93-
select (suggestion) {
94-
if (suggestion.message || suggestion.link) {
95-
this.currentSuggestion = suggestion
96-
this.showDetails = true
97-
} else {
98-
this.activate(suggestion)
99-
}
100-
},
101-
10290
async activate (suggestion) {
10391
this.showDetails = false
10492
await this.$apollo.mutate({
@@ -121,7 +109,19 @@ export default {
121109
&:not(:first-child)
122110
margin-left $padding-item
123111
124-
.info
125-
&:not(:last-child)
126-
margin-bottom $padding-item
112+
.suggestion-details
113+
padding ($padding-item * 2 - 8px) ($padding-item * 2)
114+
box-sizing border-box
115+
width 440px
116+
117+
.label
118+
font-size 20px
119+
120+
.actions-bar
121+
padding 0
122+
margin-top ($padding-item * 3)
123+
124+
.info
125+
&:not(:last-child)
126+
margin-bottom $padding-item
127127
</style>

packages/@vue/cli-ui/src/style/main.styl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ h2
3232
justify-content flex-start
3333
&.end
3434
justify-content flex-end
35+
&.fill
36+
> *
37+
flex auto 1 1
38+
width 0
3539

3640
.cta-text
3741
margin $padding-item

0 commit comments

Comments
 (0)