Skip to content

Commit

Permalink
Fixed generated assets and code formatting issues. (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Bellwood authored Dec 10, 2019
2 parents a511588 + d5af3c7 commit 39e3795
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
- v1-dependencies-

- run: composer install --no-interaction --prefer-dist
- run: composer lint || true
- run: composer lint

- run: npm run setup
- run: npm run js-lint || true
- run: npm run js-lint
- run: npm run gulp
- run: npm run styleguide

- run:
name: Assert the compiled assets were committed to the repository.
command: git --no-pager diff --exit-code css js styleguide || true
command: git --no-pager diff --exit-code css js styleguide

- run:
name: Store generated styleguide
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"sort-packages": true
},
"scripts": {
"lint": "phpcs --colors --ignore=vendor,node_modules,css,js --standard=Drupal,DrupalPractice ."
"lint": "phpcs --colors --ignore=vendor,node_modules,css,js,.tugboat --standard=Drupal,DrupalPractice ."
}
}
43 changes: 23 additions & 20 deletions govcms8_uikit_starter.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* GovCMS 8 UI-Kit Starter main theme file.
*/

use Drupal\block\Entity\Block;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatch;
use Drupal\block\Entity\Block;

/**
* Implements hook_form_system_theme_settings_alter().
*/
function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
// Create a section for My Theme settings.
$form['govcms8_uikit_starter_settings'] = [
'#type' => 'details',
'#title' => t('Custom Settings'),
'#description' => t('Configure GovCMS 8 UI-Kit Starter options'),
'#type' => 'details',
'#title' => t('Custom Settings'),
'#description' => t('Configure GovCMS 8 UI-Kit Starter options'),
'#weight' => -1000,
'#open' => TRUE,
];
Expand All @@ -32,7 +32,7 @@ function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStat
$form['govcms8_uikit_starter_settings']['header_style'] = [
'#type' => 'select',
'#title' => t('Header style'),
'#options' => [
'#options' => [
'' => t('-none-'),
'theme__header--dark' => t('Dark'),
'theme__header--alt' => t('Alt'),
Expand All @@ -45,7 +45,7 @@ function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStat
$form['govcms8_uikit_starter_settings']['main_nav_style'] = [
'#type' => 'select',
'#title' => t('Main navigation style'),
'#options' => [
'#options' => [
'' => t('-none-'),
'theme__main_nav--dark' => t('Dark'),
'theme__main_nav--alt' => t('Alt'),
Expand All @@ -58,7 +58,7 @@ function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStat
$form['govcms8_uikit_starter_settings']['side_nav_style'] = [
'#type' => 'select',
'#title' => t('Side navigation style'),
'#options' => [
'#options' => [
'' => t('-none-'),
'theme__side_nav--dark' => t('Dark'),
'theme__side_nav--alt' => t('Alt'),
Expand All @@ -71,7 +71,7 @@ function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStat
$form['govcms8_uikit_starter_settings']['footer_style'] = [
'#type' => 'select',
'#title' => t('Footer style'),
'#options' => [
'#options' => [
'' => t('-none-'),
'theme__footer--dark' => t('Dark'),
'theme__footer--alt' => t('Alt'),
Expand All @@ -84,7 +84,7 @@ function govcms8_uikit_starter_form_system_theme_settings_alter(&$form, FormStat
$form['govcms8_uikit_starter_settings']['local_task_style'] = [
'#type' => 'select',
'#title' => t('Local task style'),
'#options' => [
'#options' => [
'' => t('-none-'),
'theme__local-task--dark' => t('Dark'),
'theme__local-task--alt' => t('Alt'),
Expand Down Expand Up @@ -149,6 +149,9 @@ function govcms8_uikit_starter_form_alter(&$form, FormStateInterface $form_state
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function govcms8_uikit_starter_preprocess_menu(&$variables) {
$theme_settings_mappings = [
'side_nav_style' => [
Expand All @@ -172,10 +175,10 @@ function govcms8_uikit_starter_preprocess_menu(&$variables) {
$parent_link = $menu_link_manager->createInstance($parent_link_id);
$parent_title = $parent_link->getTitle();
$parent_url = $parent_link->getUrlObject();
$variables['parent_link'] = array(
$variables['parent_link'] = [
"title" => $parent_title,
"url" => $parent_url,
);
];
}
}
}
Expand Down Expand Up @@ -210,7 +213,8 @@ function govcms8_uikit_starter_preprocess_block(&$variables) {
];
govcms8_uikit_starter_theme_settings_mappings($variables, $theme_settings_mappings);

// Prepare a variable for logo width to be used in the branding block template.
// Prepare a variable for logo width to be used in the branding block
// template.
$logo_width = theme_get_setting('logo_width');
if ($logo_width) {
$variables['theme__logo_width'] = $logo_width . 'px';
Expand All @@ -222,7 +226,7 @@ function govcms8_uikit_starter_preprocess_block(&$variables) {
// Add a region variable to a block.
if (isset($variables["elements"]["#id"])) {
$block_id = $variables["elements"]["#id"];
$block = \Drupal\block\Entity\Block::load($block_id);
$block = Block::load($block_id);

if ($block) {
if (empty($variables["content"]["#type"]) || $variables["content"]["#type"] !== "form") {
Expand All @@ -234,14 +238,14 @@ function govcms8_uikit_starter_preprocess_block(&$variables) {
// Hide title on Main Menu.
if (isset($variables["elements"]["#id"])) {
if ($variables["elements"]["#id"] === "govcms8_uikit_starter_mainnavigation") {
$variables["hide_title"] = true;
$variables["hide_title"] = TRUE;
}
}

// Hide title on sidebar menus.
if (isset($variables["content"]["#menu_block_configuration"])) {
if ($variables["content"]["#menu_block_configuration"]["region"] === "sidebar") {
$variables["hide_title"] = true;
$variables["hide_title"] = TRUE;
}
}
}
Expand All @@ -260,7 +264,6 @@ function govcms8_uikit_starter_theme_suggestions_menu_alter(array &$suggestions,
*
* @param array $variables
* Theme variables array.
*
* @param array $theme_settings_mappings
* Array of mapping.
*/
Expand All @@ -279,15 +282,15 @@ function govcms8_uikit_starter_theme_settings_mappings(array &$variables, array
*
* @param array $links
* Link array.
*
* @param $path
* @param string $path
* Path to check.
*/
function govcms8_uikit_starter_theme_find_active_link(&$links, $path) {
function govcms8_uikit_starter_theme_find_active_link(array &$links, $path) {
foreach ($links as &$item) {
if ($item['url']->toString() === $path) {
$item['is_active'] = TRUE;
} elseif (!empty($item['below'])) {
}
elseif (!empty($item['below'])) {
govcms8_uikit_starter_theme_find_active_link($item['below'], $path);
}
}
Expand Down

0 comments on commit 39e3795

Please sign in to comment.