Compare commits
169 Commits
520dd6de9c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0af0129054 | ||
|
|
8ff2ec3766 | ||
|
|
843c71946f | ||
|
|
51e3629fa5 | ||
|
|
ddc003eb13 | ||
|
|
e81a22dd10 | ||
|
|
269cb2967c | ||
|
|
6b764ae61b | ||
|
|
44c89e6559 | ||
|
|
a541a2dac2 | ||
|
|
ff7baa0a24 | ||
|
|
623d05da91 | ||
|
|
8601288230 | ||
|
|
fa11926642 | ||
|
|
9c8ec7fb0d | ||
|
|
78c9bd1d61 | ||
|
|
9c19bd7b6b | ||
|
|
de2fd2bdc0 | ||
|
|
81235e3ce6 | ||
|
|
4f7b2fcd17 | ||
|
|
e13fa186e1 | ||
|
|
f238940622 | ||
|
|
7f4b8cab8a | ||
|
|
b0dd8cded1 | ||
|
|
f48d958a2c | ||
|
|
2cb3cc7c35 | ||
|
|
f4ab1ac7ec | ||
|
|
2769f5e8dc | ||
|
|
d7dce88751 | ||
|
|
b036002ca8 | ||
|
|
70ab1e59c4 | ||
|
|
133fa0df2b | ||
|
|
58ca4ecafa | ||
|
|
843e55841b | ||
|
|
cfe3994bc9 | ||
|
|
8b95d963fe | ||
|
|
83d8cd07d2 | ||
|
|
6b323ba746 | ||
|
|
e834ff06ab | ||
|
|
f30d9dad94 | ||
|
|
ee914c8014 | ||
|
|
b8d0dc96fd | ||
|
|
faedb21808 | ||
|
|
9bdf180f97 | ||
|
|
f383085910 | ||
|
|
2070bbebb0 | ||
|
|
9edf7f0196 | ||
|
|
d7d5ac63ac | ||
|
|
841543e984 | ||
|
|
b1c128738f | ||
|
|
51319b036b | ||
|
|
0f30e1fc41 | ||
|
|
11d5d6254a | ||
|
|
ae33d7e72a | ||
|
|
aca8599d6e | ||
|
|
43daef0455 | ||
|
|
ff296f84eb | ||
|
|
ae2b3d1327 | ||
|
|
433ff827b7 | ||
|
|
b776000cf0 | ||
|
|
c260d348d7 | ||
|
|
153f5ef9ce | ||
|
|
256df8d2aa | ||
|
|
d300d5c16b | ||
|
|
73804a0ed4 | ||
|
|
4b2c6e4f62 | ||
|
|
7382680fc5 | ||
|
|
cee8159c69 | ||
|
|
6d5077159b | ||
|
|
d74df846f2 | ||
|
|
7a8dba19ee | ||
|
|
fe8b54346a | ||
|
|
fbeced6eb2 | ||
|
|
e17b45d2ec | ||
|
|
d7bcb418d4 | ||
|
|
77bcf87cd1 | ||
|
|
8c0318c4e2 | ||
|
|
080b47a9a6 | ||
|
|
01ec722ea0 | ||
|
|
e6f36dc0bd | ||
|
|
27e19d4494 | ||
|
|
5d0f58edc1 | ||
|
|
0e7d53b582 | ||
|
|
96edd50450 | ||
|
|
dd590e1530 | ||
|
|
3133a9aa8c | ||
|
|
a52ab42c61 | ||
|
|
77e70c3536 | ||
|
|
4d9a7c3e12 | ||
|
|
6d827365ac | ||
|
|
f9c32fd7dc | ||
|
|
998cc778e6 | ||
|
|
076dc76ca4 | ||
|
|
5f260455cb | ||
|
|
bf33858e41 | ||
|
|
6ed489835f | ||
|
|
febc77032b | ||
|
|
65bfe3077f | ||
|
|
f8f1580fc7 | ||
|
|
aca7ae8ecf | ||
|
|
03aa9f8b94 | ||
|
|
2d514e9258 | ||
|
|
3c51273cc3 | ||
|
|
68bd81ec3c | ||
|
|
ef7193530b | ||
|
|
35df226d25 | ||
|
|
967864e72d | ||
|
|
7b2060c5d0 | ||
|
|
8b62506f00 | ||
|
|
d8e25ff95d | ||
|
|
808ba96049 | ||
|
|
05c4044ef3 | ||
|
|
e9fcba7ad6 | ||
|
|
a2418a810c | ||
|
|
c27cb67c2a | ||
|
|
084035fdcb | ||
|
|
e4a18da5c2 | ||
|
|
d73c39500b | ||
|
|
5dced77b4d | ||
|
|
88e1d04e0d | ||
|
|
572b63c82d | ||
|
|
f6d8a1de8d | ||
|
|
80af2e0fd0 | ||
|
|
9ddd9d3943 | ||
|
|
59cab44920 | ||
|
|
a7dbfffa8e | ||
|
|
b67b3cdc89 | ||
|
|
372fb5a6ad | ||
|
|
0c8a9b91e0 | ||
|
|
18d91b742e | ||
|
|
69dc59a1ed | ||
|
|
73ccfba393 | ||
|
|
4a5a13f6d4 | ||
|
|
697985a480 | ||
|
|
4e1f4f4a8e | ||
|
|
02a5f41800 | ||
|
|
54af09d356 | ||
|
|
de3d4781f0 | ||
|
|
66013ae1c6 | ||
|
|
69a464a767 | ||
|
|
560ce6896a | ||
|
|
91c53429e0 | ||
|
|
726cadec19 | ||
|
|
9fc2e959fa | ||
|
|
bed0387575 | ||
|
|
de431a4bc0 | ||
|
|
364d8a737a | ||
|
|
6aa5c25a5e | ||
|
|
1c8bc38f29 | ||
|
|
83c75ad3a9 | ||
|
|
ec5cac0680 | ||
|
|
770b4f6e87 | ||
|
|
b6ba1dfcd0 | ||
|
|
3e00aa5f3d | ||
|
|
c9195759a8 | ||
|
|
36b91cd5d1 | ||
|
|
4248d1b047 | ||
|
|
657d7c7407 | ||
|
|
951d364380 | ||
|
|
71be19c677 | ||
|
|
ec8c8bb678 | ||
|
|
7fac41488c | ||
|
|
2dff41f428 | ||
|
|
d181064165 | ||
|
|
df09abd9a4 | ||
|
|
d35bf9735c | ||
|
|
28f2cf281a | ||
|
|
2f1804a9fd | ||
|
|
abf0c7262d |
0
.go/pkg/mod/cache/lock
vendored
Normal file
2
.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "3.7.3"
|
||||
runner.dialect = scala3
|
||||
@@ -1,88 +0,0 @@
|
||||
# Frontend Mentor - Single price grid component
|
||||
|
||||

