A responsive UBC CLF (Common Look and Feel) theme for Drupal using Tailwind and Bootstrap. Created by the UBC IT Web Services Department.
Kraken is a theme for Drupal 10+, providing UBC-branded units with the basic structure of the UBC CLF (Common Look and Feel).
Include the theme in your project using composer require ubc-web-services/kraken
Then, use the theme as a starterkit to create your own:
cd web
php core/scripts/drupal generate-theme [themename] --name "[themename]" --starterkit kraken --path themes/custom
You should then alter the generated theme as needed and leave kraken untouched.
To make changes to the theme CSS and Javascript, you are required to use the command-line tools.
Ensure that you have node.js installed, version 12 or higher. To confirm your version, navigate to the Kraken theme directory in your command-line and type node -v
.
From the theme root, install the theme dependencies:
npm install
This will install everything required to work with the CSS and Javascript:
There are four main node.js commands defined in in /package.json
.
The two most common commands to run:
npm run dev
/src/css
directory, excluding the subdirectories, and saves the minified files in /css
. Settings in /postcss.config.js
/src/css
directory, excluding the subdirectories, and saves the unminified files in /js
. Settings in /webpack.common.js
and /webpack.dev.js
npm run prod
src > css
directory, excluding the subdirectories, and saves the minified files in /css
. Settings in /postcss.config.js
/src/css
directory, excluding the subdirectories, and saves the minified files in /js
with a .min.js
extension. Settings in /webpack.common.js
and /webpack.prod.js
.map
file) to facilitate debugging. Settings in /webpack.prod.js
There are also additional commands for CSS property sorting:
npm run css-lint
/src/css
directory for the order in which properties are declared and best practices.npm run css-fix
npm run css-lint
command.The theme makes extensive use of utility classes provided by Tailwind.
All configuration for Tailwind utilities are set in /tailwind.config.js
. The configuration uses UBC default colours, fonts, regular spacing, etc. More details about this file can be found in the Tailwind documentation.
Two very important places where it diverges fro the documentation:
md:text-white hover:text-black
become md--text-white hover--text-black
When running the production build script (npm run prod
), PurgeCSS is used to scan all Twig and Javascript files and remove any Tailwind utilities that are not in use. This allows for us to deliver a considerably smaller set of CSS classes. Note that classes not provided by Tailwind are never purged.
Additionally, all vendor prefixes for supported browsers are added automatically with Autoprefixer, so there is no need to add these (e.g. -webkit
).
I highly recommend installing the Tailwind VS Code extension. It provides code completion for Tailwind utility classes as defined in the tailwind.config.js
file. Another useful utility is the Headwind VS Code extension, that sorts classes in your markup based on an opinionated order.
Once installed and set to default, you can adjust the following theme settings:
var(--color-primary)
, --color-secondary
and --color-accent
CSS variables. These are also mapped to Tailwind classes.use
tag