Skip to content

Commit ac43da2

Browse files
committed
feat: support customize progress bar color
re #1
1 parent ace3704 commit ac43da2

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,27 @@ new LoadingScreenPlugin({
100100
})
101101
```
102102

103+
### theme
104+
105+
- Type: `ThemeConfig`
106+
- Default: `DefaultThemeConfig`
107+
108+
Customize loading screen progress bar color.
109+
110+
```ts
111+
interface ThemeConfig {
112+
client?: string
113+
server?: string
114+
modern?: string
115+
}
116+
117+
const DefaultThemeConfig = {
118+
client: '#8ed5fb',
119+
server: '#1b78bf',
120+
modern: '#2f495e'
121+
}
122+
```
123+
103124
### env
104125

105126
- Type: `'development' | 'production'`

app/app.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div v-for="bundle of bundles" :key="bundle" class="row">
2222
<h3>{{ bundle | capitalize }} bundle</h3>
2323
<div class="progress_bar_container">
24-
<div class="progress_bar" :class="bundle" :style="{ width: `${states[bundle].progress}%` }" />
24+
<div class="progress_bar" :style="{ width: `${states[bundle].progress}%`, backgroundColor: theme[bundle] }" />
2525
</div>
2626
<h4>{{ states[bundle].status }}</h4>
2727
</div>
@@ -72,7 +72,8 @@ export default {
7272
isFinished: false,
7373
baseURL: window.$BASE_URL,
7474
bundles: [],
75-
states: {}
75+
states: {},
76+
theme: window.$THEME
7677
}
7778
},
7879

app/css/loading.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,3 @@ h4 {
7676
width: 10px;
7777
transition: width 0.4s;
7878
}
79-
80-
.progress_bar.client {
81-
background-color: #8ed5fb;
82-
}
83-
84-
.progress_bar.server {
85-
background-color: #1b78bf;
86-
}
87-
88-
.progress_bar.modern {
89-
background-color: #2F495E;
90-
}
91-

app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<!-- loading_app -->
1111
<div id="webpack_loading_screen"></div>
1212
<script>window.$STATE = {STATE}</script>
13+
<script>window.$THEME = {THEME}</script>
1314
<script>window.$LOGO = '{LOGO}'</script>
1415
<script>window.$BASE_URL = '{BASE_URL}'</script>
1516
</body>

lib/loading.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class LoadingUI {
1212
this.baseURL = opts.baseURL
1313

1414
this.logo = opts.logo
15+
this.theme = opts.theme
1516

1617
this.serveIndex = this.serveIndex.bind(this)
1718
this.serveWS = this.serveWS.bind(this)
@@ -89,6 +90,7 @@ class LoadingUI {
8990
res.end(
9091
this.indexTemplate
9192
.replace('{STATE}', JSON.stringify(this.state))
93+
.replace('{THEME}', JSON.stringify(this.theme))
9294
.replace('{LOGO}', this.logo)
9395
.replace(/{BASE_URL}/g, this.baseURL)
9496
)

lib/plugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ module.exports = class ProgressPlugin extends Plugin {
1313
port: process.env.port || 4000,
1414
callback: () => {
1515
console.log(`[loading screen]: http://localhost:${this.opts.port}`)
16+
},
17+
theme: {
18+
client: '#8ed5fb',
19+
server: '#1b78bf',
20+
modern: '#2f495e'
1621
}
1722
},
1823
opts

0 commit comments

Comments
 (0)