@@ -185,4 +185,56 @@ export class Link {
185
185
document . body . appendChild ( newLink ) ;
186
186
}
187
187
}
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
+ }
188
240
}
0 commit comments