From fd61de0e586f685edd7aa98d6f39357fe09daa77 Mon Sep 17 00:00:00 2001 From: nex1994 Date: Sat, 9 May 2026 11:26:30 +0200 Subject: [PATCH 1/2] init --- .github/workflows/test.yml-template | 29 +++++++++++++++++++++++++++++ src/index.html | 1 + src/scripts/main.js | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml-template diff --git a/.github/workflows/test.yml-template b/.github/workflows/test.yml-template new file mode 100644 index 00000000..44ac4e96 --- /dev/null +++ b/.github/workflows/test.yml-template @@ -0,0 +1,29 @@ +name: Test + +on: + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm start & sleep 5 && npm test + - name: Upload tests report(cypress mochaawesome merged HTML report) + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: report + path: reports diff --git a/src/index.html b/src/index.html index 3496ee13..17cc8917 100644 --- a/src/index.html +++ b/src/index.html @@ -9,6 +9,7 @@ /> +
diff --git a/src/scripts/main.js b/src/scripts/main.js index 2cdcd10c..b25916ae 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -21,7 +21,21 @@ const food = { const tree = document.querySelector('#tree'); function createTree(element, data) { - // WRITE YOUR CODE HERE + const ul = document.createElement('ul'); + + for (const key of Object.keys(data)) { + const li = document.createElement('li'); + + li.textContent = key; + + if (Object.keys(data[key]).length > 0) { + createTree(li, data[key]); + } + + ul.appendChild(li); + } + + element.appendChild(ul); } createTree(tree, food); From c203db42f95ec2f5919833eb20efbfb336f10835 Mon Sep 17 00:00:00 2001 From: nex1994 Date: Sat, 9 May 2026 11:41:11 +0200 Subject: [PATCH 2/2] Add demo link and update page title per review feedback Co-Authored-By: Claude Sonnet 4.6 --- README.md | 2 +- src/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0adab1fe..d4a165a2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Use keys as list items. ![screenshot of the tree](example/object-tree.png) 1. Replace `` with your GitHub username in the link - - [DEMO LINK](https://.github.io/js_tree-from-object-DOM/) + - [DEMO LINK](https://nex1994.github.io/js_tree-from-object-DOM/) 2. Follow [this instructions](https://github.com/mate-academy/js_task-DOM-guideline) - Run `npm run test` command to test your code; - Run `npm run test:only -- -n` to run fast test ignoring linter; diff --git a/src/index.html b/src/index.html index 17cc8917..865cf5d9 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - Title + Tree from Object