theme

Drupal 11: Using SDC Component Library To Preview Single Directory Components

Single Directory Components (SDC) consist of a directory of files that go together to create a small component on a Drupal website. SDC can be nested together, which means that a consistent set of elements can be created and plugged together on a site.

The power of SDC comes from their ability to be self contained. If you have the need to build a complex component that displays data in a widget then building it as a SDC means that you can ensure that every time you include it, the same widget will be shown.

It is possible to add an SDC to your Drupal site without adding them into tempaltes first. You can use the SDC Component Library module to preview them whilst you are building them, and then integrate them into your site once they are ready.

Using Colour Schemes To Create Light And Dark Modes In CSS

Allowing users to switch between light and dark colour schemes on websites is a popular feature. You can often see a small sun or moon icon that allows you to change from light mode to dark colour scheme, or visa versa. Some operating systems and user agents also have the ability to activate a dark colour scheme, which websites also pick up and use.

This feature is so popular, in fact, that a number of browser extensions exist to allow users to force websites to be shown in certain colour schemes, the most popular ones making the site dark. Having a dark colour scheme on a website aids in readability, especially for people who have ADHD and similar disorders.

From a person perspective, having a dark colour scheme in a website means that I can view the content in the middle of the night without causing myself eye strain or disturbing anyone else. I often have trouble sleeping so the ability to read articles in the dark has become quite important to me.

Overriding Drupal 7 Theme Functions In Module Files

When overriding theme functions in Drupal 7 you would normally copy the theme function into the template.php and alter it to suit your needs. This isn't always convenient though, especially if you are trying to abstract functionality into modules and not have code in your theme layer that is reliant on module code. If you add theme override functions to your module files then they won't do anything as Drupal isn't looking for them there and won't pick them up.

It is possible to alter the theme registry in order to get Drupal to pick up your theme functions from your module code. This helps collect together code that performs a certain task and allows you to deploy theme alterations along with module updates.