Compare commits
115 Commits
084035fdcb
...
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 |
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
|
||||
@@ -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")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -189,7 +189,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>
|
||||
|
||||
@@ -228,7 +228,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>.
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
15-multi-step-form/.envrc
Normal file
@@ -0,0 +1 @@
|
||||
use flake
|
||||
16
15-multi-step-form/.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
15-multi-step-form/.project
Normal file
2
15-multi-step-form/.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "3.7.3"
|
||||
runner.dialect = scala3
|
||||
161
15-multi-step-form/README.org
Normal file
@@ -0,0 +1,161 @@
|
||||
* Frontend Mentor - Multi-step form solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---multi-step-form-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/multistep-form-YVAnSdqQBJ][Multi-step
|
||||
form 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:
|
||||
|
||||
- Complete each step of the sequence
|
||||
- Go back to a previous step to update their selections
|
||||
- See a summary of their selections on the final step and confirm their
|
||||
order
|
||||
- View the optimal layout for the interface depending on their device's
|
||||
screen size
|
||||
- See hover and focus states for all interactive elements on the page
|
||||
- Receive form validation messages if:
|
||||
- A field has been missed
|
||||
- The email address is not formatted correctly
|
||||
- A step is submitted, but no selection has been made
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[screenshot-desktop.png]]
|
||||
[[screenshot-mobile.png]]
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- [[https://www.frontendmentor.io/solutions/responsive-ssr-on-scala-interactivity-by-htmx-thymeleaf-templates-QIGkOSgRa4][Solution URL]]
|
||||
- [[https://efim-frontentmentor-multi-step-form.onrender.com][Live Site URL]]
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Semantic HTML5 markup
|
||||
well, i tried, but yeah
|
||||
- TailwinCSS
|
||||
- Mobile-first workflow
|
||||
- Server-side rendering, in Scala and Cask
|
||||
- htmx
|
||||
- Thymeleaf html templates
|
||||
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** hx-get and hx-post
|
||||
***** How i show correct form stage for each user on same URL
|
||||
on 'index.html' i use "initial loading" element
|
||||
#+begin_src html
|
||||
<section hx-get="/get-form" hx-trigger="load" hx-swap="outerHTML">
|
||||
<!-- here be immediate hx-get for the form. to subscitute the body -->
|
||||
<img class="w-14 text-green-500 fill-current" src="../public/images/tail-spin.svg" alt="loading..." />
|
||||
</section>
|
||||
#+end_src
|
||||
|
||||
This element will do single GET request to server to /get-form
|
||||
And user already has cookie with sessionId set from visiting the root enpoint, which returned 'index.html'
|
||||
|
||||
So request to /get-form already includes 'sessionId' cookie, and server can find \ initialize Answers data for this particular session,
|
||||
and 'currentStep' is part of the Answers
|
||||
|
||||
so reloading 'index.html' would trigger /get-form, which would render correct step.
|
||||
***** hx-post
|
||||
This will make POST request.
|
||||
If we do GET request from <input> only current input value is included, as query para.
|
||||
POST request from <input> or from <form> would include all filelds of the form.
|
||||
|
||||
So form submittion on "Next" and "Back" done via htmx POST requests, which parse and save passed attributes, but also server selects required next form step, renders it and returns for the 'hx-swap="outerHTML"'
|
||||
|
||||
hx-post on <input> allows for 'inline validation' (see useful resources)
|
||||
this allows for validating field value - in isolation or together with all other form field values.
|
||||
|
||||
**** Learned format in which browser sends POST attributes to the server
|
||||
Request payload as text:
|
||||
name=e&email=emails%40la.la&phone=%2B7%20(911)%2084-35644%20ext%20155
|
||||
|
||||
I chose this exercise also because i wanted more experience in working with forms.
|
||||
Single form would still be much nicer, even with htmx, but yeah.
|
||||
Current exercise felt like full-fledged application.
|
||||
|
||||
**** Styling of the checkbox and radiobuttons as big selectable areas
|
||||
This was first time I attempted something like this.
|
||||
Insight was to use <label> as overall container for the input and other data - descriptions and icons.
|
||||
|
||||
Because user clicking on label automatically translates into toggling of the input, no js needed.
|
||||
|
||||
Either hide (for radio button part on step 2) or keep (for checkboxes on step 3) the input, and put descriptions and icons as next element.
|
||||
|
||||
So that =peer-= styling can be used.
|
||||
|
||||
**** htmx inline validation of the phone number field
|
||||
Almost exactly as in example.
|
||||
Separate rest endpoint for the input field, which returns new rendered state.
|
||||
|
||||
hx-post is triggered on input field default trigger = "changed",
|
||||
and i guess only on focus leaving field. So this seems quite efficient.
|
||||
|
||||
This way validation can be done with very heavy libraries and access to DB and such. Over single field, or over all of them at once.
|
||||
Seems unusual, but cool
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
I want to learn more about Thymeleaf - how to use files for efficient fragment
|
||||
storage. Currently it feels that i have separate files, and it's nice, but some
|
||||
files have several fragments, and maybe need more documentation or markings.
|
||||
|
||||
Look for other templating solutions for java \ scala, maybe there are others
|
||||
with 'fragment' functionality
|
||||
|
||||
Would be nice to refactor the code, to have smaller and more directed files.
|
||||
|
||||
I am also getting better at doing flex \ grid layouts without specific
|
||||
paddings\margins on the lements, but feel that i'm still abusing that, and that
|
||||
future tinkering with layouts could be painful due to free space being
|
||||
constructed from manual paddings\margings
|
||||
|
||||
For htmx - would be nice to learn transition animations, and try to use it in a bigger exercise already.
|
||||
|
||||
*** Useful resources
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: useful-resources
|
||||
:END:
|
||||
- htmx inline validation
|
||||
https://htmx.org/examples/inline-validation/
|
||||
- htmx control of parameters sent with response
|
||||
https://htmx.org/docs/#parameters
|
||||
** Acknowledgments
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: acknowledgments
|
||||
:END:
|
||||
- svg animated spinner - from SamHerbert
|
||||
https://github.com/SamHerbert/SVG-Loaders/tree/master
|
||||
http://samherbert.net/svg-loaders/
|
||||
- tailwind elements - for their example of 'switch styled' checkbox
|
||||
which I used as inspiration for my styling
|
||||
https://tailwind-elements.com/docs/standard/forms/switch/
|
||||
- to render.com for allowing DockerImage deployments on a free tier
|
||||
they get shut down after 15 minutes of inactivity, and image has to be < 10Gb
|
||||
but this is great! no credit card needed
|
||||
17
15-multi-step-form/build.sbt
Normal file
@@ -0,0 +1,17 @@
|
||||
ThisBuild / scalaVersion := "3.2.2"
|
||||
|
||||
fork := true
|
||||
|
||||
ThisBuild / version := "0.0.1"
|
||||
ThisBuild / organization := "industries.sunshine"
|
||||
|
||||
lazy val multiStepForm = (project in file("."))
|
||||
.settings(
|
||||
name := "multi-step-form",
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %% "cask" % "0.9.1",
|
||||
"com.lihaoyi" %% "mainargs" % "0.5.0",
|
||||
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE",
|
||||
"com.googlecode.libphonenumber" % "libphonenumber" % "8.13.16"
|
||||
)
|
||||
)
|
||||
101
15-multi-step-form/default.nix
Normal file
@@ -0,0 +1,101 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
|
||||
let
|
||||
pname = "multi-step-form";
|
||||
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
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/scala-*/${pname}-assembly-*.jar $out/bin/${pname}.jar
|
||||
'';
|
||||
|
||||
depsSha256 = "sha256-zG4e7ERdi/WxzACymaYUQ0x8v4/peGARuqPAK8xvBmE=";
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
BIN
15-multi-step-form/design/active-states-step-1.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
15-multi-step-form/design/active-states-step-2.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
15-multi-step-form/design/active-states-step-3.jpg
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
15-multi-step-form/design/active-states-step-4.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
15-multi-step-form/design/desktop-design-step-1.jpg
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
15-multi-step-form/design/desktop-design-step-2-monthly.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
15-multi-step-form/design/desktop-design-step-2-yearly.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
15-multi-step-form/design/desktop-design-step-3-monthly.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
15-multi-step-form/design/desktop-design-step-3-yearly.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
15-multi-step-form/design/desktop-design-step-4-monthly.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
15-multi-step-form/design/desktop-design-step-4-yearly.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
15-multi-step-form/design/desktop-design-step-5.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
15-multi-step-form/design/desktop-preview.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
15-multi-step-form/design/mobile-design-step-1.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
15-multi-step-form/design/mobile-design-step-2-monthly.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
15-multi-step-form/design/mobile-design-step-2-yearly.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
15-multi-step-form/design/mobile-design-step-3-monthly.jpg
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
15-multi-step-form/design/mobile-design-step-3-yearly.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
15-multi-step-form/design/mobile-design-step-4-monthly.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
15-multi-step-form/design/mobile-design-step-4-yearly.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
15-multi-step-form/design/mobile-design-step-5.jpg
Normal file
|
After Width: | Height: | Size: 17 KiB |
1
15-multi-step-form/project/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
sbt.version=1.9.0
|
||||
3
15-multi-step-form/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
15-multi-step-form/screenshot-desktop.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
15-multi-step-form/screenshot-mobile.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
33
15-multi-step-form/src/input.css
Normal file
@@ -0,0 +1,33 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* path is relative to 'out.css' */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu';
|
||||
src: url('fonts/Ubuntu-Regular.ttf') format('truetype');
|
||||
font-weight: 400; /* Regular */
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Ubuntu';
|
||||
src: url('fonts/Ubuntu-Medium.ttf') format('truetype');
|
||||
font-weight: 600; /* Semibold */
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Ubuntu';
|
||||
src: url('fonts/Ubuntu-Bold.ttf') format('truetype');
|
||||
font-weight: 700; /* Bold */
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* div, p, button, ol, li, summary, article, h1 { */
|
||||
/* outline: 1px solid red; */
|
||||
/* } */
|
||||
1
15-multi-step-form/src/main/resources/public/htmx.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="274" height="568" fill="none" viewBox="0 0 274 568"><rect width="274" height="568" fill="#483EFF" rx="10"/><mask id="a" width="274" height="568" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><rect width="274" height="568" fill="#fff" rx="10"/></mask><g mask="url(#a)"><path fill="#6259FF" fill-rule="evenodd" d="M-34.692 543.101C3.247 632.538 168.767 685.017 211.96 612.52c43.194-72.497-66.099-85.653-104.735-160.569-38.635-74.916-68.657-121.674-124.482-104.607-55.824 17.068-55.375 106.32-17.436 195.757Z" clip-rule="evenodd"/><path fill="#F9818E" fill-rule="evenodd" d="M233.095 601.153c60.679-28.278 92.839-143.526 41.875-171.528-50.965-28.003-57.397 47.579-108.059 75.987-50.662 28.408-82.14 50.207-69.044 88.241 13.096 38.034 74.549 35.578 135.228 7.3Z" clip-rule="evenodd"/><path stroke="#fff" stroke-linecap="round" stroke-linejoin="bevel" stroke-width="5" d="m165.305 469.097 10.607-10.806M209.461 474.581l-12.506-10.503M187.56 488.991l-6.908 14.798"/><path fill="#FFAF7E" d="M.305 546.891c37.003 0 67-29.997 67-67s-29.997-67-67-67-67 29.997-67 67 29.997 67 67 67Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="375" height="172" viewBox="0 0 375 172"><defs><path id="a" d="M0 0h375v172H0z"/></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><use xlink:href="#a" fill="#483EFF"/><g mask="url(#b)"><g transform="translate(-151.029 -133.957)"><path fill="#6259FF" d="M79.546 349.634c54.547 128.646 292.524 204.132 354.626 99.852 62.102-104.28-95.035-123.204-150.583-230.963-55.547-107.759-98.711-175.015-178.973-150.466C24.354 92.607 25 220.987 79.546 349.634Z"/><ellipse cx="129.864" cy="258.711" fill="#FFAF7E" rx="96.329" ry="96.373"/><path fill="#F9818E" d="M464.88 433.146c87.31-40.69 133.585-206.525 60.253-246.82-73.333-40.293-82.587 68.465-155.485 109.343-72.898 40.877-118.192 72.245-99.348 126.973 18.845 54.728 107.27 51.194 194.58 10.504Z"/><g stroke="#FFF" stroke-linecap="round" stroke-linejoin="bevel" stroke-width="5"><path d="m367.336 243.125 15.263-15.549M430.872 251.016l-17.995-15.112M399.36 271.751l-9.94 21.293"/></g></g></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><g fill="none" fill-rule="evenodd"><circle cx="20" cy="20" r="20" fill="#F9818E"/><path fill="#FFF" fill-rule="nonzero" d="M25.057 15H14.944C12.212 15 10 17.03 10 19.885c0 2.857 2.212 4.936 4.944 4.936h10.113c2.733 0 4.943-2.08 4.943-4.936S27.79 15 25.057 15ZM17.5 20.388c0 .12-.108.237-.234.237h-1.552v1.569c0 .126-.138.217-.259.217H14.5c-.118 0-.213-.086-.213-.203v-1.583h-1.569c-.126 0-.217-.139-.217-.26v-.956c0-.117.086-.213.202-.213h1.584v-1.554c0-.125.082-.231.203-.231h.989c.12 0 .236.108.236.234v1.551h1.555c.125 0 .231.083.231.204v.988Zm5.347.393a.862.862 0 0 1-.869-.855c0-.472.39-.856.869-.856.481 0 .87.384.87.856 0 .471-.389.855-.87.855Zm1.9 1.866a.86.86 0 0 1-.87-.852.86.86 0 0 1 .87-.855c.48 0 .87.38.87.855a.86.86 0 0 1-.87.852Zm0-3.736a.862.862 0 0 1-.87-.854c0-.472.39-.856.87-.856s.87.384.87.856a.862.862 0 0 1-.87.854Zm1.899 1.87a.862.862 0 0 1-.868-.855c0-.472.389-.856.868-.856s.868.384.868.856a.862.862 0 0 1-.868.855Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><g fill="none" fill-rule="evenodd"><circle cx="20" cy="20" r="20" fill="#FFAF7E"/><path fill="#FFF" fill-rule="nonzero" d="M24.995 18.005h-3.998v5.998h-2v-5.998H15a1 1 0 0 0-1 1V29a1 1 0 0 0 1 1h9.995a1 1 0 0 0 1-1v-9.995a1 1 0 0 0-1-1Zm-5.997 8.996h-2v-1.999h2v2Zm2-11.175a2.999 2.999 0 1 0-2 0v2.18h2v-2.18Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 405 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="9" viewBox="0 0 12 9"><path fill="none" stroke="#FFF" stroke-width="2" d="m1 4 3.433 3.433L10.866 1"/></svg>
|
||||
|
After Width: | Height: | Size: 167 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><g fill="none" fill-rule="evenodd"><circle cx="20" cy="20" r="20" fill="#483EFF"/><path fill="#FFF" fill-rule="nonzero" d="M26.666 13H13.334A3.333 3.333 0 0 0 10 16.333v7.193a3.447 3.447 0 0 0 2.14 3.24c1.238.5 2.656.182 3.56-.8L18.52 23h2.96l2.82 2.966a3.2 3.2 0 0 0 3.56.8 3.447 3.447 0 0 0 2.14-3.24v-7.193A3.333 3.333 0 0 0 26.666 13Zm-9.333 6H16v1.333a.667.667 0 0 1-1.333 0V19h-1.333a.667.667 0 0 1 0-1.334h1.333v-1.333a.667.667 0 1 1 1.333 0v1.333h1.333a.667.667 0 1 1 0 1.334Zm7.333 2a2.667 2.667 0 1 1 0-5.333 2.667 2.667 0 0 1 0 5.333ZM26 18.333a1.333 1.333 0 1 1-2.667 0 1.333 1.333 0 0 1 2.667 0Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 704 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80"><g fill="none"><circle cx="40" cy="40" r="40" fill="#F9818E"/><path fill="#E96170" d="M48.464 79.167c.768-.15 1.53-.321 2.288-.515a40.04 40.04 0 0 0 3.794-1.266 40.043 40.043 0 0 0 3.657-1.63 40.046 40.046 0 0 0 12.463-9.898A40.063 40.063 0 0 0 78.3 51.89c.338-1.117.627-2.249.867-3.391L55.374 24.698a21.6 21.6 0 0 0-15.332-6.365 21.629 21.629 0 0 0-15.344 6.365c-8.486 8.489-8.486 22.205 0 30.694l23.766 23.775Z"/><path fill="#FFF" d="M40.003 18.333a21.58 21.58 0 0 1 15.31 6.351c8.471 8.471 8.471 22.158 0 30.63-8.47 8.47-22.156 8.47-30.627 0-8.47-8.472-8.47-22.159 0-30.63a21.594 21.594 0 0 1 15.317-6.35Zm9.865 15c-.316.028-.622.15-.872.344l-12.168 9.13-5.641-5.642c-1.224-1.275-3.63 1.132-2.356 2.356l6.663 6.663c.56.56 1.539.63 2.173.156l13.326-9.995c1.122-.816.43-2.993-.956-3.013a1.666 1.666 0 0 0-.17 0Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 908 B |
@@ -0,0 +1,32 @@
|
||||
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
|
||||
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
|
||||
<stop stop-color="hsl(228, 100%, 84%)" stop-opacity="0" offset="0%"/>
|
||||
<stop stop-color="hsl(228, 100%, 84%)" stop-opacity=".631" offset="63.146%"/>
|
||||
<stop stop-color="hsl(228, 100%, 84%)" offset="100%"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g transform="translate(1 1)">
|
||||
<path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2">
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="rotate"
|
||||
from="0 18 18"
|
||||
to="360 18 18"
|
||||
dur="0.9s"
|
||||
repeatCount="indefinite" />
|
||||
</path>
|
||||
<circle fill="#fff" cx="36" cy="18" r="1">
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="rotate"
|
||||
from="0 18 18"
|
||||
to="360 18 18"
|
||||
dur="0.9s"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1509
15-multi-step-form/src/main/resources/public/out.css
Normal file
30
15-multi-step-form/src/main/resources/templates/_index.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<title>TEst</title>
|
||||
<meta name="description" content="" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<!-- Place favicon.ico in the root directory -->
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<main class="bg-green-200">
|
||||
<h1 class="text-3xl">Hello!</h1>
|
||||
<secion>
|
||||
<p>into the template</p>
|
||||
</secion>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
58
15-multi-step-form/src/main/resources/templates/index.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!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"
|
||||
th:href="'public/images/favicon-32x32.png'"
|
||||
href="../public/images/favicon-32x32.png"
|
||||
/>
|
||||
<link
|
||||
th:href="'public/out.css'"
|
||||
href="../public/out.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<script th:src="'public/htmx.min.js'" src="../public/htmx.min.js"></script>
|
||||
<title>Frontend Mentor | Multi-step form</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="grid place-content-center w-screen h-screen bg-magnolia">
|
||||
<section hx-get="/get-form" hx-trigger="load" hx-swap="outerHTML">
|
||||
<!-- here be immediate hx-get for the form. to subscitute the body -->
|
||||
<img
|
||||
class="w-14 text-green-500 fill-current"
|
||||
th:src="'public/images/tail-spin.svg'"
|
||||
src="../public/images/tail-spin.svg"
|
||||
alt="loading..."
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="absolute top-0 end-0" id="new-session-control">
|
||||
<button hx-get="/force-new-session">Request new session</button>
|
||||
</section>
|
||||
<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>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
233
15-multi-step-form/src/main/resources/templates/step1.html
Normal file
@@ -0,0 +1,233 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<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="./assets/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<title>Frontend Mentor | Multi-step form</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 class="grid place-content-center h-screen bg-magnolia">
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<form
|
||||
class="flex flex-col items-center w-screen h-screen md:grid md:items-start md:p-5 md:bg-white md:rounded-2xl md:grid-cols-[auto_1fr] md:w-desktop-form md:h-desktop-form md:drop-shadow-2xl"
|
||||
id="form-step"
|
||||
th:fragment="formFragment(formData)"
|
||||
hx-post="/submit-step/1/2"
|
||||
hx-swap="outerHTML"
|
||||
action="/submit-step/1/2"
|
||||
method="post"
|
||||
>
|
||||
<summary
|
||||
class="w-full h-44 bg-no-repeat bg-cover md:row-span-2 md:tracking-widest bg-sidebar-mobile marker:text-white md:bg-sidebar-desktop md:h-[568px] md:w-[274px]"
|
||||
id="sidebar"
|
||||
th:fragment="stepsSummary(formData)"
|
||||
>
|
||||
<ol
|
||||
class="grid grid-cols-[repeat(4,_auto)] gap-x-5 content-center items-center place-content-center h-24 md:flex-col md:h-full md:grid-rows-[repeat(4,_auto)] md:grid-cols-1 md:content-start md:p-10 md:gap-y-7 text-white text-sm uppercase"
|
||||
>
|
||||
<li
|
||||
class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]"
|
||||
th:each="stepNum: ${formData.stepsAmount}"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 font-bold text-white rounded-full border border-white"
|
||||
th:classappend="${stepNum.index} == ${formData.userAnswers.currentStep} ? '!bg-light-blue !text-marine-blue'"
|
||||
th:text="${stepNum.index}"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray"
|
||||
>Step <span th:text="${stepNum.index}">1</span></span
|
||||
><span class="font-bold" th:text="${stepNum.name}"
|
||||
>Your info</span
|
||||
>
|
||||
</p>
|
||||
</li>
|
||||
<li
|
||||
class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]"
|
||||
th:remove="all"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 2</span
|
||||
><span class="font-bold">Select plan</span>
|
||||
</p>
|
||||
</li>
|
||||
<li
|
||||
class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]"
|
||||
th:remove="all"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 3</span
|
||||
><span class="font-bold">Add-ons</span>
|
||||
</p>
|
||||
</li>
|
||||
<li
|
||||
class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]"
|
||||
th:remove="all"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
4
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 4</span
|
||||
><span class="font-bold">summary</span>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</summary>
|
||||
<section
|
||||
id="multipage-form-container"
|
||||
class="flex flex-col py-8 px-6 -mt-20 w-11/12 bg-white rounded-xl md:px-24 md:mt-0 md:w-full drop-shadow-xl md:drop-shadow-none"
|
||||
>
|
||||
<!-- Step 1 start -->
|
||||
<h1 class="text-2xl font-bold md:text-4xl text-marine-blue">
|
||||
Personal info
|
||||
</h1>
|
||||
<p class="py-3 text-cool-gray">
|
||||
Please provide your name, email address, and phone number.
|
||||
</p>
|
||||
<div class="contents">
|
||||
<label
|
||||
for="name"
|
||||
class="pt-3 text-sm md:pt-5 md:pb-2 text-marine-blue"
|
||||
>Name</label
|
||||
>
|
||||
<input
|
||||
id="name"
|
||||
th:value="${formData.userAnswers.step1.name}"
|
||||
name="name"
|
||||
type="text"
|
||||
required
|
||||
placeholder="e.g. Stephen King"
|
||||
class="p-1 px-4 h-10 text-sm font-semibold rounded border md:p-6 md:px-4 md:text-base md:rounded-lg focus:outline-none placeholder:text-cool-gray invalid:border-strawberry-red focus:border-marine-blue"
|
||||
/>
|
||||
</div>
|
||||
<div class="contents">
|
||||
<label
|
||||
for="email"
|
||||
class="pt-3 text-sm md:pt-5 md:pb-2 text-marine-blue"
|
||||
>Email Address</label
|
||||
>
|
||||
<input
|
||||
id="email"
|
||||
th:value="${formData.userAnswers.step1.email}"
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
placeholder="e.g. stephenking@lorem.com"
|
||||
class="p-1 px-4 h-10 text-sm font-semibold rounded border md:p-6 md:px-4 md:text-base md:rounded-lg focus:outline-none placeholder:text-cool-gray invalid:border-strawberry-red focus:border-marine-blue"
|
||||
/>
|
||||
</div>
|
||||
<!-- Following is email input field
|
||||
it has outer div that sets separate 'value' variable
|
||||
and innder div which denotes fragment, parametrized by this only variable
|
||||
now i should be able to render only this input field as fragment -->
|
||||
<div
|
||||
th:with="value=${formData.userAnswers.step1.phone},error=''"
|
||||
class="contents relative"
|
||||
>
|
||||
<div
|
||||
class="contents"
|
||||
hx-target="this"
|
||||
hx-swap="outerHTML"
|
||||
th:fragment="email-input (value,error)"
|
||||
>
|
||||
<label
|
||||
for="phone"
|
||||
class="pt-3 text-sm md:pt-5 md:pb-2 text-marine-blue"
|
||||
>Phone Number</label
|
||||
>
|
||||
<input
|
||||
id="phone"
|
||||
th:value="${value}"
|
||||
name="phone"
|
||||
type="tel"
|
||||
required
|
||||
placeholder="e.g. +1 234 567 890"
|
||||
class="p-1 px-4 h-10 text-sm font-semibold rounded border md:p-6 md:px-4 md:text-base md:rounded-lg focus:outline-none placeholder:text-cool-gray invalid:border-strawberry-red focus:border-marine-blue"
|
||||
th:classappend="${!error.isEmpty} ? 'border-strawberry-red' : ''"
|
||||
hx-post="/step1/phonenumber"
|
||||
hx-indicator="#ind"
|
||||
/>
|
||||
<div
|
||||
th:if="${error} != null"
|
||||
th:text="${error}"
|
||||
class="text-sm text-strawberry-red">Please enter valid phone number</div>
|
||||
<img
|
||||
id="ind"
|
||||
src="../public/images/tail-spin.svg"
|
||||
th:src="'public/images/tail-spin.svg'"
|
||||
class="absolute w-14 h-14 htmx-indicator"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 1 end -->
|
||||
</section>
|
||||
<div class="md:hidden grow"></div>
|
||||
<section
|
||||
id="footer-controls"
|
||||
class="flex flex-row items-center py-4 w-full bg-white md:items-end md:h-full"
|
||||
>
|
||||
<div class="grow"></div>
|
||||
<input
|
||||
type="submit"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
value="Next Step"
|
||||
/>
|
||||
<a
|
||||
th:remove="all"
|
||||
href="step2.html"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
>Next Step</a
|
||||
>
|
||||
</section>
|
||||
</form>
|
||||
<div 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>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
260
15-multi-step-form/src/main/resources/templates/step2.html
Normal file
@@ -0,0 +1,260 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<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="./assets/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<title>Frontend Mentor | Multi-step form</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>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<main class="grid place-content-center h-screen">
|
||||
<form
|
||||
class="flex flex-col items-center w-screen h-screen md:grid md:items-start md:p-5 md:bg-white md:rounded-2xl md:grid-cols-[auto_1fr] md:w-desktop-form md:h-desktop-form md:drop-shadow-2xl"
|
||||
id="form-step"
|
||||
hx-post="/submit-step/2/3"
|
||||
hx-swap="outerHTML"
|
||||
action="/submit-step/2/3"
|
||||
method="post"
|
||||
th:fragment="formFragment(formData)"
|
||||
>
|
||||
<summary
|
||||
class="w-full h-44 bg-no-repeat md:row-span-2 bg-sidebar-mobile marker:text-white md:bg-sidebar-desktop md:h-[568px] md:w-[274px]"
|
||||
id="sidebar"
|
||||
th:replace="~{step1::stepsSummary (${formData})}"
|
||||
>
|
||||
<ol
|
||||
class="grid grid-cols-[repeat(4,_auto)] gap-x-5 content-center items-center place-content-center h-24 md:flex-col md:h-full md:grid-rows-[repeat(4,_auto)] md:grid-cols-1 md:content-start md:p-10 md:gap-y-7 text-white text-sm uppercase"
|
||||
>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 1</span
|
||||
><span class="font-bold">Your info</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 2</span
|
||||
><span class="font-bold">Select plan</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 3</span
|
||||
><span class="font-bold">Add-ons</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
4
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 4</span
|
||||
><span class="font-bold">summary</span>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</summary>
|
||||
<section
|
||||
id="multipage-form-container"
|
||||
class="flex flex-col py-8 px-6 -mt-20 w-11/12 bg-white rounded-xl md:px-24 md:mt-0 md:w-full drop-shadow-xl md:drop-shadow-none"
|
||||
>
|
||||
<!-- Step 2 start -->
|
||||
<h1 class="text-2xl font-bold md:text-4xl text-marine-blue">
|
||||
Select your plan
|
||||
</h1>
|
||||
<p class="py-3 mb-4 text-cool-gray">
|
||||
You have the option of monthly or yearly billing.
|
||||
</p>
|
||||
<div
|
||||
class="flex flex-col gap-y-3 my-3 w-full md:flex-row md:gap-x-4"
|
||||
id="plan-type-inputs"
|
||||
th:fragment="planTypesInputs(formData)"
|
||||
>
|
||||
<label
|
||||
for="ArcadePlanType"
|
||||
class="relative h-20 md:h-40 md:grow"
|
||||
th:each="planType: ${formData.availablePlans}"
|
||||
th:for="${planType}"
|
||||
>
|
||||
<input
|
||||
id="ArcadePlanType"
|
||||
th:id="${planType}"
|
||||
type="radio"
|
||||
name="plan-type"
|
||||
value="Arcade"
|
||||
th:value="${planType}"
|
||||
class="hidden peer"
|
||||
th:checked="${formData.userAnswers.step2.planType.toString()} == ${planType.toString()}"
|
||||
checked
|
||||
/>
|
||||
<div
|
||||
class="grid absolute inset-y-0 inset-x-0 place-content-center h-full rounded-lg border md:grid-cols-1 md:p-4 grid-cols-[auto_1fr] border-light-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia/50 md:grid-rows-[1fr_auto_auto] hover:bg-magnolia/[.1] hover:border-purplish-blue"
|
||||
>
|
||||
<img
|
||||
class="place-self-center px-4 md:row-span-1 md:place-self-start md:px-0"
|
||||
th:src="${planType.iconPath}" src="../public/images/icon-arcade.svg" alt="" />
|
||||
<div class="flex flex-col items-start">
|
||||
<h2 th:text="${planType}" class="font-semibold text-marine-blue">Arcade</h2>
|
||||
<p
|
||||
th:text="|$${formData.planCost(planType)}/${formData.periodCostLabel}|"
|
||||
class="text-sm text-cool-gray"
|
||||
>
|
||||
$9/mo
|
||||
</p>
|
||||
<p th:if="${formData.userAnswers.step2.isYearly}" class="text-xs text-marine-blue">
|
||||
2 months free
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label
|
||||
for="AdvancedPlanType"
|
||||
class="relative h-20 md:w-32"
|
||||
th:remove="all"
|
||||
>
|
||||
<input
|
||||
id="AdvancedPlanType"
|
||||
type="radio"
|
||||
name="plan-type"
|
||||
value="Advanced"
|
||||
class="hidden peer"
|
||||
th:checked="${formData.userAnswers.step2.planType.toString()} == 'Advanced'"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 inset-x-0 rounded-lg border border-cool-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia"
|
||||
>
|
||||
<img src="../public/images/icon-advanced.svg" alt="" />
|
||||
<h2>Advanced</h2>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label
|
||||
for="ProPlanType"
|
||||
class="relative h-20 md:w-32"
|
||||
th:remove="all"
|
||||
>
|
||||
<input
|
||||
id="ProPlanType"
|
||||
type="radio"
|
||||
name="plan-type"
|
||||
value="Pro"
|
||||
class="hidden peer"
|
||||
th:checked="${formData.userAnswers.step2.planType.toString()} == 'Pro'"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 inset-x-0 rounded-lg border border-cool-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia"
|
||||
>
|
||||
<img src="../public/images/icon-pro.svg" alt="" />
|
||||
<h2>Pro</h2>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="grid grid-flow-col-dense place-content-center mt-3 w-full rounded-lg md:mt-5 bg-light-gray/25"
|
||||
>
|
||||
<div
|
||||
class="inline-grid grid-cols-3 place-items-center h-12 text-sm font-bold"
|
||||
>
|
||||
<input
|
||||
class="mr-2 w-9 h-5 ml-2 rounded-full appearance-none mt-[0.3rem] bg-marine-blue after:absolute after:h-3 after:w-3 after:rounded-full after:border-none after:bg-neutral-100 after:transition-[background-color_0.2s,transform_0.2s] checked:after:ml-[1.2rem] after:ml-[0.25rem] after:mt-[0.25rem] hover:cursor-pointer col-start-2 row-start-1 peer md:mx-4"
|
||||
type="checkbox"
|
||||
name="isPackageYearly"
|
||||
role="switch"
|
||||
id="packageDuration"
|
||||
th:checked="${formData.userAnswers.step2.isYearly}"
|
||||
hx-post="/step2/planTypeInputs"
|
||||
hx-target="#plan-type-inputs"
|
||||
hx-swap="outerHTML"
|
||||
/>
|
||||
<p
|
||||
class="row-start-1 text-marine-blue peer-checked:text-cool-gray"
|
||||
>
|
||||
Monthly
|
||||
</p>
|
||||
<p
|
||||
class="row-start-1 text-cool-gray peer-checked:text-marine-blue"
|
||||
>
|
||||
Yearly
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2 end -->
|
||||
</section>
|
||||
<div class="md:hidden grow"></div>
|
||||
<section
|
||||
id="footer-controls"
|
||||
class="flex flex-row items-center py-4 w-full bg-white md:items-end md:h-full"
|
||||
>
|
||||
<a
|
||||
hx-post="/submit-step/2/1"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#form-step"
|
||||
href="step1.html"
|
||||
class="ml-6 text-sm font-semibold md:pb-3 md:ml-24 md:text-base text-cool-gray"
|
||||
>Go Back</a
|
||||
>
|
||||
<div class="grow"></div>
|
||||
<input
|
||||
type="submit"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
value="Next Step"
|
||||
/>
|
||||
<a
|
||||
th:remove="all"
|
||||
href="step3.html"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
>Next Step</a
|
||||
>
|
||||
</section>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
241
15-multi-step-form/src/main/resources/templates/step3.html
Normal file
@@ -0,0 +1,241 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<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="./assets/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<title>Frontend Mentor | Multi-step form</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>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<main class="grid place-content-center h-screen">
|
||||
<form
|
||||
class="flex flex-col items-center w-screen h-screen md:grid md:items-start md:p-5 md:bg-white md:rounded-2xl md:grid-cols-[auto_1fr] md:w-desktop-form md:h-desktop-form md:drop-shadow-2xl"
|
||||
id="form-step"
|
||||
hx-post="/submit-step/3/4"
|
||||
hx-swap="outerHTML"
|
||||
action="/submit-step/3/4"
|
||||
method="post"
|
||||
th:fragment="formFragment(formData)"
|
||||
>
|
||||
<summary
|
||||
class="w-full h-44 bg-no-repeat md:row-span-2 bg-sidebar-mobile marker:text-white md:bg-sidebar-desktop md:h-[568px] md:w-[274px]"
|
||||
id="sidebar"
|
||||
th:replace="~{step1::stepsSummary (${formData})}"
|
||||
>
|
||||
<ol
|
||||
class="grid grid-cols-[repeat(4,_auto)] gap-x-5 content-center items-center place-content-center h-24 md:flex-col md:h-full md:grid-rows-[repeat(4,_auto)] md:grid-cols-1 md:content-start md:p-10 md:gap-y-7 text-white text-sm uppercase"
|
||||
>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 1</span
|
||||
><span class="font-bold">Your info</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 2</span
|
||||
><span class="font-bold">Select plan</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 3</span
|
||||
><span class="font-bold">Add-ons</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
4
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 4</span
|
||||
><span class="font-bold">summary</span>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</summary>
|
||||
<section
|
||||
id="multipage-form-container"
|
||||
class="flex flex-col py-8 px-6 -mt-20 w-11/12 bg-white rounded-xl md:px-24 md:mt-0 md:w-full drop-shadow-xl md:drop-shadow-none"
|
||||
>
|
||||
<!-- Step 3 start -->
|
||||
<h1 class="text-2xl font-bold md:text-4xl text-marine-blue">
|
||||
Pick add-ons
|
||||
</h1>
|
||||
<p class="py-3 md:pb-10 text-cool-gray">
|
||||
Add-ons help enhance your gaming experience.
|
||||
</p>
|
||||
<div class="flex flex-col gap-y-3 w-full text-sm md:text-base">
|
||||
<label
|
||||
th:each="addon: ${formData.availableAddons}"
|
||||
for="multiplayer-games"
|
||||
th:for="${addon}"
|
||||
class="relative pl-5 h-16 md:w-full md:h-20"
|
||||
>
|
||||
<input
|
||||
id="multiplayer-games"
|
||||
th:id="${addon}"
|
||||
type="checkbox"
|
||||
value="OnlineService"
|
||||
th:value="${addon}"
|
||||
name="addon-services"
|
||||
class="absolute z-40 my-5 w-6 h-6 text-white rounded-lg border md:my-7 accent-purplish-blue border-light-gray peer"
|
||||
th:checked="${formData.userAnswers.step3.containsAddon(addon)}"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 inset-x-0 z-20 rounded-lg border border-cool-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia/75 hover:bg-magnolia/[.1] hover:border-purplish-blue"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center ml-16 h-full grid-cols-[1fr_70px]"
|
||||
>
|
||||
<h1 th:text="${addon.name}"
|
||||
class="font-bold text-marine-blue"
|
||||
>Online Service</h1>
|
||||
<p th:text="${addon.description}"
|
||||
class="text-xs text-cool-gray"
|
||||
>
|
||||
Access to multiplayer games
|
||||
</p>
|
||||
<p
|
||||
class="col-start-2 row-span-2 row-start-1 self-center text-purplish-blue"
|
||||
th:text="|+$${formData.addonCost(addon)}/${formData.periodCostLabel}|"
|
||||
>
|
||||
+$1/mo
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<label
|
||||
for="larger-storage"
|
||||
class="relative pl-6 h-20 md:w-full"
|
||||
th:remove="all"
|
||||
>
|
||||
<input
|
||||
id="larger-storage"
|
||||
type="checkbox"
|
||||
name="addon-services"
|
||||
value="LargerStorage"
|
||||
class="my-7 w-6 h-6 peer"
|
||||
th:checked="${formData.userAnswers.step3.containsAddon('LargerStorage')}"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 inset-x-0 rounded-lg border border-cool-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia/50"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center ml-20 h-full grid-cols-[1fr_100px]"
|
||||
>
|
||||
<h1>Larger storage</h1>
|
||||
<p>Extra 1TB of cloud save</p>
|
||||
<p class="col-start-2 row-span-2 row-start-1 self-center">
|
||||
+$2/mo
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<label
|
||||
for="custom-profile"
|
||||
class="relative pl-6 h-20 md:w-full"
|
||||
th:remove="all"
|
||||
>
|
||||
<input
|
||||
id="custom-profile"
|
||||
type="checkbox"
|
||||
name="addon-services"
|
||||
value="CustomProfile"
|
||||
class="my-7 w-6 h-6 peer"
|
||||
th:checked="${formData.userAnswers.step3.containsAddon('CustomProfile')}"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-y-0 inset-x-0 rounded-lg border border-cool-gray peer-checked:border-purplish-blue peer-checked:bg-magnolia/50"
|
||||
>
|
||||
<div
|
||||
class="grid place-content-center ml-20 h-full grid-cols-[1fr_100px]"
|
||||
>
|
||||
<h1>Customizable Profile</h1>
|
||||
<p>Custom theme on your profile</p>
|
||||
<p class="col-start-2 row-span-2 row-start-1 self-center">
|
||||
+$2/mo
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Step 3 end -->
|
||||
</section>
|
||||
<div class="md:hidden grow"></div>
|
||||
<section
|
||||
id="footer-controls"
|
||||
class="flex flex-row items-center py-4 w-full bg-white md:items-end md:h-full"
|
||||
>
|
||||
<a
|
||||
hx-post="/submit-step/3/2"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#form-step"
|
||||
href="step2.html"
|
||||
class="ml-6 text-sm font-semibold md:pb-3 md:ml-24 md:text-base text-cool-gray"
|
||||
>Go Back</a
|
||||
>
|
||||
<div class="grow"></div>
|
||||
<input
|
||||
type="submit"
|
||||
href="step4.html"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
value="Next Step"
|
||||
/>
|
||||
<a
|
||||
th:remove="all"
|
||||
href="step4.html"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-marine-blue"
|
||||
>Next Step</a
|
||||
>
|
||||
</section>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
204
15-multi-step-form/src/main/resources/templates/step4.html
Normal file
@@ -0,0 +1,204 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<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="./assets/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<title>Frontend Mentor | Multi-step form</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>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<main class="grid place-content-center h-screen">
|
||||
<form
|
||||
class="flex flex-col items-center w-screen h-screen md:grid md:items-start md:p-5 md:bg-white md:rounded-2xl md:grid-cols-[auto_1fr] md:w-desktop-form md:h-desktop-form md:drop-shadow-2xl"
|
||||
id="form-step"
|
||||
hx-post="/submit-step/4/5"
|
||||
action="/submit-step/4/5"
|
||||
hx-swap="outerHTML"
|
||||
method="post"
|
||||
th:fragment="formFragment(formData)"
|
||||
>
|
||||
<summary
|
||||
class="w-full h-44 bg-no-repeat md:row-span-2 bg-sidebar-mobile marker:text-white md:bg-sidebar-desktop md:h-[568px] md:w-[274px]"
|
||||
id="sidebar"
|
||||
th:replace="~{step1::stepsSummary (${formData})}"
|
||||
>
|
||||
<ol
|
||||
class="grid grid-cols-[repeat(4,_auto)] gap-x-5 content-center items-center place-content-center h-24 md:flex-col md:h-full md:grid-rows-[repeat(4,_auto)] md:grid-cols-1 md:content-start md:p-10 md:gap-y-7 text-white text-sm uppercase"
|
||||
>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 1</span
|
||||
><span class="font-bold">Your info</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 2</span
|
||||
><span class="font-bold">Select plan</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 3</span
|
||||
><span class="font-bold">Add-ons</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
4
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 4</span
|
||||
><span class="font-bold">summary</span>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</summary>
|
||||
<section
|
||||
id="multipage-form-container"
|
||||
class="flex flex-col py-8 px-6 -mt-20 w-11/12 bg-white rounded-xl md:px-24 md:mt-0 md:w-full drop-shadow-xl md:drop-shadow-none"
|
||||
>
|
||||
<!-- Step 3 start -->
|
||||
<h1 class="text-2xl font-bold md:text-4xl text-marine-blue">
|
||||
Finishing up
|
||||
</h1>
|
||||
<p class="pt-3 pb-5 md:pb-8 text-cool-gray">
|
||||
Double-check everything looks OK before confirming.
|
||||
</p>
|
||||
<div
|
||||
class="flex flex-col w-full text-sm rounded-lg divide-y md:text-base bg-magnolia/75"
|
||||
id="selection-overview"
|
||||
>
|
||||
<div id="selected-plan" class="grid p-3 md:p-6 grid-cols-[1fr_auto]">
|
||||
<h2 th:text="${formData.fullPlanName}"
|
||||
class="font-bold text-marine-blue"
|
||||
>Arcade (Monthly)</h2>
|
||||
<p
|
||||
th:text="|$${formData.selectedPlanCost}/${formData.periodCostLabel}|"
|
||||
class="row-span-2 self-end font-bold text-marine-blue"
|
||||
>
|
||||
$90/y
|
||||
</p>
|
||||
<a
|
||||
hx-post="/submit-step/4/2"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#form-step"
|
||||
href="step3.html"
|
||||
hx-params="not form-confirmed"
|
||||
class="underline text-cool-gray"
|
||||
>Change</a
|
||||
>
|
||||
</div>
|
||||
<div id="selected-addons" class="flex flex-col gap-y-4 p-3 md:p-6 mp-10"
|
||||
th:if="not ${formData.userAnswers.step3.addonsAsJava.isEmpty}"
|
||||
>
|
||||
<div
|
||||
th:each="addon: ${formData.userAnswers.step3.addonsAsJava}"
|
||||
class="flex flex-row"
|
||||
>
|
||||
<p th:text="${addon.name}" class="grow text-cool-gray">Online service</p>
|
||||
<p
|
||||
th:text="|+$${formData.addonCost(addon)}/${formData.periodCostLabel}|"
|
||||
>
|
||||
+$10/yr
|
||||
</p>
|
||||
</div>
|
||||
<div th:remove="all">Larger storage +$20/yr</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="flex flex-row p-3 mt-5 md:px-6">
|
||||
<p class="grow text-cool-gray">
|
||||
Total (per
|
||||
<span
|
||||
th:text="${formData.userAnswers.step2.isYearly} ? 'year' : 'month'"
|
||||
>year</span
|
||||
>)
|
||||
</p>
|
||||
<p
|
||||
th:text="|+$${formData.fullOrderPrice}/${formData.periodCostLabel}|"
|
||||
class="font-bold md:text-lg text-purplish-blue"
|
||||
>
|
||||
$120
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Step 3 end -->
|
||||
</section>
|
||||
<div class="md:hidden grow"></div>
|
||||
<section
|
||||
id="footer-controls"
|
||||
class="flex flex-row items-center py-4 w-full bg-white md:items-end md:h-full"
|
||||
>
|
||||
<a
|
||||
hx-post="/submit-step/4/3"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#form-step"
|
||||
href="step3.html"
|
||||
class="ml-6 text-sm font-semibold md:pb-3 md:ml-24 md:text-base text-cool-gray"
|
||||
hx-params="not form-confirmed"
|
||||
>Go Back</a
|
||||
>
|
||||
<div class="grow"></div>
|
||||
<input type="hidden" name="form-confirmed" value="true" />
|
||||
<input
|
||||
type="submit"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-purplish-blue"
|
||||
value="Confirm"
|
||||
/>
|
||||
<a
|
||||
th:remove="all"
|
||||
href="step5.html"
|
||||
class="grid place-content-center mr-3 w-24 h-10 text-sm font-semibold text-white rounded md:mr-24 md:w-32 md:h-12 md:text-base md:rounded-lg bg-purplish-blue"
|
||||
>Confirm</a
|
||||
>
|
||||
</section>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
119
15-multi-step-form/src/main/resources/templates/step5.html
Normal file
@@ -0,0 +1,119 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<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="./assets/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<title>Frontend Mentor | Multi-step form</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>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browserupgrade">
|
||||
You are using an <strong>outdated</strong> browser. Please
|
||||
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||
your experience.
|
||||
</p>
|
||||
<![endif]-->
|
||||
|
||||
<main class="grid place-content-center h-screen">
|
||||
<article
|
||||
class="flex flex-col items-center w-screen h-screen md:grid md:items-start md:p-5 md:bg-white md:rounded-2xl md:grid-cols-[auto_1fr] md:w-desktop-form md:h-desktop-form md:drop-shadow-2xl"
|
||||
id="form-step"
|
||||
th:fragment="formFragment(formData)"
|
||||
>
|
||||
<summary
|
||||
class="w-full h-44 bg-no-repeat md:row-span-2 bg-sidebar-mobile marker:text-white md:bg-sidebar-desktop md:h-[568px] md:w-[274px]"
|
||||
id="sidebar"
|
||||
th:replace="~{step1::stepsSummary (${formData})}"
|
||||
>
|
||||
<ol
|
||||
class="grid grid-cols-[repeat(4,_auto)] gap-x-5 content-center items-center place-content-center h-24 md:flex-col md:h-full md:grid-rows-[repeat(4,_auto)] md:grid-cols-1 md:content-start md:p-10 md:gap-y-7 text-white text-sm uppercase"
|
||||
>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 1</span
|
||||
><span class="font-bold">Your info</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 2</span
|
||||
><span class="font-bold">Select plan</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 3</span
|
||||
><span class="font-bold">Add-ons</span>
|
||||
</p>
|
||||
</li>
|
||||
<li class="items-center md:grid md:gap-x-4 md:grid-cols-[auto_1fr]">
|
||||
<div
|
||||
class="grid place-content-center w-8 h-8 text-white rounded-full border border-white"
|
||||
>
|
||||
4
|
||||
</div>
|
||||
<p class="hidden md:flex md:flex-col">
|
||||
<span class="text-light-gray">Step 4</span
|
||||
><span class="font-bold">summary</span>
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</summary>
|
||||
<section
|
||||
id="multipage-form-container"
|
||||
class="flex flex-col gap-y-4 items-center py-20 px-8 -mt-20 w-11/12 bg-white rounded-xl md:row-span-2 md:justify-center md:px-24 md:mt-0 md:w-full md:h-full drop-shadow-xl md:drop-shadow-none"
|
||||
>
|
||||
<!-- Step 5 start -->
|
||||
|
||||
<img src="../public/images/icon-thank-you.svg" alt="" class="mb-2 w-14 h-14 md:w-20 md:h-20" />
|
||||
<h2 class="text-2xl font-bold md:mt-2 md:text-4xl text-marine-blue">Thank you!</h2>
|
||||
<p class="text-center text-cool-gray">
|
||||
Thanks for confirming your subscription! We hope you have fun
|
||||
using our platform. If you ever need support, please feel free
|
||||
to email us at support@loremgaming.com.
|
||||
</p>
|
||||
|
||||
<!-- Step 5 end -->
|
||||
|
||||
</section>
|
||||
<div class="md:hidden grow"></div>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
22
15-multi-step-form/src/main/scala/multistepform/Main.scala
Normal file
@@ -0,0 +1,22 @@
|
||||
package multistepform
|
||||
|
||||
import mainargs.{main, arg, ParserForMethods}
|
||||
|
||||
object Main {
|
||||
@main def run(
|
||||
@arg(name="port", short='p', doc="Port on which server will start service")
|
||||
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[cask.main.Routes] = Seq(Routes())
|
||||
override def port: Int = portArg
|
||||
override def host: String = hostArg
|
||||
}
|
||||
server.main(Array.empty)
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
||||
}
|
||||
219
15-multi-step-form/src/main/scala/multistepform/Models.scala
Normal file
@@ -0,0 +1,219 @@
|
||||
package multistepform
|
||||
|
||||
import java.util.UUID
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
object Models {
|
||||
|
||||
/** Labels and form info which dynamically depend on user answers e.g plan
|
||||
* name 'Arcade (Yearly)' vs 'Pro (Monthly)'
|
||||
*/
|
||||
final case class FormData(
|
||||
userAnswers: Answers
|
||||
) {
|
||||
val stepsAmount = Steps.values.toList.asJava
|
||||
|
||||
// yeah, in real world it will not be this simple
|
||||
def yearlyCost(monthlyCost: Int): Int = 10 * monthlyCost
|
||||
|
||||
def periodCostLabel: String = {
|
||||
if (userAnswers.step2.isYearly) "yr" else "mo"
|
||||
}
|
||||
|
||||
def selectedPlanCost: Int = planCost(userAnswers.step2.planType)
|
||||
|
||||
def planCost(plan: PlanType): Int = {
|
||||
val monthlyPlanCost = plan.monthlyCost
|
||||
if (userAnswers.step2.isYearly) yearlyCost(monthlyPlanCost)
|
||||
else monthlyPlanCost
|
||||
}
|
||||
|
||||
def addonCost(addon: Addons): Int = {
|
||||
val monthCost = addon.monthlyCost
|
||||
if (userAnswers.step2.isYearly) yearlyCost(monthCost) else monthCost
|
||||
}
|
||||
|
||||
def fullPlanName: String = {
|
||||
val period = if (userAnswers.step2.isYearly) "Yearly" else "Monthly"
|
||||
s"${userAnswers.step2.planType} (${period})"
|
||||
}
|
||||
|
||||
def fullOrderPrice: Int = {
|
||||
selectedPlanCost + userAnswers.step3.addons.toList.map(addonCost).sum
|
||||
}
|
||||
|
||||
def availablePlans = PlanType.values.toList.asJava
|
||||
|
||||
def availableAddons = Addons.values.toList.asJava
|
||||
}
|
||||
|
||||
final case class Answers(
|
||||
sessionId: String = "",
|
||||
currentStep: Int = 1,
|
||||
step1: StepAnswers.Step1 = StepAnswers.Step1(),
|
||||
step2: StepAnswers.Step2 = StepAnswers.Step2(),
|
||||
step3: StepAnswers.Step3 = StepAnswers.Step3(),
|
||||
step4: StepAnswers.Step4 = StepAnswers.Step4()
|
||||
) {
|
||||
// this is not enforced by compiler, sad, maintain by hand in html template files
|
||||
def fragmentName: String = s"step${currentStep}"
|
||||
|
||||
def updateStep(stepNum: Int, rawData: String, nextStep: Int): Answers = {
|
||||
stepNum match {
|
||||
case 1 =>
|
||||
this.copy(
|
||||
step1 = this.step1.fromFormData(rawData),
|
||||
currentStep = nextStep
|
||||
)
|
||||
case 2 =>
|
||||
this.copy(
|
||||
step2 = this.step2.fromFormData(rawData),
|
||||
currentStep = nextStep
|
||||
)
|
||||
case 3 =>
|
||||
this.copy(
|
||||
step3 = this.step3.fromFormData(rawData),
|
||||
currentStep = nextStep
|
||||
)
|
||||
case 4 =>
|
||||
this.copy(
|
||||
step4 = this.step4.fromFormData(rawData),
|
||||
currentStep = nextStep
|
||||
)
|
||||
case _ => this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** TODO would be nice to connect answers to the steps enum in some helpful
|
||||
* way.
|
||||
*/
|
||||
enum Steps(val index: Int, val name: String):
|
||||
case Step1 extends Steps(1, "Your info")
|
||||
case Step2 extends Steps(2, "Select plan")
|
||||
case Step3 extends Steps(3, "Add-ons")
|
||||
case Step4 extends Steps(4, "Summary")
|
||||
|
||||
enum PlanType(val monthlyCost: Int, val iconPath: String):
|
||||
case Arcade extends PlanType(9, "public/images/icon-arcade.svg")
|
||||
case Advanced extends PlanType(12, "public/images/icon-advanced.svg")
|
||||
case Pro extends PlanType(15, "public/images/icon-pro.svg")
|
||||
def name(): String = {
|
||||
this.toString().replaceAll("([a-z])([A-Z])", "$1 $2")
|
||||
}
|
||||
|
||||
enum Addons(val monthlyCost: Int, val description: String):
|
||||
case OnlineService extends Addons(1, "Access to multiplayer games")
|
||||
case LargerStorage extends Addons(2, "Extra 1TB of cloud storage")
|
||||
case CustomProfile extends Addons(2, "Custom theme on your profile")
|
||||
|
||||
/** Change camel case into human readable. Adding single space before each
|
||||
* uppercase
|
||||
*/
|
||||
def name(): String = {
|
||||
this.toString().replaceAll("([a-z])([A-Z])", "$1 $2")
|
||||
}
|
||||
|
||||
sealed trait StepAnswers {
|
||||
def fromFormData(rawData: String): StepAnswers
|
||||
def submitted: Boolean
|
||||
}
|
||||
object StepAnswers {
|
||||
final case class Step1(
|
||||
name: String = "",
|
||||
email: String = "",
|
||||
phone: String = "",
|
||||
override val submitted: Boolean = false
|
||||
) extends StepAnswers {
|
||||
override def fromFormData(rawData: String): Step1 = {
|
||||
println(s"parsing step 1 data $rawData")
|
||||
val fieldValues = rawData
|
||||
.split("&")
|
||||
.filterNot(_.isEmpty())
|
||||
.map { field =>
|
||||
val Array(name, value) = field.split("=")
|
||||
name -> value
|
||||
}
|
||||
.toMap
|
||||
|
||||
val name = fieldValues.getOrElse("name", "")
|
||||
val email = fieldValues.getOrElse("email", "")
|
||||
val phone = fieldValues.getOrElse("phone", "")
|
||||
|
||||
Step1(name, email, phone, submitted = true)
|
||||
}
|
||||
}
|
||||
final case class Step2(
|
||||
planType: PlanType = PlanType.Arcade,
|
||||
isYearly: Boolean = false,
|
||||
override val submitted: Boolean = false
|
||||
) extends StepAnswers {
|
||||
override def fromFormData(rawData: String): Step2 = {
|
||||
println(s"parsing step 2 data $rawData")
|
||||
val fieldValues = rawData
|
||||
.split("&")
|
||||
.filterNot(_.isEmpty())
|
||||
.map { field =>
|
||||
val Array(name, value) = field.split("=")
|
||||
name -> value
|
||||
}
|
||||
.toMap
|
||||
|
||||
val planType =
|
||||
PlanType.valueOf(fieldValues.getOrElse("plan-type", "Arcade"))
|
||||
val isYearly = fieldValues.get("isPackageYearly").contains("on")
|
||||
|
||||
Step2(planType, isYearly, submitted = true)
|
||||
}
|
||||
}
|
||||
final case class Step3(
|
||||
addons: Set[Addons] = Set.empty,
|
||||
override val submitted: Boolean = false
|
||||
) extends StepAnswers {
|
||||
def addonsAsJava = addons.asJava
|
||||
|
||||
def containsAddon(addonName: String): Boolean = {
|
||||
addons.contains(Addons.valueOf(addonName))
|
||||
}
|
||||
|
||||
override def fromFormData(rawData: String): Step3 = {
|
||||
println(s"parsing step 3 data $rawData")
|
||||
// for multiple checkboxes data comes in form of
|
||||
// addon-services=OnlineService&addon-services=CustomProfile
|
||||
val fieldValues = rawData
|
||||
.split("&")
|
||||
.filterNot(_.isEmpty())
|
||||
.map { field =>
|
||||
val Array(name, value) = field.split("=")
|
||||
name -> value
|
||||
}
|
||||
|
||||
val addonsStrings = fieldValues
|
||||
.groupMap(_._1)(_._2)
|
||||
.getOrElse("addon-services", Array.empty[String])
|
||||
println(s"in step 3 got strings ${addonsStrings.mkString(", ")}")
|
||||
val addons = addonsStrings.map(Addons.valueOf(_)).toSet
|
||||
|
||||
Step3(addons, submitted = true)
|
||||
}
|
||||
}
|
||||
final case class Step4(
|
||||
override val submitted: Boolean = false
|
||||
) extends StepAnswers {
|
||||
override def fromFormData(rawData: String): Step4 = {
|
||||
val fieldValues = rawData
|
||||
.split("&")
|
||||
.filterNot(_.isEmpty())
|
||||
.map { field =>
|
||||
println(s"working with field $field")
|
||||
val Array(name, value) = field.split("=")
|
||||
name -> value
|
||||
}
|
||||
.toMap
|
||||
|
||||
val isConfirmed = fieldValues.contains("form-confirmed")
|
||||
Step4(isConfirmed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
222
15-multi-step-form/src/main/scala/multistepform/Routes.scala
Normal file
@@ -0,0 +1,222 @@
|
||||
package multistepform
|
||||
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||
import org.thymeleaf.TemplateEngine
|
||||
import org.thymeleaf.context.Context
|
||||
import cask.endpoints.ParamReader
|
||||
import java.util.UUID
|
||||
import scala.jdk.CollectionConverters._
|
||||
import multistepform.Models.Answers
|
||||
import scala.annotation.internal.requiresCapability
|
||||
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||
|
||||
import java.net.URLDecoder
|
||||
import scala.util.Try
|
||||
|
||||
case class Routes()(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)
|
||||
|
||||
val sessoinCookieName = "sessionId"
|
||||
|
||||
/** This route works with and without 'sessionId' cookie present set's this
|
||||
* cookie if not present, and returns initial 'index.html' where the form is
|
||||
* not yet initialized, and will be requested for the session
|
||||
*/
|
||||
@cask.get("/")
|
||||
def getIndex(ctx: cask.Request) = {
|
||||
val sessionCookie = ctx.cookies.get(sessoinCookieName)
|
||||
lazy val newSessionCookies = sessionCookie match {
|
||||
case None =>
|
||||
Seq(
|
||||
cask.Cookie(
|
||||
sessoinCookieName,
|
||||
UUID.randomUUID().toString(),
|
||||
path = "/"
|
||||
)
|
||||
)
|
||||
case Some(_) => Seq.empty // don't set new cookies
|
||||
}
|
||||
|
||||
println(s"getting cookie $sessionCookie will set new? ${newSessionCookies}")
|
||||
|
||||
val context = new Context()
|
||||
val indexPage = templateEngine.process("index", context)
|
||||
cask.Response(
|
||||
indexPage,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8"),
|
||||
cookies = newSessionCookies
|
||||
)
|
||||
}
|
||||
|
||||
@cask.get("/force-new-session")
|
||||
def forceNewSession() = {
|
||||
val newSessionCookie =
|
||||
cask.Cookie(sessoinCookieName, UUID.randomUUID().toString(), path = "/")
|
||||
println(s"setting new session ${newSessionCookie.value}")
|
||||
cask.Response(
|
||||
s"New session forced. Force new session",
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8"),
|
||||
cookies = Seq(newSessionCookie)
|
||||
)
|
||||
}
|
||||
|
||||
val formDataContextVarName = "formData"
|
||||
|
||||
/** This method only works when cookie 'sessionId' is present will get or init
|
||||
* Form State for the session, and return last unsubmitted form step fragment
|
||||
*/
|
||||
@cask.get("/get-form")
|
||||
def getForm(sessionId: cask.Cookie) = {
|
||||
val id = sessionId.value
|
||||
val state = Sessions.sessionReplies.getOrElse(id, Answers(id))
|
||||
println(s"starting form for $state")
|
||||
val context = new Context()
|
||||
val formData = Models.FormData(state)
|
||||
context.setVariable(formDataContextVarName, formData)
|
||||
val formFragment = templateEngine.process(
|
||||
state.fragmentName,
|
||||
Set("formFragment").asJava,
|
||||
context
|
||||
)
|
||||
cask.Response(
|
||||
formFragment,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
@cask.post("/submit-step/:stepNum/:nextStep")
|
||||
def submitStep(
|
||||
sessionId: cask.Cookie,
|
||||
stepNum: Int,
|
||||
nextStep: Int,
|
||||
request: cask.Request
|
||||
) = {
|
||||
val id = sessionId.value
|
||||
println(s"got $request for $id. it's data is ${request.text()}")
|
||||
|
||||
// note: this is nice at step #1 because not storing anything before first submission
|
||||
// but on followup steps, if data lost - new default object is created
|
||||
// and that is not nice
|
||||
val userAnswers = Sessions.sessionReplies.getOrElse(id, Answers(id))
|
||||
|
||||
val submittedData = URLDecoder.decode(request.text(), "UTF-8")
|
||||
|
||||
val updatedAnswers =
|
||||
userAnswers.updateStep(stepNum, submittedData, nextStep)
|
||||
|
||||
Sessions.sessionReplies.update(id, updatedAnswers)
|
||||
|
||||
val context = new Context()
|
||||
val formData = Models.FormData(updatedAnswers)
|
||||
context.setVariable(formDataContextVarName, formData)
|
||||
val nextFormFragment = templateEngine.process(
|
||||
updatedAnswers.fragmentName,
|
||||
Set("formFragment").asJava,
|
||||
context
|
||||
)
|
||||
println(s"the state now is $updatedAnswers")
|
||||
cask.Response(
|
||||
nextFormFragment,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
@cask.post("/step1/phonenumber")
|
||||
def validateStep1PhoneNumber(request: cask.Request) = {
|
||||
val submittedData = URLDecoder.decode(request.text(), "UTF-8")
|
||||
println(
|
||||
s"getting data ${request.data} or ${request.text()} or $submittedData"
|
||||
)
|
||||
val fieldValues = submittedData
|
||||
.split("&")
|
||||
.filterNot(_.isEmpty())
|
||||
.map { field =>
|
||||
println(s"looking at field $field")
|
||||
val (name, value) = field.split("=").toList match {
|
||||
case List(name, value) => name -> value
|
||||
case name :: tail => name -> tail.headOption.getOrElse("")
|
||||
case Nil => ???
|
||||
}
|
||||
name -> value
|
||||
}
|
||||
.toMap
|
||||
|
||||
val name = fieldValues.getOrElse("name", "")
|
||||
val email = fieldValues.getOrElse("email", "")
|
||||
val phone = fieldValues.getOrElse("phone", "")
|
||||
|
||||
println(s"after parsing name=$name | email=$email | phone=$phone")
|
||||
|
||||
val phoneUtils = PhoneNumberUtil.getInstance()
|
||||
val phoneNum = Try(
|
||||
phoneUtils.parse(phone, CountryCodeSource.UNSPECIFIED.name())
|
||||
).toOption
|
||||
val isPhoneValid = phoneNum.map(phoneUtils.isValidNumber(_)).getOrElse(false)
|
||||
|
||||
val error = if (isPhoneValid) "" else "Please input valid phone number"
|
||||
|
||||
val context = new Context()
|
||||
context.setVariable("value", phone)
|
||||
context.setVariable("error", error)
|
||||
val inputDiv =
|
||||
templateEngine.process("step1", Set("email-input").asJava, context)
|
||||
|
||||
cask.Response(
|
||||
inputDiv,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
/** This endpoint re-renders 'plan type inputs' so that togglng monthly\yearly
|
||||
* could redraw their html
|
||||
*/
|
||||
@cask.post("/step2/planTypeInputs")
|
||||
def getPlanTypeInputs(sessionId: cask.Cookie, request: cask.Request) = {
|
||||
val id = sessionId.value
|
||||
val submittedData = URLDecoder.decode(request.text(), "UTF-8")
|
||||
println(s"requesting plan type inputs for $id and $request")
|
||||
Sessions.sessionReplies.get(id) match {
|
||||
case None =>
|
||||
cask.Response(
|
||||
"Can't find answers for your session, please reload the page",
|
||||
404
|
||||
)
|
||||
case Some(answers) => {
|
||||
// here changing yearly/monthly part of state based on passed checkbox value
|
||||
// and selected plan
|
||||
// only for purposes of rendering the fragment
|
||||
// not persisting, unless next or previous buttons are pressed
|
||||
val withYearlyParamSetAndSelectedPlan =
|
||||
answers.step2.fromFormData(submittedData)
|
||||
val updatedState =
|
||||
answers.copy(step2 = withYearlyParamSetAndSelectedPlan)
|
||||
val formData = Models.FormData(updatedState)
|
||||
val context = new Context()
|
||||
context.setVariable(formDataContextVarName, formData)
|
||||
val planTypesInputsHtml = templateEngine.process(
|
||||
"step2",
|
||||
Set("planTypesInputs").asJava,
|
||||
context
|
||||
)
|
||||
println(s"updating plan type inputs for $answers")
|
||||
cask.Response(
|
||||
planTypesInputsHtml,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@cask.staticResources("/public")
|
||||
def publicFiles() = "public"
|
||||
|
||||
initialize()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package multistepform
|
||||
|
||||
import multistepform.Models.Answers
|
||||
|
||||
object Sessions {
|
||||
// the simplest form of storing data
|
||||
// i'll be relying on Render.com killing my app after 15 minutes of inactivity for GC
|
||||
// no need to manage concurrency really, because requests for same session are really far apart
|
||||
// and load will average to be 10req/day :shrug:
|
||||
val sessionReplies = scala.collection.mutable.Map.empty[String, Answers]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package example
|
||||
|
||||
class ExampleSuite extends munit.FunSuite:
|
||||
|
||||
test("addition") {
|
||||
assert(1 + 1 == 2)
|
||||
}
|
||||
end ExampleSuite
|
||||
37
15-multi-step-form/style-guide.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Front-end Style Guide
|
||||
|
||||
## Layout
|
||||
|
||||
The designs were created to the following widths:
|
||||
|
||||
- Mobile: 375px
|
||||
- Desktop: 1440px
|
||||
|
||||
## Colors
|
||||
|
||||
### Primary
|
||||
|
||||
- Marine blue: hsl(213, 96%, 18%)
|
||||
- Purplish blue: hsl(243, 100%, 62%)
|
||||
- Pastel blue: hsl(228, 100%, 84%)
|
||||
- Light blue: hsl(206, 94%, 87%)
|
||||
- Strawberry red: hsl(354, 84%, 57%)
|
||||
|
||||
### Neutral
|
||||
|
||||
- Cool gray: hsl(231, 11%, 63%)
|
||||
- Light gray: hsl(229, 24%, 87%)
|
||||
- Magnolia: hsl(217, 100%, 97%)
|
||||
- Alabaster: hsl(231, 100%, 99%)
|
||||
- White: hsl(0, 0%, 100%)
|
||||
|
||||
## Typography
|
||||
|
||||
### Body Copy
|
||||
|
||||
- Font size (paragraph): 16px
|
||||
|
||||
### Font
|
||||
|
||||
- Family: [Ubuntu](https://fonts.google.com/specimen/Ubuntu)
|
||||
- Weights: 400, 500, 700
|
||||
41
15-multi-step-form/tailwind.config.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: ["./src/**/*.{scala,html}"],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// ### Primary
|
||||
"marine-blue": "hsl(213, 96%, 18%)",
|
||||
"purplish-blue": "hsl(243, 100%, 62%)",
|
||||
"pastel-blue": "hsl(228, 100%, 84%)",
|
||||
"light-blue": "hsl(206, 94%, 87%)",
|
||||
"strawberry-red": "hsl(354, 84%, 57%)",
|
||||
|
||||
// ### neutral
|
||||
"cool-gray": "hsl(231, 11%, 63%)",
|
||||
"light-gray": "hsl(229, 24%, 87%)",
|
||||
magnolia: "hsl(217, 100%, 97%)",
|
||||
alabaster: "hsl(231, 100%, 99%)",
|
||||
},
|
||||
backgroundImage: {
|
||||
'sidebar-mobile': 'url("images/bg-sidebar-mobile.svg")',
|
||||
'sidebar-desktop': 'url("images/bg-sidebar-desktop.svg")',
|
||||
},
|
||||
fontFamily: {
|
||||
'sans': ['Ubuntu', 'sans-serif'], // This will set Roboto as the default sans font
|
||||
},
|
||||
fontWeight: {
|
||||
'normal': 400,
|
||||
'semibold': 600,
|
||||
'bold': 700,
|
||||
},
|
||||
width: {
|
||||
'desktop-form': '60rem',
|
||||
},
|
||||
height: {
|
||||
'desktop-form': '38rem',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
16
16-countries-page-from-api/.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
16-countries-page-from-api/.project
Normal file
2
16-countries-page-from-api/.scalafmt.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "3.7.10"
|
||||
runner.dialect = scala3
|
||||
136
16-countries-page-from-api/README.org
Normal file
@@ -0,0 +1,136 @@
|
||||
* Frontend Mentor - REST Countries API with color theme switcher solution
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: frontend-mentor---rest-countries-api-with-color-theme-switcher-solution
|
||||
:END:
|
||||
This is a solution to the
|
||||
[[https://www.frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher-5cacc469fec04111f7b848ca][REST
|
||||
Countries API with color theme switcher 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 all countries from the API on the homepage
|
||||
- Search for a country using an =input= field
|
||||
- Filter countries by region
|
||||
- Click on a country to see more detailed information on a separate page
|
||||
- Click through to the border countries on the detail page
|
||||
- Toggle the color scheme between light and dark mode /(optional)/
|
||||
|
||||
*** Screenshot
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screenshot
|
||||
:END:
|
||||
[[mobile-main.png]]
|
||||
[[mobile-single.png]]
|
||||
[[desktop-main.png]]
|
||||
[[desktop-single.png]]
|
||||
|
||||
|
||||
*** Links
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: links
|
||||
:END:
|
||||
- Solution URL: https://github.com/efim/Learning-HTMX/tree/master/16-countries-page-from-api
|
||||
- Live Site URL: https://efim-frontentmentor-countries-page.onrender.com/
|
||||
|
||||
** My process
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: my-process
|
||||
:END:
|
||||
*** Built with
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: built-with
|
||||
:END:
|
||||
- Scala Server Side Rendering
|
||||
- Htmx
|
||||
- TailwindCSS
|
||||
- Flexbox
|
||||
- CSS Grid
|
||||
- Mobile-first workflow
|
||||
|
||||
|
||||
*** What I learned
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: what-i-learned
|
||||
:END:
|
||||
**** polling download for 'infinite scroll'
|
||||
https://htmx.org/examples/infinite-scroll/
|
||||
|
||||
I've done almost same thing as example,
|
||||
but i'm appending additional empty div, that inserts responses instead of itself
|
||||
|
||||
this way i have one template fragment with repeater,
|
||||
and don't have to add hx attributes to the last one,
|
||||
|
||||
i just have separate fragment that i append to response which will trigger new
|
||||
load on enter view.
|
||||
**** having html 5 native autocomplete with <datalist> tag
|
||||
just server side rendering it with all country names is yay
|
||||
**** inserting thymeleaf templates by css selector
|
||||
https://www.thymeleaf.org/doc/tutorials/3.1/usingthymeleaf.html#appendix-c-markup-selector-syntax
|
||||
|
||||
this way i can insert <script> tag from index page, without declaring it as a fragment,
|
||||
because i'll want is static anyway.
|
||||
|
||||
and can share 'dark mode' js code between pages
|
||||
**** building docker image
|
||||
First off: using nix docker tools, and sbt assembly to create 'uber jar'
|
||||
now 'nix build .#countries-page-image' builds an image and symlinks it to ./result
|
||||
|
||||
$ docker load < result
|
||||
loads the image
|
||||
|
||||
and it can be started
|
||||
$ docker image list
|
||||
$ docker run -d -p 9090:8080 <image-id>
|
||||
**** deploying to render.com
|
||||
need to auth the docker cli, then tag an image with my repository name
|
||||
$ docker login
|
||||
$ docker tag 141 efim1234/rock-paper-scissors:latest
|
||||
$ podman push localhost/efim1234/countries-page:latest docker.io/efim1234/countries-page:latest
|
||||
|
||||
and now render.com, when creating "new service"
|
||||
can find "efim1234/countries-page:latest" as public image and use it
|
||||
**** using browser history
|
||||
with either server side
|
||||
HX-Push -> "some-url"
|
||||
or
|
||||
hx-push-url="true" in the html side
|
||||
|
||||
so that url is put into address bar,
|
||||
and browser save the body into history
|
||||
|
||||
and now my website has forward and backward navigation
|
||||
|
||||
only bug - the 'filter by region' for some reason doesn't maintain the selected value
|
||||
|
||||
*** Continued development
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: continued-development
|
||||
:END:
|
||||
In future project i'll probably want to lean and use go.
|
||||
For smaller binaries of the server, using PocketBase as embedded backend functions,
|
||||
and maybe having a better chances of just doing some real world small projects.
|
||||
|
||||
*** Useful resources
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: useful-resources
|
||||
:END:
|
||||
- htmx documentation and examples
|
||||
https://htmx.org/docs/#introduction
|
||||
- thymeleaf documentation
|
||||
https://www.thymeleaf.org/doc/tutorials/3.1/usingthymeleaf.html#introducing-thymeleaf
|
||||
- TailwindCSS documentation
|
||||
https://tailwindcss.com/docs/installation
|
||||
- heroicons: MIT licensed svg icons
|
||||
https://github.com/tailwindlabs/heroicons
|
||||
- render.com for providing free hosting for services from docker images
|
||||
17
16-countries-page-from-api/build.sbt
Normal file
@@ -0,0 +1,17 @@
|
||||
name := "countries-page"
|
||||
|
||||
val toolkitV = "0.1.7"
|
||||
val toolkit = "org.scala-lang" %% "toolkit" % toolkitV
|
||||
val toolkitTest = "org.scala-lang" %% "toolkit-test" % toolkitV
|
||||
|
||||
val cask = "com.lihaoyi" %% "cask" % "0.9.1"
|
||||
val mainargs = "com.lihaoyi" %% "mainargs" % "0.5.4"
|
||||
val requests = "com.lihaoyi" %% "requests" % "0.8.0"
|
||||
|
||||
ThisBuild / scalaVersion := "3.2.2"
|
||||
libraryDependencies ++= Seq(cask, mainargs, requests)
|
||||
libraryDependencies += toolkit
|
||||
libraryDependencies += (toolkitTest % Test)
|
||||
|
||||
// https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf
|
||||
libraryDependencies += "org.thymeleaf" % "thymeleaf" % "3.1.2.RELEASE"
|
||||
37
16-countries-page-from-api/default.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{ pkgs, lib, sbt-derivation }:
|
||||
let pname = "countries-page";
|
||||
in rec {
|
||||
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
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp target/scala-*/${pname}-assembly-*.jar $out/bin/${pname}.jar
|
||||
'';
|
||||
|
||||
depsSha256 = "sha256-PZYt1xvT8BKkFedA8nQvjvuE6JtmxNh0aSManAe4DpY=";
|
||||
};
|
||||
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" = { }; };
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
BIN
16-countries-page-from-api/design/desktop-design-detail-dark.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 26 KiB |
BIN
16-countries-page-from-api/design/desktop-design-home-dark.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
16-countries-page-from-api/design/desktop-design-home-light.jpg
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
16-countries-page-from-api/design/desktop-preview.jpg
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
16-countries-page-from-api/design/mobile-design-detail-dark.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
16-countries-page-from-api/design/mobile-design-detail-light.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
16-countries-page-from-api/design/mobile-design-home-dark.jpg
Normal file
|
After Width: | Height: | Size: 203 KiB |
BIN
16-countries-page-from-api/design/mobile-design-home-light.jpg
Normal file
|
After Width: | Height: | Size: 216 KiB |
BIN
16-countries-page-from-api/desktop-main.png
Normal file
|
After Width: | Height: | Size: 194 KiB |
BIN
16-countries-page-from-api/desktop-single.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
16-countries-page-from-api/mobile-main.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
16-countries-page-from-api/mobile-single.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
1
16-countries-page-from-api/project/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
sbt.version=1.9.0
|
||||
3
16-countries-page-from-api/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")
|
||||
28
16-countries-page-from-api/src/input.css
Normal file
@@ -0,0 +1,28 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'NunitoSans';
|
||||
src: url('/public/fonts/nunito-sans/NunitoSans-Regular.ttf') format('truetype');
|
||||
font-weight: 400; /* Regular */
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'NunitoSans';
|
||||
src: url('/public/fonts/nunito-sans/NunitoSans-Bold.ttf') format('truetype');
|
||||
font-weight: 700; /* Bold */
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'NunitoSans';
|
||||
src: url('/public/fonts/nunito-sans/NunitoSans-ExtraBold.ttf') format('truetype');
|
||||
font-weight: 800; /* ExtraBold */
|
||||
font-style: normal;
|
||||
}
|
||||