Skip to content

Commit 152cb06

Browse files
authored
Merge pull request #7 from CGWebDev2003/feature/add-spinner-class
Add spinner class
2 parents 6477432 + 8139953 commit 152cb06

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

neptune.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,56 @@ export class Link {
185185
document.body.appendChild(newLink);
186186
}
187187
}
188+
}
189+
190+
/**
191+
* @class Button
192+
* @description Create a new Neptune Button
193+
*
194+
* @param {any} config Add your configuration
195+
*
196+
* parent -> class or id of your target element, when null its document.body
197+
*
198+
* style -> primary, cta, information, success, warning, error
199+
*
200+
* animation -> linnear, eased
201+
*
202+
* @example
203+
* const mySpinner = new Spinner({
204+
* parent: "#container",
205+
* style: "primary",
206+
* animation: "eased"
207+
* });
208+
*/
209+
export class Spinner {
210+
constructor(config) {
211+
// Create Link
212+
const newSpinner = document.createElement('div');
213+
const spinnerInner = document.createElement('div')
214+
const spinnerHole = document.createElement('div')
215+
newSpinner.classList.add('spinner');
216+
217+
spinnerInner.classList.add('spinner-inner');
218+
spinnerHole.classList.add('spinner-hole');
219+
220+
newSpinner.appendChild(spinnerHole);
221+
newSpinner.appendChild(spinnerInner);
222+
223+
// Setup Style
224+
if (config.style != null) {
225+
newSpinner.classList.add('spinner-' + config.style);
226+
}
227+
228+
// Setup Animation
229+
if (config.animation != null) {
230+
newSpinner.classList.add('spin-' + config.animation)
231+
}
232+
233+
// Append to parent element
234+
if (config.parent != null) {
235+
document.querySelector(config.parent).appendChild(newSpinner);
236+
} else {
237+
document.body.appendChild(newSpinner);
238+
}
239+
}
188240
}

0 commit comments

Comments
 (0)