-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from grucloud/interactive-comments-section
Interactive comments section
- Loading branch information
Showing
29 changed files
with
829 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { describe, vi, it, assert, expect } from "vitest"; | ||
|
||
const sleep = (ms = 50) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
import Bau from "../bau"; | ||
const comments = [ | ||
{ id: 1, replies: [] }, | ||
{ id: 2, replies: [] }, | ||
]; | ||
describe("nested array", async () => { | ||
const bau = Bau(); | ||
const { h1, div, button, ul, li } = bau.tags; | ||
|
||
const commentsState = bau.state(comments); | ||
|
||
const Comment = (comment) => { | ||
const repliesState = bau.state(comment.replies); | ||
return li( | ||
h1(comment.id), | ||
button( | ||
{ | ||
id: `button-${comment.id}`, | ||
onclick: () => { | ||
repliesState.val.push({ id: 3, comment: "hi" }); | ||
}, | ||
}, | ||
"Add reply" | ||
), | ||
bau.loop(repliesState, ul(), (r) => li(r.comment)) | ||
); | ||
}; | ||
|
||
const TestComponent = () => div(bau.loop(commentsState, ul(), Comment)); | ||
|
||
it("click", async () => { | ||
const el = TestComponent(); | ||
document.body.appendChild(el); | ||
|
||
document.getElementById("button-1").click(); | ||
await sleep(); | ||
const ulEl = el.querySelector("ul"); | ||
|
||
assert.equal(ulEl.childNodes.length, 2); | ||
document.body.removeChild(el); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
save-exact = true | ||
package-lock = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Frontend Mentor Interactive Comments Section | ||
|
||
Here is the implementation in [Bau.js](https://github.com/grucloud/bau) of the [Frontend Mentor Interactive Comments Section code challenge](https://www.frontendmentor.io/challenges/interactive-comments-section-iG1RugEG9) | ||
|
||
## Workflow | ||
|
||
Install the dependencies: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
Start a development server: | ||
|
||
```sh | ||
npm run dev | ||
``` | ||
|
||
Build a production version: | ||
|
||
```sh | ||
npm run build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
href="./assets/images/favicon-32x32.png" | ||
/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Interactive Comments Section | FrontendMentor</title> | ||
<style id="bau-css"></style> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "frontendmentor-interactive-comments-section", | ||
"homepage": "https://grucloud.github.io/bau/frontendmentor/interactive-comments-section/", | ||
"private": true, | ||
"version": "0.95.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"deploy": "gh-pages -d ../../dist" | ||
}, | ||
"devDependencies": { | ||
"gh-pages": "6.1.1", | ||
"typescript": "^5.0.2", | ||
"vite": "^5.2.11" | ||
}, | ||
"dependencies": { | ||
"@grucloud/bau": "^0.95.0", | ||
"@grucloud/bau-css": "^0.95.0", | ||
"@grucloud/bau-ui": "^0.95.0", | ||
"dayjs": "1.11.13" | ||
} | ||
} |
Binary file added
BIN
+3.97 KB
...s/interactive-comments-section/public/assets/images/avatars/image-amyrobson.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.61 KB
examples/interactive-comments-section/public/assets/images/avatars/image-amyrobson.webp
Binary file not shown.
Binary file added
BIN
+3.76 KB
...s/interactive-comments-section/public/assets/images/avatars/image-juliusomo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.2 KB
examples/interactive-comments-section/public/assets/images/avatars/image-juliusomo.webp
Binary file not shown.
Binary file added
BIN
+4.11 KB
...s/interactive-comments-section/public/assets/images/avatars/image-maxblagun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.19 KB
examples/interactive-comments-section/public/assets/images/avatars/image-maxblagun.webp
Binary file not shown.
Binary file added
BIN
+3.48 KB
...interactive-comments-section/public/assets/images/avatars/image-ramsesmiron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.63 KB
examples/interactive-comments-section/public/assets/images/avatars/image-ramsesmiron.webp
Binary file not shown.
Binary file added
BIN
+1.04 KB
examples/interactive-comments-section/public/assets/images/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/interactive-comments-section/public/assets/images/icon-delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/interactive-comments-section/public/assets/images/icon-edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/interactive-comments-section/public/assets/images/icon-minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/interactive-comments-section/public/assets/images/icon-plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
examples/interactive-comments-section/public/assets/images/icon-reply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"currentUser": { | ||
"image": { | ||
"png": "./assets/images/avatars/image-juliusomo.png", | ||
"webp": "./assets/images/avatars/image-juliusomo.webp" | ||
}, | ||
"username": "juliusomo" | ||
}, | ||
"comments": [ | ||
{ | ||
"id": 1, | ||
"content": "Impressive! Though it seems the drag feature could be improved. But overall it looks incredible. You've nailed the design and the responsiveness at various breakpoints works really well.", | ||
"createdAt": "1 month ago", | ||
"score": 12, | ||
"user": { | ||
"image": { | ||
"png": "./assets/images/avatars/image-amyrobson.png", | ||
"webp": "./assets/images/avatars/image-amyrobson.webp" | ||
}, | ||
"username": "amyrobson" | ||
}, | ||
"replies": [] | ||
}, | ||
{ | ||
"id": 2, | ||
"content": "Woah, your project looks awesome! How long have you been coding for? I'm still new, but think I want to dive into React as well soon. Perhaps you can give me an insight on where I can learn React? Thanks!", | ||
"createdAt": "2 weeks ago", | ||
"score": 5, | ||
"user": { | ||
"image": { | ||
"png": "./assets/images/avatars/image-maxblagun.png", | ||
"webp": "./assets/images/avatars/image-maxblagun.webp" | ||
}, | ||
"username": "maxblagun" | ||
}, | ||
"replies": [ | ||
{ | ||
"id": 3, | ||
"content": "If you're still new, I'd recommend focusing on the fundamentals of HTML, CSS, and JS before considering React. It's very tempting to jump ahead but lay a solid foundation first.", | ||
"createdAt": "1 week ago", | ||
"score": 4, | ||
"replyingTo": "maxblagun", | ||
"user": { | ||
"image": { | ||
"png": "./assets/images/avatars/image-ramsesmiron.png", | ||
"webp": "./assets/images/avatars/image-ramsesmiron.webp" | ||
}, | ||
"username": "ramsesmiron" | ||
} | ||
}, | ||
{ | ||
"id": 4, | ||
"content": "I couldn't agree more with this. Everything moves so fast and it always seems like everyone knows the newest library/framework. But the fundamentals are what stay constant.", | ||
"createdAt": "2 days ago", | ||
"score": 2, | ||
"replyingTo": "ramsesmiron", | ||
"user": { | ||
"image": { | ||
"png": "./assets/images/avatars/image-juliusomo.png", | ||
"webp": "./assets/images/avatars/image-juliusomo.webp" | ||
}, | ||
"username": "juliusomo" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.