Compare commits
29 Commits
fe8b54346a
...
faedb21808
Author | SHA1 | Date |
---|---|---|
|
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 |
|
@ -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,0 +1,2 @@
|
||||||
|
version = "3.7.10"
|
||||||
|
runner.dialect = scala3
|
|
@ -0,0 +1,115 @@
|
||||||
|
# Frontend Mentor - REST Countries API with color theme switcher solution
|
||||||
|
|
||||||
|
This is a solution to the [REST Countries API with color theme switcher challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher-5cacc469fec04111f7b848ca). Frontend Mentor challenges help you improve your coding skills by building realistic projects.
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [The challenge](#the-challenge)
|
||||||
|
- [Screenshot](#screenshot)
|
||||||
|
- [Links](#links)
|
||||||
|
- [My process](#my-process)
|
||||||
|
- [Built with](#built-with)
|
||||||
|
- [What I learned](#what-i-learned)
|
||||||
|
- [Continued development](#continued-development)
|
||||||
|
- [Useful resources](#useful-resources)
|
||||||
|
- [Author](#author)
|
||||||
|
- [Acknowledgments](#acknowledgments)
|
||||||
|
|
||||||
|
**Note: Delete this note and update the table of contents based on what sections you keep.**
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
### The challenge
|
||||||
|
|
||||||
|
Users should be able to:
|
||||||
|
|
||||||
|
- See 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
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Add a screenshot of your solution. The easiest way to do this is to use Firefox to view your project, right-click the page and select "Take a Screenshot". You can choose either a full-height screenshot or a cropped one based on how long the page is. If it's very long, it might be best to crop it.
|
||||||
|
|
||||||
|
Alternatively, you can use a tool like [FireShot](https://getfireshot.com/) to take the screenshot. FireShot has a free option, so you don't need to purchase it.
|
||||||
|
|
||||||
|
Then crop/optimize/edit your image however you like, add it to your project, and update the file path in the image above.
|
||||||
|
|
||||||
|
**Note: Delete this note and the paragraphs above when you add your screenshot. If you prefer not to add a screenshot, feel free to remove this entire section.**
|
||||||
|
|
||||||
|
### Links
|
||||||
|
|
||||||
|
- Solution URL: [Add solution URL here](https://your-solution-url.com)
|
||||||
|
- Live Site URL: [Add live site URL here](https://your-live-site-url.com)
|
||||||
|
|
||||||
|
## My process
|
||||||
|
|
||||||
|
### Built with
|
||||||
|
|
||||||
|
- Semantic HTML5 markup
|
||||||
|
- CSS custom properties
|
||||||
|
- Flexbox
|
||||||
|
- CSS Grid
|
||||||
|
- Mobile-first workflow
|
||||||
|
- [React](https://reactjs.org/) - JS library
|
||||||
|
- [Next.js](https://nextjs.org/) - React framework
|
||||||
|
- [Styled Components](https://styled-components.com/) - For styles
|
||||||
|
|
||||||
|
**Note: These are just examples. Delete this note and replace the list above with your own choices**
|
||||||
|
|
||||||
|
### What I learned
|
||||||
|
|
||||||
|
Use this section to recap over some of your major learnings while working through this project. Writing these out and providing code samples of areas you want to highlight is a great way to reinforce your own knowledge.
|
||||||
|
|
||||||
|
To see how you can add code snippets, see below:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<h1>Some HTML code I'm proud of</h1>
|
||||||
|
```
|
||||||
|
```css
|
||||||
|
.proud-of-this-css {
|
||||||
|
color: papayawhip;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
```js
|
||||||
|
const proudOfThisFunc = () => {
|
||||||
|
console.log('🎉')
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want more help with writing markdown, we'd recommend checking out [The Markdown Guide](https://www.markdownguide.org/) to learn more.
|
||||||
|
|
||||||
|
**Note: Delete this note and the content within this section and replace with your own learnings.**
|
||||||
|
|
||||||
|
### Continued development
|
||||||
|
|
||||||
|
Use this section to outline areas that you want to continue focusing on in future projects. These could be concepts you're still not completely comfortable with or techniques you found useful that you want to refine and perfect.
|
||||||
|
|
||||||
|
**Note: Delete this note and the content within this section and replace with your own plans for continued development.**
|
||||||
|
|
||||||
|
### Useful resources
|
||||||
|
|
||||||
|
- [Example resource 1](https://www.example.com) - This helped me for XYZ reason. I really liked this pattern and will use it going forward.
|
||||||
|
- [Example resource 2](https://www.example.com) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.
|
||||||
|
|
||||||
|
**Note: Delete this note and replace the list above with resources that helped you during the challenge. These could come in handy for anyone viewing your solution or for yourself when you look back on this project in the future.**
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
- Website - [Add your name here](https://www.your-site.com)
|
||||||
|
- Frontend Mentor - [@yourusername](https://www.frontendmentor.io/profile/yourusername)
|
||||||
|
- Twitter - [@yourusername](https://www.twitter.com/yourusername)
|
||||||
|
|
||||||
|
**Note: Delete this note and add/remove/edit lines above based on what links you'd like to share.**
|
||||||
|
|
||||||
|
## Acknowledgments
|
||||||
|
|
||||||
|
This is where you can give a hat tip to anyone who helped you out on this project. Perhaps you worked in a team or got some inspiration from someone else's solution. This is the perfect place to give them some credit.
|
||||||
|
|
||||||
|
**Note: Delete this note and edit this section's content as necessary. If you completed this challenge by yourself, feel free to delete this section entirely.**
|
|
@ -0,0 +1,100 @@
|
||||||
|
# Frontend Mentor - REST Countries API with color theme switcher
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Welcome! 👋
|
||||||
|
|
||||||
|
Thanks for checking out this front-end coding challenge.
|
||||||
|
|
||||||
|
[Frontend Mentor](https://www.frontendmentor.io) challenges help you improve your coding skills by building realistic projects.
|
||||||
|
|
||||||
|
**To do this challenge, you need a good understanding of HTML, CSS, and JavaScript.**
|
||||||
|
|
||||||
|
## The challenge
|
||||||
|
|
||||||
|
Your challenge is to integrate with the [REST Countries API](https://restcountries.com) to pull country data and display it like in the designs.
|
||||||
|
|
||||||
|
You can use any JavaScript framework/library on the front-end such as [React](https://reactjs.org) or [Vue](https://vuejs.org). You also have complete control over which packages you use to do things like make HTTP requests or style your project.
|
||||||
|
|
||||||
|
Your 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)*
|
||||||
|
|
||||||
|
Want some support on the challenge? [Join our Slack community](https://www.frontendmentor.io/slack) and ask questions in the **#help** channel.
|
||||||
|
|
||||||
|
**⚠️ NOTE ⚠️: Sometimes the REST Countries API can go down. We've added a `data.json` file with all the country data if you prefer to use that instead. However, please be aware that the data in the JSON file might not be up-to-date.**
|
||||||
|
|
||||||
|
## Where to find everything
|
||||||
|
|
||||||
|
Your task is to build out the project to the designs inside the `/design` folder.
|
||||||
|
|
||||||
|
In this challenge, you will find mobile and desktop designs in light and dark mode color schemes for both pages.
|
||||||
|
|
||||||
|
The designs are in JPG static format. Using JPGs will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`.
|
||||||
|
|
||||||
|
If you would like the design files (we provide Sketch & Figma versions) to inspect the design in more detail, you can [subscribe as a PRO member](https://www.frontendmentor.io/pro).
|
||||||
|
|
||||||
|
There are no assets for this challenge, as the country flags will be pulled from the [REST Countries API](https://restcountries.com) and you can use an icon font library for the icons.
|
||||||
|
|
||||||
|
There is also a `style-guide.md` file containing the information you'll need, such as color palette and fonts.
|
||||||
|
|
||||||
|
## Building your project
|
||||||
|
|
||||||
|
Feel free to use any workflow that you feel comfortable with. Below is a suggested process, but do not feel like you need to follow these steps:
|
||||||
|
|
||||||
|
1. Initialize your project as a public repository on [GitHub](https://github.com/). Creating a repo will make it easier to share your code with the community if you need help. If you're not sure how to do this, [have a read-through of this Try Git resource](https://try.github.io/).
|
||||||
|
2. Configure your repository to publish your code to a web address. This will also be useful if you need some help during a challenge as you can share the URL for your project with your repo URL. There are a number of ways to do this, and we provide some recommendations below.
|
||||||
|
3. Look through the designs to start planning out how you'll tackle the project. This step is crucial to help you think ahead for CSS classes to create reusable styles.
|
||||||
|
4. Before adding any styles, structure your content with HTML. Writing your HTML first can help focus your attention on creating well-structured content.
|
||||||
|
5. Write out the base styles for your project, including general content styles, such as `font-family` and `font-size`.
|
||||||
|
6. Start adding styles to the top of the page and work down. Only move on to the next section once you're happy you've completed the area you're working on.
|
||||||
|
|
||||||
|
## Deploying your project
|
||||||
|
|
||||||
|
As mentioned above, there are many ways to host your project for free. Our recommend hosts are:
|
||||||
|
|
||||||
|
- [GitHub Pages](https://pages.github.com/)
|
||||||
|
- [Vercel](https://vercel.com/)
|
||||||
|
- [Netlify](https://www.netlify.com/)
|
||||||
|
|
||||||
|
You can host your site using one of these solutions or any of our other trusted providers. [Read more about our recommended and trusted hosts](https://medium.com/frontend-mentor/frontend-mentor-trusted-hosting-providers-bf000dfebe).
|
||||||
|
|
||||||
|
## Create a custom `README.md`
|
||||||
|
|
||||||
|
We strongly recommend overwriting this `README.md` with a custom one. We've provided a template inside the [`README-template.md`](./README-template.md) file in this starter code.
|
||||||
|
|
||||||
|
The template provides a guide for what to add. A custom `README` will help you explain your project and reflect on your learnings. Please feel free to edit our template as much as you like.
|
||||||
|
|
||||||
|
Once you've added your information to the template, delete this file and rename the `README-template.md` file to `README.md`. That will make it show up as your repository's README file.
|
||||||
|
|
||||||
|
## Submitting your solution
|
||||||
|
|
||||||
|
Submit your solution on the platform for the rest of the community to see. Follow our ["Complete guide to submitting solutions"](https://medium.com/frontend-mentor/a-complete-guide-to-submitting-solutions-on-frontend-mentor-ac6384162248) for tips on how to do this.
|
||||||
|
|
||||||
|
Remember, if you're looking for feedback on your solution, be sure to ask questions when submitting it. The more specific and detailed you are with your questions, the higher the chance you'll get valuable feedback from the community.
|
||||||
|
|
||||||
|
## Sharing your solution
|
||||||
|
|
||||||
|
There are multiple places you can share your solution:
|
||||||
|
|
||||||
|
1. Share your solution page in the **#finished-projects** channel of the [Slack community](https://www.frontendmentor.io/slack).
|
||||||
|
2. Tweet [@frontendmentor](https://twitter.com/frontendmentor) and mention **@frontendmentor**, including the repo and live URLs in the tweet. We'd love to take a look at what you've built and help share it around.
|
||||||
|
3. Share your solution on other social channels like LinkedIn.
|
||||||
|
4. Blog about your experience building your project. Writing about your workflow, technical choices, and talking through your code is a brilliant way to reinforce what you've learned. Great platforms to write on are [dev.to](https://dev.to/), [Hashnode](https://hashnode.com/), and [CodeNewbie](https://community.codenewbie.org/).
|
||||||
|
|
||||||
|
We provide templates to help you share your solution once you've submitted it on the platform. Please do edit them and include specific questions when you're looking for feedback.
|
||||||
|
|
||||||
|
The more specific you are with your questions the more likely it is that another member of the community will give you feedback.
|
||||||
|
|
||||||
|
## Got feedback for us?
|
||||||
|
|
||||||
|
We love receiving feedback! We're always looking to improve our challenges and our platform. So if you have anything you'd like to mention, please email hi[at]frontendmentor[dot]io.
|
||||||
|
|
||||||
|
This challenge is completely free. Please share it with anyone who will find it useful for practice.
|
||||||
|
|
||||||
|
**Have fun building!** 🚀
|
|
@ -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"
|
|
@ -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" = { }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 203 KiB |
After Width: | Height: | Size: 216 KiB |
|
@ -0,0 +1 @@
|
||||||
|
sbt.version=1.9.0
|
|
@ -0,0 +1,3 @@
|
||||||
|
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||||
|
|
||||||
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
|
@ -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;
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com),
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 386.242 386.242" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path id="Arrow_Back" d="M374.212,182.3H39.432l100.152-99.767c4.704-4.704,4.704-12.319,0-17.011
|
||||||
|
c-4.704-4.704-12.319-4.704-17.011,0L3.474,184.61c-4.632,4.632-4.632,12.379,0,17.011l119.1,119.1
|
||||||
|
c4.704,4.704,12.319,4.704,17.011,0c4.704-4.704,4.704-12.319,0-17.011L39.432,206.36h334.779c6.641,0,12.03-5.39,12.03-12.03
|
||||||
|
S380.852,182.3,374.212,182.3z"/>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 790 B |
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
width="800px" height="800px" viewBox="0 0 81.289 81.289"
|
||||||
|
xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path d="M79.248,38.668c-1.246-0.464-2.669-0.088-3.518,0.95c-4.791,5.84-11.858,9.192-19.403,9.192
|
||||||
|
c-13.833,0-25.083-11.255-25.083-25.083c0-6.963,2.808-13.441,7.908-18.242c0.977-0.918,1.26-2.357,0.705-3.579
|
||||||
|
c-0.552-1.222-1.818-1.959-3.157-1.826C15.778,2.112,0,19.511,0,40.555c0,22.424,18.245,40.669,40.672,40.669
|
||||||
|
c22.16,0,40.002-17.363,40.616-39.528C81.324,40.355,80.508,39.136,79.248,38.668z M40.671,74.953
|
||||||
|
c-18.971,0-34.402-15.43-34.402-34.4c0-14.93,9.389-27.69,22.859-32.43c-2.714,4.689-4.156,10.022-4.156,15.605
|
||||||
|
c0,17.292,14.065,31.355,31.357,31.355c6.317,0,12.373-1.882,17.479-5.322C69.82,64.399,56.557,74.953,40.671,74.953z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M15.7955 15.8111L21 21M18 10.5C18 14.6421 14.6421 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 469 B |
|
@ -0,0 +1,194 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||||
|
<title>Exploring countries</title>
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link href="../public/output.css" th:href=@{~/public/output.css}
|
||||||
|
rel="stylesheet" />
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
||||||
|
|
||||||
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||||
|
<!-- Place favicon.ico in the root directory -->
|
||||||
|
</head>
|
||||||
|
<body
|
||||||
|
class="bg-very-light-gray h-screen flex flex-col dark:bg-very-dark-blue dark:text-white"
|
||||||
|
hx-boost="true"
|
||||||
|
>
|
||||||
|
<!--[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]-->
|
||||||
|
<header th:replace="~{index :: header}">
|
||||||
|
<div
|
||||||
|
class="flex-1 max-w-screen-xl h-20 flex flex-row justify-between items-center px-4"
|
||||||
|
>
|
||||||
|
<a th:href="@{~/}" href="index.html"
|
||||||
|
><h1 class="grow font-bold md:text-2xl">Where in the world?</h1>
|
||||||
|
</a>
|
||||||
|
<button id="toggleDarkMode" class="flex flex-row gap-x-2">
|
||||||
|
<svg
|
||||||
|
class="text-black dark:text-white h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M21.7519 15.0019C20.597 15.4839 19.3296 15.75 18 15.75C12.6152 15.75 8.25 11.3848 8.25 5.99999C8.25 4.67039 8.51614 3.40296 8.99806 2.24805C5.47566 3.71785 3 7.19481 3 11.25C3 16.6348 7.36522 21 12.75 21C16.8052 21 20.2821 18.5243 21.7519 15.0019Z"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<p>Dark Mode</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<nav
|
||||||
|
class="flex flex-none h-32 px-8 py-10 max-w-screen-xl place-self-center w-full md:h-48 items-center"
|
||||||
|
>
|
||||||
|
<a href="index.html" th:href="@{~/}" class="h-fit">
|
||||||
|
<div
|
||||||
|
class="h-9 w-28 bg-white drop-shadow-[0_0_3px_rgba(0,0,0,0.5)] text-md rounded px-5 py-2 flex flex-row gap-x-3 place-content-center dark:bg-dark-blue"
|
||||||
|
>
|
||||||
|
<!-- Back icon -->
|
||||||
|
<svg
|
||||||
|
class="text-black dark:text-white h-full"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M10.5 19.5L3 12M3 12L10.5 4.5M3 12H21"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<!-- <img
|
||||||
|
src="../public/icons/back-svgrepo-com.svg"
|
||||||
|
class="w-4 h-5"
|
||||||
|
alt=""
|
||||||
|
/> -->
|
||||||
|
<p>Back</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main
|
||||||
|
class="px-8 pb-10 flex flex-col gap-y-10 md:grid md:grid-cols-2 md:h-max md:place-self-center w-full max-w-screen-xl"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="https://flagcdn.com/de.svg"
|
||||||
|
th:src="${country.flag}"
|
||||||
|
th:alt="|flag of ${country.nameView}|"
|
||||||
|
class="w-full md:w-10/12"
|
||||||
|
/>
|
||||||
|
<section
|
||||||
|
id="stat-block"
|
||||||
|
class="contents md:grid md:grid-cols-2 md:gap-y-10 md:py-10"
|
||||||
|
>
|
||||||
|
<h1
|
||||||
|
class="text-2xl font-bold pt-2 -mb-4 md:col-span-full md:text-3xl"
|
||||||
|
th:text="${country.nameView}"
|
||||||
|
>
|
||||||
|
Germany
|
||||||
|
</h1>
|
||||||
|
<dl class="space-y-2" id="main-stats">
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Native name:</dt>
|
||||||
|
<dd th:text="${country.nativeName}">Belgie</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Population:</dt>
|
||||||
|
<dd
|
||||||
|
th:text="${#numbers.formatInteger(country.population, 3, 'COMMA')}"
|
||||||
|
>
|
||||||
|
81,771,900
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Region:</dt>
|
||||||
|
<dd th:text="${country.region}">Europe</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Sub Region:</dt>
|
||||||
|
<dd th:text="${country.subregion}">Western Europe</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Capital:</dt>
|
||||||
|
<dd th:text="${country.capitalView}">Berlin</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl class="space-y-2" id="additional-stats">
|
||||||
|
<div th:if="${country.topLevelDomain.nonEmpty()}" class="flex">
|
||||||
|
<dt class="font-bold mr-2">Top Level Domain:</dt>
|
||||||
|
<dd th:text="${country.topLevelDomain.get()}">.be</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Currencies:</dt>
|
||||||
|
<!-- <dd th:text="${#strings.listJoin(country.currencies.map(_.name),',')}">Euro</dd> -->
|
||||||
|
<dd th:text="${#strings.listJoin(country.currenciesView, ',')}">
|
||||||
|
Euro
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Languages:</dt>
|
||||||
|
<dd th:text="${#strings.listJoin(country.languagesView, ', ')}">
|
||||||
|
Dutch, French, German
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
<section
|
||||||
|
id="neighboring-countries"
|
||||||
|
class="md:col-span-full md:flex md:flex-row md:items-center md:gap-x-2"
|
||||||
|
>
|
||||||
|
<h2 class="font-bold text-lg md:pr-2">Border Countries:</h2>
|
||||||
|
<div class="grid grid-cols-3 gap-2">
|
||||||
|
<a
|
||||||
|
href="/"
|
||||||
|
class="text-center min-h-9 bg-white drop-shadow text-md rounded px-5 py-2 md:w-32 md:py-1 dark:bg-dark-blue"
|
||||||
|
th:each="border : ${borderCountries}"
|
||||||
|
th:text="${border}"
|
||||||
|
th:href="@{~/country(countryName=${border})}"
|
||||||
|
>France</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
<script
|
||||||
|
th:replace="~{index :: script#dark-mode-scripts}"
|
||||||
|
type="text/javascript"
|
||||||
|
>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const darkMode = localStorage.getItem("darkMode");
|
||||||
|
console.log("yoyo");
|
||||||
|
if (darkMode === "true") {
|
||||||
|
document.documentElement.classList.add("dark");
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.remove("dark");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document
|
||||||
|
.getElementById("toggleDarkMode")
|
||||||
|
.addEventListener("click", function () {
|
||||||
|
document.documentElement.classList.toggle("dark");
|
||||||
|
localStorage.setItem(
|
||||||
|
"darkMode",
|
||||||
|
document.documentElement.classList.contains("dark")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,265 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||||
|
<title>Exploring countries</title>
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link href="../public/output.css" th:href=@{~/public/output.css}
|
||||||
|
rel="stylesheet" />
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
||||||
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||||
|
<!-- Place favicon.ico in the root directory -->
|
||||||
|
</head>
|
||||||
|
<body
|
||||||
|
class="bg-very-light-gray h-screen flex flex-col dark:bg-very-dark-blue dark:text-white"
|
||||||
|
hx-boost="true"
|
||||||
|
>
|
||||||
|
<!--[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]-->
|
||||||
|
<header
|
||||||
|
class="w-screen bg-white h-20 flex flex-row shadow-md place-content-center flex-none dark:bg-dark-blue"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex-1 max-w-screen-xl h-20 flex flex-row justify-between items-center px-4"
|
||||||
|
>
|
||||||
|
<a th:href="@{~/}" href="index.html"
|
||||||
|
><h1 class="grow font-bold md:text-2xl">Where in the world?</h1>
|
||||||
|
</a>
|
||||||
|
<button id="toggleDarkMode" class="flex flex-row gap-x-2">
|
||||||
|
<svg
|
||||||
|
class="text-black dark:text-white h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M21.7519 15.0019C20.597 15.4839 19.3296 15.75 18 15.75C12.6152 15.75 8.25 11.3848 8.25 5.99999C8.25 4.67039 8.51614 3.40296 8.99806 2.24805C5.47566 3.71785 3 7.19481 3 11.25C3 16.6348 7.36522 21 12.75 21C16.8052 21 20.2821 18.5243 21.7519 15.0019Z"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<p>Dark Mode</p>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<nav
|
||||||
|
class="flex flex-col flex-none md:flex-row px-6 my-4 justify-around h-48 md:h-32 md:items-center"
|
||||||
|
>
|
||||||
|
<form
|
||||||
|
method="get"
|
||||||
|
id="search-country"
|
||||||
|
action=""
|
||||||
|
hx-get="/country"
|
||||||
|
hx-target="body"
|
||||||
|
hx-push-url="true"
|
||||||
|
class="md:w-1/4 md:min-w-max"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex flex-row items-center bg-white shadow-md h-14 md:h-16 rounded-lg md:w-full dark:bg-dark-blue"
|
||||||
|
>
|
||||||
|
<!-- <p class="w-16 grid place-content-center">IC</p> -->
|
||||||
|
<svg
|
||||||
|
class="text-black dark:text-white h-6 px-7"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
d="M9 3.5C5.96243 3.5 3.5 5.96243 3.5 9C3.5 12.0376 5.96243 14.5 9 14.5C10.519 14.5 11.893 13.8852 12.8891 12.8891C13.8852 11.893 14.5 10.519 14.5 9C14.5 5.96243 12.0376 3.5 9 3.5ZM2 9C2 5.13401 5.13401 2 9 2C12.866 2 16 5.13401 16 9C16 10.6625 15.4197 12.1906 14.4517 13.3911L17.7803 16.7197C18.0732 17.0126 18.0732 17.4874 17.7803 17.7803C17.4874 18.0732 17.0126 18.0732 16.7197 17.7803L13.3911 14.4517C12.1906 15.4197 10.6625 16 9 16C5.13401 16 2 12.866 2 9Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<input
|
||||||
|
class="appearance-none flex-grow focus:outline-none mr-2 dark:bg-dark-blue dark:placeholder:text-white"
|
||||||
|
type="text"
|
||||||
|
id="country.nameView-input"
|
||||||
|
name="countryName"
|
||||||
|
list="country.nameViews-list"
|
||||||
|
placeholder="Search for a country..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<datalist id="country.nameViews-list">
|
||||||
|
<option
|
||||||
|
th:each="country : ${allCountriesList}"
|
||||||
|
th:value="${country.nameView}"
|
||||||
|
value=""
|
||||||
|
></option>
|
||||||
|
</datalist>
|
||||||
|
</form>
|
||||||
|
<form>
|
||||||
|
<select
|
||||||
|
name="region"
|
||||||
|
class="block w-62 mt-1 h-14 md:h-16 w-64 bg-white shadow-lg rounded-md shadow-sm focus:outline-none px-7 dark:bg-dark-blue"
|
||||||
|
hx-get="/countries-cards"
|
||||||
|
hx-target="#countries-main-list"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
value=""
|
||||||
|
selected
|
||||||
|
disabled
|
||||||
|
th:selected="${#strings.isEmpty(selectedRegion)}"
|
||||||
|
>
|
||||||
|
Filter by Region
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
th:each="region: ${regionsSet}"
|
||||||
|
th:value="${region}"
|
||||||
|
th:text="${region}"
|
||||||
|
th:selected="${selectedRegion == region}"
|
||||||
|
value="Africa"
|
||||||
|
>
|
||||||
|
Africa
|
||||||
|
</option>
|
||||||
|
<option th:remove="all" value="Americas">Americas</option>
|
||||||
|
<option th:remove="all" value="Asia">Asia</option>
|
||||||
|
<option th:remove="all" value="Europe">Europe</option>
|
||||||
|
<option th:remove="all" value="Oceania">Oceania</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</nav>
|
||||||
|
<main
|
||||||
|
class="flex flex-col items-center gap-10 pb-8 md:grid md:grid-cols-[repeat(auto-fill,_275px)] md:px-20 md:justify-around"
|
||||||
|
id="countries-main-list"
|
||||||
|
>
|
||||||
|
<article
|
||||||
|
th:fragment="cards-of-countries (countriesList)"
|
||||||
|
th:each="country : ${countriesList}"
|
||||||
|
id="germany"
|
||||||
|
th:id="${country.alpha3Code}"
|
||||||
|
class="bg-white min-h-[350px] w-[275px] flex flex-col rounded-lg shadow-lg dark:bg-dark-blue"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="country.html"
|
||||||
|
th:href="@{~/country(countryName=${country.nameView})}"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="https://flagcdn.com/de.svg"
|
||||||
|
th:src="${country.flag}"
|
||||||
|
alt="flag of Germany"
|
||||||
|
th:alt="|flag of ${country.nameView}|"
|
||||||
|
class="rounded-t-lg max-h-56 w-full"
|
||||||
|
/>
|
||||||
|
<section class="p-8 space-y-3 min-h-fit">
|
||||||
|
<h2 class="text-2xl font-bold" th:text="${country.nameView}">
|
||||||
|
Germany
|
||||||
|
</h2>
|
||||||
|
<dl class="space-y-1">
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Population:</dt>
|
||||||
|
<dd
|
||||||
|
th:text="${#numbers.formatInteger(country.population, 3, 'COMMA')}"
|
||||||
|
>
|
||||||
|
81,771,900
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Region:</dt>
|
||||||
|
<dd th:text="${country.region}">Europe</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Capital:</dt>
|
||||||
|
<dd th:text="${country.capitalView}">Berlin</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
</a>
|
||||||
|
</article>
|
||||||
|
<div
|
||||||
|
th:fragment="infiniteScrollAnchor (nextPage, selectedRegion)"
|
||||||
|
th:if="${nextPage != -1}"
|
||||||
|
id="next-page-anchor"
|
||||||
|
hx-trigger="revealed"
|
||||||
|
th:hx-get="@{~/countries-cards(region=${selectedRegion},page=${nextPage})}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<article
|
||||||
|
id="usa"
|
||||||
|
class="bg-white h-[350px] w-[275px] flex flex-col rounded-lg shadow-lg dark:bg-dark-blue"
|
||||||
|
th:remove="all"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="https://flagcdn.com/us.svg"
|
||||||
|
alt="flag of the USA"
|
||||||
|
class="rounded-t-lg"
|
||||||
|
/>
|
||||||
|
<section class="p-8 space-y-3">
|
||||||
|
<h2 class="text-2xl font-bold">United States of America</h2>
|
||||||
|
<dl class="space-y-1">
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Population:</dt>
|
||||||
|
<dd>329,484,123</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Region:</dt>
|
||||||
|
<dd>Americas</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Capital:</dt>
|
||||||
|
<dd>Washington, D.C.</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article
|
||||||
|
id="Brazil"
|
||||||
|
class="bg-white h-[350px] w-[275px] flex flex-col rounded-lg shadow-lg dark:bg-dark-blue"
|
||||||
|
th:remove="all"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="https://flagcdn.com/br.svg"
|
||||||
|
alt="flag of Germany"
|
||||||
|
class="rounded-t-lg"
|
||||||
|
/>
|
||||||
|
<section class="p-8 space-y-3">
|
||||||
|
<h2 class="text-2xl font-bold">Brazil</h2>
|
||||||
|
<dl class="space-y-1">
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Population:</dt>
|
||||||
|
<dd>212,559,409</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Region:</dt>
|
||||||
|
<dd>Americas</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<dt class="font-bold mr-2">Capital:</dt>
|
||||||
|
<dd>Brasília</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
<script id="dark-mode-scripts" type="text/javascript">
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const darkMode = localStorage.getItem("darkMode");
|
||||||
|
if (darkMode === "true") {
|
||||||
|
document.documentElement.classList.add("dark");
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.remove("dark");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document
|
||||||
|
.getElementById("toggleDarkMode")
|
||||||
|
.addEventListener("click", function () {
|
||||||
|
document.documentElement.classList.toggle("dark");
|
||||||
|
localStorage.setItem(
|
||||||
|
"darkMode",
|
||||||
|
document.documentElement.classList.contains("dark")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,48 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
import upickle.default._
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
|
|
||||||
|
final case class Country(
|
||||||
|
name: Name,
|
||||||
|
cca3: String,
|
||||||
|
population: Int,
|
||||||
|
region: String,
|
||||||
|
subregion: String = "",
|
||||||
|
flags: Flags,
|
||||||
|
capital: List[String] = List.empty,
|
||||||
|
tld: Option[String] = None, // maybe optional?
|
||||||
|
currencies: Map[String, Currency] = Map.empty,
|
||||||
|
languages: Map[String, String] = Map.empty,
|
||||||
|
borders: List[String] = List.empty
|
||||||
|
) derives ReadWriter {
|
||||||
|
def currenciesView = currencies.values.map(_.name).toList.asJava
|
||||||
|
def languagesView = languages.values.toList.asJava
|
||||||
|
def nameView = name.common
|
||||||
|
def capitalView = capital.headOption.getOrElse("")
|
||||||
|
def nativeName = name.nativeName.headOption.map(_._2.common).getOrElse("")
|
||||||
|
def topLevelDomain = tld
|
||||||
|
def alpha3Code = cca3
|
||||||
|
def flag = flags.svg
|
||||||
|
}
|
||||||
|
|
||||||
|
final case class Name(
|
||||||
|
common: String,
|
||||||
|
nativeName: Map[String, Name.Native] = Map.empty
|
||||||
|
) derives ReadWriter
|
||||||
|
object Name {
|
||||||
|
final case class Native(
|
||||||
|
common: String
|
||||||
|
) derives ReadWriter
|
||||||
|
}
|
||||||
|
|
||||||
|
final case class Currency(
|
||||||
|
name: String,
|
||||||
|
symbol: String = ""
|
||||||
|
) derives ReadWriter
|
||||||
|
|
||||||
|
final case class Flags(
|
||||||
|
png: String,
|
||||||
|
svg: String,
|
||||||
|
alt: String = ""
|
||||||
|
) derives ReadWriter
|
|
@ -0,0 +1,55 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode
|
||||||
|
import org.thymeleaf.TemplateEngine
|
||||||
|
import org.thymeleaf.context.Context
|
||||||
|
import cask.model.Response
|
||||||
|
import mainargs.{main, arg, ParserForMethods, Flag}
|
||||||
|
import scala.util.Try
|
||||||
|
|
||||||
|
object MinimalApplication extends cask.Routes {
|
||||||
|
|
||||||
|
@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"
|
||||||
|
) = {
|
||||||
|
println(s"Will start server on ${hostArg}:${portArg}")
|
||||||
|
val countriesDb = loadCountries()
|
||||||
|
val server = new cask.Main {
|
||||||
|
override def allRoutes: Seq[cask.main.Routes] = Seq(
|
||||||
|
Routes(countries = countriesDb)
|
||||||
|
)
|
||||||
|
override def port: Int = portArg
|
||||||
|
override def host: String = hostArg
|
||||||
|
}
|
||||||
|
server.main(Array.empty)
|
||||||
|
}
|
||||||
|
|
||||||
|
def loadCountries() = {
|
||||||
|
val defaultCountriesData: List[Country] =
|
||||||
|
upickle.default.read[List[Country]](
|
||||||
|
scala.io.Source.fromResource("temporary/all.json").getLines().mkString,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
val apiDataRequest = requests.get("https://restcountries.com/v3.1/all")
|
||||||
|
val apiData = Try(
|
||||||
|
upickle.default.read[List[Country]](apiDataRequest.text(), true)
|
||||||
|
)
|
||||||
|
if (apiData.isFailure)
|
||||||
|
println(s"> data load failed ${apiData}")
|
||||||
|
else
|
||||||
|
println(s"> api data load is successful")
|
||||||
|
|
||||||
|
apiData.toOption.getOrElse(defaultCountriesData)
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
import cask.model.Response
|
||||||
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||||
|
import org.thymeleaf.TemplateEngine
|
||||||
|
import org.thymeleaf.context.Context
|
||||||
|
import org.thymeleaf.templatemode.TemplateMode
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
|
import cask.model.Request
|
||||||
|
|
||||||
|
case class Routes(countries: List[Country])(implicit
|
||||||
|
cc: castor.Context,
|
||||||
|
log: cask.Logger
|
||||||
|
) extends cask.Routes {
|
||||||
|
|
||||||
|
/** initializing thymeleaf template engine which finds and renders html
|
||||||
|
* templates by name
|
||||||
|
*/
|
||||||
|
def buildTemplateEngine(): TemplateEngine = {
|
||||||
|
val templateResolver = new ClassLoaderTemplateResolver()
|
||||||
|
templateResolver.setTemplateMode(TemplateMode.HTML)
|
||||||
|
templateResolver.setPrefix("/templates/")
|
||||||
|
templateResolver.setSuffix(".html")
|
||||||
|
templateResolver.setCacheTTLMs(3600000L);
|
||||||
|
|
||||||
|
val templateEngine = new TemplateEngine()
|
||||||
|
templateEngine.setTemplateResolver(templateResolver)
|
||||||
|
|
||||||
|
templateEngine
|
||||||
|
}
|
||||||
|
val engine: TemplateEngine = buildTemplateEngine()
|
||||||
|
|
||||||
|
private val pageSize = 12
|
||||||
|
|
||||||
|
@cask.get("/")
|
||||||
|
def indexPage(region: Option[String] = None, page: Int = 0) = {
|
||||||
|
val context = new Context()
|
||||||
|
|
||||||
|
val regions = countries.map(_.region).distinct.sorted.asJava
|
||||||
|
val selectedCountries = region match {
|
||||||
|
case None => countries
|
||||||
|
case Some("") => countries
|
||||||
|
case Some(selectedRegion) => countries.filter(_.region == selectedRegion)
|
||||||
|
}
|
||||||
|
|
||||||
|
val startIndex = page * pageSize
|
||||||
|
val countriesPage =
|
||||||
|
selectedCountries.slice(startIndex, startIndex + pageSize)
|
||||||
|
// if current page is not full - there will be no next page
|
||||||
|
val nextPage = if (countriesPage.length == pageSize) page + 1 else -1
|
||||||
|
context.setVariable("nextPage", nextPage)
|
||||||
|
|
||||||
|
context.setVariable("regionsSet", regions)
|
||||||
|
context.setVariable("countriesList", countriesPage.asJava)
|
||||||
|
context.setVariable("allCountriesList", countries.asJava)
|
||||||
|
context.setVariable("selectedRegion", region.getOrElse(""))
|
||||||
|
|
||||||
|
val indexPage = engine.process("index", context)
|
||||||
|
Response(
|
||||||
|
indexPage,
|
||||||
|
headers = Seq("Content-Type" -> "text/html; charset=utf-8")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** this method returns directly set of cards and new anchor for loading next
|
||||||
|
* page of cards
|
||||||
|
*
|
||||||
|
* intended to be called from "next-page-anchor" with htmx
|
||||||
|
*/
|
||||||
|
@cask.get("/countries-cards")
|
||||||
|
def getPageOfCountriesCards(region: Option[String] = None, page: Int = 0) = {
|
||||||
|
val context = new Context()
|
||||||
|
|
||||||
|
val selectedCountries = region match {
|
||||||
|
case None => countries
|
||||||
|
case Some("") => countries
|
||||||
|
case Some(selectedRegion) => countries.filter(_.region == selectedRegion)
|
||||||
|
}
|
||||||
|
|
||||||
|
val startIndex = page * pageSize
|
||||||
|
val countriesPage =
|
||||||
|
selectedCountries.slice(startIndex, startIndex + pageSize)
|
||||||
|
// if current page is not full - there will be no next page
|
||||||
|
val nextPage = if (countriesPage.length == pageSize) page + 1 else -1
|
||||||
|
context.setVariable("countriesList", countriesPage.asJava)
|
||||||
|
context.setVariable("selectedRegion", region.getOrElse(""))
|
||||||
|
context.setVariable("nextPage", nextPage)
|
||||||
|
|
||||||
|
val cards = engine.process(
|
||||||
|
"index",
|
||||||
|
Set("cards-of-countries", "infiniteScrollAnchor").asJava,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
// this is to store switch to another region in the history
|
||||||
|
val newUrl = s"/?region=${region.getOrElse("")}"
|
||||||
|
// only save url when new region is requested, not on addtional card loads
|
||||||
|
val urlHeaderOpt = if (page == 0) Seq("HX-Push" -> newUrl) else Seq.empty
|
||||||
|
Response(
|
||||||
|
cards,
|
||||||
|
headers = Seq(
|
||||||
|
"Content-Type" -> "text/html; charset=utf-8"
|
||||||
|
) ++ urlHeaderOpt
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.get("/country")
|
||||||
|
def getCountryPage(countryName: String) = {
|
||||||
|
val context = new Context()
|
||||||
|
countries.find(_.name.common == countryName) match {
|
||||||
|
case Some(selectedCountry) =>
|
||||||
|
context.setVariable("country", selectedCountry)
|
||||||
|
val borderCountries = countries
|
||||||
|
.filter(c => selectedCountry.borders.contains(c.alpha3Code))
|
||||||
|
.map(_.name.common)
|
||||||
|
.sortBy(_.length())
|
||||||
|
.asJava
|
||||||
|
|
||||||
|
context.setVariable("borderCountries", borderCountries)
|
||||||
|
|
||||||
|
val countryPage = engine.process("country", context)
|
||||||
|
Response(
|
||||||
|
countryPage,
|
||||||
|
headers = Seq("Content-Type" -> "text/html; charset=utf-8")
|
||||||
|
)
|
||||||
|
case None => Response("", 400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.post("/do-thing")
|
||||||
|
def doThing(request: cask.Request) = {
|
||||||
|
request.text().reverse
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.staticResources("public")
|
||||||
|
def giveStaticResources() = "public"
|
||||||
|
|
||||||
|
initialize()
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
class ExampleSuite extends munit.FunSuite:
|
||||||
|
|
||||||
|
test("addition") {
|
||||||
|
assert(1 + 1 == 2)
|
||||||
|
}
|
||||||
|
end ExampleSuite
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Front-end Style Guide
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
The designs were created to the following widths:
|
||||||
|
|
||||||
|
- Mobile: 375px
|
||||||
|
- Desktop: 1440px
|
||||||
|
|
||||||
|
## Colors
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
|
||||||
|
- Dark Blue (Dark Mode Elements): hsl(209, 23%, 22%)
|
||||||
|
- Very Dark Blue (Dark Mode Background): hsl(207, 26%, 17%)
|
||||||
|
- Very Dark Blue (Light Mode Text): hsl(200, 15%, 8%)
|
||||||
|
- Dark Gray (Light Mode Input): hsl(0, 0%, 52%)
|
||||||
|
- Very Light Gray (Light Mode Background): hsl(0, 0%, 98%)
|
||||||
|
- White (Dark Mode Text & Light Mode Elements): hsl(0, 0%, 100%)
|
||||||
|
|
||||||
|
## Typography
|
||||||
|
|
||||||
|
### Body Copy
|
||||||
|
|
||||||
|
- Homepage Items: 14px
|
||||||
|
- Detail Page: 16px
|
||||||
|
|
||||||
|
### Fonts
|
||||||
|
|
||||||
|
- Family: [Nunito Sans](https://fonts.google.com/specimen/Nunito+Sans)
|
||||||
|
- Weights: 300, 600, 800
|
||||||
|
|
||||||
|
## Icons
|
||||||
|
|
||||||
|
For the icons, you can use a font icon library. Don't worry if the icons that you choose don't look exactly like they do on the design.
|
||||||
|
|
||||||
|
Some suggestions can be found below:
|
||||||
|
|
||||||
|
- [Font Awesome](https://fontawesome.com)
|
||||||
|
- [IcoMoon](https://icomoon.io)
|
||||||
|
- [Ionicons](https://ionicons.com)
|
|
@ -0,0 +1,20 @@
|
||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ["./src/main/resources/**/*.html"],
|
||||||
|
darkMode: 'class',
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
'dark-gray': 'hsl(0, 0%, 52%)', // light mode input
|
||||||
|
'very-light-gray': 'hsl(0, 0%, 98%)', // light mode bg
|
||||||
|
'dark-blue': 'hsl(209, 23%, 22%)', // dark mode elements
|
||||||
|
'very-dark-blue': 'hsl(207, 26%, 17%)', // dark mode bg
|
||||||
|
},
|
||||||
|
fontFamily: {
|
||||||
|
'sans': ['NunitoSans', 'sans-serif'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
inherit pkgs sbt-derivation;
|
inherit pkgs sbt-derivation;
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
};
|
};
|
||||||
|
countries-page = import ./16-countries-page-from-api {
|
||||||
|
inherit pkgs sbt-derivation;
|
||||||
|
lib = pkgs.lib;
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
@ -58,6 +62,8 @@
|
||||||
packages.multi-step-form = multi-step-form.package;
|
packages.multi-step-form = multi-step-form.package;
|
||||||
packages.multi-step-form-image = multi-step-form.image;
|
packages.multi-step-form-image = multi-step-form.image;
|
||||||
nixosModules.multi-step-form = multi-step-form.module;
|
nixosModules.multi-step-form = multi-step-form.module;
|
||||||
|
packages.countries-page = countries-page.package;
|
||||||
|
packages.countries-page-image = countries-page.image;
|
||||||
});
|
});
|
||||||
# see https://serokell.io/blog/practical-nix-flakes
|
# see https://serokell.io/blog/practical-nix-flakes
|
||||||
}
|
}
|
||||||
|
|