summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-09-22 10:17:07 +0100
committerAlex Pott2014-09-22 10:17:07 +0100
commitce7fefdb1d76a1829f921417f56f14877e6a27fd (patch)
treebf327bf1bce059c7d67633eff11114ac6ce9c6d0
parente5921e78dd091da38326639b8c204a5d43f16149 (diff)
Issue #2228745 by Wim Leers, sqndr, nod_, undertext: Fixed Color module doesn't look for CSS files declared in a library.
-rw-r--r--core/modules/color/color.module30
-rw-r--r--core/modules/color/src/Tests/ColorTest.php2
-rw-r--r--core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc12
-rw-r--r--core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml2
-rw-r--r--core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml5
-rw-r--r--core/modules/color/tests/modules/color_test/themes/color_test_theme/css/colors.css7
-rw-r--r--core/themes/bartik/bartik.info.yml13
7 files changed, 59 insertions, 12 deletions
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index a0c0896..b192709 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -94,6 +94,36 @@ function color_css_alter(&$css) {
}
/**
+ * Implements hook_library_alter().
+ *
+ * Replaces style sheets declared in libraries with color-altered style sheets.
+ */
+function color_library_alter(&$library, $name) {
+ $active_theme = \Drupal::theme()->getActiveTheme();
+ $theme_key = $active_theme->getName();
+ $theme_libraries = $active_theme->getLibraries();
+ if (in_array($name, $theme_libraries)) {
+ // Override stylesheets.
+ $color_paths = \Drupal::config('color.theme.' . $theme_key)->get('stylesheets');
+ if (!empty($color_paths)) {
+ foreach ($library['css'] as &$css) {
+ // Loop over the path array with recolored CSS files to find matching
+ // paths which could replace the non-recolored paths.
+ foreach ($color_paths as $color_path) {
+ // Color module currently requires unique file names to be used,
+ // which allows us to compare different file paths.
+ if (drupal_basename($css['data']) == drupal_basename($color_path)) {
+ // Replace the path to the new css file.
+ // This keeps the order of the stylesheets intact.
+ $css['data'] = $color_path;
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
* Implements hook_preprocess_page().
*
* Replace the logo with the colored version if available.
diff --git a/core/modules/color/src/Tests/ColorTest.php b/core/modules/color/src/Tests/ColorTest.php
index fb400a3..acf17ff 100644
--- a/core/modules/color/src/Tests/ColorTest.php
+++ b/core/modules/color/src/Tests/ColorTest.php
@@ -66,7 +66,7 @@ class ColorTest extends WebTestBase {
),
'color_test_theme' => array(
'palette_input' => 'palette[bg]',
- 'scheme' => '',
+ 'scheme' => 'custom',
'scheme_color' => '#3b3b3b',
),
);
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
index 904e71c..bf0affe 100644
--- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
@@ -8,13 +8,25 @@
$info = array(
'fields' => array(
'bg' => t('Main background'),
+ 'text' => t('Text color'),
),
'schemes' => array(
'default' => array(
'title' => t('Default'),
'colors' => array(
'bg' => '#ff0000',
+ 'text' => '#0000ff',
),
),
+ 'custom' => array(
+ 'title' => t('Custom'),
+ 'colors' => array(
+ 'bg' => '#ff0000',
+ 'text' => '#3b3b3b',
+ ),
+ ),
+ ),
+ 'css' => array(
+ 'css/colors.css',
),
);
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml
index 01f8ffe..4fbd9bf 100644
--- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.info.yml
@@ -3,3 +3,5 @@ type: theme
description: 'Theme for testing the color module'
version: VERSION
core: 8.x
+libraries:
+ - color_test_theme/base
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml
new file mode 100644
index 0000000..afe4318
--- /dev/null
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml
@@ -0,0 +1,5 @@
+base:
+ version: VERSION
+ css:
+ theme:
+ css/colors.css: {}
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/css/colors.css b/core/modules/color/tests/modules/color_test/themes/color_test_theme/css/colors.css
new file mode 100644
index 0000000..07a4193
--- /dev/null
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/css/colors.css
@@ -0,0 +1,7 @@
+html {
+ color: #0000ff;
+}
+
+body {
+ color: #ff0000;
+}
diff --git a/core/themes/bartik/bartik.info.yml b/core/themes/bartik/bartik.info.yml
index bd0bf89..22b8a8d 100644
--- a/core/themes/bartik/bartik.info.yml
+++ b/core/themes/bartik/bartik.info.yml
@@ -4,17 +4,8 @@ description: 'A flexible, recolorable theme with many regions and a responsive,
package: Core
version: VERSION
core: 8.x
-# @todo use library version once color module is fixed #2228745
-#libraries:
-# - bartik/base
-#
-stylesheets:
- all:
- - css/layout.css
- - css/style.css
- - css/colors.css
- print:
- - css/print.css
+libraries:
+ - bartik/base
ckeditor_stylesheets:
- css/ckeditor-iframe.css
regions: