-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdummy-code.js
More file actions
35 lines (30 loc) · 947 Bytes
/
Copy pathdummy-code.js
File metadata and controls
35 lines (30 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Dummy code for feature/buttons branch
// This file contains sample code for button component implementation
class ButtonComponent {
constructor(label, onClick, type = 'primary') {
this.label = label;
this.onClick = onClick;
this.type = type;
}
render() {
const button = document.createElement('button');
button.textContent = this.label;
button.className = `btn btn-${this.type}`;
button.addEventListener('click', this.onClick);
return button;
}
addToDOM(selector) {
const container = document.querySelector(selector);
if (container) {
container.appendChild(this.render());
console.log(`Button "${this.label}" added to DOM`);
}
}
}
// Usage example
const submitButton = new ButtonComponent('Submit', () => {
console.log('Form submitted!');
}, 'primary');
const cancelButton = new ButtonComponent('Cancel', () => {
console.log('Action cancelled');
}, 'secondary');