Skip to content

Commit

Permalink
feat: support customize progress bar color
Browse files Browse the repository at this point in the history
re #1
  • Loading branch information
2nthony committed May 12, 2019
1 parent ace3704 commit ac43da2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ new LoadingScreenPlugin({
})
```

### theme

- Type: `ThemeConfig`
- Default: `DefaultThemeConfig`

Customize loading screen progress bar color.

```ts
interface ThemeConfig {
client?: string
server?: string
modern?: string
}

const DefaultThemeConfig = {
client: '#8ed5fb',
server: '#1b78bf',
modern: '#2f495e'
}
```

### env

- Type: `'development' | 'production'`
Expand Down
5 changes: 3 additions & 2 deletions app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div v-for="bundle of bundles" :key="bundle" class="row">
<h3>{{ bundle | capitalize }} bundle</h3>
<div class="progress_bar_container">
<div class="progress_bar" :class="bundle" :style="{ width: `${states[bundle].progress}%` }" />
<div class="progress_bar" :style="{ width: `${states[bundle].progress}%`, backgroundColor: theme[bundle] }" />
</div>
<h4>{{ states[bundle].status }}</h4>
</div>
Expand Down Expand Up @@ -72,7 +72,8 @@ export default {
isFinished: false,
baseURL: window.$BASE_URL,
bundles: [],
states: {}
states: {},
theme: window.$THEME
}
},

Expand Down
13 changes: 0 additions & 13 deletions app/css/loading.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,3 @@ h4 {
width: 10px;
transition: width 0.4s;
}

.progress_bar.client {
background-color: #8ed5fb;
}

.progress_bar.server {
background-color: #1b78bf;
}

.progress_bar.modern {
background-color: #2F495E;
}

1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<!-- loading_app -->
<div id="webpack_loading_screen"></div>
<script>window.$STATE = {STATE}</script>
<script>window.$THEME = {THEME}</script>
<script>window.$LOGO = '{LOGO}'</script>
<script>window.$BASE_URL = '{BASE_URL}'</script>
</body>
Expand Down
2 changes: 2 additions & 0 deletions lib/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LoadingUI {
this.baseURL = opts.baseURL

this.logo = opts.logo
this.theme = opts.theme

this.serveIndex = this.serveIndex.bind(this)
this.serveWS = this.serveWS.bind(this)
Expand Down Expand Up @@ -89,6 +90,7 @@ class LoadingUI {
res.end(
this.indexTemplate
.replace('{STATE}', JSON.stringify(this.state))
.replace('{THEME}', JSON.stringify(this.theme))
.replace('{LOGO}', this.logo)
.replace(/{BASE_URL}/g, this.baseURL)
)
Expand Down
5 changes: 5 additions & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module.exports = class ProgressPlugin extends Plugin {
port: process.env.port || 4000,
callback: () => {
console.log(`[loading screen]: http://localhost:${this.opts.port}`)
},
theme: {
client: '#8ed5fb',
server: '#1b78bf',
modern: '#2f495e'
}
},
opts
Expand Down

0 comments on commit ac43da2

Please sign in to comment.