-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OEL-450: Theme the site branding block. #3
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71ddb6a
OEL-450: Add block--system-branding-block.html.twig component.
abel-santos-corral 56702b0
OEL-450: Add test SiteBrandingBlockTest.
abel-santos-corral bcc49b9
OEL-450: Fix typo in block name and clean SiteBrandingBlockTest.php c…
abel-santos-corral 21f18a3
OEL-450: Add kernel test.
drishu 760db5a
OEL-450: Kernel block rendering test.
drishu 4a610f7
OEL-450: Move classes to link.
drishu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
templates/overrides/navigation/block--system-branding-block.html.twig
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends "block.html.twig" %} | ||
{# | ||
/** | ||
* @file | ||
* Theme override for a branding block. | ||
* | ||
* Each branding element variable (logo, name, slogan) is only available if | ||
* enabled in the block configuration. | ||
* | ||
* Available variables: | ||
* - site_logo: Logo for site as defined in Appearance or theme settings. | ||
* - site_name: Name for site as defined in Site information settings. | ||
* - site_slogan: Slogan for site as defined in Site information settings. | ||
*/ | ||
#} | ||
{% block content %} | ||
{% if site_logo %} | ||
<a href="{{ path('<front>') }}" rel="home" class="site-logo"> | ||
<img src="{{ site_logo }}" alt="{{ 'Home'|t }}" /> | ||
</a> | ||
{% endif %} | ||
{% if site_name %} | ||
<div class="site-name h1 text-white text-decoration-none align-bottom"> | ||
<a href="{{ path('<front>') }}" rel="home">{{ site_name }}</a> | ||
</div> | ||
{% endif %} | ||
{% if site_slogan %} | ||
<div class="site-slogan">{{ site_slogan }}</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\Tests\oe_whitelabel\Functional; | ||
|
||
use Drupal\Tests\BrowserTestBase; | ||
|
||
/** | ||
* Tests of Site Branding Block. | ||
*/ | ||
class SiteBrandingBlockTest extends BrowserTestBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static $modules = [ | ||
'config', | ||
'system', | ||
'ui_patterns', | ||
'ui_patterns_library', | ||
'ui_patterns_settings', | ||
'components', | ||
'field', | ||
'field_ui', | ||
'toolbar', | ||
'block', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
// Enable and set OpenEuropa Whitelabel Theme as default. | ||
\Drupal::service('theme_installer')->install(['oe_whitelabel']); | ||
\Drupal::configFactory() | ||
->getEditable('system.theme') | ||
->set('default', 'oe_whitelabel') | ||
->save(); | ||
|
||
/* Rebuild the ui_pattern definitions to collect the ones provided by | ||
oe_whitelabel itself. */ | ||
\Drupal::service('plugin.manager.ui_patterns')->clearCachedDefinitions(); | ||
|
||
// Ensure that the system branding block is placed as well. | ||
$this->drupalPlaceBlock('system_branding_block', [ | ||
'region' => 'header', | ||
]); | ||
|
||
} | ||
|
||
/** | ||
* Asserts classes contained at site branding block. | ||
*/ | ||
public function testClassesSiteName(): void { | ||
$this->drupalGet('<front>'); | ||
$assert_session = $this->assertSession(); | ||
$assert_session->elementExists('css', 'div.site-name.h1.text-white.text-decoration-none.align-bottom'); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use a functional test just to check some classes and/or markup.
Please use something similar to https://github.com/openeuropa/oe_theme/blob/2.x/tests/Kernel/RenderingTest.php#L103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the end that one was incompatible with blocks