Skip to content

Commit d0703b0

Browse files
author
Guillaume Chau
committedMar 6, 2018
feat(ui): ProjectCreate path preview
1 parent db67f1e commit d0703b0

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed
 

‎packages/@vue/cli-ui/src/filters.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Display a folder path
3+
* @param {string} value path
4+
* @param {number} maxLength maximum length of displayed path
5+
*/
6+
export function folder (value, maxLength = -1) {
7+
value = value.replace(/\\/g, '/')
8+
9+
if (value.charAt(value.length - 1) !== '/') {
10+
value += '/'
11+
}
12+
13+
if (maxLength !== -1 && value.length > maxLength) {
14+
const exceeded = value.length - maxLength + 3
15+
const firstEnd = Math.floor(maxLength / 2 - exceeded / 2)
16+
const lastStart = Math.ceil(maxLength / 2 + exceeded / 2)
17+
value = value.substring(0, firstEnd) + '...' + value.substring(lastStart)
18+
}
19+
20+
return value
21+
}

‎packages/@vue/cli-ui/src/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import App from './App.vue'
33
import router from './router'
44
import { apolloProvider } from './vue-apollo'
55
import VueUi from '@vue/ui'
6+
import * as Filters from './filters'
67

78
Vue.use(VueUi)
89

10+
for (const key in Filters) {
11+
Vue.filter(key, Filters[key])
12+
}
13+
914
Vue.config.productionTip = false
1015

1116
const app = new Vue({

‎packages/@vue/cli-ui/src/views/ProjectCreate.vue

+33-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<div class="project-details vue-grid col-1 big-gap">
1515
<VueFormField
1616
title="Project folder"
17-
:subtitle="cwd"
1817
>
1918
<VueInput
2019
v-model="formData.folder"
@@ -23,10 +22,26 @@
2322
class="big"
2423
/>
2524

26-
<VueButton
27-
label="Change current working directory"
28-
:to="{ name: 'project-select', query: { tab: 'create', hideTabs: true } }"
29-
/>
25+
<div slot="subtitle">
26+
<div class="project-path">
27+
<div class="path">
28+
<span
29+
class="cwd"
30+
v-tooltip="cwd"
31+
>
32+
{{ cwd | folder(42 - formData.folder.length) }}
33+
</span>
34+
<span class="folder">{{ formData.folder }}</span>
35+
</div>
36+
37+
<VueButton
38+
icon-left="edit"
39+
class="icon-button"
40+
v-tooltip="'Change base directory'"
41+
:to="{ name: 'project-select', query: { tab: 'create', hideTabs: true } }"
42+
/>
43+
</div>
44+
</div>
3045
</VueFormField>
3146

3247
<VueFormField
@@ -358,4 +373,17 @@ export default {
358373
max-width 400px
359374
width 100%
360375
margin 42px auto
376+
377+
.project-path
378+
h-box()
379+
box-center()
380+
381+
.path
382+
flex 100% 1 1
383+
margin-right 6px
384+
h-box()
385+
align-items baseline
386+
387+
.folder
388+
font-weight bold
361389
</style>

0 commit comments

Comments
 (0)
Please sign in to comment.