Dublin Library

The Publishing project

Exporting block themes from the full site editor

When the block editor first came out, one of the things I found lacking was the ability to save theme templates and template blocks to files on my computer. WordPress 6.0 gives developers the ability to export a full theme as a zipped archive. This feature was first available in version 5.9 but it only allowed you to save the template files. In 6.0 the export feature produces a fully working theme archive that can be imported into another WordPress site or unzipped into a directory we can push into a Git repository or to do work in preparation to...

Continue reading →

Running WordPress with Docker

There are many ways to run WordPress locally on your development machine. You can install MAMP/WAMP/XAMP or any other bundled LAMP stack, configure a database and install WordPress You can install Local by Flywheel, start it up and get a WordPress instance There is one more way to do it: You can use Docker. Docker provides a way to run container-based applications on your local system. All it requires is that you have Docker Engine for Linux or Docker Desktop for macOS and Windows installed. As a quick introduction: Our WordPress installation using Docker requires two images: A WordPress image...

Continue reading →

Rounding numbers in Javascript

There are times when we need to round numbers to show on a web page. For example, we might want to round a number to two decimal places when showing currency values. It is tempting just to truncate the values but that has its drawbacks. You may lose precision if you truncate the value without rounding it. Enter toFixed. This method takes a number and returns the rounded value to the number of places specified in the parameter. The code below does the following: 1. set up a constant holding the number we want to round 2. use the toFixed...

Continue reading →

Working with gradients in CSS

I'm not very partial to working with colors in general and with gradients in particular. They used to only be available when working with SVG and not CSS. At some point we gained the ability to work with gradients in CSS and, more recently, it became possible to work with multiple kinds of gradients. This post will dive into linear gradients, the ones that I use most often on web content. What is a gradient? Gradients are images that show a transition between two or more colors. These transitions are shown as either linear, radial, or radial. Gradients can be...

Continue reading →

Font formats for the web and converting from one to another

Using fonts on the web has a longer story than many would think. The @font-face at-rule has been around since the early days of the web. Initially, there were no fonts on the web... the goal was to share documents, not to produce the polished documents that we see today. In the beginning, web browsers relied on locally installed fonts both for performance the modems of the time would take forever to download a font. We could use any of the pre-defined fonts: Andale Mono Arial Arial Black Comic Sans MS Courier New Georgia Impact Times New Roman Trebuchet MS...

Continue reading →

Color Fonts

CSS Fonts Level 4 introduces support for color fontshttps://www.w3.org/TR/css-fonts-4/color-font-support. The idea is that these fonts will be less resource-intensive because they will make fewer round trips to the server to manipulate the colors available to display the font. In theory there are no browsers that currently support this defining a custom palette for color fonts look like this: The @font-paletter-values at-rule The name of the palette we are creating The font family that the palette is associated with The base palette that we're overriding A list of one or more override colors css @font-palette-values Cooler { font-family: Bradley; base-palette: 1;...

Continue reading →

Creating a JSON schema

JSON Schemashttps://json-schema.org/ allows us to create a schema for JSON data. This would allow us to validate the data and ensure that it is complete and has the correct structure. This would also address one of the drawbacks of NoSQL and, potentially, XML databases: how to ensure that the data is complete, meaning that all records contain the same data. We'll build a schema for interview-like content for a JSON document that we'll later convert to XML. The content for the interview object This is a complete JSON document that matches the schema. I cheated a little with the document...

Continue reading →

How opinionated is too opinionated?

Part of my love/hate relationship with Rails is that I think it is too opinionated for its own good. It makes it easier for people to write apps if you accept the opinions that DHH and the Rails community have baked into the platform over the years. Don't make me think, or why I switched to Rails from JavaScript SPAshttps://reviewbunny.app/blog/dont-make-me-think-or-why-i-switched-to-rails-from-javascript-spas makes a comparison between Javascript and the need to manually select the tools and technologies that we use in our projects in contrast to Rails and its "convention over configuration" approach. It made me think about the two opposite sides...

Continue reading →

Text Shadows in CSS

I've always liked shadows as a way to give depth to content that would otherwise be flat and uninspiring. My first approach at creating shadows in CSS was to use box-shadowhttps://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow, primarily in title boxes where the entire container would have a shadow and not the individual laters. text-shadowhttps://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow does the same thing for text that box-shadow does for boxes. As presented in the example below, the four values for the text-shadow property are: offset-x offset-y blur-radius color css h1 { color: rebeccapurple; font-size: 160px; text-shadow: 8px 4px 2px darkgrey; } Shadows are a nice way to provide depth to...

Continue reading →

CSS aspect ratio

In replaced elementshttps://developer.mozilla.org/en-US/docs/Web/CSS/Replacedelement, aspect ratiohttps://en.wikipedia.org/wiki/Aspectratioimage is the ratio of the width to the height of an image. Until recently we had to rely on the browser's calculations of "implicit" aspect ratios. Over time this was ok and worked well, the jump of text wasn't as bad as it is today or the images loaded fast enough so it wouldn't be a problem. Over time browsers implemented a more accurate way of calculating the aspect ratio. This would prevent jank and content shifting by setting the dimensions of the image before it is loaded. css img, inputtype="image", video, embed, iframe, marquee,...

Continue reading →