Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 2 years ago

HTMX, Tailwind, Scala SSR, Thymeleaf & Cask, deployed via docker image

tailwind-css
efim•390
@efim
A solution to the Rock, Paper, Scissors game challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Submitting before finilazing README with lessons learned, but I'm all to eager to feel completion of at least the task itself.

First step of actually using HTMX - parts of the page are getting updated to the fragments returned by "hx:get" requests. HTMX is the small js library that extends HTML language with interactivity - so that all tags could issude Ajax requests, and responses of these requests could be spliced into the page.

It was hard figuring out more complex things of Thymeleaf templates: fragment is named part of the template which can be rendered separately from the whole .html template file. This way i can have one 'showdown.html' for the view after player chooses the hand, so it's possible to open it as a static file. But then render only part of "showdown-table" to be spliced into 'index.html' instead of "controlls"

Prevoius "frontend only tasks" I hosted on CloudFlare pages, because it was easy to compile ScalaJS into static site and serve the files. Here I'm creating and publishing a Docker image, and hosting on render.com, because it allows gratis hosting from docker images with some limitations. (If the project is not running for 15 minutes it's spunned down, so please wait for the server to start up if you're visiting the page and it takes long to load)

I'm also using inline scripting to save updates score into local storage, and get it on page load.

I'm most unsure about the way to organize fragments, maybe i want less fragments on a single page, so it would be easier to have more fine grained "showdown-only-player.html" and "showdown-player-and-house.html" for different parts of the flow

I'm also quite happy with my idea of using CSS variables for styling of fragments, this way i can have 'style="<staticly available var definitions>"' which would be completely overridded on render time with 'th:style="<values taken from variables>"' But i suppose that these stylings of the fragments are better done not in code (having "8rem" as attribute of the model), but in the outer tags of the pages that include the fragment.

And a huge thing left undone - I didn't look at the desktop design request in the beginning - and my organization of "player hand", "house hand" and "game result message" weren't easily compatible to the desktop design request, so for now desktop design is just scaled up mobile design.

Which is also a huge thing I'll need to learn - if i'm to style the fragments with CSS variables, then controlling their styling with TailwindCSS md: ld: prefixes becomes hard. So another hack - i've just applied "md:transform-150"

Things to do learn in the future: more about organizing fragnemnts and their stlyes

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on efim's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.