Compare commits
182 Commits
73bd2eba84
...
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 | ||
|
|
520dd6de9c | ||
|
|
1d7647bcdf | ||
|
|
6cd6c8cc3e | ||
|
|
0816b79c26 | ||
|
|
578c5d7d05 | ||
|
|
b8c5a0f19b | ||
|
|
3e395b5034 | ||
|
|
77dca6b951 | ||
|
|
509c45b357 | ||
|
|
d0f8cd771e | ||
|
|
e23afdab6f | ||
|
|
e618397eb8 | ||
|
|
f37fc0da11 |
11
.gitignore
vendored
@@ -5,11 +5,12 @@
|
|||||||
*/dist/
|
*/dist/
|
||||||
/11-single-price-grid-component/.bloop/
|
/11-single-price-grid-component/.bloop/
|
||||||
|
|
||||||
*/project/project/
|
**/.bloop
|
||||||
*/project/metals.sbt
|
**/project/project/
|
||||||
*/project/.bloop
|
**/project/metals.sbt
|
||||||
*/project/target/
|
**/project/.bloop
|
||||||
*/target/
|
**/project/target/
|
||||||
|
**/target/
|
||||||
|
|
||||||
*/result
|
*/result
|
||||||
result
|
result
|
||||||
|
|||||||
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
|
||||||
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 / version := "0.0.1"
|
||||||
ThisBuild / organization := "industries.sunshine"
|
ThisBuild / organization := "industries.sunshine"
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
lazy val singlePriceGridComponent = (project in file("."))
|
||||||
.settings(
|
.settings(
|
||||||
name := "priceGrid",
|
name := "priceGrid",
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{ pkgs, lib, sbt-derivation }:
|
{ pkgs, lib, sbt-derivation }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
pname = "price-grid-app";
|
||||||
package = sbt-derivation.lib.mkSbtDerivation {
|
package = sbt-derivation.lib.mkSbtDerivation {
|
||||||
inherit pkgs;
|
inherit pkgs pname;
|
||||||
# ...and the rest of the arguments
|
# ...and the rest of the arguments
|
||||||
pname = "price-grid-app";
|
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
|
||||||
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
nativeBuildInputs = [ pkgs.nodePackages.tailwindcss ];
|
||||||
@@ -43,6 +43,12 @@ let
|
|||||||
default = "localhost";
|
default = "localhost";
|
||||||
description = "Host to bind to.";
|
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 {
|
config = lib.mkIf cfg.enable {
|
||||||
users.groups.price-grid-app-group = { };
|
users.groups.price-grid-app-group = { };
|
||||||
@@ -51,22 +57,62 @@ let
|
|||||||
group = "price-grid-app-group";
|
group = "price-grid-app-group";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.price-grid-app = {
|
systemd.services.price-grid-app =
|
||||||
description = "My Java Service";
|
let serverHost = if cfg.useNginx then "localhost" else cfg.host;
|
||||||
wantedBy = [ "multi-user.target" ];
|
in {
|
||||||
after = [ "network.target" ];
|
description = "My Java Service";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
startLimitIntervalSec = 30;
|
||||||
|
startLimitBurst = 10;
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart =
|
||||||
|
"${pkgs.jdk}/bin/java -jar ${package}/bin/priceGridApp.jar -p ${
|
||||||
|
toString cfg.port
|
||||||
|
} --host ${serverHost}";
|
||||||
|
WorkingDirectory = "${package}/bin";
|
||||||
|
Restart = "on-failure";
|
||||||
|
User = "price-grid-app-user";
|
||||||
|
Group = "price-grid-app-group";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
services.nginx = lib.mkIf cfg.useNginx {
|
||||||
ExecStart =
|
virtualHosts.${cfg.host} = {
|
||||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/priceGridApp.jar -p ${toString cfg.port} --host ${cfg.host}";
|
locations."/".proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
||||||
Restart = "on-failure";
|
|
||||||
User = "price-grid-app-user";
|
|
||||||
Group = "price-grid-app-group";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
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 {
|
in {
|
||||||
package = package;
|
inherit package module image;
|
||||||
module = module;
|
|
||||||
}
|
}
|
||||||
|
|||||||
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",
|
target := "_blank",
|
||||||
"Frontend Mentor. "
|
"Frontend Mentor. "
|
||||||
),
|
),
|
||||||
"Coded by ",
|
"Source code at",
|
||||||
a(href := "#", "Your Name Here")
|
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
|
||||||
0
12-order-summary-component-thymeleaf/.project
Normal file
2
12-order-summary-component-thymeleaf/.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
version = "3.7.3"
|
||||||
|
runner.dialect = scala3
|
||||||
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
|
||||||
21
12-order-summary-component-thymeleaf/build.sbt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
ThisBuild / scalaVersion := "3.2.2"
|
||||||
|
fork := true
|
||||||
|
|
||||||
|
ThisBuild / version := "0.0.1"
|
||||||
|
ThisBuild / organization := "industries.sunshine"
|
||||||
|
|
||||||
|
val toolkitV = "0.1.7"
|
||||||
|
val toolkit = "org.scala-lang" %% "toolkit" % toolkitV
|
||||||
|
val toolkitTest = "org.scala-lang" %% "toolkit-test" % toolkitV
|
||||||
|
|
||||||
|
lazy val orderSummaryComponent = (project in file("."))
|
||||||
|
.settings(
|
||||||
|
name := "order-summary-component",
|
||||||
|
libraryDependencies += toolkit,
|
||||||
|
libraryDependencies += (toolkitTest % Test),
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"com.lihaoyi" %% "cask" % "0.9.1",
|
||||||
|
"com.lihaoyi" %% "mainargs" % "0.5.0",
|
||||||
|
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE"
|
||||||
|
)
|
||||||
|
)
|
||||||
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
BIN
12-order-summary-component-thymeleaf/design/active-states.jpg
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
12-order-summary-component-thymeleaf/design/desktop-design.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
12-order-summary-component-thymeleaf/design/desktop-preview.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
12-order-summary-component-thymeleaf/design/mobile-design.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1 @@
|
|||||||
|
sbt.version=1.9.0
|
||||||
3
12-order-summary-component-thymeleaf/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")
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><g fill="none" fill-rule="evenodd"><circle cx="24" cy="24" r="24" fill="#DFE6FB"/><path fill="#717FA6" fill-rule="nonzero" d="M32.574 15.198a.81.81 0 00-.646-.19L20.581 16.63a.81.81 0 00-.696.803V26.934a3.232 3.232 0 00-1.632-.44A3.257 3.257 0 0015 29.747 3.257 3.257 0 0018.253 33a3.257 3.257 0 003.253-3.253v-8.37l9.726-1.39v5.327a3.232 3.232 0 00-1.631-.441 3.257 3.257 0 00-3.254 3.253 3.257 3.257 0 003.254 3.253 3.257 3.257 0 003.253-3.253V15.81a.81.81 0 00-.28-.613z"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 549 B |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="437"><path fill="#D6E1FF" fill-rule="evenodd" d="M0 349.974c218.558 116.035 460.05 116.035 724.475 0s502.933-116.035 715.525 0V0H0v349.974z"/></svg>
|
||||||
|
After Width: | Height: | Size: 209 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="375" height="194"><path fill="#D6E1FF" fill-rule="evenodd" d="M-131.808 155.366c97.026 51.512 204.233 51.512 321.62 0 117.388-51.512 223.27-51.512 317.648 0V0h-639.268v155.366z"/></svg>
|
||||||
|
After Width: | Height: | Size: 232 B |
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 |
11
12-order-summary-component-thymeleaf/src/input.css
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* div, p, button { */
|
||||||
|
/* outline: 1px solid red; */
|
||||||
|
/* } */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<p>Hello, <span th:text="${name}">Name</span>!</p>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<!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
|
||||||
|
rel="icon"
|
||||||
|
type="image/png"
|
||||||
|
sizes="32x32"
|
||||||
|
href="./public/images/favicon-32x32.png"
|
||||||
|
/>
|
||||||
|
<link href="/dist/output.css" rel="stylesheet" />
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@500;700;900&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<title>Frontend Mentor | Order summary card</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>
|
||||||
|
<!-- too bad that images in TailwindCSS classes are referenced from output.css -->
|
||||||
|
<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>
|
||||||
|
<!-- main container -->
|
||||||
|
<div class="bg-pale-blue w-screen h-screen grid place-content-center">
|
||||||
|
<div th:replace="order-summary" />
|
||||||
|
</div>
|
||||||
|
<div class="attribution fixed bottom-0 inset-x-0">
|
||||||
|
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,37 @@
|
|||||||
|
<div
|
||||||
|
class="bg-white rounded-xl drop-shadow-2xl flex flex-col items-center w-[320px] h-[565px] md:w-[450px] md:h-[700px]"
|
||||||
|
>
|
||||||
|
<img src="public/images/illustration-hero.svg" class="rounded-t-xl w-full" />
|
||||||
|
<h1 class="text-xl font-extrabold my-7 md:text-3xl md:mt-10">
|
||||||
|
Order Summary
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p class="text-center text-desaturated-blue px-8 mb-5 md:px-12">
|
||||||
|
You can now listen to millions of songs, audiobooks, and podcasts on any
|
||||||
|
device anywhere you like!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="bg-very-pale-blue rounded-xl p-4 w-[calc(100%-3rem)] flex flex-row md:w-[calc(100%-6rem)] md:h-24 md:items-center md:p-6"
|
||||||
|
>
|
||||||
|
<img src="public/images/icon-music.svg" class="md:w-12 md:h-12" />
|
||||||
|
<div class="flex flex-col grow pl-3 md:pl-6 justify-center">
|
||||||
|
<p class="font-bold text-sm text-dark-blue md:text-base">Annual Plan</p>
|
||||||
|
<p class="text-desaturated-blue text-sm md:text-base">$59.99/year</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="underline text-xs text-bright-blue font-bold hover:no-underline hover:text-warm-blue"
|
||||||
|
>
|
||||||
|
Change
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="bg-bright-blue rounded-xl drop-shadow-2xl text-white font-bold py-3 my-6 w-[calc(100%-3rem)] md:w-[calc(100%-6rem)] md:my-8 hover:bg-warm-blue"
|
||||||
|
>
|
||||||
|
Proceed to Payment
|
||||||
|
</button>
|
||||||
|
<button class="text-desaturated-blue font-bold hover:text-dark-blue">
|
||||||
|
Cancel Order
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
//> using dep com.lihaoyi::cask:0.9.1
|
||||||
|
//> using dep com.lihaoyi::mainargs:0.5.0
|
||||||
|
//> using dep org.thymeleaf:thymeleaf:3.1.1.RELEASE
|
||||||
|
package example
|
||||||
|
|
||||||
|
import mainargs.{main, arg, ParserForMethods}
|
||||||
|
|
||||||
|
object Main {
|
||||||
|
@main def run(
|
||||||
|
@arg(
|
||||||
|
name = "post",
|
||||||
|
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 val allRoutes = Seq(AppRoutes())
|
||||||
|
override def port = portArg
|
||||||
|
override def host = 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 {
|
||||||
|
@cask.get("/")
|
||||||
|
def index() = {
|
||||||
|
import org.thymeleaf.context.Context
|
||||||
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||||
|
import org.thymeleaf.TemplateEngine
|
||||||
|
|
||||||
|
val templateResolver = new ClassLoaderTemplateResolver()
|
||||||
|
templateResolver.setPrefix("templates/");
|
||||||
|
templateResolver.setSuffix(".html")
|
||||||
|
templateResolver.setTemplateMode("HTML5")
|
||||||
|
|
||||||
|
val templateEngine = new TemplateEngine()
|
||||||
|
templateEngine.setTemplateResolver(templateResolver)
|
||||||
|
|
||||||
|
val a = 11
|
||||||
|
val context = new Context()
|
||||||
|
context.setVariable("name", s"Johny $a")
|
||||||
|
|
||||||
|
val result = templateEngine.process("index", context)
|
||||||
|
|
||||||
|
cask.Response(
|
||||||
|
result,
|
||||||
|
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.staticFiles("/dist") // this is what path gets matched
|
||||||
|
def distFiles() = "dist"
|
||||||
|
|
||||||
|
@cask.staticFiles("/public") // this is what path gets matched
|
||||||
|
def publicFiles() = "public"
|
||||||
|
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
class ExampleSuite extends munit.FunSuite:
|
||||||
|
|
||||||
|
test("addition") {
|
||||||
|
assert(1 + 1 == 2)
|
||||||
|
}
|
||||||
|
end ExampleSuite
|
||||||
32
12-order-summary-component-thymeleaf/style-guide.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Front-end Style Guide
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
The designs were created to the following widths:
|
||||||
|
|
||||||
|
- Mobile: 375px
|
||||||
|
- Desktop: 1440px
|
||||||
|
|
||||||
|
## Colors
|
||||||
|
|
||||||
|
### Primary
|
||||||
|
|
||||||
|
- Pale blue: hsl(225, 100%, 94%)
|
||||||
|
- Bright blue: hsl(245, 75%, 52%)
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
|
||||||
|
- Very pale blue: hsl(225, 100%, 98%)
|
||||||
|
- Desaturated blue: hsl(224, 23%, 55%)
|
||||||
|
- Dark blue: hsl(223, 47%, 23%)
|
||||||
|
|
||||||
|
## Typography
|
||||||
|
|
||||||
|
### Body Copy
|
||||||
|
|
||||||
|
- Font size (paragraph): 16px
|
||||||
|
|
||||||
|
### Font
|
||||||
|
|
||||||
|
- Family: [Red Hat Display](https://fonts.google.com/specimen/Red+Hat+Display)
|
||||||
|
- Weights: 500, 700, 900
|
||||||
27
12-order-summary-component-thymeleaf/tailwind.config.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ["./src/**/*.html"],
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
'pale-blue': 'hsl(225, 100%, 94%)',
|
||||||
|
'bright-blue': 'hsl(245, 75%, 52%)',
|
||||||
|
'very-pale-blue': 'hsl(225, 100%, 98%)',
|
||||||
|
'desaturated-blue': 'hsl(224, 23%, 55%)',
|
||||||
|
'dark-blue': 'hsl(223, 47%, 23%)',
|
||||||
|
'warm-blue': 'hsl(245, 83%, 68%)',
|
||||||
|
},
|
||||||
|
fontFamily: {
|
||||||
|
'sans': ['Red Hat Display', 'sans-serif'], // This will set Roboto as the default sans font
|
||||||
|
},
|
||||||
|
fontWeight: {
|
||||||
|
'normal': 500,
|
||||||
|
'bold': 700,
|
||||||
|
'extrabold': 900,
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||