Skip to content

Commit

Permalink
Adds a new sample events page and adds it to Percy (GoogleChrome#4604)
Browse files Browse the repository at this point in the history
* Refactors collection usage in the events layout, adds a new sample page and tells percy to take a snapshot of it.

* Updates percy/

* Moves the new sample page over to the handbook as that's where all the percy pages will ultimately live when this is released

* Disables javascript on the meet-the-team page to prevent an issue with the web-tabs component.

* Reenables js on the events page

* Adds data-unresolved attribute to the web-tabs component and removal to BaseElement@firstUpdated,  providing the ability to detect double render.

* Removes double negative.

* Fixes package-lock and adds the new page to the index file.

* Switches from unresolved to resolved.

* revert changes to unrelated file

* revert changes to unrelated file
  • Loading branch information
johnrich85 authored Feb 7, 2023
1 parent 1e7edb2 commit 87b328f
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 102 deletions.
3 changes: 2 additions & 1 deletion .percy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const SNAPSHOTS = [
'/en/docs/handbook/content-types/docs-landing/index.html',
'/en/docs/handbook/content-types/doc-post/index.html',
'/en/docs/handbook/content-types/landing/index.html',
'/en/docs/handbook/content-types/meet-the-team/index.html',
];

module.exports = {
Expand Down Expand Up @@ -33,6 +34,6 @@ module.exports = {
exclude: [
// Prevent percy to snapshot all index.html files in ./dist dir
({ name }) => !SNAPSHOTS.includes(name)
]
],
}
}
197 changes: 103 additions & 94 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"devDependencies": {
"@ava/babel": "^1.0.1",
"@google-cloud/secret-manager": "^3.2.2",
"@percy/cli": "^1.1.0",
"@percy/cli": "^1.16.0",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"ava": "^3.12.1",
Expand Down
12 changes: 6 additions & 6 deletions site/_includes/partials/events-list.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<web-tab title="{{ 'i18n.events.upcoming_events' | i18n(locale) }}">
<div id="upcoming-events"
class="display-grid grid-cols-1 grid-gap-400"
total-items="{{ collections.currentEvents.length }}">
{% for event in collections.currentEvents.slice(0,show) %}
total-items="{{ currentEvents.length }}">
{% for event in currentEvents.slice(0,show) %}
{% include 'partials/event-card.njk' %}
{% endfor %}
</div>

{% if collections.currentEvents.length > show %}
{% if currentEvents.length > show %}
<button id="load-upcoming-events"
class="load-more__button type--small display-inline-flex"
aria-controls="upcoming-events"
Expand All @@ -33,13 +33,13 @@
<web-tab title="{{ 'i18n.events.past_events' | i18n(locale) }}">
<div id="past-events"
class="display-grid grid-cols-1 grid-gap-400"
total-items="{{ collections.pastEvents.length }}">
{% for event in collections.pastEvents.slice(0,show) %}
total-items="{{ pastEvents.length }}">
{% for event in pastEvents.slice(0,show) %}
{% include 'partials/event-card.njk' %}
{% endfor %}
</div>

{% if collections.pastEvents.length > show %}
{% if pastEvents.length > show %}
<button id="load-past-events"
class="load-more__button type--small display-inline-flex"
aria-controls="upcoming-events"
Expand Down
8 changes: 8 additions & 0 deletions site/_js/web-components/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ import {LitElement} from 'lit-element';

/* eslint-disable require-jsdoc */
export class BaseElement extends LitElement {
/**
* @param {PropertyValues} changedProperties
*/
firstUpdated(changedProperties) {
this.setAttribute('data-resolved', '');
super.firstUpdated(changedProperties);
}

createRenderRoot() {
// Disable shadow DOM.
// Instead templates will be rendered in the light DOM.
Expand Down
5 changes: 5 additions & 0 deletions site/_js/web-components/web-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ export class WebTabs extends BaseElement {
}

render() {
if ('resolved' in this.dataset) {
return Array.from(this.children);
}

this._tabPanels = Array.from(this.children);
const tabs = this._formatTabs();

return html`
<div role="tablist">${tabs}</div>
${this._tabPanels}
Expand Down
Loading

0 comments on commit 87b328f

Please sign in to comment.