Skip to content

Commit

Permalink
Merge pull request #223 from localgovdrupal/1.x
Browse files Browse the repository at this point in the history
Release 1.2.14
  • Loading branch information
finnlewis authored Jun 27, 2022
2 parents 22d5a1f + 68c9b78 commit 77df1b9
Show file tree
Hide file tree
Showing 9 changed files with 326 additions and 3 deletions.
214 changes: 214 additions & 0 deletions .github/workflows/localgov_microsites.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
##
# Managed by https://github.com/localgovdrupal/github_workflow_manager
---
name: Test LocalGov Microsites localgovdrupal/localgov_base drupal-theme

on:
push:
branches:
- '1.x'
pull_request:
branches:
- '1.x'

env:
LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov_base
LOCALGOV_DRUPAL_PROJECT_PATH: web/themes/contrib/localgov_base

jobs:

build:
name: Install LocalGov Microsites
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '1.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Save git branch and git repo names to env if this is not a pull request
if: github.event_name != 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "HEAD_USER=localgovdrupal" >> $GITHUB_ENV
- name: Save git branch and git repo names to env if this is a pull request
if: github.event_name == 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
export HEAD="${{ github.event.pull_request.head.label }}"
echo "HEAD_USER=${HEAD%%:*}" >> $GITHUB_ENV
- name: Set composer branch reference for version branches
if: endsWith(github.ref, '.x')
run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV

- name: Set composer branch reference for non-version branches
if: endsWith(github.ref, '.x') == false
run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV

- name: Get the latest tagged release for branch version
run: |
LATEST_RELEASE=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GIT_BASE%'.x'} | grep -Po '(?<=refs/tags/)[^"]+' | tail -1)
if [ -z $LATEST_RELEASE ]; then LATEST_RELEASE=1.x-dev; fi
echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV
- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Clone drupal_container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Create LocalGov Microsites project
run: |
composer create-project --stability dev --no-install localgovdrupal/localgov_microsites_project ./html "${{ matrix.localgov-version }}"
composer --working-dir=./html require --no-install localgovdrupal/localgov_microsites:${{ matrix.localgov-version }}-dev
composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }}
composer --working-dir=./html install
- name: Obtain the test target using Composer
if: env.HEAD_USER == 'localgovdrupal'
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${LOCALGOV_DRUPAL_PROJECT}.git
composer global config github-oauth.github.com ${{ github.token }}
composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}"
- name: Obtain the test target using Git
if: env.HEAD_USER != 'localgovdrupal'
uses: actions/checkout@v2
with:
path: ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}

phpcs:
name: Coding standards checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '1.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run coding standards checks
run: |
cd html
./bin/phpcs -p ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpstan:
name: Deprecated code checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '1.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run deprecated code checks
run: |
cd html
./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpunit:
name: PHPUnit tests
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '1.x'
drupal-version:
- '~9.3'
php-version:
- '7.4'
- '8.1'

steps:

- name: Clone Drupal container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
- name: Start Docker environment
run: docker-compose -f docker-compose.yml up -d

- name: Run PHPUnit tests
run: |
mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest
sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist
docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html'
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4 ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}"
6 changes: 6 additions & 0 deletions css/base/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ body {
--ia-block-bg-color: var(--color-white);
--ia-block-bg-color-promoted: var(--color-white);

/* Link component */
--link-icon-margin: var(--spacing-smaller);

/* Link and summary component */
--link-and-summary-title-icon-margin: var(--spacing-smaller);

/* Featured Subsite */
--featured-subsite-bg-color: var(--color-grey-light);

Expand Down
2 changes: 1 addition & 1 deletion css/components/link-and-summary.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.link-block__title-icon {
flex-shrink: 0;
margin-right: var(--spacing-smaller);
margin-right: var(--link-and-summary-title-icon-margin);
}

.link-block__title {
Expand Down
10 changes: 10 additions & 0 deletions css/components/link.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.link-wrapper {
display: flex;
align-items: center;
}

.link-icon {
flex-shrink: 0;
margin-right: var(--link-icon-margin);
}

3 changes: 3 additions & 0 deletions css/components/link.ie11.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.link-icon {
margin-right: 0.5rem;
}
4 changes: 4 additions & 0 deletions css/layout/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
justify-content: center;
}

.lgd-row--vertically-centered {
align-items: center;
}

.lgd-row > * {
margin-right: calc(var(--grid-column-spacing) / 2);
margin-left: calc(var(--grid-column-spacing) / 2);
Expand Down
6 changes: 6 additions & 0 deletions localgov_base.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ link-and-summary:
css/components/link-and-summary.ie11.css: {}
css/components/link-and-summary.css: {}

link:
css:
theme:
css/components/link.ie11.css: {}
css/components/link.css: {}

key-contacts:
css:
theme:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<div class="link-block__title-wrapper">
{% include "@localgov_base/includes/icons/icon.html.twig" with {
icon_name: title_icon,
icon_wrapper_element: 'div',
icon_classes: 'link-block__title-icon',
}
%}
Expand All @@ -77,4 +76,4 @@
{{ content|without('localgov_link') }}
</div>

</div>
</div>
81 changes: 81 additions & 0 deletions templates/paragraphs/paragraph--localgov-link.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{#
/**
* @file
* Default theme implementation to display a paragraph.
*
* Available variables:
* - paragraph: Full paragraph entity.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - paragraph.getCreatedTime() will return the paragraph creation timestamp.
* - paragraph.id(): The paragraph ID.
* - paragraph.bundle(): The type of the paragraph, for example, "image" or "text".
* - paragraph.getOwnerId(): The user ID of the paragraph author.
* See Drupal\paragraphs\Entity\Paragraph for a full list of public properties
* and methods for the paragraph object.
* - content: All paragraph items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - paragraphs: The current template type (also known as a "theming hook").
* - paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an
* "Image" it would result in "paragraphs--type--image". Note that the machine
* name will often be in a short form of the human readable label.
* - paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a
* preview would result in: "paragraphs--view-mode--preview", and
* default: "paragraphs--view-mode--default".
* - view_mode: View mode; for example, "preview" or "full".
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_paragraph()
*
* @ingroup themeable
*/
#}

{%
set classes = [
'link',
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished'
]
%}

{% if not localgov_base_remove_css %}
{{ attach_library('localgov_base/link') }}
{% endif %}

{% set title_icon = 'chevron-right' %}

<div{{ attributes.addClass(classes) }}>

{% if paragraph.localgov_url.value %}
<div class="link-wrapper">
{% include "@localgov_base/includes/icons/icon.html.twig" with {
icon_name: title_icon,
icon_classes: 'link-icon',
}
%}
<div class="link-content">
<a href="{{ content.localgov_url.content }}">
{{ content.localgov_title.0 }}
</a>
</div>
</div>
{% endif %}

{% if content|without('localgov_url','localgov_title') %}
<div class="link-block__content">
{{ content|without('localgov_url','localgov_title') }}
</div>
{% endif %}

</div>

0 comments on commit 77df1b9

Please sign in to comment.