diff --git a/core/lib/Drupal/Core/Layout/IconGenerator.php b/core/lib/Drupal/Core/Layout/IconGenerator.php index dfa0b1b..6b5a2c2 100644 --- a/core/lib/Drupal/Core/Layout/IconGenerator.php +++ b/core/lib/Drupal/Core/Layout/IconGenerator.php @@ -3,38 +3,14 @@ namespace Drupal\Core\Layout; /** - * A class that supports generating layout icons based on well-formed config. - * - * @internal - * The layout system is currently experimental and should only be leveraged by - * experimental modules and development releases of contributed modules. - * See https://www.drupal.org/core/experimental for more information. + * Generates layout icons from well-formed config. */ -class IconGenerator { +class IconGenerator implements IconGeneratorInterface { /** - * Generates a SVG based on a Layout's icon map. - * - * @param array $icon_map - * A two dimensional array representing the visual output of the layout. - * @param int $width - * (optional) The width of the generated SVG. Defaults to 250. - * @param int $height - * (optional) The height of the generated SVG. Defaults to 300. - * @param string $fill - * (optional) The fill color of regions. Defaults to 'lightgray'. - * @param string $stroke - * (optional) The color of region borders. Defaults to 'black'. - * @param int $stroke_width - * (optional) The width of region borders. Defaults to 2. - * @param int $padding - * (optional) The padding between regions. Any value above 0 is valid. - * Defaults to 5. - * - * @return array - * A render array representing a SVG icon. + * {@inheritdoc} */ - public function generateSvgFromIconMap($icon_map, $width = 250, $height = 300, $fill = 'lightgray', $stroke = 'black', $stroke_width = 2, $padding = 5) { + public function generateSvgFromIconMap(array $icon_map, $width = 250, $height = 300, $stroke_width = 1, $padding = 3, $fill = 'lightgray', $stroke = 'black') { $build = [ '#type' => 'html_tag', '#tag' => 'svg', diff --git a/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php b/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php new file mode 100644 index 0000000..369b33f --- /dev/null +++ b/core/lib/Drupal/Core/Layout/IconGeneratorInterface.php @@ -0,0 +1,52 @@ +getIconPath()) { $icon = [ '#theme' => 'image', '#uri' => $icon_path, + '#width' => $width, + '#height' => $height, ]; } elseif ($icon_map = $this->get('icon_map')) { - $icon = $this->getIconGenerator()->generateSvgFromIconMap($icon_map); + $icon = $this->getIconGenerator()->generateSvgFromIconMap($icon_map, $width, $height, $stroke_width, $padding, $fill, $stroke); } return $icon; } diff --git a/core/modules/layout_discovery/layout_discovery.layouts.yml b/core/modules/layout_discovery/layout_discovery.layouts.yml index 16ffc63..755a96b 100644 --- a/core/modules/layout_discovery/layout_discovery.layouts.yml +++ b/core/modules/layout_discovery/layout_discovery.layouts.yml @@ -39,6 +39,12 @@ layout_twocol_bricks: library: layout_discovery/twocol_bricks category: 'Columns: 2' default_region: middle + icon_map: + - [top] + - [first_above, second_above] + - [middle] + - [first_below, second_below] + - [bottom] regions: top: label: Top @@ -62,6 +68,10 @@ layout_threecol_25_50_25: library: layout_discovery/threecol_25_50_25 category: 'Columns: 3' default_region: second + icon_map: + - [top] + - [first, second, second, third] + - [bottom] regions: top: label: Top @@ -81,6 +91,10 @@ layout_threecol_33_34_33: library: layout_discovery/threecol_33_34_33 category: 'Columns: 3' default_region: first + icon_map: + - [top] + - [first, second, third] + - [bottom] regions: top: label: Top diff --git a/core/modules/layout_discovery/layouts/twocol/twocol.png b/core/modules/layout_discovery/layouts/twocol/twocol.png deleted file mode 100644 index f0a094e..0000000 --- a/core/modules/layout_discovery/layouts/twocol/twocol.png +++ /dev/null @@ -1,3 +0,0 @@ -PNG - - IHDR'sRGBIDATxӱMCQDADSD@EDY;E|0d߬\.Qq/RO ߾|~|~~FOiw~LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#a0H-`'0 {8h v? LÞ,OzS'#q 8nM.IENDB` \ No newline at end of file