- Create a custom module (I'm calling mine
mymodule
) and place it in/modules/custom/mymodule
- Add the
mymodule.module
file and place in the custom mode - Create the
mymodule.libraries.yml
file and place in the new library that points to the CSS - Create the CSS file within a
css
directory. Name it the same thing that you have in themymodule.libraries.yml
(gin-global.css)
Last active
January 4, 2023 16:40
-
-
Save mherchel/b7d14cf49ec54550c90b091fe4f28bd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Custom Gin styles here. */ | |
.my-gin-selector { | |
color: red; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gin-global: | |
css: | |
component: | |
css/gin-global.css: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_preprocess_HOOK(). | |
*/ | |
function mymodule_custom_preprocess_html(&$variables, $hook) { | |
$activeThemeName = \Drupal::service('theme.manager')->getActiveTheme()->getName(); | |
if ($activeThemeName === 'gin') { | |
$variables['#attached']['library'][] = 'mymodule/gin-global'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment