Skip to content

Commit 44bbb3d

Browse files
committed
Add badge class
1 parent bcf4d42 commit 44bbb3d

File tree

6 files changed

+71
-69
lines changed

6 files changed

+71
-69
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/node_modules/
2-
/dev_example/
2+
test.js

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Added
1313

14-
-
14+
- Badge class
15+
- Button class

index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
9+
10+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@neptune-css/[email protected]/neptune.css">
11+
<link rel="icon" type="image/x-icon" href="/assets/favicon.ico">
12+
<title>JavaScript API | Neptune examples</title>
13+
</head>
14+
<body>
15+
16+
<div class="myElement" id="element"></div>
17+
18+
<script type="module" src="./test.js"></script>
19+
</body>
20+
</html>

javascriptAPI.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

neptune.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @class Badge
3+
* @description Create a new Neptune Badge
4+
*
5+
* @param {any} config Add your configuration
6+
*
7+
* parent -> class or id of your target element, when null its document.body
8+
*
9+
* text -> content of your badge
10+
*
11+
* size -> s, m, l
12+
*
13+
* style -> primary, accent, information, success, warning, error
14+
*
15+
* @example
16+
* const myBadge = new Badge({
17+
* parent: "#container",
18+
* text: "My Badge",
19+
* size: "m",
20+
* style: "primary"
21+
* });
22+
*/
23+
export class Badge {
24+
constructor(config) {
25+
// Create Badge
26+
const newBadge = document.createElement('span');
27+
newBadge.classList.add('badge');
28+
newBadge.innerText = config.text;
29+
30+
// Setup Size
31+
if (config.size != null) {
32+
newBadge.classList.add('badge-' + config.size);
33+
}
34+
35+
// Setup Style
36+
if (config.style != null) {
37+
// Setup Style
38+
newBadge.classList.add('badge-' + config.style);
39+
}
40+
41+
// Append badge to DOM
42+
if (config.parent != null) {
43+
document.querySelector(config.parent).appendChild(newBadge)
44+
} else {
45+
document.body.appendChild(newBadge);
46+
}
47+
}
48+
}

src/elements/createDiv.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)