|
||||
|
||||
## Welcome! 👋
|
||||
|
||||
Thanks for checking out this front-end coding challenge.
|
||||
|
||||
[Frontend Mentor](https://www.frontendmentor.io) challenges help you improve your coding skills by building realistic projects.
|
||||
|
||||
**To do this challenge, you need a basic understanding of HTML and CSS.**
|
||||
|
||||
## The challenge
|
||||
|
||||
Your users should be able to:
|
||||
|
||||
- View the optimal layout for the component depending on their device's screen size
|
||||
- See a hover state on desktop for the Sign Up call-to-action
|
||||
|
||||
Want some support on the challenge? [Join our Slack community](https://www.frontendmentor.io/slack) and ask questions in the **#help** channel.
|
||||
|
||||
## Where to find everything
|
||||
|
||||
Your task is to build out the project to the designs inside the `/design` folder. You will find both a mobile and a desktop version of the design.
|
||||
|
||||
The designs are in JPG static format. Using JPGs will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`.
|
||||
|
||||
If you would like the design files (we provide Sketch & Figma versions) to inspect the design in more detail, you can [subscribe as a PRO member](https://www.frontendmentor.io/pro).
|
||||
|
||||
You will find all the required assets in the `/images` folder. The assets are already optimized.
|
||||
|
||||
There is also a `style-guide.md` file containing the information you'll need, such as color palette and fonts.
|
||||
|
||||
## Building your project
|
||||
|
||||
Feel free to use any workflow that you feel comfortable with. Below is a suggested process, but do not feel like you need to follow these steps:
|
||||
|
||||
1. Initialize your project as a public repository on [GitHub](https://github.com/). Creating a repo will make it easier to share your code with the community if you need help. If you're not sure how to do this, [have a read-through of this Try Git resource](https://try.github.io/).
|
||||
2. Configure your repository to publish your code to a web address. This will also be useful if you need some help during a challenge as you can share the URL for your project with your repo URL. There are a number of ways to do this, and we provide some recommendations below.
|
||||
3. Look through the designs to start planning out how you'll tackle the project. This step is crucial to help you think ahead for CSS classes to create reusable styles.
|
||||
4. Before adding any styles, structure your content with HTML. Writing your HTML first can help focus your attention on creating well-structured content.
|
||||
5. Write out the base styles for your project, including general content styles, such as `font-family` and `font-size`.
|
||||
6. Start adding styles to the top of the page and work down. Only move on to the next section once you're happy you've completed the area you're working on.
|
||||
|
||||
## Deploying your project
|
||||
|
||||
As mentioned above, there are many ways to host your project for free. Our recommend hosts are:
|
||||
|
||||
- [GitHub Pages](https://pages.github.com/)
|
||||
- [Vercel](https://vercel.com/)
|
||||
- [Netlify](https://www.netlify.com/)
|
||||
|
||||
You can host your site using one of these solutions or any of our other trusted providers. [Read more about our recommended and trusted hosts](https://medium.com/frontend-mentor/frontend-mentor-trusted-hosting-providers-bf000dfebe).
|
||||
|
||||
## Create a custom `README.md`
|
||||
|
||||
We strongly recommend overwriting this `README.md` with a custom one. We've provided a template inside the [`README-template.md`](./README-template.md) file in this starter code.
|
||||
|
||||
The template provides a guide for what to add. A custom `README` will help you explain your project and reflect on your learnings. Please feel free to edit our template as much as you like.
|
||||
|
||||
Once you've added your information to the template, delete this file and rename the `README-template.md` file to `README.md`. That will make it show up as your repository's README file.
|
||||
|
||||
## Submitting your solution
|
||||
|
||||
Submit your solution on the platform for the rest of the community to see. Follow our ["Complete guide to submitting solutions"](https://medium.com/frontend-mentor/a-complete-guide-to-submitting-solutions-on-frontend-mentor-ac6384162248) for tips on how to do this.
|
||||
|
||||
Remember, if you're looking for feedback on your solution, be sure to ask questions when submitting it. The more specific and detailed you are with your questions, the higher the chance you'll get valuable feedback from the community.
|
||||
|
||||
## Sharing your solution
|
||||
|
||||
There are multiple places you can share your solution:
|
||||
|
||||
1. Share your solution page in the **#finished-projects** channel of the [Slack community](https://www.frontendmentor.io/slack).
|
||||
2. Tweet [@frontendmentor](https://twitter.com/frontendmentor) and mention **@frontendmentor**, including the repo and live URLs in the tweet. We'd love to take a look at what you've built and help share it around.
|
||||
3. Share your solution on other social channels like LinkedIn.
|
||||
4. Blog about your experience building your project. Writing about your workflow, technical choices, and talking through your code is a brilliant way to reinforce what you've learned. Great platforms to write on are [dev.to](https://dev.to/), [Hashnode](https://hashnode.com/), and [CodeNewbie](https://community.codenewbie.org/).
|
||||
|
||||
We provide templates to help you share your solution once you've submitted it on the platform. Please do edit them and include specific questions when you're looking for feedback.
|
||||
|
||||
The more specific you are with your questions the more likely it is that another member of the community will give you feedback.
|
||||
|
||||
## Got feedback for us?
|
||||
|
||||
We love receiving feedback! We're always looking to improve our challenges and our platform. So if you have anything you'd like to mention, please email hi[at]frontendmentor[dot]io.
|
||||
|
||||
This challenge is completely free. Please share it with anyone who will find it useful for practice.
|
||||
|
||||
**Have fun building!** 🚀
|
||||
121
11-single-price-grid-component/README.org
Normal file
@@ -0,0 +1,121 @@
|
||||
* Frontend Mentor - Single price grid component solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---single-price-grid-component-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/single-price-grid-component-5ce41129d0ff452fec5abbbc][Single
|
||||
price grid component challenge on Frontend Mentor]]. Frontend Mentor
|
||||
challenges help you improve your coding skills by building realistic
|
||||
projects.
|
||||
|
||||
** Overview
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: overview
|
||||
:END:
|
||||
*** The challenge
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: the-challenge
|
||||
:END:
|
||||
Users should be able to:
|
||||
|
||||
- View the optimal layout for the component depending on their device's
|
||||
screen size
|
||||
- See a hover state on desktop for the Sign Up call-to-action
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[./screenshot-desktop.png]]
|
||||
[[./screenshot-mobile.png]]
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- [[https://www.frontendmentor.io/solutions/tailwind-scala-ssr-scalatags-and-cask-deployed-with-docker-image-UPzyFXyf_L][Solution URL]]
|
||||
- [[https://efim-frontentmentor-price-grid-component.onrender.com/][Live Site URL]]
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Semantic HTML5 markup
|
||||
- TailwindCSS
|
||||
- Scalatags
|
||||
html generation on backend
|
||||
- Cask
|
||||
simple Scala web server, with annotations to mark routes and simple functions to process request
|
||||
- Mobile-first workflow
|
||||
- Nix
|
||||
for building the application, nix module for easy install to servers with NixOS, and docker image for other deployment
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** Setting up Cask server to serve static resources
|
||||
Previously in Vite the /public directory was just automagically made available to the production build.
|
||||
Now, with @cask.staticFiles("/public") the route /public would serve files from "public" directory
|
||||
|
||||
The path is relative, so directory from which the server is started is important.
|
||||
But the thing works.
|
||||
|
||||
**** First time installing TailwindCSS with cli, without the frontend bundler integration
|
||||
https://tailwindcss.com/docs/installation
|
||||
|
||||
#+begin_src bash
|
||||
$ tailwindcss -i ./src/input.css -o ./dist/output.css --watch
|
||||
#+end_src
|
||||
|
||||
Idea for this exercise was to generate `out.css` of the final TailwindCSS stylesheet into /dist directory, which would be in .gitignore
|
||||
|
||||
The problem I've encountered - the nix derivation doesn't like to have all of the files in the tmp build directory, so files are referenced and loaded by neat library function
|
||||
#+begin_src nix
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
#+end_src
|
||||
|
||||
Which only puts unignored files into store.
|
||||
So one time for the build step i'm using tailwind this way:
|
||||
#+begin_src nix
|
||||
buildPhase = ''
|
||||
sbt assembly
|
||||
tailwindcss -i ./src/input.css -o ./output.css
|
||||
'';
|
||||
#+end_src
|
||||
|
||||
and then copy resulting file where the server expects it to be.
|
||||
|
||||
**** Written a NixOS module with Systemd service and a Nginx reverse proxy
|
||||
on my NixOS server i just need to reference the flake by the repository url, import the module, and then
|
||||
|
||||
#+begin_src nix
|
||||
imports = [ inputs.htmx-examples.nixosModules.x86_64-linux.price-grid-app ];
|
||||
services.priceGridService = {
|
||||
enable = true;
|
||||
host = "price-grid.frontendmentor.sunshine.industries";
|
||||
port = 12345;
|
||||
};
|
||||
#+end_src
|
||||
|
||||
setting up config values, and =enable = true;= makes the server instantiate the systemd service, which will cover restarts and logs, and nginx reverse proxy.
|
||||
|
||||
**** Found out about =Workdir= setting of systemd servcie and =WorkingDir= of docker image
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
This was first app (exercise #11) in the experiment with learning SSR in Scala, i've already completed exercise #14, and in the following steps I'm learning Thymeleaf templating engine, and HTMX - the library for extending html to make pages that allow easier partial page updates.
|
||||
|
||||
** Acknowledgments
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: acknowledgments
|
||||
:END:
|
||||
My gratitude to render.com who are providing free tier for the service hosting from the docker image.
|
||||
Which was necessary for me to submit the solution into frontendmentor.
|
||||
And to DockerHub for hosting my docker images gratis as well.
|
||||
And to Nix for their documentation!
|
||||
@@ -4,7 +4,7 @@ fork := true
|
||||
ThisBuild / version := "0.0.1"
|
||||
ThisBuild / organization := "industries.sunshine"
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
lazy val singlePriceGridComponent = (project in file("."))
|
||||
.settings(
|
||||
name := "priceGrid",
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
|
||||
let
|
||||
pname = "price-grid-app";
|
||||
package = sbt-derivation.lib.mkSbtDerivation {
|
||||
inherit pkgs;
|
||||
inherit pkgs pname;
|
||||
# ...and the rest of the arguments
|
||||
pname = "price-grid-app";
|
||||
version = "0.0.1";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
||||
@@ -84,7 +84,35 @@ let
|
||||
};
|
||||
};
|
||||
};
|
||||
image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = pname;
|
||||
tag = "latest";
|
||||
created = "now";
|
||||
config = {
|
||||
Cmd = [ "${pkgs.jdk}/bin/java" "-jar" "${package}/bin/priceGridApp.jar" "--host" "0.0.0.0" ];
|
||||
ExposedPorts = {
|
||||
"8080/tcp" = {};
|
||||
};
|
||||
WorkingDir = "${package}/bin";
|
||||
};
|
||||
};
|
||||
# image = pkgs.dockerTools.buildImage {
|
||||
# name = pname;
|
||||
# tag = "latest";
|
||||
# created = "now";
|
||||
# copyToRoot = pkgs.buildEnv {
|
||||
# name = "image-root";
|
||||
# paths = [ package pkgs.dockerTools.binSh pkgs.coreutils ];
|
||||
# pathsToLink = [ "/bin" "/dist" "/public" ];
|
||||
# };
|
||||
# config = {
|
||||
# Cmd = [ "${pkgs.jdk}/bin/java" "-jar" "${package}/bin/priceGridApp.jar" "--host" "0.0.0.0" ];
|
||||
# ExposedPorts = {
|
||||
# "8080/tcp" = {};
|
||||
# };
|
||||
# WorkingDir = "${package}/bin";
|
||||
# };
|
||||
# };
|
||||
in {
|
||||
package = package;
|
||||
module = module;
|
||||
inherit package module image;
|
||||
}
|
||||
|
||||
BIN
11-single-price-grid-component/screenshot-desktop.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
11-single-price-grid-component/screenshot-mobile.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
@@ -128,8 +128,8 @@ object Page {
|
||||
target := "_blank",
|
||||
"Frontend Mentor. "
|
||||
),
|
||||
"Coded by ",
|
||||
a(href := "#", "Your Name Here")
|
||||
"Source code at",
|
||||
a(href := "https://github.com/efim/Learning-HTMX", "Your Name Here")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
16
12-order-summary-component-thymeleaf/.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
.bsp/
|
||||
.scala-build/
|
||||
.metals/
|
||||
.direnv
|
||||
*/dist/
|
||||
/11-single-price-grid-component/.bloop/
|
||||
|
||||
**/.bloop
|
||||
**/project/project/
|
||||
**/project/metals.sbt
|
||||
**/project/.bloop
|
||||
**/project/target/
|
||||
**/target/
|
||||
|
||||
*/result
|
||||
result
|
||||
@@ -1,110 +0,0 @@
|
||||
# Frontend Mentor - Order summary card solution
|
||||
|
||||
This is a solution to the [Order summary card challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/order-summary-component-QlPmajDUj). Frontend Mentor challenges help you improve your coding skills by building realistic projects.
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [Overview](#overview)
|
||||
- [The challenge](#the-challenge)
|
||||
- [Screenshot](#screenshot)
|
||||
- [Links](#links)
|
||||
- [My process](#my-process)
|
||||
- [Built with](#built-with)
|
||||
- [What I learned](#what-i-learned)
|
||||
- [Continued development](#continued-development)
|
||||
- [Useful resources](#useful-resources)
|
||||
- [Author](#author)
|
||||
- [Acknowledgments](#acknowledgments)
|
||||
|
||||
**Note: Delete this note and update the table of contents based on what sections you keep.**
|
||||
|
||||
## Overview
|
||||
|
||||
### The challenge
|
||||
|
||||
Users should be able to:
|
||||
|
||||
- See hover states for interactive elements
|
||||
|
||||
### Screenshot
|
||||
|
||||

|
||||
|
||||
Add a screenshot of your solution. The easiest way to do this is to use Firefox to view your project, right-click the page and select "Take a Screenshot". You can choose either a full-height screenshot or a cropped one based on how long the page is. If it's very long, it might be best to crop it.
|
||||
|
||||
Alternatively, you can use a tool like [FireShot](https://getfireshot.com/) to take the screenshot. FireShot has a free option, so you don't need to purchase it.
|
||||
|
||||
Then crop/optimize/edit your image however you like, add it to your project, and update the file path in the image above.
|
||||
|
||||
**Note: Delete this note and the paragraphs above when you add your screenshot. If you prefer not to add a screenshot, feel free to remove this entire section.**
|
||||
|
||||
### Links
|
||||
|
||||
- Solution URL: [Add solution URL here](https://your-solution-url.com)
|
||||
- Live Site URL: [Add live site URL here](https://your-live-site-url.com)
|
||||
|
||||
## My process
|
||||
|
||||
### Built with
|
||||
|
||||
- Semantic HTML5 markup
|
||||
- CSS custom properties
|
||||
- Flexbox
|
||||
- CSS Grid
|
||||
- Mobile-first workflow
|
||||
- [React](https://reactjs.org/) - JS library
|
||||
- [Next.js](https://nextjs.org/) - React framework
|
||||
- [Styled Components](https://styled-components.com/) - For styles
|
||||
|
||||
**Note: These are just examples. Delete this note and replace the list above with your own choices**
|
||||
|
||||
### What I learned
|
||||
|
||||
Use this section to recap over some of your major learnings while working through this project. Writing these out and providing code samples of areas you want to highlight is a great way to reinforce your own knowledge.
|
||||
|
||||
To see how you can add code snippets, see below:
|
||||
|
||||
```html
|
||||
<h1>Some HTML code I'm proud of</h1>
|
||||
```
|
||||
```css
|
||||
.proud-of-this-css {
|
||||
color: papayawhip;
|
||||
}
|
||||
```
|
||||
```js
|
||||
const proudOfThisFunc = () => {
|
||||
console.log('🎉')
|
||||
}
|
||||
```
|
||||
|
||||
If you want more help with writing markdown, we'd recommend checking out [The Markdown Guide](https://www.markdownguide.org/) to learn more.
|
||||
|
||||
**Note: Delete this note and the content within this section and replace with your own learnings.**
|
||||
|
||||
### Continued development
|
||||
|
||||
Use this section to outline areas that you want to continue focusing on in future projects. These could be concepts you're still not completely comfortable with or techniques you found useful that you want to refine and perfect.
|
||||
|
||||
**Note: Delete this note and the content within this section and replace with your own plans for continued development.**
|
||||
|
||||
### Useful resources
|
||||
|
||||
- [Example resource 1](https://www.example.com) - This helped me for XYZ reason. I really liked this pattern and will use it going forward.
|
||||
- [Example resource 2](https://www.example.com) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.
|
||||
|
||||
**Note: Delete this note and replace the list above with resources that helped you during the challenge. These could come in handy for anyone viewing your solution or for yourself when you look back on this project in the future.**
|
||||
|
||||
## Author
|
||||
|
||||
- Website - [Add your name here](https://www.your-site.com)
|
||||
- Frontend Mentor - [@yourusername](https://www.frontendmentor.io/profile/yourusername)
|
||||
- Twitter - [@yourusername](https://www.twitter.com/yourusername)
|
||||
|
||||
**Note: Delete this note and add/remove/edit lines above based on what links you'd like to share.**
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
This is where you can give a hat tip to anyone who helped you out on this project. Perhaps you worked in a team or got some inspiration from someone else's solution. This is the perfect place to give them some credit.
|
||||
|
||||
**Note: Delete this note and edit this section's content as necessary. If you completed this challenge by yourself, feel free to delete this section entirely.**
|
||||
105
12-order-summary-component-thymeleaf/README.org
Normal file
@@ -0,0 +1,105 @@
|
||||
* Frontend Mentor - Order summary card solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---order-summary-card-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/order-summary-component-QlPmajDUj][Order
|
||||
summary card challenge on Frontend Mentor]]. Frontend Mentor challenges
|
||||
help you improve your coding skills by building realistic projects.
|
||||
|
||||
** Overview
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: overview
|
||||
:END:
|
||||
*** The challenge
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: the-challenge
|
||||
:END:
|
||||
Users should be able to:
|
||||
|
||||
- See hover states for interactive elements
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[screenshot-desktop.png]]
|
||||
[[screenshot-mobile.png]]
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- [[https://www.frontendmentor.io/solutions/responsive-by-tailwindcss-ssr-on-scala-with-cask-thymeleaf-template-bMMgFdajHT][Solution URL]]
|
||||
- [[https://efim-frontentmentor-order-summary.onrender.com/][Live Site URL]]
|
||||
Free instance on render.com is turned off after 15 minutes of inactivity, please give the server a moment to start up if you're visiting it at the moment of being turned off
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Semantic HTML5 markup
|
||||
- Tailwincss
|
||||
- Mobile-first workflow
|
||||
- SSR in Scala & Cask webserver
|
||||
- Thymeleaf templates
|
||||
|
||||
**** running during development
|
||||
installing "sbt-revolver":
|
||||
#+begin_src scala
|
||||
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||
#+end_src
|
||||
|
||||
then `~reStart -p 49012`
|
||||
|
||||
otherwise =~= in front of sbt command reruns it only if it finished execution.
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** placing Thymeleaf templates
|
||||
if they are in src/main/resources - they should be available on class path.
|
||||
and search should be relative to the resources, i.e putting templates into dir "templates"
|
||||
then
|
||||
#+begin_src scala
|
||||
val templateResolver = new ClassLoaderTemplateResolver()
|
||||
templateResolver.setPrefix("templates/");
|
||||
templateResolver.setSuffix(".html")
|
||||
val result = templateEngine.process("index", context)
|
||||
#+end_src
|
||||
will look for file in "src/main/resources/templates/index.html" to treat as a template
|
||||
**** to reload web server during development - sbt plugin "sbt-revolver"
|
||||
|
||||
**** with these html templates I can start learning and using Emmet mode in Emacs
|
||||
https://github.com/smihica/emmet-mode
|
||||
|
||||
**** Importing Thymeleaf template
|
||||
There are other methods to include templates like th:replace and th:include, which have slightly different behaviours. th:insert keeps the host tag (the div in your case), th:replace replaces the whole host tag with the fragment, and th:include replaces the inner content of the host tag with the fragment.
|
||||
|
||||
So i can actually have the "Order Summary" as reusable part.
|
||||
**** getting responsive background image with Tailwincss
|
||||
#+begin_src html
|
||||
<div
|
||||
class="bg-[url('../public/images/pattern-background-mobile.svg')] fixed h-screen w-screen bg-no-repeat bg-contain md:bg-[url('../public/images/pattern-background-desktop.svg')]"
|
||||
></div>
|
||||
#+end_src
|
||||
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
This was first exercise I've done with Thymeleaf templates.
|
||||
|
||||
Next is using fragments with some dynamic content and styling.
|
||||
Then attempting to include htmx fueled reactivity.
|
||||
|
||||
** Acknowledgments
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: acknowledgments
|
||||
:END:
|
||||
Lots of gratitude to Thymeleaf templates, they seem to be very advandced and thoughtfully designed
|
||||
@@ -8,7 +8,7 @@ val toolkitV = "0.1.7"
|
||||
val toolkit = "org.scala-lang" %% "toolkit" % toolkitV
|
||||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % toolkitV
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
lazy val orderSummaryComponent = (project in file("."))
|
||||
.settings(
|
||||
name := "order-summary-component",
|
||||
libraryDependencies += toolkit,
|
||||
|
||||
101
12-order-summary-component-thymeleaf/default.nix
Normal file
@@ -0,0 +1,101 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
|
||||
let
|
||||
pname = "order-summary-component-app";
|
||||
package = sbt-derivation.lib.mkSbtDerivation {
|
||||
inherit pkgs pname;
|
||||
# ...and the rest of the arguments
|
||||
version = "0.0.1";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
||||
buildPhase = ''
|
||||
sbt assembly
|
||||
tailwindcss -i ./src/input.css -o ./output.css
|
||||
'';
|
||||
# css path different from ordinary development,
|
||||
# because .gitignore makes it unavailable during nix build
|
||||
# anyway copied to correct place
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/scala-*/order-summary-component-assembly-*.jar $out/bin/${pname}.jar
|
||||
mkdir -p $out/bin/dist
|
||||
cp ./output.css $out/bin/dist/output.css
|
||||
cp -r public $out/bin/public
|
||||
'';
|
||||
|
||||
depsSha256 = "sha256-ADQB4qTl69ERlLAURrtR3fWa7PUdYjFLk5QdU5QgxRQ=";
|
||||
};
|
||||
|
||||
in {
|
||||
inherit package;
|
||||
module = { config, pkgs, ... }:
|
||||
let cfg = config.services.orderSummaryComponent;
|
||||
in {
|
||||
options.services.orderSummaryComponent = {
|
||||
enable = lib.mkEnableOption "My service";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 8080;
|
||||
description = "Port to listen on.";
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
description = "Host to bind to.";
|
||||
};
|
||||
|
||||
useNginx = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to use Nginx to proxy requests.";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups.order-summary-component-group = { };
|
||||
users.users.order-summary-component-user = {
|
||||
isSystemUser = true;
|
||||
group = "order-summary-component-group";
|
||||
};
|
||||
|
||||
systemd.services.orderSummaryComponent =
|
||||
let serverHost = if cfg.useNginx then "localhost" else cfg.host;
|
||||
in {
|
||||
description = "Exercise app Order Summary Component";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 10;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/${pname}.jar -p ${
|
||||
toString cfg.port
|
||||
} --host ${serverHost}";
|
||||
WorkingDirectory = "${package}/bin";
|
||||
Restart = "on-failure";
|
||||
User = "order-summary-component-user";
|
||||
Group = "order-summary-component-group";
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.useNginx {
|
||||
virtualHosts.${cfg.host} = {
|
||||
locations."/".proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = pname;
|
||||
tag = "latest";
|
||||
created = "now";
|
||||
config = {
|
||||
Cmd = [ "${pkgs.jdk}/bin/java" "-jar" "${package}/bin/${pname}.jar" "--host" "0.0.0.0" ];
|
||||
ExposedPorts = {
|
||||
"8080/tcp" = {};
|
||||
};
|
||||
WorkingDir = "${package}/bin";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
||||
|
||||
BIN
12-order-summary-component-thymeleaf/screenshot-desktop.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
12-order-summary-component-thymeleaf/screenshot-mobile.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
12-order-summary-component-thymeleaf/screenshot.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
@@ -43,7 +43,7 @@
|
||||
Challenge by
|
||||
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
|
||||
>Frontend Mentor</a
|
||||
>. Coded by <a href="#">Your Name Here</a>.
|
||||
>. Source code at <a href="https://github.com/efim/Learning-HTMX">Your Name Here</a>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
16
13-testimonials-grid-section/.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
.bsp/
|
||||
.scala-build/
|
||||
.metals/
|
||||
.direnv
|
||||
*/dist/
|
||||
/11-single-price-grid-component/.bloop/
|
||||
|
||||
**/.bloop
|
||||
**/project/project/
|
||||
**/project/metals.sbt
|
||||
**/project/.bloop
|
||||
**/project/target/
|
||||
**/target/
|
||||
|
||||
*/result
|
||||
result
|
||||
0
13-testimonials-grid-section/.project
Normal file
2
13-testimonials-grid-section/.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "3.7.3"
|
||||
runner.dialect = scala3
|
||||
101
13-testimonials-grid-section/README.org
Normal file
@@ -0,0 +1,101 @@
|
||||
* Frontend Mentor - Testimonials grid section solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---testimonials-grid-section-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/testimonials-grid-section-Nnw6J7Un7][Testimonials
|
||||
grid section challenge on Frontend Mentor]]. Frontend Mentor challenges
|
||||
help you improve your coding skills by building realistic projects.
|
||||
|
||||
** Overview
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: overview
|
||||
:END:
|
||||
*** The challenge
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: the-challenge
|
||||
:END:
|
||||
Users should be able to:
|
||||
|
||||
- View the optimal layout for the site depending on their device's
|
||||
screen size
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[screenshot-desktop.png]]
|
||||
[[screenshot-mobile.png]]
|
||||
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- [[https://efim-frontentmentor-testimoinals-grid.onrender.com/][Solution URL]]
|
||||
- Live Site URL
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Semantic HTML5 markup
|
||||
- TailwindCSS
|
||||
- CSS Grid
|
||||
- SSR on Scala with Cask
|
||||
- Thymeleaf templates
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** defining template fragments in Thymeleaf that take parameters
|
||||
Bigger thing i didn't understand is that element marked by "th:fragment" are also rendered.
|
||||
|
||||
I had a problem with 'th:each' being defined on the same element as 'th:fragment'
|
||||
|
||||
even though due to th:each single 'testimonial' object is available for inserting. if i try to use that singular 'testimonial' as fragment argument, the also existing 'th:each' over "testimonials" runs and sinse there's no passed list of objects - nothing gets rendered.
|
||||
|
||||
So 'th:each' should be around the single fragment in the future.
|
||||
Currently i've hacked this by passing List(testimonial) for re-rendering a single item.
|
||||
|
||||
**** A way to style fragments from the code
|
||||
I've initially implemented the static page, with manually settin different testimonial colors and sizes, but then implemented a template fragment, which uses "th:classappend" to add tailwind color and size classes from the context objects.
|
||||
|
||||
This way unfortunately the tag marked with "th:fragement" (and it is getting rendered when template file is opened as a static file) doesn't have stylings.
|
||||
|
||||
And I'd really like a way that allows for having a fully displayed static template, which doesn't interfere with rendering.
|
||||
|
||||
Also - had to remember to not have space in
|
||||
content: ["./src/**/*.{html,scala}"],
|
||||
so that TailwindCSS would also monitor classes in the code
|
||||
|
||||
**** first attempt to use partial gragments as replies to htmx requests
|
||||
I've added logic for transposing the 2x1 card into 1x2 and vice-versa (as an exercise in using htmx).
|
||||
|
||||
Backing in "next orientation" into argument for the hx-get request, which is executed on click, and receives new html markup to get inserted, with the testimonial orientation classes changed.
|
||||
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
a better way to style the components, so that static file would also have the styling on the 'fragment' element
|
||||
|
||||
already found a way to render fragments without needing to put them into a separate file.
|
||||
|
||||
*** Useful resources
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: useful-resources
|
||||
:END:
|
||||
- The htmx [[https://htmx.org/docs/][documentation]] and [[https://htmx.org/examples/][examples]]
|
||||
- [[https://htmx.org/essays/][The articles on htmx approach to web dev]]
|
||||
|
||||
** Acknowledgments
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: acknowledgments
|
||||
:END:
|
||||
Here I'll like to express gratitute to htmx, for writing examples and articles which helped me to go from totally not understanding their position, to actively wanting to learn this.
|
||||
15
13-testimonials-grid-section/build.sbt
Normal file
@@ -0,0 +1,15 @@
|
||||
ThisBuild / scalaVersion := "3.2.2"
|
||||
fork := true
|
||||
|
||||
ThisBuild / version := "0.0.1"
|
||||
ThisBuild / organization := "industries.sunshine"
|
||||
|
||||
lazy val testimonialsGrid = (project in file("."))
|
||||
.settings(
|
||||
name := "testimonials-grid-section",
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %% "cask" % "0.9.1",
|
||||
"com.lihaoyi" %% "mainargs" % "0.5.0",
|
||||
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE",
|
||||
)
|
||||
)
|
||||
105
13-testimonials-grid-section/default.nix
Normal file
@@ -0,0 +1,105 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
|
||||
let
|
||||
pname = "testimonials-grid-section";
|
||||
package = sbt-derivation.lib.mkSbtDerivation {
|
||||
inherit pkgs pname;
|
||||
# ...and the rest of the arguments
|
||||
version = "0.0.1";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
||||
buildPhase = ''
|
||||
sbt assembly
|
||||
tailwindcss -i ./src/input.css -o ./output.css
|
||||
'';
|
||||
# css path different from ordinary development,
|
||||
# because .gitignore makes it unavailable during nix build
|
||||
# anyway copied to correct place
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/scala-*/${pname}-assembly-*.jar $out/bin/${pname}.jar
|
||||
mkdir -p $out/bin/dist
|
||||
cp ./output.css $out/bin/dist/output.css
|
||||
cp -r public $out/bin/public
|
||||
'';
|
||||
|
||||
depsSha256 = "sha256-Y5RktcE3fxUJci4o7LTuNlBEybTdVRqsG551AkVeRPw=";
|
||||
};
|
||||
|
||||
in {
|
||||
inherit package;
|
||||
module = { config, pkgs, ... }:
|
||||
let cfg = config.services.${pname};
|
||||
in {
|
||||
options.services.${pname} = {
|
||||
enable = lib.mkEnableOption "My frontendmentor exercise ${pname}";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 8080;
|
||||
description = "Port to listen on.";
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
description = "Host to bind to.";
|
||||
};
|
||||
|
||||
useNginx = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to use Nginx to proxy requests.";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups."${pname}-group" = { };
|
||||
users.users."${pname}-user" = {
|
||||
isSystemUser = true;
|
||||
group = "${pname}-group";
|
||||
};
|
||||
|
||||
systemd.services.${pname} =
|
||||
let serverHost = if cfg.useNginx then "localhost" else cfg.host;
|
||||
in {
|
||||
description = "Exercise app ${pname}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 10;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/${pname}.jar -p ${
|
||||
toString cfg.port
|
||||
} --host ${serverHost}";
|
||||
WorkingDirectory = "${package}/bin";
|
||||
Restart = "on-failure";
|
||||
User = "${pname}-user";
|
||||
Group = "${pname}-group";
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.useNginx {
|
||||
virtualHosts.${cfg.host} = {
|
||||
locations."/".proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = pname;
|
||||
tag = "latest";
|
||||
created = "now";
|
||||
config = {
|
||||
Cmd = [
|
||||
"${pkgs.jdk}/bin/java"
|
||||
"-jar"
|
||||
"${package}/bin/${pname}.jar"
|
||||
"--host"
|
||||
"0.0.0.0"
|
||||
];
|
||||
ExposedPorts = { "8080/tcp" = { }; };
|
||||
WorkingDir = "${package}/bin";
|
||||
};
|
||||
};
|
||||
}
|
||||
BIN
13-testimonials-grid-section/design/desktop-design.jpg
Normal file
|
After Width: | Height: | Size: 123 KiB |
BIN
13-testimonials-grid-section/design/desktop-preview.jpg
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
13-testimonials-grid-section/design/mobile-design.jpg
Normal file
|
After Width: | Height: | Size: 119 KiB |
1
13-testimonials-grid-section/project/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
sbt.version=1.9.0
|
||||
3
13-testimonials-grid-section/project/plugins.sbt
Normal file
@@ -0,0 +1,3 @@
|
||||
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
||||
1
13-testimonials-grid-section/public/deps/htmx.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="104" height="102" xmlns="http://www.w3.org/2000/svg"><path d="M104 102V59.727H84.114c0-5.871.689-11.182 2.068-15.933 1.379-4.75 3.42-9.287 6.125-13.61C95.01 25.86 98.909 22.257 104 19.375V0c-9.758 4.27-17.712 9.874-23.864 16.813-6.151 6.939-10.712 14.545-13.681 22.818C63.485 47.904 62 59.941 62 75.74V102h42zm-62 0V59.727H22.114c0-5.871.689-11.182 2.068-15.933 1.379-4.75 3.42-9.287 6.125-13.61C33.01 25.86 36.909 22.257 42 19.375V0c-9.652 4.27-17.58 9.874-23.784 16.813C12.01 23.752 7.424 31.358 4.455 39.631 1.485 47.904 0 59.941 0 75.74V102h42z" fill="#A775F1" fill-rule="nonzero"/></svg>
|
||||
|
After Width: | Height: | Size: 604 B |
BIN
13-testimonials-grid-section/public/images/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
13-testimonials-grid-section/public/images/image-daniel.jpg
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
13-testimonials-grid-section/public/images/image-jeanette.jpg
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
13-testimonials-grid-section/public/images/image-jonathan.jpg
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
13-testimonials-grid-section/public/images/image-kira.jpg
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
13-testimonials-grid-section/public/images/image-patrick.jpg
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
13-testimonials-grid-section/screenshot-desktop.png
Normal file
|
After Width: | Height: | Size: 280 KiB |
BIN
13-testimonials-grid-section/screenshot-mobile.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
7
13-testimonials-grid-section/src/input.css
Normal file
@@ -0,0 +1,7 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html {
|
||||
font-size: 13px;
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<!-- displays site properly based on user's device -->
|
||||
|
||||
<link href="/dist/output.css" rel="stylesheet" />
|
||||
<link href="../../../../dist/output.css" rel="stylesheet" th:remove="all" />
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="public/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@500;600&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Frontend Mentor | [Challenge Name Here]</title>
|
||||
|
||||
<script type="text/javascript" src="public/deps/htmx.min.js"></script>
|
||||
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
|
||||
<style>
|
||||
.attribution {
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
}
|
||||
.attribution a {
|
||||
color: hsl(228, 45%, 44%);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="grid grid-flow-col-dense place-content-center bg-light-grayish-blue">
|
||||
<div class="py-20 px-7 space-y-7 min-h-screen text-white md:grid md:gap-[30px] md:py-0 md:px-0 h-max max-w-[1200px] md:grid-cols-[repeat(auto-fill,_255px)] md:auto-rows-[280px] md:mt-[160px] md:space-y-0">
|
||||
<section
|
||||
th:fragment="testimonialSection(testimonials)"
|
||||
th:each="testimonial : ${testimonials}"
|
||||
th:classappend="${testimonial.additionalSizeClasses} + ' ' + ${testimonial.additionalColorClasses}"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow "
|
||||
th:id="${testimonial.id}"
|
||||
th:hx-get="'/testimonial/' + ${testimonial.id} + '?nextOrientation=' + ${testimonial.followupOrientation}"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<img
|
||||
alt="Avatar image"
|
||||
src="../../../../public/images/image-daniel.jpg"
|
||||
th:src="${testimonial.avatarUrl}"
|
||||
class="mr-5 w-10 h-10 rounded-full border-2 border-gray-400"
|
||||
/>
|
||||
<div class="grow">
|
||||
<h1
|
||||
th:text="${testimonial.author}"
|
||||
>Daniel Clifford</h1>
|
||||
<p class="text-sm opacity-50">Verified Graduate</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="text-2xl"
|
||||
th:text="${testimonial.header}"
|
||||
>
|
||||
I received a job offer mid-course, and the subjects I learned were
|
||||
current, if not more so, in the company I joined. I honestly feel I
|
||||
got every penny’s worth.
|
||||
</h2>
|
||||
<p class="opacity-[70%] pb-2 leading-snug"
|
||||
th:text="${testimonial.text}"
|
||||
>
|
||||
“ I was an EMT for many years before I joined the bootcamp. I’ve been
|
||||
looking to make a transition and have heard some people who had an
|
||||
amazing experience here. I signed up for the free intro course and
|
||||
found it incredibly fun! I enrolled shortly thereafter. The next 12
|
||||
weeks was the best - and most grueling - time of my life. Since
|
||||
completing the course, I’ve successfully switched careers, working as
|
||||
a Software Engineer at a VR startup. ”
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section
|
||||
th:remove="all"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl bg-very-dark-grayish-blue first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<img
|
||||
alt="Avatar image"
|
||||
src="../../../../public/images/image-jonathan.jpg"
|
||||
class="mr-5 w-10 h-10 rounded-full border-2 border-gray-400"
|
||||
/>
|
||||
<div class="grow">
|
||||
<h1>Jonathan Walters</h1>
|
||||
<p class="text-sm opacity-50">Verified Graduate</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="text-2xl">
|
||||
The team was very supportive and kept me motivated
|
||||
</h2>
|
||||
<p class="opacity-[70%] pb-2 leading-snug">
|
||||
“ I started as a total newbie with virtually no coding skills. I now
|
||||
work as a mobile engineer for a big company. This was one of the best
|
||||
investments I’ve made in myself. ”
|
||||
</p>
|
||||
</section>
|
||||
<section
|
||||
th:remove="all"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl bg-white text-very-dark-blackish-blue first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<img
|
||||
alt="Avatar image"
|
||||
src="../../../../public/images/image-jeanette.jpg"
|
||||
class="mr-5 w-10 h-10 rounded-full border-2 border-gray-400"
|
||||
/>
|
||||
<div class="grow">
|
||||
<h1>Jeanette Harmon</h1>
|
||||
<p class="text-sm leading-snug opacity-50">Verified Graduate</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="text-2xl">An overall wonderful and rewarding experience</h2>
|
||||
<p class="opacity-[70%] pb-2 leading-snug">
|
||||
“ Thank you for the wonderful experience! I now have a job I really
|
||||
enjoy, and make a good living while doing something I love. ”
|
||||
</p>
|
||||
</section>
|
||||
<section
|
||||
th:remove="all"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl bg-very-dark-blackish-blue text-white first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow md:col-span-2"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<img
|
||||
alt="Avatar image"
|
||||
src="../../../../public/images/image-patrick.jpg"
|
||||
class="mr-5 w-10 h-10 rounded-full border-2 border-gray-400"
|
||||
/>
|
||||
<div class="grow">
|
||||
<h1>Patrick Abrams</h1>
|
||||
<p class="text-sm leading-snug opacity-50">Verified Graduate</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="text-2xl">
|
||||
Awesome teaching support from TAs who did the bootcamp themselves.
|
||||
Getting guidance from them and learning from their experiences was
|
||||
easy.
|
||||
</h2>
|
||||
<p class="opacity-[70%] pb-2 leading-snug">
|
||||
“ The staff seem genuinely concerned about my progress which I find
|
||||
really refreshing. The program gave me the confidence necessary to be
|
||||
able to go out in the world and present myself as a capable junior
|
||||
developer. The standard is above the rest. You will get the personal
|
||||
attention you need from an incredible community of smart and amazing
|
||||
people. ”
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section
|
||||
th:remove="all"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl bg-white text-very-dark-blackish-blue first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow md:row-span-2 md:row-start-1 md:col-end-[-1]"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<img
|
||||
alt="Avatar image"
|
||||
src="../../../../public/images/image-kira.jpg"
|
||||
class="mr-5 w-10 h-10 rounded-full border-2 border-gray-400"
|
||||
/>
|
||||
<div class="grow">
|
||||
<h1>Kira Whittle</h1>
|
||||
<p class="text-sm opacity-50">Verified Graduate</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="text-2xl">
|
||||
Such a life-changing experience. Highly recommended!
|
||||
</h2>
|
||||
Quis hendrerit dolor magna eget est lorem ipsum dolor sit amet, consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis! Nam libero justo, laoreet sit amet cursus sit amet, dictum sit amet justo donec.
|
||||
<p class="opacity-[70%] pb-2 leading-snug">
|
||||
“ Before joining the bootcamp, I’ve never written a line of code. I
|
||||
needed some structure from professionals who can help me learn
|
||||
programming step by step. I was encouraged to enroll by a former
|
||||
student of theirs who can only say wonderful things about the program.
|
||||
The entire curriculum and staff did not disappoint. They were very
|
||||
hands-on and I never had to wait long for assistance. The agile team
|
||||
project, in particular, was outstanding. It took my learning to the
|
||||
next level in a way that no tutorial could ever have. In fact, I’ve
|
||||
often referred to it during interviews as an example of my developent
|
||||
experience. It certainly helped me land a job as a full-stack
|
||||
developer after receiving multiple offers. 100% recommend! ”
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="fixed inset-x-0 bottom-0 attribution">
|
||||
Challenge by
|
||||
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
|
||||
>Frontend Mentor</a
|
||||
>. Source code at <a href="https://github.com/efim/Learning-HTMX">Your Name Here</a>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<section
|
||||
th:replace="index::testimonialSection(testimonials=${selectedTestimonials})">
|
||||
</section>
|
||||
@@ -0,0 +1,86 @@
|
||||
package testimonialsgrid
|
||||
|
||||
import mainargs.{main, arg, ParserForMethods}
|
||||
import cask.main.Routes
|
||||
|
||||
import org.thymeleaf.context.Context
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||
import org.thymeleaf.TemplateEngine
|
||||
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
object Main {
|
||||
@main def run(
|
||||
@arg(
|
||||
name = "port",
|
||||
short = 'p',
|
||||
doc = "Port on which server will start serving."
|
||||
)
|
||||
portArg: Int = 8080,
|
||||
@arg(name = "host", doc = "Host on which server will start serving.")
|
||||
hostArg: String = "localhost"
|
||||
): Unit = {
|
||||
println(s"Will start server on ${hostArg}:${portArg}")
|
||||
val server = new cask.Main {
|
||||
override def allRoutes: Seq[Routes] = Seq(AppRoutes())
|
||||
override def port: Int = portArg
|
||||
override def host: String = hostArg
|
||||
}
|
||||
server.main(Array.empty)
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
||||
|
||||
case class AppRoutes()(implicit cc: castor.Context, log: cask.Logger)
|
||||
extends cask.Routes {
|
||||
val templateResolver = new ClassLoaderTemplateResolver()
|
||||
templateResolver.setPrefix("templates/");
|
||||
templateResolver.setSuffix(".html")
|
||||
templateResolver.setTemplateMode("HTML5")
|
||||
|
||||
val templateEngine = new TemplateEngine()
|
||||
templateEngine.setTemplateResolver(templateResolver)
|
||||
|
||||
@cask.get("/")
|
||||
def index() = {
|
||||
val context = new Context()
|
||||
context.setVariable(
|
||||
"testimonials",
|
||||
Testimonial.sameAsRequested.asJava
|
||||
)
|
||||
val result = templateEngine.process("index", context)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
@cask.get("/testimonial/:id")
|
||||
def getTestimonial(id: String, nextOrientation: Int) = {
|
||||
// println(s"got params $nextOrientation")
|
||||
val context = new Context()
|
||||
// wow, i need copy because attributes are vars and not vals,
|
||||
// didn't have to think about this in a long long time
|
||||
val foundTestimonial =
|
||||
Testimonial.sameAsRequested.find(_.id == id).get.copy()
|
||||
|
||||
foundTestimonial.setNextSizeClass(nextOrientation)
|
||||
// println(
|
||||
// s"should change size and orientation : $foundTestimonial "
|
||||
// )
|
||||
context.setVariable("selectedTestimonials", List(foundTestimonial).asJava)
|
||||
val result = templateEngine.process("testimonialSection", context)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
@cask.staticFiles("/dist")
|
||||
def distFiles() = "dist"
|
||||
@cask.staticFiles("/public")
|
||||
def publicFiles() = "public"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package testimonialsgrid
|
||||
import scala.beans.BeanProperty
|
||||
import java.util.UUID
|
||||
import scala.util.Random
|
||||
|
||||
final case class Testimonial(
|
||||
@BeanProperty var avatarUrl: String,
|
||||
@BeanProperty var author: String,
|
||||
@BeanProperty var header: String,
|
||||
@BeanProperty var text: String,
|
||||
@BeanProperty var id: String,
|
||||
@BeanProperty var additionalColorClasses: String,
|
||||
@BeanProperty var additionalSizeClasses: String,
|
||||
@BeanProperty var followupOrientation: Int = 0,
|
||||
sequentSizeClasses: List[String] = List("")
|
||||
) {
|
||||
def setNextSizeClass(key: Int): Unit = {
|
||||
val nextOrientationIndex = (key + 1) % sequentSizeClasses.size
|
||||
this.additionalSizeClasses = sequentSizeClasses(nextOrientationIndex)
|
||||
this.followupOrientation = nextOrientationIndex
|
||||
}
|
||||
}
|
||||
|
||||
object Testimonial {
|
||||
val colorful = List(
|
||||
new Testimonial(
|
||||
"public/images/image-patrick.jpg",
|
||||
"Leopold",
|
||||
" Odio facilisis mauris sit amet massa vitae tortor condimentum lacinimport java.util.UUID ia quis vel eros donec ac odio tempor orci dapibus ultrices. ",
|
||||
" Nibh sed pulvinar proin gravida hendrerit? Massa tincidunt nunc pulvinar sapien et ligula libero nunc!",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-red-500",
|
||||
""
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-jonathan.jpg",
|
||||
"Aragorn",
|
||||
" Eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum! ",
|
||||
" Egestas fringilla phasellus faucibus scelerisque eleifend! Dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in! ",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-blue-500",
|
||||
"md:col-span-2"
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-jeanette.jpg",
|
||||
"Jeanatte Mamamia",
|
||||
" Id venenatis a, condimentum vitae sapien pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas sed tempus, urna et pharetra pharetra! ",
|
||||
" Amet nulla facilisi morbi tempus iaculis urna, id volutpat lacus laoreet non curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Lorem dolor, sed viverra ipsum nunc aliquet bibendum? ",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-green-200 text-black",
|
||||
"md:row-span-2"
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-kira.jpg",
|
||||
"Mamma mia",
|
||||
" Id venenatis a, condimentum vitae sapien pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas sed tempus, urna et pharetra pharetra! ",
|
||||
""" Quis hendrerit dolor magna eget est lorem ipsum dolor sit amet, consectetur adipiscing elit pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis! Nam libero justo, laoreet sit amet cursus sit amet, dictum sit amet justo donec.
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-amber-200 text-black",
|
||||
"md:col-span-2"
|
||||
)
|
||||
)
|
||||
|
||||
val sameAsRequested = List(
|
||||
new Testimonial(
|
||||
"public/images/image-daniel.jpg",
|
||||
"Daniel Clifford",
|
||||
"""I received a job offer mid-course, and the subjects I learned were current, if not more so,
|
||||
in the company I joined. I honestly feel I got every penny’s worth.
|
||||
""",
|
||||
""" “ I was an EMT for many years before I joined the bootcamp. I’ve been looking to make a
|
||||
transition and have heard some people who had an amazing experience here. I signed up
|
||||
for the free intro course and found it incredibly fun! I enrolled shortly thereafter.
|
||||
The next 12 weeks was the best - and most grueling - time of my life. Since completing
|
||||
the course, I’ve successfully switched careers, working as a Software Engineer at a VR startup. ”
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-moderate-violet",
|
||||
"md:col-span-2",
|
||||
sequentSizeClasses = List("md:row-span-2", "md:col-span-2")
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-jonathan.jpg",
|
||||
"Jonathan Walters",
|
||||
" The team was very supportive and kept me motivated ",
|
||||
""" " Egestas fringilla phasellus faucibus scelerisque eleifend! Dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in! ",
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-very-dark-grayish-blue",
|
||||
"md:col-span-1"
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-jeanette.jpg",
|
||||
"Jeanette Harmon",
|
||||
"An overall wonderful and rewarding experience",
|
||||
""" “ Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living
|
||||
while doing something I love. ”
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-white text-very-dark-blackish-blue",
|
||||
"md:col-span-1"
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-patrick.jpg",
|
||||
"Patrick Abrams",
|
||||
""" " Eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum! ",
|
||||
""",
|
||||
""" “ The staff seem genuinely concerned about my progress which I find really refreshing. The program
|
||||
gave me the confidence necessary to be able to go out in the world and present myself as a capable
|
||||
junior developer. The standard is above the rest. You will get the personal attention you need from
|
||||
an incredible community of smart and amazing people. ”
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-very-dark-blackish-blue",
|
||||
"md:col-span-2",
|
||||
sequentSizeClasses = List("md:row-span-2", "md:col-span-2")
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-kira.jpg",
|
||||
"Kira Whittle",
|
||||
" Such a life-changing experience. Highly recommended! ",
|
||||
""" “ Before joining the bootcamp, I’ve never written a line of code. I
|
||||
needed some structure from professionals who can help me learn
|
||||
programming step by step. I was encouraged to enroll by a former
|
||||
student of theirs who can only say wonderful things about the program.
|
||||
The entire curriculum and staff did not disappoint. They were very
|
||||
hands-on and I never had to wait long for assistance. The agile team
|
||||
project, in particular, was outstanding. It took my learning to the
|
||||
next level in a way that no tutorial could ever have. In fact, I’ve
|
||||
often referred to it during interviews as an example of my developent
|
||||
experience. It certainly helped me land a job as a full-stack
|
||||
developer after receiving multiple offers. 100% recommend! ”
|
||||
""",
|
||||
UUID.randomUUID().toString(),
|
||||
"bg-white text-very-dark-blackish-blue",
|
||||
"md:row-span-2 md:col-end-[-1] md:row-start-1",
|
||||
sequentSizeClasses = List("md:row-span-2","md:col-span-2")
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package example
|
||||
|
||||
class ExampleSuite extends munit.FunSuite:
|
||||
|
||||
test("addition") {
|
||||
assert(1 + 1 == 2)
|
||||
}
|
||||
end ExampleSuite
|
||||
38
13-testimonials-grid-section/style-guide.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Front-end Style Guide
|
||||
|
||||
## Layout
|
||||
|
||||
The designs were created to the following widths:
|
||||
|
||||
- Mobile: 375px
|
||||
- Desktop: 1440px
|
||||
|
||||
## Colors
|
||||
|
||||
### Primary
|
||||
|
||||
Moderate violet: hsl(263, 55%, 52%)
|
||||
Very dark grayish blue: hsl(217, 19%, 35%)
|
||||
Very dark blackish blue: hsl(219, 29%, 14%)
|
||||
White: hsl(0, 0%, 100%)
|
||||
|
||||
### Neutral
|
||||
|
||||
Light gray: hsl(0, 0%, 81%)
|
||||
Light grayish blue: hsl(210, 46%, 95%)
|
||||
|
||||
Note for text colors:
|
||||
|
||||
1. "Verified Graduate" has the same color as the person's name with 50% opacity
|
||||
2. Review paragraphs inside the quotations have the same color as well, but are at 70% opacity
|
||||
|
||||
## Typography
|
||||
|
||||
### Body Copy
|
||||
|
||||
- Font size: 13px
|
||||
|
||||
### Font
|
||||
|
||||
- Family: [Barlow Semi Condensed](https://fonts.google.com/specimen/Barlow+Semi+Condensed)
|
||||
- Weights: 500, 600
|
||||
24
13-testimonials-grid-section/tailwind.config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: ["./src/**/*.{html,scala}"],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
'moderate-violet': 'hsl(263, 55%, 52%)',
|
||||
'very-dark-grayish-blue': 'hsl(217, 19%, 35%)',
|
||||
'very-dark-blackish-blue': 'hsl(219, 29%, 14%)',
|
||||
'light-gray': 'hsl(0, 0%, 81%)',
|
||||
'light-grayish-blue': 'hsl(210, 46%, 95%)',
|
||||
},
|
||||
fontFamily: {
|
||||
'sans': ['Barlow Semi Condensed', 'sans-serif'], // This will set Roboto as the default sans font
|
||||
},
|
||||
fontWeight: {
|
||||
'normal': 400,
|
||||
'bold': 500,
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
|
||||
16
14-rock-paper-scissors/.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
.bsp/
|
||||
.scala-build/
|
||||
.metals/
|
||||
.direnv
|
||||
*/dist/
|
||||
/11-single-price-grid-component/.bloop/
|
||||
|
||||
**/.bloop
|
||||
**/project/project/
|
||||
**/project/metals.sbt
|
||||
**/project/.bloop
|
||||
**/project/target/
|
||||
**/target/
|
||||
|
||||
*/result
|
||||
result
|
||||
0
14-rock-paper-scissors/.project
Normal file
2
14-rock-paper-scissors/.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "3.7.3"
|
||||
runner.dialect = scala3
|
||||
166
14-rock-paper-scissors/README.org
Normal file
@@ -0,0 +1,166 @@
|
||||
* Frontend Mentor - Rock, Paper, Scissors solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---rock-paper-scissors-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/rock-paper-scissors-game-pTgwgvgH][Rock,
|
||||
Paper, Scissors challenge on Frontend Mentor]]. Frontend Mentor
|
||||
challenges help you improve your coding skills by building realistic
|
||||
projects.
|
||||
|
||||
** Overview
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: overview
|
||||
:END:
|
||||
*** The challenge
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: the-challenge
|
||||
:END:
|
||||
Users should be able to:
|
||||
|
||||
- View the optimal layout for the game depending on their device's
|
||||
screen size
|
||||
- Play Rock, Paper, Scissors against the computer
|
||||
- Maintain the state of the score after refreshing the browser
|
||||
/(optional)/
|
||||
- *Bonus*: Play Rock, Paper, Scissors, Lizard, Spock against the
|
||||
computer /(optional)/
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[screenshot-desktop.png]]
|
||||
[[screenshot-mobile.png]]
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- Solution URL
|
||||
- [[https://efim-frontendmentor-rock-paper-scissors.onrender.com/][Live Site URL]]
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Semantic HTML5 markup
|
||||
- TailwindCSS, css animations
|
||||
- Flexbox & CSS Grid
|
||||
- Mobile-first workflow
|
||||
- SSR on Scala with Cask
|
||||
- Thymeleaf templates
|
||||
- htmx for partial page updates and interactivity
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** for template fragement styling - using CSS vars in <style> tag
|
||||
Allows for "initial" fragment specification to have static styling for viewing the page directly.
|
||||
|
||||
This is useful for fragments that should have different stylings, like hand selection badges - should have different colors, so colors are specified in the code and passed as css var values via "th:style".
|
||||
|
||||
Ordinary "style" attribute allows the tag which is marked by "th:fragment" to be viewed with some default styles. This is needed because for the "static" view of the page, browser ignores "th:fragment" attribute and just renders what it knows, as well as 'paper' and 'rock' badges, which are marked by "th:remove='all'" tag, which means they are only present in the "mockup static view"
|
||||
|
||||
But! Syling sizes this way seems to be an error, i don't want to specify 8rem in my code for the fragments, and that also makes styling of responsive design complicated. I guess I'll want the fragment itself occupy "all parent" and control the size of parent from html where the fragment is inserted.
|
||||
**** different htmx controls:
|
||||
***** the hx-get on the click
|
||||
substitutes the hand selection part of the page to the initial "showdown" - with selected hand and animated wait on the "house choice".
|
||||
***** on load + delay:3s hx-get
|
||||
on "wait for house choice" fragemnt
|
||||
means the "get house choice" rest method executed automatically, and generates random choice.
|
||||
|
||||
I'm substituting both hands \ whole 'showdown table' so i'm passing also a players choice into '/house-choice' rest endpoint.
|
||||
|
||||
I could only substitue the house choice badge and the message, that would have been a simpler design.
|
||||
***** i wanted for message to show up with delay
|
||||
so initially i though I'll do another timed on load request to fetch message, but figured that i could use css animation to fade the message in.
|
||||
***** handling state of the fragment
|
||||
Creating a scala object "ShowdownState" allows for setting single variable into context, and then at least "having all attributes of state" is enforced by scala compiler.
|
||||
|
||||
In documentaion i found that there's a shorthand for referencing attributes of single object:
|
||||
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#expressions-on-selections-asterisk-syntax
|
||||
|
||||
So i could set "th:object="${showdownState}"
|
||||
and then reference directly it's attributes by "*{playersChoice}"
|
||||
|
||||
This can mitigate untyped nature of template variables.
|
||||
***** I got more experience with laying out template fragments.
|
||||
Putting 'showdown table' into separate file definitely helped, styling in the opened static file is nice.
|
||||
|
||||
I'm not sure how much separate files are necessary. Maybe state of "player hand is present, house hand is not present" separate of "showdown and both hands are present" would be easier for styling. Because fragments could be shown at the page.
|
||||
|
||||
Negative side of that - all other "not for render" parts of the page would have to be styled and kept in sync with the parts of pages for styling.
|
||||
Maybe I'll do put some bigger fragments into separate files, but not recrete the outer page for them, just keep them in center of blank page.
|
||||
|
||||
***** Triggering client events from HTMX
|
||||
https://htmx.org/headers/hx-trigger/
|
||||
|
||||
Adding header to REST response will trigger js event in the page.
|
||||
#+begin_src scala
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq(
|
||||
"Content-Type" -> "text/html;charset=UTF-8",
|
||||
"HX-Trigger-After-Settle" -> s"""{"updateScore": ${showdownState.scoreChange}}"""
|
||||
)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
This is a way to pass data from server into js code, executing on client.
|
||||
For exmaple +1 \ +0 \ -1 for the score change.
|
||||
|
||||
***** Using small js scripts for browser functions
|
||||
|
||||
I.e updating score, saving it into local storage and loading.
|
||||
|
||||
Two simple scripts directly near the html markup which contains the score:
|
||||
#+begin_src html
|
||||
<script type="text/javascript">
|
||||
document.body.addEventListener("updateScore", function (evt) {
|
||||
let scoreElement = document.querySelector("#the-score-number");
|
||||
let newScore =
|
||||
parseInt(scoreElement.textContent) + evt.detail.value;
|
||||
console.log(
|
||||
`the score will update by ${evt.detail.value} to ${newScore}`
|
||||
);
|
||||
localStorage.setItem("score", newScore);
|
||||
scoreElement.textContent = newScore;
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
let scoreElement = document.querySelector("#the-score-number");
|
||||
let storedScore = localStorage.getItem("score");
|
||||
if (storedScore !== null) {
|
||||
scoreElement.textContent = storedScore;
|
||||
} else {
|
||||
scoreElement.textContent = 0;
|
||||
localStorage.setItem("score", 0);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
#+end_src
|
||||
|
||||
And debugging directly in the static preview.
|
||||
We can create event in the console and fire it from any element:
|
||||
|
||||
#+begin_src js
|
||||
var myEvent2 = new CustomEvent('updateScore', {detail : {value: -1}});
|
||||
document.body.dispatchEvent(myEvent2)
|
||||
#+end_src
|
||||
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
I could remake the html, to take into account the desktop layout. Which i didn't plan out and just didn't do - right now desktop only shows mobile layout increased in size.
|
||||
|
||||
Overall in the future I'd want to practice more with features available in htmx, to know how to make websites with interactivity expected my modern users.
|
||||
And also - practice integration with js libraries - htmx examples show integration with sortable via events, and many others can be possible.
|
||||
|
||||
15
14-rock-paper-scissors/build.sbt
Normal file
@@ -0,0 +1,15 @@
|
||||
ThisBuild / scalaVersion := "3.2.2"
|
||||
fork := true
|
||||
|
||||
ThisBuild / version := "0.0.1"
|
||||
ThisBuild / organization := "industries.sunshine"
|
||||
|
||||
lazy val rockPaperScissors = (project in file("."))
|
||||
.settings(
|
||||
name := "rock-paper-scissors",
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %% "cask" % "0.9.1",
|
||||
"com.lihaoyi" %% "mainargs" % "0.5.0",
|
||||
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE",
|
||||
)
|
||||
)
|
||||
104
14-rock-paper-scissors/default.nix
Normal file
@@ -0,0 +1,104 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
|
||||
let
|
||||
pname = "rock-paper-scissors";
|
||||
package = sbt-derivation.lib.mkSbtDerivation {
|
||||
inherit pkgs pname;
|
||||
# ...and the rest of the arguments
|
||||
version = "0.0.1";
|
||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
||||
buildPhase = ''
|
||||
tailwindcss -i ./src/input.css -o ./src/main/resources/public/output.css
|
||||
sbt assembly
|
||||
'';
|
||||
# css path different from ordinary development,
|
||||
# because .gitignore makes it unavailable during nix build
|
||||
# anyway copied to correct place
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/scala-*/${pname}-assembly-*.jar $out/bin/${pname}.jar
|
||||
'';
|
||||
|
||||
depsSha256 = "sha256-Y5RktcE3fxUJci4o7LTuNlBEybTdVRqsG551AkVeRPw=";
|
||||
};
|
||||
|
||||
module = { config, pkgs, ... }:
|
||||
let cfg = config.services.${pname};
|
||||
in {
|
||||
options.services.${pname} = {
|
||||
enable = lib.mkEnableOption "My frontendmentor exercise ${pname}";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 8080;
|
||||
description = "Port to listen on.";
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
description = "Host to bind to.";
|
||||
};
|
||||
|
||||
useNginx = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to use Nginx to proxy requests.";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups."${pname}-group" = { };
|
||||
users.users."${pname}-user" = {
|
||||
isSystemUser = true;
|
||||
group = "${pname}-group";
|
||||
};
|
||||
|
||||
systemd.services.${pname} =
|
||||
let serverHost = if cfg.useNginx then "localhost" else cfg.host;
|
||||
in {
|
||||
description = "Exercise app ${pname}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
startLimitIntervalSec = 30;
|
||||
startLimitBurst = 10;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/${pname}.jar -p ${
|
||||
toString cfg.port
|
||||
} --host ${serverHost}";
|
||||
WorkingDirectory = "${package}/bin";
|
||||
Restart = "on-failure";
|
||||
User = "${pname}-user";
|
||||
Group = "${pname}-group";
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.useNginx {
|
||||
virtualHosts.${cfg.host} = {
|
||||
locations."/".proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
image = pkgs.dockerTools.buildLayeredImage {
|
||||
name = pname;
|
||||
tag = "latest";
|
||||
created = "now";
|
||||
config = {
|
||||
Cmd = [ "${pkgs.jdk}/bin/java" "-jar" "${package}/bin/${pname}.jar" "--host" "0.0.0.0" ];
|
||||
ExposedPorts = {
|
||||
"8080/tcp" = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
# image = pkgs.dockerTools.buildLayeredImage { # so, wow, this works
|
||||
# name = "hello2";
|
||||
# tag = "latest";
|
||||
# config.Cmd = [ "${pkgs.hello}/bin/hello" ];
|
||||
# };
|
||||
in {
|
||||
package = package;
|
||||
module = module;
|
||||
image = image;
|
||||
}
|
||||
|
After Width: | Height: | Size: 38 KiB |
BIN
14-rock-paper-scissors/design/bonus/desktop-step-1-bonus.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
14-rock-paper-scissors/design/bonus/desktop-step-2-bonus.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
14-rock-paper-scissors/design/bonus/desktop-step-3-bonus.jpg
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
14-rock-paper-scissors/design/bonus/desktop-step-4-bonus.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
14-rock-paper-scissors/design/bonus/mobile-rules-modal-bonus.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
14-rock-paper-scissors/design/bonus/mobile-step-1-bonus.jpg
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
14-rock-paper-scissors/design/bonus/mobile-step-2-bonus.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
14-rock-paper-scissors/design/bonus/mobile-step-3-bonus.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
14-rock-paper-scissors/design/bonus/mobile-step-4-bonus.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
14-rock-paper-scissors/design/desktop-preview.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-rules-modal.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-step-1.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-step-2.jpg
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-step-3.jpg
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-step-4-lose.jpg
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
14-rock-paper-scissors/design/original/desktop-step-4-win.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-rules-modal.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-step-1.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-step-2.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-step-3.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-step-4-lose.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
14-rock-paper-scissors/design/original/mobile-step-4-win.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |
1
14-rock-paper-scissors/project/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
sbt.version=1.9.0
|
||||
3
14-rock-paper-scissors/project/plugins.sbt
Normal file
@@ -0,0 +1,3 @@
|
||||
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
||||
BIN
14-rock-paper-scissors/screenshot-desktop.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
14-rock-paper-scissors/screenshot-mobile.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
53
14-rock-paper-scissors/src/input.css
Normal file
@@ -0,0 +1,53 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* div, section, span, p, h1, button { */
|
||||
/* outline: 1px solid red; */
|
||||
/* } */
|
||||
|
||||
@keyframes slowly-appear {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
30% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.slowly-appear {
|
||||
animation: slowly-appear 3s;
|
||||
}
|
||||
|
||||
@keyframes pulsing-animation {
|
||||
0% {
|
||||
transform: scale(0);
|
||||
}
|
||||
100% {
|
||||
transform: scale(2);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pulsing-animation {
|
||||
animation: pulsing-animation 1s;
|
||||
animation-iteration-count: 3;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
@keyframes quickly-appear {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
.quickly-appear {
|
||||
animation: quickly-appear 2s;
|
||||
transform-origin: center;
|
||||
}
|
||||
1
14-rock-paper-scissors/src/main/resources/public/deps/htmx.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="329" height="313"><path fill="none" stroke="#000" stroke-width="15" d="M164.5 9.27L9.26 122.06l59.296 182.495h191.888L319.74 122.06 164.5 9.271z" opacity=".2"/></svg>
|
||||
|
After Width: | Height: | Size: 213 B |
@@ -0,0 +1 @@
|
||||
<svg width="313" height="278" xmlns="http://www.w3.org/2000/svg"><path stroke="#000" stroke-width="15" fill="none" opacity=".2" d="M156.5 262 300 8H13z"/></svg>
|
||||
|
After Width: | Height: | Size: 160 B |
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path fill="#3B4262" fill-rule="evenodd" d="M16.97 0l2.122 2.121-7.425 7.425 7.425 7.425-2.121 2.12-7.425-7.424-7.425 7.425L0 16.97l7.425-7.425L0 2.121 2.121 0l7.425 7.425L16.971 0z" opacity=".25"/></svg>
|
||||
|
After Width: | Height: | Size: 267 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="63" height="60"><path fill="#3B4262" d="M49.483 2.096c3.229-2 6.324-2.433 8.714-1.219 5.359 2.72 4.583 12.845 2.39 17.232-1.238 2.477-3.432 4.287-6.527 5.387-1.2 3.799-2.884 7.064-5.034 9.764a7.904 7.904 0 005.079 1.837h.09l3.02-2.982c.761-.75 1.994-.751 2.754 0 .76.75.76 1.968 0 2.718l-.267.264h.608c1.075 0 1.947.861 1.947 1.923 0 1.061-.872 1.922-1.947 1.922h-.608l.267.264c.76.75.76 1.968 0 2.719-.38.375-.878.563-1.376.563-.499 0-.997-.188-1.377-.563l-3.022-2.983h-.09a11.823 11.823 0 01-7.724-2.857c-.415.377-.843.738-1.284 1.083-3.732 2.92-8.294 4.617-13.627 5.082a12.08 12.08 0 01.343 6.352l-.02.09 2.325 3.66a1.998 1.998 0 01-.589 2.741 1.936 1.936 0 01-1.057.316 1.953 1.953 0 01-1.651-.912l-.206-.324-.13.605a1.966 1.966 0 01-1.913 1.562 1.95 1.95 0 01-.419-.046 1.984 1.984 0 01-1.498-2.36l.13-.605-.32.209a1.946 1.946 0 01-2.709-.597 1.998 1.998 0 01.59-2.74l3.617-2.353.02-.09a8.073 8.073 0 00-.713-5.394 44.773 44.773 0 01-4.797-.4c-4.684-.634-7.341 1.433-8.044 2.081-5.518 5.093-6.586 14.092-6.596 14.183a1.977 1.977 0 01-1.96 1.757 1.97 1.97 0 01-1.63-.867c-.087-.13-2.164-3.234-3.075-7.615-1.237-5.95.238-11.407 4.266-15.783a20.702 20.702 0 018.738-5.615l-.407.106a7.99 7.99 0 00-3.375-.747h-.09l-3.032 2.983a1.965 1.965 0 01-1.382.563c-.5 0-1-.188-1.382-.563a1.9 1.9 0 010-2.719l.268-.264h-.61c-1.08 0-1.954-.86-1.954-1.922 0-1.062.875-1.922 1.954-1.922h.61l-.268-.264a1.9 1.9 0 010-2.72c.763-.75 2-.75 2.764 0l3.032 2.983h.09a11.87 11.87 0 018.661 3.726l-.217-.223a22.914 22.914 0 015.352.095c4.946.67 8.99-.018 12.113-2.052a12.215 12.215 0 01-2.71-7.7v-.092L30.6 16.287a2.034 2.034 0 010-2.812 1.885 1.885 0 012.725 0l.265.273v-.621c0-1.099.862-1.989 1.926-1.989s1.927.89 1.927 1.989v.62l.265-.272a1.885 1.885 0 012.725 0c1.146 1.183.32 2.483 0 2.812l-2.99 3.086v.091c0 1.878.635 3.673 1.771 5.098 1.412-1.686 2.522-3.808 3.325-6.36-.587-1.625-1.5-5.473.828-9.837 1.22-2.285 3.564-4.687 6.117-6.269z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="49" height="59"><path fill="#3B4262" d="M47.125 11.832a2.922 2.922 0 00-1.232-.198c-.57.04-1.029.271-1.302.65-1.604 2.248-2.919 6.493-3.979 9.905-.486 1.577-1.14 3.688-1.612 4.69-.493-2.807.064-13.09.28-17.05l.003-.064c.15-2.751.17-3.234.138-3.446-.238-1.509-.843-2.5-1.799-2.943-.966-.45-2.22-.25-3.572.563-.677.41-.865 1.816-1.446 8.19l-.002.028c-.32 3.502-1.058 11.566-1.965 12.91-1.023-1.88-2.431-12.555-3.039-17.176-.425-3.236-.673-5.094-.84-5.655-.35-1.176-1.83-2.176-3.295-2.232-1.22-.06-2.22.56-2.698 1.638-.894.995-.578 4.292.41 12.102.47 3.718 1.44 11.395.83 12.257-1.219-.133-3.31-4.942-6.215-14.299-.816-2.62-1.068-3.408-1.318-3.753-.494-1.202-2.172-2.129-3.676-2.024a3.183 3.183 0 00-.377.049c-.787.156-2.584.881-2.2 4.226 1.06 4.637 2.213 8.041 3.331 11.346l.023.066c.669 1.98 1.302 3.85 1.89 5.925 1.385 4.9.846 7.94.84 7.975-.046.312-.143.503-.288.57a.556.556 0 01-.195.045c-.44.03-1.098-.26-1.437-.45-.776-1.482-4.636-8.544-8.134-9.524l-.126-.037-.127.012c-1.283.121-2.226.606-2.803 1.441-.914 1.32-.535 3.002-.444 3.34l.052.12c.028.051 2.834 5.165 3.268 7.544.374 2.04 2.311 4.25 3.869 6.026l.064.073c.508.58.946 1.083 1.292 1.548 4.519 4.713 11.665 8.677 11.723 8.71.892.657 1.387 1.293 1.44 1.84a.798.798 0 01-.16.58l-.155.162.988.96 18.853-1.324.804-3.684c2.486-10.402 1.967-19.272 1.958-19.33.01-.327.706-3.483 1.266-6.033l.017-.065c1.117-5.08 2.505-11.4 2.772-13.803.116-1.028-.542-1.972-1.675-2.401z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><path fill="#3B4262" d="M45.06 12.22c-.642-8.096-9.734-7.269-9.734-7.269-3.837-6.765-9.832-1.865-9.832-1.865-4.606-6.63-10.38-.486-10.38-.486-9.957-1.074-9.571 7.066-9.571 7.066-.234 2.588 1.403 10.593 1.403 10.593-1.477-4.614-4.68-.784-4.68-.784-3.94 6.078-.975 9.405-.975 9.405 5.33 6.246 16.688 13.743 16.688 13.743 4.113 2.356 2.373 4.457 2.373 4.457l24.876-4.11.571-4.718c3.782-11.436-.739-26.032-.739-26.032z"/></svg>
|
||||
|
After Width: | Height: | Size: 486 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="51" height="58"><path fill="#3B4262" d="M13.971 25.702l6.012-8.415c-2.499-.415-7.088-.507-10.846 3.235C3.212 26.421.812 39.163.312 42.248L15.37 57.24c2.711-.232 14.713-1.827 26.279-13.34.122-.249 2.94-2.321.636-4.614-1.1-1.095-2.919-1.074-4.042.044-.572.57-1.461.577-2.021.02-.56-.557-.552-1.443.02-2.012l4.087-4.069c2.076-2.067.119-5.555-2.78-4.717l-3.345 2.851c-.611.53-1.52.439-2.022-.14-.519-.597-.408-1.503.183-2.013 11.687-10.208 9.98-8.979 17.5-15.995 2.809-2.329-.725-6.447-3.493-4.09L28.182 25.45c-.529.448-1.34.457-1.86-.02-.601-.517-.615-1.262-.222-1.85L38.787 3.944c1.854-2.5-1.795-5.277-3.749-2.757L16.28 27.307c-.452.65-1.364.8-1.985.345a1.377 1.377 0 01-.323-1.95z"/></svg>
|
||||
|
After Width: | Height: | Size: 735 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="59"><path fill="#3B4262" d="M44.042 32.422l-.863-.86c-2.062-2.054-5.433-2.5-7.95-1.06l-5.376 3.059 1.12-24.502c0-2.054-1.678-3.726-3.743-3.726-.446 0-.875.079-1.273.222l.134-1.315c0-2.077-1.705-3.767-3.798-3.767-1.936 0-3.559 1.445-3.764 3.299l-3.45 20.75c-.045.282-.536.253-.588.075L10.416 7.962a3.658 3.658 0 00-3.502-2.629c-1.118 0-2.157.501-2.853 1.375a3.592 3.592 0 00-.69 3.08l.792 3.35a3.34 3.34 0 00-1.335.168 3.447 3.447 0 00-2.326 3.818L2.9 30.85c0 5.415.953 9.423 1.754 11.83a13.61 13.61 0 01.687 4.291c0 1.284-.179 2.562-.534 3.796l-1.86 6.482c-.104.366-.03.76.198 1.065.232.304.592.483.975.483h21.97a1.218 1.218 0 001.16-1.6c-.013-.031-1.033-3.169-.067-7.437 1.225-.99 5.514-4.462 7.054-5.862 2.546-2.315 9.521-9.468 9.817-9.772a1.21 1.21 0 00-.012-1.705z"/></svg>
|
||||
|
After Width: | Height: | Size: 836 B |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 12 KiB |
1121
14-rock-paper-scissors/src/main/resources/public/output.css
Normal file
234
14-rock-paper-scissors/src/main/resources/templates/index.html
Normal file
@@ -0,0 +1,234 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<!-- displays site properly based on user's device -->
|
||||
|
||||
<script src="public/deps/htmx.min.js"></script>
|
||||
<link
|
||||
href="../public/output.css"
|
||||
th:href="'public/output.css'"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="../public/images/favicon-32x32.png"
|
||||
th:href="'public/images/favicon-32x32.png'"
|
||||
/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Frontend Mentor | Rock, Paper, Scissors</title>
|
||||
|
||||
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
|
||||
<style>
|
||||
.attribution {
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
}
|
||||
.attribution a {
|
||||
color: hsl(228, 45%, 44%);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main
|
||||
class="flex flex-col justify-between items-center pt-8 w-screen h-screen bg-gradient-to-b from-radial-gradient-top to-radial-gradient-bottom"
|
||||
>
|
||||
<section
|
||||
id="heading"
|
||||
class="flex flex-row items-center w-10/12 rounded-md md:w-1/2 md:h-36 md:rounded-xl border-[3px] border-header-outline h-[100px]"
|
||||
>
|
||||
<h1
|
||||
class="pl-4 text-xl font-bold leading-none text-white uppercase md:text-5xl grow md:leading-[2.2rem]"
|
||||
>
|
||||
<span class="block">rock</span> <span class="block">paper</span>
|
||||
<span class="block">scissors</span>
|
||||
</h1>
|
||||
<h2
|
||||
class="flex flex-col justify-around items-center py-2 mr-3 bg-white rounded-md md:mr-5 md:w-40 md:h-4/5 md:rounded-lg w-[80px] h-[70px] text-score-text rouned-md"
|
||||
>
|
||||
<span class="text-xs uppercase md:text-xl md:leading-none">Score</span>
|
||||
<span id="the-score-number" class="text-4xl font-extrabold md:text-6xl">12</span>
|
||||
<script type="text/javascript">
|
||||
document.body.addEventListener("updateScore", function (evt) {
|
||||
let scoreElement = document.querySelector("#the-score-number");
|
||||
let newScore =
|
||||
parseInt(scoreElement.textContent) + evt.detail.value;
|
||||
console.log(
|
||||
`the score will update by ${evt.detail.value} to ${newScore}`
|
||||
);
|
||||
localStorage.setItem("score", newScore);
|
||||
scoreElement.textContent = newScore;
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
let scoreElement = document.querySelector("#the-score-number");
|
||||
let storedScore = localStorage.getItem("score");
|
||||
if (storedScore !== null) {
|
||||
scoreElement.textContent = storedScore;
|
||||
} else {
|
||||
scoreElement.textContent = 0;
|
||||
localStorage.setItem("score", 0);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</h2>
|
||||
</section>
|
||||
|
||||
<section
|
||||
id="controls"
|
||||
class="bg-center bg-no-repeat bg-60% bg-triangle-pattern w-[375px] h-[375px] relative md:scale-150"
|
||||
>
|
||||
<!-- This control will be repeated 3 times, with different htmx requests -->
|
||||
<div
|
||||
th:each="choiceBadgeData : ${choiceBadges}"
|
||||
id="paper-control"
|
||||
th:id="${choiceBadgeData.c.name} + '-control'"
|
||||
hx-get="/select/paper"
|
||||
th:hx-get="'/select/' + ${choiceBadgeData.c.name}"
|
||||
hx-target="#controls"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
<!-- This badge is fragment to be repeated in other pages as well -->
|
||||
<div
|
||||
th:fragment="choiceBadge (choiceBadgeData)"
|
||||
th:id="${choiceBadgeData.c.name}"
|
||||
id="paper"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
--diameter: 8rem;
|
||||
--bg-dark: hsl(230, 89%, 62%);
|
||||
--bg-bright: hsl(230, 89%, 65%);
|
||||
--top-offset: 6rem;
|
||||
--left-offset: 6rem;
|
||||
--translation: 50%;
|
||||
position: absolute;
|
||||
"
|
||||
th:style="| --diameter: ${choiceBadgeData.s.diameter};
|
||||
--bg-dark: ${choiceBadgeData.s.bgDark};
|
||||
--bg-bright: ${choiceBadgeData.s.bgBright};
|
||||
${choiceBadgeData.p.toStyle}; |"
|
||||
>
|
||||
<div
|
||||
class="absolute top-1/2 left-1/2 w-3/4 h-3/4 bg-gradient-to-b from-gray-300 to-gray-100 rounded-full -translate-x-1/2 -translate-y-1/2"
|
||||
></div>
|
||||
<img
|
||||
src="../public/images/icon-paper.svg"
|
||||
th:src="${choiceBadgeData.c.iconPath}"
|
||||
class="absolute top-1/2 left-1/2 w-1/3 -translate-x-1/2 -translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- This controls is only for static preview -->
|
||||
<div
|
||||
th:remove="all"
|
||||
id="scissors"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
--diameter: 8rem;
|
||||
--bg-dark: hsl(39, 89%, 49%);
|
||||
--bg-bright: hsl(40, 84%, 53%);
|
||||
--top-offset: 6rem;
|
||||
--left-offset: 17rem;
|
||||
--translation: 50%;
|
||||
position: absolute;
|
||||
"
|
||||
>
|
||||
<div
|
||||
class="absolute top-1/2 left-1/2 w-3/4 h-3/4 bg-gradient-to-b from-gray-300 to-gray-100 rounded-full -translate-x-1/2 -translate-y-1/2"
|
||||
></div>
|
||||
<img
|
||||
src="../public/images/icon-scissors.svg"
|
||||
class="absolute top-1/2 left-1/2 w-1/3 -translate-x-1/2 -translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- This controls is only for static preview -->
|
||||
<div
|
||||
th:remove="all"
|
||||
id="rock"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
--diameter: 8rem;
|
||||
--bg-dark: hsl(349, 71%, 52%);
|
||||
--bg-bright: hsl(349, 70%, 56%);
|
||||
--top-offset: 15rem;
|
||||
--left-offset: 11.5rem;
|
||||
--translation: 50%;
|
||||
position: absolute;
|
||||
"
|
||||
>
|
||||
<div
|
||||
class="absolute top-1/2 left-1/2 w-3/4 h-3/4 bg-gradient-to-b from-gray-300 to-gray-100 rounded-full -translate-x-1/2 -translate-y-1/2"
|
||||
></div>
|
||||
<img
|
||||
src="../public/images/icon-rock.svg"
|
||||
class="absolute top-1/2 left-1/2 w-1/3 -translate-x-1/2 -translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- This is rules overlay modal window -->
|
||||
<dialog
|
||||
id="rules-dialog"
|
||||
class="w-screen h-screen md:rounded-lg md:w-[400px] md:h-[400px]"
|
||||
>
|
||||
<div class="flex flex-col justify-between w-full h-full">
|
||||
<h1
|
||||
class="grid place-content-center h-1/4 text-3xl font-bold tracking-wide uppercase md:h-12"
|
||||
>
|
||||
Rules
|
||||
</h1>
|
||||
<div class="grid place-content-center grow">
|
||||
<img
|
||||
src="../public/images/image-rules.svg"
|
||||
alt="Rules of the game: rock beats scissors, scissors beat paper, paper beats rock."
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
id="close-dialog-button"
|
||||
class="grid place-content-center h-32 md:absolute md:top-5 md:w-12 md:h-12 md:end-5"
|
||||
>
|
||||
<img
|
||||
src="../public/images/icon-close.svg"
|
||||
alt="Close rules display"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<div class="py-12">
|
||||
<button
|
||||
id="rules-button"
|
||||
class="w-32 h-10 text-base text-2xl tracking-widest text-white uppercase rounded-lg border border-white"
|
||||
>
|
||||
Rules
|
||||
</button>
|
||||
<script type="text/javascript">
|
||||
const dialog = document.getElementById("rules-dialog");
|
||||
const openButton = document.getElementById("rules-button");
|
||||
const closeButton = document.getElementById("close-dialog-button");
|
||||
openButton.addEventListener("click", function () {
|
||||
dialog.showModal();
|
||||
});
|
||||
closeButton.addEventListener("click", function () {
|
||||
dialog.close();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="fixed inset-x-0 bottom-0 attribution">
|
||||
Challenge by
|
||||
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
|
||||
>Frontend Mentor</a
|
||||
>. Source code at <a href="https://github.com/efim/Learning-HTMX">Your Name Here</a>.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,202 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<!-- displays site properly based on user's device -->
|
||||
|
||||
<link
|
||||
href="../public/output.css"
|
||||
th:href="'public/output.css'"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="../public/images/favicon-32x32.png"
|
||||
th:href="'public/images/favicon-32x32.png'"
|
||||
/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Frontend Mentor | Rock, Paper, Scissors</title>
|
||||
|
||||
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
|
||||
<style>
|
||||
.attribution {
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
}
|
||||
.attribution a {
|
||||
color: hsl(228, 45%, 44%);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main
|
||||
class="flex flex-col justify-between items-center pt-8 w-screen h-screen bg-gradient-to-b from-radial-gradient-top to-radial-gradient-bottom"
|
||||
>
|
||||
<section
|
||||
id="heading"
|
||||
class="flex flex-row items-center w-10/12 rounded-md border-[3px] border-header-outline h-[100px]"
|
||||
>
|
||||
<h1
|
||||
class="pl-4 text-xl font-bold leading-none text-white uppercase grow"
|
||||
>
|
||||
<span class="block">rock</span> <span class="block">paper</span>
|
||||
<span class="block">scissors</span>
|
||||
</h1>
|
||||
<h2
|
||||
class="flex flex-col justify-around items-center py-2 mr-3 bg-white rounded-md w-[80px] h-[70px] text-score-text rouned-md"
|
||||
>
|
||||
<span class="text-xs uppercase">Score</span
|
||||
><span class="text-4xl font-extrabold">12</span>
|
||||
</h2>
|
||||
</section>
|
||||
|
||||
<div id="showdown-table" th:fragment="showdown-table (showdownState)" class="md:scale-150">
|
||||
<section class="grid grid-cols-2 w-[375px] h-[300px]">
|
||||
<div
|
||||
id="players-choice"
|
||||
class="flex relative flex-col items-center pt-14"
|
||||
>
|
||||
<!-- This will be imported fragment -->
|
||||
<!-- <p th:text="${showdownState}">Hello</p> -->
|
||||
<div
|
||||
th:replace="index::choiceBadge (${showdownState.playersChoice})"
|
||||
></div>
|
||||
<!-- This is end of the game animated halo -->
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[150px] h-[150px]"
|
||||
th:classappend="${showdownState.isPlayerWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[200px] h-[200px]"
|
||||
th:classappend="${showdownState.isPlayerWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[260px] h-[260px]"
|
||||
th:classappend="${showdownState.isPlayerWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<div
|
||||
th:remove="all"
|
||||
id="rock"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
--diameter: 8rem;
|
||||
--bg-dark: hsl(349, 71%, 52%);
|
||||
--bg-bright: hsl(349, 70%, 56%);
|
||||
--top-offset: 0rem;
|
||||
--left-offset: 0rem;
|
||||
--translation: 0%;
|
||||
position: relative;
|
||||
"
|
||||
>
|
||||
<div
|
||||
class="absolute top-1/2 left-1/2 w-3/4 h-3/4 bg-gradient-to-b from-gray-300 to-gray-100 rounded-full -translate-x-1/2 -translate-y-1/2"
|
||||
></div>
|
||||
<img
|
||||
src="../public/images/icon-rock.svg"
|
||||
class="absolute top-1/2 left-1/2 w-1/3 -translate-x-1/2 -translate-y-1/2"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="absolute top-2/3 tracking-widest text-center text-white uppercase text-md"
|
||||
>
|
||||
You picked
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
id="house-choice"
|
||||
class="flex relative flex-col items-center pt-14"
|
||||
>
|
||||
<!-- Here will be imported fragment -->
|
||||
<!-- conditionally either house choice or request for house choice -->
|
||||
<!-- <div th:text="${showdownState.houseChoice.nonEmpty} ? 'nonEmpty' : 'empty'">...</div> -->
|
||||
<div
|
||||
th:replace="${showdownState.houseChoice.nonEmpty} ? ~{index::choiceBadge (${showdownState.houseChoice.get})} : ~{::house-choice-placeholder}"
|
||||
class="w-0 h-0"
|
||||
th:class=""
|
||||
>
|
||||
...
|
||||
</div>
|
||||
<!-- This is end of the game animated halo for house choice -->
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[150px] h-[150px]"
|
||||
th:classappend="${showdownState.isHouseWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[200px] h-[200px]"
|
||||
th:classappend="${showdownState.isHouseWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<div
|
||||
class="absolute mt-16 bg-white rounded-full opacity-5 -translate-y-1/2 w-[260px] h-[260px]"
|
||||
th:classappend="${showdownState.isHouseWin} ? 'quickly-appear' : 'invisible' "
|
||||
></div>
|
||||
<!-- This will be shown before the house made the choice, this will trigger timed request for house choice -->
|
||||
<div class="w-full h-full" th:remove="all">
|
||||
<div
|
||||
class="flex relative flex-col items-center h-full"
|
||||
th:fragment="house-choice-placeholder"
|
||||
th:hx-get="'/house-choice/' + ${showdownState.playersChoice.c.name}"
|
||||
hx-get="/house-choice/paper"
|
||||
hx-target="#showdown-table"
|
||||
hx-trigger="load delay:3s"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
<div
|
||||
class="rounded-full mt-[1rem] bg-radial-gradient-top h-[100px] w-[100px]"
|
||||
></div>
|
||||
<div
|
||||
class="absolute bg-white rounded-full opacity-20 w-[100px] h-[100px] mt-[1rem] pulsing-animation"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="absolute top-2/3 tracking-widest text-center text-white uppercase text-md"
|
||||
>
|
||||
The house picked
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- FRAGMENT : showdown result -->
|
||||
<section
|
||||
id="message"
|
||||
class="flex flex-col items-center text-white slowly-appear"
|
||||
th:classappend="${showdownState.gameResult.nonEmpty} ? '' : 'invisible'"
|
||||
>
|
||||
<p
|
||||
class="text-6xl font-bold text-center uppercase"
|
||||
th:text="${showdownState.gameResult.nonEmpty} ? 'You ' + ${showdownState.gameResult.get} : 'awesome'"
|
||||
>
|
||||
You lose
|
||||
</p>
|
||||
<a
|
||||
class="grid place-content-center mt-6 w-9/12 h-12 tracking-widest uppercase bg-white rounded-xl text-radial-gradient-bottom"
|
||||
href="/"
|
||||
>
|
||||
Play again
|
||||
</a>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="py-12">
|
||||
<button
|
||||
class="w-32 h-10 text-base text-2xl tracking-widest text-white uppercase rounded-lg border border-white"
|
||||
>
|
||||
Rules
|
||||
</button>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="fixed inset-x-0 bottom-0 attribution">
|
||||
Challenge by
|
||||
<a href="https://www.frontendmentor.io?ref=challenge" target="_blank"
|
||||
>Frontend Mentor</a
|
||||
>. Coded by <a href="#">Your Name Here</a>.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,132 @@
|
||||
package rockpaperscissors
|
||||
|
||||
import mainargs.{main, arg, ParserForMethods}
|
||||
import cask.main.Routes
|
||||
import org.thymeleaf.context.Context
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||
import org.thymeleaf.TemplateEngine
|
||||
import org.thymeleaf.Thymeleaf
|
||||
|
||||
import scala.jdk.CollectionConverters._
|
||||
import javax.swing.text.Position
|
||||
import rockpaperscissors.Models.Positioning
|
||||
import scala.util.Random
|
||||
import rockpaperscissors.Models.ShowdownState
|
||||
|
||||
object Main {
|
||||
@main def run(
|
||||
@arg(
|
||||
name = "port",
|
||||
short = 'p',
|
||||
doc = "Port on which server will start serving"
|
||||
)
|
||||
portArg: Int = 8080,
|
||||
@arg(name = "host", doc = "Host on which server will start serving.")
|
||||
hostArg: String = "localhost"
|
||||
): Unit = {
|
||||
println(s"Will start server on ${hostArg}:${portArg}")
|
||||
val server = new cask.Main {
|
||||
override def allRoutes: Seq[Routes] = Seq(AppRoutes())
|
||||
override def port: Int = portArg
|
||||
override def host: String = hostArg
|
||||
}
|
||||
server.main(Array.empty)
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
println(s"got args : $args")
|
||||
ParserForMethods(this).runOrExit(args)
|
||||
}
|
||||
|
||||
case class AppRoutes(pathPrefix: String = "")(implicit cc: castor.Context, log: cask.Logger)
|
||||
extends cask.Routes {
|
||||
val templateResolver = new ClassLoaderTemplateResolver()
|
||||
templateResolver.setPrefix("templates/");
|
||||
templateResolver.setSuffix(".html")
|
||||
templateResolver.setTemplateMode("HTML5")
|
||||
|
||||
val templateEngine = new TemplateEngine()
|
||||
templateEngine.setTemplateResolver(templateResolver)
|
||||
|
||||
@cask.get(s"$pathPrefix/")
|
||||
def index(req: cask.Request) = {
|
||||
val context = new Context()
|
||||
val choices = Models.choiceSelectionItems.asJava
|
||||
context.setVariable(
|
||||
"choiceBadges",
|
||||
choices
|
||||
)
|
||||
val result = templateEngine.process("index", context)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
@cask.get(s"$pathPrefix/select/:choice")
|
||||
def acceptPlayerVote(choice: String) = {
|
||||
val context = new Context()
|
||||
val badge = Models.choiceSelectionItems.find(_.c.name == choice)
|
||||
val response = badge match {
|
||||
case Some(playersChoiceBadge) =>
|
||||
val badge = playersChoiceBadge.copy()
|
||||
badge.p = Positioning.Relative
|
||||
val showdownState = ShowdownState(badge, None, false)
|
||||
context.setVariable("showdownState", showdownState)
|
||||
val result = templateEngine.process(
|
||||
"showdown",
|
||||
Set("showdown-table").asJava,
|
||||
context
|
||||
)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
case None =>
|
||||
cask.Response(s"Unknown choice: '${choice}'", 400)
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
@cask.get(s"$pathPrefix/house-choice/:playersChoice")
|
||||
def requestHouseChoice(playersChoice: String) = {
|
||||
val context = new Context()
|
||||
val badge = Models.choiceSelectionItems.find(_.c.name == playersChoice)
|
||||
val response = badge match {
|
||||
case Some(playersChoiceBadge) =>
|
||||
val badge = playersChoiceBadge.copy()
|
||||
badge.p =
|
||||
Positioning.Relative // this probably should be set in enclosing html tag
|
||||
val houseChoice =
|
||||
Models.choiceSelectionItems(Random.nextInt(3)).copy()
|
||||
houseChoice.p = Positioning.Relative
|
||||
println(s"getting house choice $houseChoice")
|
||||
val showdownState = ShowdownState(badge, Some(houseChoice), false)
|
||||
context.setVariable("showdownState", showdownState)
|
||||
val result = templateEngine.process(
|
||||
"showdown",
|
||||
Set("showdown-table").asJava,
|
||||
context
|
||||
)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq(
|
||||
"Content-Type" -> "text/html;charset=UTF-8",
|
||||
"HX-Trigger-After-Settle" -> s"""{"updateScore": ${showdownState.scoreChange}}"""
|
||||
)
|
||||
)
|
||||
case None =>
|
||||
cask.Response(s"Unknown choice: '${playersChoice}'", 400)
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
@cask.staticResources(s"$pathPrefix/public")
|
||||
def publicFiles(req: cask.Request) = {
|
||||
"public"
|
||||
}
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
}
|
||||