If you are doing development on this extension, then you'll need to build your changes in the .css files. This requires the toolchain for SCSS=>CSS compilation which can get by simply running
npm i
Once you have the tools, you can run npx gulp watch
. This will monitor the SCSS files and automatically recompile whenever they are changed.
# npx command ensures you run the local version of gulp rather than the global one
npx gulp watch
If you would like to just compile files without watching, simply run npx gulp
.
npx gulp
Following is the list of git hooks, stored in .githooks/, that the project provides:
Installed automatically on npm i
. In addition of running the JS/SCSS linters on your changes, the hook will block the commit if it contains any .css files (see "Submitting a PR").
Installed automatically on npm i
. The hook will be triggered after a successful git merge
or git pull
command, and will rebuild the .css files via gulp sass
if it will detect new changes in any of the .scss files.
Needs to be installed manually (cp .githooks/post-checkout .git/hooks/post-checkout
). The hook does the same that post-merge
does, only difference being that is triggered whenever a checkout happens, most likely because HEAD
is pointing to a new branch.
It can be useful in case one wants to make sure to always rebuild when switching branches, or for automated setups when a branch is being deployed automatically on a remote site.
Given that the .css files are still part of the repo but should not be included in commits, if you want to make sure you don't accidentally end up trying to add them in a commit, you can run:
git update-index --skip-worktree css/*
which will make your local repo ignore any changes on both minified files. To undo it, simply run
git update-index --no-skip-worktree css/*
base/
Where vanilla Bootstrap is located. Contains the original Bootstrap SASS partials (scss/vendor/bootstrap/
) but also custom partials (scss/overrides
) and mixins (scss/mixins
) that allow using Bootstrap alongside the original CiviCRM stylecss/
Contains the two post-processed css files,bootstrap.css
andcustom-civicrm.css
fonts/
Font files used by the themejs/
Any custom javascript code that the theme relies onscss/
Contains the SASS partials that make up Shoreditch. It's split into two sub-foldersscss/civicrm
Contains the style that the theme applies to the existing core screens, in order to make them look like as if they were also Bootstrap-based pages.scss/bootstrap
Contains the custom Bootstrap theme. In here not only the base Bootstrap theme is customized, but also Bootstrap elements are augmented with new modifiers, and completely custom component are added.
Any style changes that are aimed at making the core screens look like they are part of the Bootstrap theme, should go here.
While custom-civicrm.css
can be thought of as the "legacy mode" of Shoreditch, this component can be considered as the actual theme.
There are three main types of changes you might want to introduce to the theme
- Tweak the overall look-and-feel. (i.e., color palette, border radius, line height) These are usually accomplished by working on the
overrides/_variables.scss
partial, as Bootstrap "exposes" many basic traits of the style as SASS variables. - Customize a Bootstrap component (i.e., changing the padding of
.panel
, adding a custom variation of.btn
) You can do that in theoverrides/_variables.scss
file, or if Bootstrap doesn't provide a SASS variable for the change you need to implement, you can write the overriding style in theoverrides/style/_{component}.scss
partial. - Add a custom component (i.e., wizard component) There are some component in CiviCRM that do not have any equivalent in the Bootstrap component library, and as such they have to be written from scratch. Those components go in the
components/
folder, each in an individual partial.
Shoreditch is first and foremost a customized Bootstrap theme, and as such it should not deviate from the original Bootstrap as much as possible.
Any custom variable, override, modifier, or component should be considered exceptions to the basic theme and should be justified and carefully planned, as each adds complexity that over time would make the theme harder to maintain and to work on.
Bootstrap comes packaged with plenty of SASS variables that covers many of the traits of the whole theme and of the individual components (like $padding-base-vertical
, $modal-inner-padding
, $badge-font-weight
, etc), so always make sure to check first if the changes that you want to implement can be done so by simply tweaking a variable value.
Sometimes you might need to add custom SASS variables to the overrides/_variable.scss
partial. In order to differentiate them from the original variables, always prefix them with $crm-
($crm-badge-min-width
, $crm-gray-lightest
, etc).
The overriding/style
folder contains the partials that are meant to override and augment the original style, and the partials are organized so that they reflect the structure in base/vendor/bootstrap/
.
If you need to add a partial in overriding/style
make sure that it is matching one of the originals.
For custom modifiers, stick with the dasherized bootstrap convention. So .panel-bigger
, .badge-square
, etc
For custom components, use the BEM convention, making sure to prefix the block name with crm_
. So .crm_custom-component
, .crm_foo__bar--baz
, etc.
Adding a custom components to achieve a specific design should be considered as a last resort, when no suitable Bootstrap component had been found that could either be used as-is or being augmented with a custom modifier.
The theme is meant to be as generic as possible, and as such no site/extension specific changes and/or components should be added to it.