Skip to content

Commit ca909b2

Browse files
committed
refactor: update CSS classes
1 parent 5283c20 commit ca909b2

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

js/src/loading-button.js

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,19 @@ import BaseComponent from './base-component'
2929
const NAME = 'loading-button'
3030
const DATA_KEY = 'coreui.loading-button'
3131
const EVENT_KEY = `.${DATA_KEY}`
32-
// const DATA_API_KEY = '.data-api'
3332

3433
const MAX_PERCENT = 100
3534
const MILLISECONDS = 10
3635
const PROGRESS_BAR_BG_COLOR_LIGHT = 'rgba(255, 255, 255, .2)'
3736
const PROGRESS_BAR_BG_COLOR_DARK = 'rgba(0, 0, 0, .2)'
3837

39-
// const SELECTOR_COMPONENT = '[data-coreui="loading-button"]'
40-
4138
const EVENT_START = `start${EVENT_KEY}`
4239
const EVENT_STOP = `stop${EVENT_KEY}`
4340
const EVENT_COMPLETE = `complete${EVENT_KEY}`
44-
// const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
4541

46-
const CLASS_NAME_LOADING_BUTTON_LOADING = 'loading-button-loading'
47-
const CLASS_NAME_LOADING_BUTTON_PROGRESS = 'loading-button-progress'
48-
const CLASS_NAME_LOADING_BUTTON_SPINNER = 'loading-button-spinner'
42+
const CLASS_NAME_IS_LOADING = 'is-loading'
43+
const CLASS_NAME_LOADING_BUTTON_PROGRESS = 'btn-loading-progress'
44+
const CLASS_NAME_LOADING_BUTTON_SPINNER = 'btn-loading-spinner'
4945

5046
const Default = {
5147
percent: 0,
@@ -71,8 +67,6 @@ const DefaultType = {
7167

7268
class LoadingButton extends BaseComponent {
7369
constructor(element, config) {
74-
// eslint-disable-next-line no-console
75-
console.log('created')
7670
super(element)
7771

7872
this._config = this._getConfig(config)
@@ -110,15 +104,15 @@ class LoadingButton extends BaseComponent {
110104
this._createProgressBar()
111105

112106
setTimeout(() => {
113-
this._element.classList.add(CLASS_NAME_LOADING_BUTTON_LOADING)
107+
this._element.classList.add(CLASS_NAME_IS_LOADING)
114108
this._loading()
115109
EventHandler.trigger(this._element, EVENT_START)
116110
}, 1)
117111
}
118112
}
119113

120114
stop() {
121-
this._element.classList.remove(CLASS_NAME_LOADING_BUTTON_LOADING)
115+
this._element.classList.remove(CLASS_NAME_IS_LOADING)
122116
const stoped = () => {
123117
this._removeSpinner()
124118
this._removeProgressBar()
@@ -169,7 +163,7 @@ class LoadingButton extends BaseComponent {
169163
this._element = null
170164
}
171165

172-
update(config) { // public method
166+
update(config) {
173167
this._config = this._getConfig(config)
174168
}
175169

@@ -299,24 +293,13 @@ class LoadingButton extends BaseComponent {
299293
}
300294
}
301295

302-
static jQueryInterface(config, par) {
296+
static jQueryInterface(config) {
303297
return this.each(function () {
304-
LoadingButton.loadingButtonInterface(this, config, par)
298+
LoadingButton.loadingButtonInterface(this, config)
305299
})
306300
}
307301
}
308302

309-
/**
310-
* ------------------------------------------------------------------------
311-
* Data Api implementation
312-
* ------------------------------------------------------------------------
313-
*/
314-
// EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
315-
// SelectorEngine.find(SELECTOR_COMPONENT).forEach(element => {
316-
// LoadingButton.loadingButtonInterface(element, Manipulator.getDataAttributes(element))
317-
// })
318-
// })
319-
320303
/**
321304
* ------------------------------------------------------------------------
322305
* jQuery

scss/_loading-button.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
// Loading button
33
//
44

5-
.loading-button {
5+
.btn-loading {
66
position: relative;
77
overflow: hidden;
88
}
99

10-
.loading-button-progress {
10+
.btn-loading-progress {
1111
position: absolute;
1212
top: 0;
1313
left: 0;
1414
width: 0%;
1515
height: 100%;
1616
}
1717

18-
.loading-button-spinner {
18+
.btn-loading-spinner {
1919
margin-right: $spacer;
2020
margin-left: - ($spacer * 2);
2121
opacity: 0;
2222
@include transition(margin .15s, opacity .15s, border .15s);
2323
}
2424

25-
.loading-button-loading {
26-
.loading-button-spinner {
25+
.btn-loading.is-loading {
26+
.btn-loading-spinner {
2727
width: 1rem;
2828
margin-left: 0;
2929
opacity: 1;

0 commit comments

Comments
 (0)