Skip to content

CYF-WORKSHOP/ Button #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions dom-merge-conflict/tasks/buttons-and-counter/src/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Header } from "./header";
import { main } from "./main";
//increments the number in a node's text
function increment(node) {
let current = node.textContent;
Expand All @@ -7,19 +9,10 @@ function increment(node) {
export function App() {
const body = document.createElement("body");

const header = document.createElement("header");
header.innerHTML = `
<h1>Number Counter</h1>
<p>A simple counter. Press increment to increase the count by one.</p>
`;
body.appendChild(header);
body.appendChild(Header());

const main = document.createElement("main");
main.innerHTML = `
<p id="counter" data-testid="counter">0</p>
<button id="increment">Increment</button>
`;
body.appendChild(main);

body.appendChild(main());

const button = body.querySelector("#increment");
const counter = body.querySelector("#counter");
Expand Down
9 changes: 9 additions & 0 deletions dom-merge-conflict/tasks/buttons-and-counter/src/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

export function Header(){
const header = document.createElement("header");
header.innerHTML = `
<h1>Number Counter</h1>
<p>A simple counter. Press increment to increase the count by one.</p>
`;
return header;
}
10 changes: 10 additions & 0 deletions dom-merge-conflict/tasks/buttons-and-counter/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function main(){

const main = document.createElement("main");
main.innerHTML = `
<p id="counter" data-testid="counter">0</p>
<button id="increment">Increment</button>
`;
return main;
}