Skip to content

Commit f005033

Browse files
committed
Add Link class
1 parent 3e93271 commit f005033

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

CHANGELOG.md

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

1414
- Badge class
15-
- Button class
15+
- Button class
16+
- Link class

neptune.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,38 @@ export class Button {
123123
}
124124
}
125125

126+
export class Link {
127+
constructor(config) {
128+
// Create Link
129+
const newLink = document.createElement('a');
130+
newLink.classList.add('link');
131+
newLink.innerText = config.text;
132+
133+
// Setup Size
134+
if (config.size != null) {
135+
newLink.classList.add('link-' + config.size);
136+
}
137+
138+
// Setup Style
139+
if (config.style != null) {
140+
newLink.classList.add('link-' + config.style);
141+
}
142+
143+
// Setup title
144+
if (config.title != null) {
145+
newLink.title = config.title;
146+
}
147+
148+
// Setup href
149+
if (config.href != null) {
150+
newLink.href = config.href;
151+
}
152+
153+
// Append to parent element
154+
if (config.parent != null) {
155+
document.querySelector(config.parent).appendChild(newLink);
156+
} else {
157+
document.body.appendChild(newLink);
158+
}
159+
}
160+
}

0 commit comments

Comments
 (0)