Skip to content

Commit

Permalink
Merge pull request #5 from cogwizzle/dice
Browse files Browse the repository at this point in the history
dice
  • Loading branch information
cogwizzle authored Mar 2, 2024
2 parents 177bbbb + f054bd1 commit beea213
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 26 deletions.
Binary file modified blog.db
Binary file not shown.
96 changes: 96 additions & 0 deletions content/dungeon-tools-dice-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Recently I built another tool,
[<u>https://dungeonworldcharacter.com/</u>](https://dungeonworldcharacter.com/),
as a static site that uses very little JavaScript in comparison with
today’s modern goliaths. If you want to see more about that project
check out this blog post
[<u>here</u>](https://cogwizzle.com/dungeon%20world%20character%20sheet.html).
In the retrospective of the project I noted that I would’ve built it
differently if I had to do it all over again. I would’ve used
[<u>progressive
enhancement</u>](https://en.wikipedia.org/wiki/Progressive_enhancement#:~:text=Progressive%20enhancement%20is%20a%20strategy,receive%20the%20enhanced%20version%20instead.)
over top of a traditionally server rendered application.

Today I’m excited to announce a new tool that does just this! I’ve built
a progressively enhanced PWA experience that works better with
JavaScript, but still functions without it. I built this application for
two reasons. The tool is called
[<u>https://dice.dungeon-tools.com/</u>](https://dice.dungeon-tools.com/).

<img src="/dungeon-tools-dice-app/image1.png"
style="width:6.5in;height:5.20833in" />

*Figure 1: Dice App*

# What is it?

This is a dice app that allows players to easily roll digital dice for
Tabletop Role playing experiences. It will work with or without
JavaScript. The site runs primarily on PHP. I built the PHP only
experience first. It works with a slightly degraded experience if you
use the PHP only experience. Every dice roll causes the page to refresh
but it works.

The app really shines with the JavaScript enabled experience. For
starters it is a PWA. It allows folks to install the application like it
is a native app as well as cache resources so that it is really fast on
subsequent page loads. Additionally the PWA uses JavaScript exclusively
to roll the dice and updates the UI with the results. You can see up to
your last 8 rolls on screen.

The small amount of JavaScript that does exist on the site is written
using HATEOAS as an inspiration for keeping track of state. The
handwritten JavaScript is only 40 lines long including comments. The
forms and UI that composed the PHP native experience were able to inform
how the JavaScript application state should run.

In addition to the progressively enhanced JavaScript experience we chose
to go with Picocss this time around. This gives us light and dark themes
based on the users preferences as well as some really sane defaults when
it comes to plain Jane HTML element styling.

## API

In addition to the app native functionality I also built a HATEOAS
inspired REST API. I will likely tie this feature directly into the
Dungeon World Character app to allow for the app to roll dice. The API
is simple. We have d4, d6, d8, d10, d12, and d20 endpoints. The format
is
[<u>https://dice.dungeontools.com/api/d4</u>](https://dice.dungeontools.com/api/d4).
These APIs are open and free to use.

# Retrospective

There are still small tweaks to be made to the dice app. I need to
download and cache the Pico CSS library and I have one small cache issue
that isn’t affecting any of the application execution. Obviously the
plan is to patch those few things up over the next couple of days. Aside
from those small pieces I’m actually really happy with using this
progressive enhancement technique to build high quality experiences on
the web.

This application is really small so it was an easy case study on the
progressively enhancing a web application. I’d like to continue this
style of development to build high performance web applications in the
future. Perhaps some of this technique can be moved over to some of my
other projects. I love how little JavaScript is required. It brings me
back to the early days of my career.

PicoCSS is a joy to work with. I really like how simple it is to get
started and how little custom CSS you have to write in order for it to
look nice. I do think that for larger projects it might not be the ideal
choice. I’m looking into other libraries like
[<u>Bulma</u>](https://bulma.io/) for future projects. PicoCSS is great
if you don’t want to do a lot of customization. I feel like Bulma is a
bit heavier than PicoCSS but has more flexibility. If you want the
ultimate control over everything you can’t go wrong with
[<u>Tailwind</u>](https://tailwindcss.com/).

I’m currently using Cloudways by Digital Ocean to host my project. I hit
a couple of speed bumps during the deployment of the app, but I think it
was a skill issue on my part. I’m still learning the Cloudways platform
so I’m sure it will get more intuitive as time goes on. In retrospect
this will likely be the way that I host apps in the future. Especially
after hearing about terrifying stories like
[<u>this</u>](https://old.reddit.com/r/webdev/comments/1b14bty/netlify_just_sent_me_a_104k_bill_for_a_simple/)
on Serverless platforms. The site may go down because my server isn’t
that powerful, but at least I won’t wake up to a rough bill.
20 changes: 10 additions & 10 deletions content/dungeon-world-character-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Web Application features to allow it to work completely offline. You can
install the application by simply visiting the website and clicking the
install button in the URL bar of your favorite browser.

<img src="images/dungeon-world-character-sheet/image1.png"
<img src="/dungeon-world-character-sheet/image1.png"
style="width:6.5in;height:0.29167in" />

*Figure 1: Showing the install symbol in the browser URL bar.*
<img src="images/dungeon-world-character-sheet/image2.png"
<img src="/dungeon-world-character-sheet/image2.png"
style="width:0.25in;height:0.20833in" />

The choice to make this application a Progressive Web Application
Expand All @@ -39,12 +39,12 @@ website was to allow anybody in the world to use it regardless of high
speed internet accessibility. In addition this bought me an incredibly
performant web application as well.

<img src="images/dungeon-world-character-sheet/image5.png"
<img src="/dungeon-world-character-sheet/image5.png"
style="width:6.5in;height:1.61111in" />

*Figure 2: Lighthouse Metrics for unthrottled load of the page.*

<img src="images/dungeon-world-character-sheet/image4.png"
<img src="/dungeon-world-character-sheet/image4.png"
style="width:6.5in;height:3.66667in" />

*Figure 3: Showing I delivered a premium experience with very little
Expand Down Expand Up @@ -78,7 +78,7 @@ built in classes and we wanted to build in all of those skills and class
features. We also wanted to let players add their own custom homebrew
content as well. Let’s take a look at what the default form looks like.

<img src="images/dungeon-world-character-sheet/image7.png"
<img src="/dungeon-world-character-sheet/image7.png"
style="width:6.5in;height:4.06944in" />

*Figure 4: Empty Dungeon World Character Sheet Form*
Expand All @@ -87,7 +87,7 @@ As you can see in figure 4 we give our players the option to fill in
whatever they want if they haven’t selected their class. This works
great for homebrew content.

<img src="images/dungeon-world-character-sheet/image10.png"
<img src="/dungeon-world-character-sheet/image10.png"
style="width:1.39063in;height:2.70399in" />

*Figure 5: Smart options*
Expand All @@ -96,7 +96,7 @@ While we allow them to type whatever class they want in the field we
give them a smart list of options for the built in Dungeon World
classes. This system is used all throughout the character sheet.

<img src="images/dungeon-world-character-sheet/image8.png"
<img src="/dungeon-world-character-sheet/image8.png"
style="width:6.5in;height:4.06944in" />

*Figure 6: Once the class has been selected the form changes
Expand All @@ -113,7 +113,7 @@ characters.
There are several inputs that allow a user to input information in a
list style format. An example of this is the Gear field

<img src="images/dungeon-world-character-sheet/image6.png"
<img src="/dungeon-world-character-sheet/image6.png"
style="width:6.5in;height:1.55556in" />

*Figure 7: Gear field.*
Expand All @@ -138,7 +138,7 @@ localStorage cache every time a field was changed in the application.

### Saving and Loading

<img src="images/dungeon-world-character-sheet/image3.png"
<img src="/dungeon-world-character-sheet/image3.png"
style="width:3.1875in;height:2.33333in" />

*Figure 8: Saving and loading.*
Expand All @@ -147,7 +147,7 @@ Saving and loading can be done from the side bar right next to the
character class. Saving will allow you to take a character sheet like
the one in figure 9 and get a JSON file that looks like this.

<img src="images/dungeon-world-character-sheet/image9.png"
<img src="/dungeon-world-character-sheet/image9.png"
style="width:6.5in;height:4.06944in" />

*Figure 9: Example character sheet.*
Expand Down
108 changes: 108 additions & 0 deletions docs/dungeon tools dice app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cogwizzle - Blog</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
rel="stylesheet"
href="styles/styles.min.css"
/>
</head>
<body>
<nav class="container">
<ul>
<li>
<h1>Cogwizzle</h1>
</li>
</ul>
<ul>
<li>
<a href="/">Blog</a>
</li>
</ul>
</nav>
<main class="container">
<p>Recently I built another tool, <a
href="https://dungeonworldcharacter.com/"><u>https://dungeonworldcharacter.com/</u></a>,
as a static site that uses very little JavaScript in comparison with
today’s modern goliaths. If you want to see more about that project
check out this blog post <a
href="https://cogwizzle.com/dungeon%20world%20character%20sheet.html"><u>here</u></a>.
In the retrospective of the project I noted that I would’ve built it
differently if I had to do it all over again. I would’ve used <a
href="https://en.wikipedia.org/wiki/Progressive_enhancement#:~:text=Progressive%20enhancement%20is%20a%20strategy,receive%20the%20enhanced%20version%20instead."><u>progressive
enhancement</u></a> over top of a traditionally server rendered
application.</p>
<p>Today I’m excited to announce a new tool that does just this! I’ve
built a progressively enhanced PWA experience that works better with
JavaScript, but still functions without it. I built this application for
two reasons. The tool is called <a
href="https://dice.dungeon-tools.com/"><u>https://dice.dungeon-tools.com/</u></a>.</p>
<p><img src="/dungeon-tools-dice-app/image1.png"
style="width:6.5in;height:5.20833in" /></p>
<p><em>Figure 1: Dice App</em></p>
<h1 id="what-is-it">What is it?</h1>
<p>This is a dice app that allows players to easily roll digital dice
for Tabletop Role playing experiences. It will work with or without
JavaScript. The site runs primarily on PHP. I built the PHP only
experience first. It works with a slightly degraded experience if you
use the PHP only experience. Every dice roll causes the page to refresh
but it works.</p>
<p>The app really shines with the JavaScript enabled experience. For
starters it is a PWA. It allows folks to install the application like it
is a native app as well as cache resources so that it is really fast on
subsequent page loads. Additionally the PWA uses JavaScript exclusively
to roll the dice and updates the UI with the results. You can see up to
your last 8 rolls on screen.</p>
<p>The small amount of JavaScript that does exist on the site is written
using HATEOAS as an inspiration for keeping track of state. The
handwritten JavaScript is only 40 lines long including comments. The
forms and UI that composed the PHP native experience were able to inform
how the JavaScript application state should run.</p>
<p>In addition to the progressively enhanced JavaScript experience we
chose to go with Picocss this time around. This gives us light and dark
themes based on the users preferences as well as some really sane
defaults when it comes to plain Jane HTML element styling.</p>
<h2 id="api">API</h2>
<p>In addition to the app native functionality I also built a HATEOAS
inspired REST API. I will likely tie this feature directly into the
Dungeon World Character app to allow for the app to roll dice. The API
is simple. We have d4, d6, d8, d10, d12, and d20 endpoints. The format
is <a
href="https://dice.dungeontools.com/api/d4"><u>https://dice.dungeontools.com/api/d4</u></a>.
These APIs are open and free to use.</p>
<h1 id="retrospective">Retrospective</h1>
<p>There are still small tweaks to be made to the dice app. I need to
download and cache the Pico CSS library and I have one small cache issue
that isn’t affecting any of the application execution. Obviously the
plan is to patch those few things up over the next couple of days. Aside
from those small pieces I’m actually really happy with using this
progressive enhancement technique to build high quality experiences on
the web.</p>
<p>This application is really small so it was an easy case study on the
progressively enhancing a web application. I’d like to continue this
style of development to build high performance web applications in the
future. Perhaps some of this technique can be moved over to some of my
other projects. I love how little JavaScript is required. It brings me
back to the early days of my career.</p>
<p>PicoCSS is a joy to work with. I really like how simple it is to get
started and how little custom CSS you have to write in order for it to
look nice. I do think that for larger projects it might not be the ideal
choice. I’m looking into other libraries like <a
href="https://bulma.io/"><u>Bulma</u></a> for future projects. PicoCSS
is great if you don’t want to do a lot of customization. I feel like
Bulma is a bit heavier than PicoCSS but has more flexibility. If you
want the ultimate control over everything you can’t go wrong with <a
href="https://tailwindcss.com/"><u>Tailwind</u></a>.</p>
<p>I’m currently using Cloudways by Digital Ocean to host my project. I
hit a couple of speed bumps during the deployment of the app, but I
think it was a skill issue on my part. I’m still learning the Cloudways
platform so I’m sure it will get more intuitive as time goes on. In
retrospect this will likely be the way that I host apps in the future.
Especially after hearing about terrifying stories like <a
href="https://old.reddit.com/r/webdev/comments/1b14bty/netlify_just_sent_me_a_104k_bill_for_a_simple/"><u>this</u></a>
on Serverless platforms. The site may go down because my server isn’t
that powerful, but at least I won’t wake up to a rough bill.</p>
</main>
</body>
</html>
23 changes: 12 additions & 11 deletions docs/dungeon world character sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ <h1>Cogwizzle</h1>
</ul>
</nav>
<main class="container">
<h1 id="dungeon-world-character-sheet">Dungeon World Character Sheet</h1>
<h1 id="dungeon-world-character-sheet">Dungeon World Character
Sheet</h1>
<p><a href="https://dungeon-world.com/"><u>Dungeon World</u></a> is a
popular Tabletop RPG (TTRPG) system that is built on top of the Powered
By the Apocalypse system. The game system is not as popular as other
Expand All @@ -44,22 +45,22 @@ <h1 id="technology-stack">Technology Stack</h1>
Web Application features to allow it to work completely offline. You can
install the application by simply visiting the website and clicking the
install button in the URL bar of your favorite browser.</p>
<p><img src="images/dungeon-world-character-sheet/image1.png"
<p><img src="/dungeon-world-character-sheet/image1.png"
style="width:6.5in;height:0.29167in" /></p>
<p><em>Figure 1: Showing the install symbol in the browser URL bar.</em>
<img src="images/dungeon-world-character-sheet/image2.png"
<img src="/dungeon-world-character-sheet/image2.png"
style="width:0.25in;height:0.20833in" /></p>
<p>The choice to make this application a Progressive Web Application
without a JavaScript framework was done intentionally to keep the
website accessible to as many people as possible. The goal of the
website was to allow anybody in the world to use it regardless of high
speed internet accessibility. In addition this bought me an incredibly
performant web application as well.</p>
<p><img src="images/dungeon-world-character-sheet/image5.png"
<p><img src="/dungeon-world-character-sheet/image5.png"
style="width:6.5in;height:1.61111in" /></p>
<p><em>Figure 2: Lighthouse Metrics for unthrottled load of the
page.</em></p>
<p><img src="images/dungeon-world-character-sheet/image4.png"
<p><img src="/dungeon-world-character-sheet/image4.png"
style="width:6.5in;height:3.66667in" /></p>
<p><em>Figure 3: Showing I delivered a premium experience with very
little JavaScript.</em></p>
Expand Down Expand Up @@ -87,19 +88,19 @@ <h2 id="dynamic-form">Dynamic Form</h2>
class features. We also wanted to let players add their own custom
homebrew content as well. Let’s take a look at what the default form
looks like.</p>
<p><img src="images/dungeon-world-character-sheet/image7.png"
<p><img src="/dungeon-world-character-sheet/image7.png"
style="width:6.5in;height:4.06944in" /></p>
<p><em>Figure 4: Empty Dungeon World Character Sheet Form</em></p>
<p>As you can see in figure 4 we give our players the option to fill in
whatever they want if they haven’t selected their class. This works
great for homebrew content.</p>
<p><img src="images/dungeon-world-character-sheet/image10.png"
<p><img src="/dungeon-world-character-sheet/image10.png"
style="width:1.39063in;height:2.70399in" /></p>
<p><em>Figure 5: Smart options</em></p>
<p>While we allow them to type whatever class they want in the field we
give them a smart list of options for the built in Dungeon World
classes. This system is used all throughout the character sheet.</p>
<p><img src="images/dungeon-world-character-sheet/image8.png"
<p><img src="/dungeon-world-character-sheet/image8.png"
style="width:6.5in;height:4.06944in" /></p>
<p><em>Figure 6: Once the class has been selected the form changes
substantially.</em></p>
Expand All @@ -111,7 +112,7 @@ <h2 id="dynamic-form">Dynamic Form</h2>
<h2 id="list-inputs">List Inputs</h2>
<p>There are several inputs that allow a user to input information in a
list style format. An example of this is the Gear field</p>
<p><img src="images/dungeon-world-character-sheet/image6.png"
<p><img src="/dungeon-world-character-sheet/image6.png"
style="width:6.5in;height:1.55556in" /></p>
<p><em>Figure 7: Gear field.</em></p>
<p>As you enter an item in the field it expands and adds another field
Expand All @@ -130,13 +131,13 @@ <h3 id="cache">Cache</h3>
localStorage cache every time a field was changed in the
application.</p>
<h3 id="saving-and-loading">Saving and Loading</h3>
<p><img src="images/dungeon-world-character-sheet/image3.png"
<p><img src="/dungeon-world-character-sheet/image3.png"
style="width:3.1875in;height:2.33333in" /></p>
<p><em>Figure 8: Saving and loading.</em></p>
<p>Saving and loading can be done from the side bar right next to the
character class. Saving will allow you to take a character sheet like
the one in figure 9 and get a JSON file that looks like this.</p>
<p><img src="images/dungeon-world-character-sheet/image9.png"
<p><img src="/dungeon-world-character-sheet/image9.png"
style="width:6.5in;height:4.06944in" /></p>
<p><em>Figure 9: Example character sheet.</em></p>
<p><em>Gary.json</em></p>
Expand Down
Binary file added docs/dungeon-tools-dice-app/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit beea213

Please sign in to comment.