diff --git a/core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php b/core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php index 29adc583dc..e7218b3c29 100644 --- a/core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php +++ b/core/lib/Drupal/Core/Layout/Icon/SvgIconBuilder.php @@ -28,14 +28,14 @@ class SvgIconBuilder implements IconBuilderInterface { * * @var int */ - protected $width = 250; + protected $width = 125; /** * The height of the SVG. * * @var int */ - protected $height = 300; + protected $height = 150; /** * The padding between regions. @@ -49,7 +49,7 @@ class SvgIconBuilder implements IconBuilderInterface { * * @var int|null */ - protected $strokeWidth = 2; + protected $strokeWidth = 1; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Layout/LayoutDefinition.php b/core/lib/Drupal/Core/Layout/LayoutDefinition.php index 967a0a38e9..c87b618d11 100644 --- a/core/lib/Drupal/Core/Layout/LayoutDefinition.php +++ b/core/lib/Drupal/Core/Layout/LayoutDefinition.php @@ -414,15 +414,14 @@ public function setIconMap($icon_map) { * (optional) The height of the icon. Defaults to 150. * @param int $stroke_width * (optional) If an icon map is used, the width of region borders. - * Defaults to 1. * @param int $padding * (optional) If an icon map is used, the padding between regions. Any - * value above 0 is valid. Defaults to 4. + * value above 0 is valid. * * @return array * A render array for the icon. */ - public function getIcon($width = 125, $height = 150, $stroke_width = 1, $padding = 4) { + public function getIcon($width = 125, $height = 150, $stroke_width = NULL, $padding = NULL) { $icon = []; if ($icon_path = $this->getIconPath()) { $icon = [ @@ -438,9 +437,13 @@ public function getIcon($width = 125, $height = 150, $stroke_width = 1, $padding ->setId($this->id()) ->setLabel($this->getLabel()) ->setWidth($width) - ->setHeight($height) - ->setPadding($padding) - ->setStrokeWidth($stroke_width); + ->setHeight($height); + if ($padding) { + $icon_builder->setPadding($padding); + } + if ($stroke_width) { + $icon_builder->setStrokeWidth($stroke_width); + } $icon = $icon_builder->build($icon_map); } return $icon; diff --git a/core/misc/dialog/off-canvas.layout.css b/core/misc/dialog/off-canvas.layout.css index 3b2b52e387..aa3a5373ea 100644 --- a/core/misc/dialog/off-canvas.layout.css +++ b/core/misc/dialog/off-canvas.layout.css @@ -1,6 +1,8 @@ /** * @file * Visual styling for layouts in the off-canvas dialog. + * + * See seven/css/layout/layout.css */ .layout-icon__region { diff --git a/core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php b/core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php index ac9d380808..13738e401c 100644 --- a/core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php @@ -24,6 +24,7 @@ class IconBuilderTest extends KernelTestBase { public function testBuild(SvgIconBuilder $icon_builder, $icon_map, $expected) { $renderer = $this->container->get('renderer'); + $icon_builder->setWidth(250)->setHeight(300); $build = $icon_builder->build($icon_map); $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($build, $renderer) { @@ -43,7 +44,8 @@ public function providerTestBuild() { $data['two_column'][] = (new SvgIconBuilder()) ->setId('two_column') - ->setLabel('Two Column'); + ->setLabel('Two Column') + ->setStrokeWidth(2); $data['two_column'][] = [['left', 'right']]; $data['two_column'][] = <<<'EOD' Two Column @@ -72,6 +74,7 @@ public function providerTestBuild() { EOD; $data['two_column_border_collapse'][] = (new SvgIconBuilder()) + ->setStrokeWidth(2) ->setPadding(-2); $data['two_column_border_collapse'][] = [['left', 'right']]; $data['two_column_border_collapse'][] = <<<'EOD' @@ -85,7 +88,8 @@ public function providerTestBuild() { EOD; - $data['stacked'][] = (new SvgIconBuilder()); + $data['stacked'][] = (new SvgIconBuilder()) + ->setStrokeWidth(2); $data['stacked'][] = [ ['sidebar', 'top', 'top'], ['sidebar', 'left', 'right'], diff --git a/core/themes/seven/css/layout/layout.css b/core/themes/seven/css/layout/layout.css index eb7c2bf0b3..39649e43c1 100644 --- a/core/themes/seven/css/layout/layout.css +++ b/core/themes/seven/css/layout/layout.css @@ -4,3 +4,11 @@ .page-content { margin-bottom: 80px; } + +/** + * Add color to layout icons. + */ +.layout-icon__region { + fill: #f5f5f2; + stroke: #666; +} diff --git a/core/themes/stable/css/core/dialog/off-canvas.layout.css b/core/themes/stable/css/core/dialog/off-canvas.layout.css index 3b2b52e387..aa3a5373ea 100644 --- a/core/themes/stable/css/core/dialog/off-canvas.layout.css +++ b/core/themes/stable/css/core/dialog/off-canvas.layout.css @@ -1,6 +1,8 @@ /** * @file * Visual styling for layouts in the off-canvas dialog. + * + * See seven/css/layout/layout.css */ .layout-icon__region {