A boilerplate for implementing the OCHA Common Design base-theme in a way that allows for "upstream" changes such as security updates, new features, and so forth. The sub-theme is ready to help you implement the following types of customizations:
- modifying the Common Design to customise its colors
- modifying the icon sprite to add your own icons
- override/extend base-theme templates
- adding/overriding/extending frontend components
Refer to Drupal 8+ Theming documentation for more information.
- Copy this directory to
/themes/custom/
- Rename the
common_design_subtheme.info.yml.example
tocommon_design_subtheme.info.yml
- Customize the
name
/description
fields of the info file. - Select the sub-theme in
/admin/appearance
and rebuild the cache.
- Set the logo
logo: 'img/logos/your-logo.svg'
in thecommon_design_subtheme.info.yml
file. - Adjust
--brand-logo-width
insidecss/brand.css
Replace the favicon in the theme's root, and the homescreen icons in img/
with branded versions
Change the CSS Vars in css/brand.css
and save the file. Sass is no longer needed in CD v7.
- Copy SVG icons from the Humanitarian icon set into the subtheme
img/icons
directory and follow the instructions in the common_design README to generate a sprite with those new icons. - Edit the subtheme's
templates/cd/cd-icons/cd-icons.html.twig
to include the generated sprite file.
Add new components by defining new libraries in common_design_subtheme.libraries.yml
and attaching them to relevant templates. Or use existing components from common_design.libraries.yml
base-theme by overriding Twig templates in the sub-theme and attaching the libraries like so:
{# Use a CD base-theme component #}
{{ attach_library('common_design/cd-teaser') }}
{# Attach a custom sub-theme library #}
{{ attach_library('common_design_subtheme/my-article-teaser') }}
Occasionally you might want to totally replace a given library that is output by core or CD base-theme. In that case, use libraries-override
to replace the library of your choice with the customized version. No additional work should be necessary to attach libraries inside Twig templates.
Core and CD base-theme libraries can be extended with small customizations by using the libraries-extend
directive in common_design_subtheme.info.yml
. By extending a library, your customizations automatically apply when any core or base-theme library would normally be output. Use this feature to override colors inside components, for example.
Override theme preprocess functions by copying from common_design.theme
and editing as needed. For example, if new icons are added, a new icon sprite will need to be generated and the common_design_preprocess_html
hook used to attach
the icon sprite to the page will need a new path to reflect the sub theme's icon sprite location.
Refer to common_design README for general details about base-theme and instructions for compilation. There should be no need to use Sass in the sub-theme anymore.
Refer to common_design README E2E testing for information about running tests.