diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1b4b984f7..f7429f2be 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -9,22 +9,9 @@ on: pull_request: jobs: - Coveralls: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [15.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npx jest tests/static/ --coverage - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + call_coveralls: + uses: yext/slapshot-reusable-workflows/.github/workflows/coverage.yml@v1 + with: + test_script: npx jest tests/static/ --coverage + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/percy-snapshots.yml b/.github/workflows/percy-snapshots.yml index f71776293..a5053af80 100644 --- a/.github/workflows/percy-snapshots.yml +++ b/.github/workflows/percy-snapshots.yml @@ -1,6 +1,6 @@ name: Percy Snapshots -on: +on: push: branches-ignore: dev/* pull_request: @@ -14,90 +14,46 @@ jobs: - id: nonce run: echo "::set-output name=result::${{ github.run_id }}-$(date +%s)" - default-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_default: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - iframe-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_iframe: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js iframe - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js iframe + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - spanish-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_spanish: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js spanish - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js spanish + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - rtl-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_rtl: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js rtl - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js rtl + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 48caaf756..2ecb067ec 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,19 +6,7 @@ name: Run Tests on: [push, pull_request] jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x, 15.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test + call_run_tests: + uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@v1 + with: + build_script: '' diff --git a/.github/workflows/sync_develop_and_main.yml b/.github/workflows/sync_develop_and_main.yml index 3c1bfb9d1..45808a607 100644 --- a/.github/workflows/sync_develop_and_main.yml +++ b/.github/workflows/sync_develop_and_main.yml @@ -1,27 +1,11 @@ -name: create PR from main to develop +name: Create PR from main to develop on: push: branches: [main, master] -permissions: - contents: read - pull-requests: write - jobs: - createPullRequest: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: extract package version - id: vars - run: | - PACKAGE_VERSION="v$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')" - echo ::set-output name=tag::${PACKAGE_VERSION} - - uses: repo-sync/pull-request@v2 - with: - source_branch: "${{ github.event.repository.default_branch }}" - destination_branch: "develop" - pr_title: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop" - pr_body: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop" - github_token: ${{ secrets.GITHUB_TOKEN }} + call_sync_develop_and_main: + uses: yext/slapshot-reusable-workflows/.github/workflows/sync_develop_and_main.yml@v1 + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml index e4a944be6..a246e47fa 100644 --- a/.github/workflows/version-update.yml +++ b/.github/workflows/version-update.yml @@ -4,49 +4,8 @@ on: push: branches: [release/*, hotfix/*] -permissions: - contents: write - pull-requests: write - jobs: - update-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - - name: update package version - id: vars - run: | - BRANCH_NAME="${GITHUB_REF#refs/heads/}" - PACKAGE_VERSION="${GITHUB_REF##*/}" - echo ::set-output name=branch::${BRANCH_NAME} - if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]] - then - if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+$ ]] - then - PACKAGE_VERSION="${PACKAGE_VERSION}.0" - fi - echo ::set-output name=version::${PACKAGE_VERSION} - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - if npm version ${PACKAGE_VERSION} | tee >( grep -q 'npm ERR! Version not changed' ) - then - echo "Package version is already in sync with branch name." - echo ::set-output name=should_create_pr::0 - exit 0 - fi - echo ::set-output name=should_create_pr::1 - git push -u origin HEAD:"dev/update-version-${PACKAGE_VERSION}" - else - echo "Branch name ${BRANCH_NAME} does not have the correct format with package version." - exit 1 - fi - - name: create version update pr - if: steps.vars.outputs.should_create_pr == 1 - uses: repo-sync/pull-request@v2 - with: - source_branch: "dev/update-version-${{ steps.vars.outputs.version }}" - destination_branch: "${{ steps.vars.outputs.branch }}" - pr_title: "Update Package Version to ${{ steps.vars.outputs.version }}" - pr_body: "*An automated PR which updates the version number in package.json and package-lock.json files*" - github_token: ${{ secrets.GITHUB_TOKEN }} + call_version_update: + uses: yext/slapshot-reusable-workflows/.github/workflows/version_update.yml@v1 + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wcag_test.yml b/.github/workflows/wcag_test.yml index c0a7aa60d..e2c267310 100644 --- a/.github/workflows/wcag_test.yml +++ b/.github/workflows/wcag_test.yml @@ -5,20 +5,7 @@ on: branches: [develop, hotfix/*, release/*, support/*] jobs: - WCAG-test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [14.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - run: npm run wcag \ No newline at end of file + call_wcag_test: + uses: yext/slapshot-reusable-workflows/.github/workflows/wcag_test.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site diff --git a/cards/card_component.js b/cards/card_component.js index 511d3fb92..6d1543dd3 100644 --- a/cards/card_component.js +++ b/cards/card_component.js @@ -80,32 +80,57 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component { cardData.feedbackEnabled = ANSWERS.getAnalyticsOptIn() && cardData.feedback; - const { details, showMoreDetails } = cardData; - - const cardDetails = details || ''; - const cardShowMoreConfig = showMoreDetails || {}; - const { showMoreLimit } = cardShowMoreConfig; - - // Set the value of excessDetailsToggle. Note that it is not enough to have a showMoreLimit. - // The card's details must extend past this limit as well for the toggling to be enabled. - const showExcessDetailsToggle = showMoreLimit && cardDetails.length > showMoreLimit; - - const truncatedDetails = showExcessDetailsToggle - ? `${cardDetails.substring(0, showMoreLimit)}...` - : ''; + const { showExcessDetailsToggle, truncatedDetails } = + this._getTruncatedDetails(cardData.details, cardData.showMoreDetails); this.validateDataForRender(cardData); return super.setState({ ...data, card: cardData, - showExcessDetailsToggle: showExcessDetailsToggle, - truncatedDetails: truncatedDetails, + showExcessDetailsToggle, + truncatedDetails, cardName: `{{componentName}}`, relativePath: `{{relativePath}}` }); } + /** + * Returns whether to render the excess details toggle, and + * if so, the truncated details text. + * + * @param {string} details + * @param {Object} showMoreDetails + * @param {number} showMoreDetails.showMoreLimit + * @param {string} showMoreDetails.truncatedDetails + */ + _getTruncatedDetails(details = '', showMoreDetails = {}) { + const { showMoreLimit, truncatedDetails: userSpecifiedTruncatedDetails } = showMoreDetails; + + if (userSpecifiedTruncatedDetails) { + const showExcessDetailsToggle = userSpecifiedTruncatedDetails.length < details.length + const truncatedDetails = showExcessDetailsToggle ? userSpecifiedTruncatedDetails : ''; + return { + showExcessDetailsToggle, + truncatedDetails + } + } + + const suffix = '...'; + + // Set the value of excessDetailsToggle. Note that it is not enough to have a showMoreLimit. + // The card's details must extend past this limit as well for the toggling to be enabled. + const showExcessDetailsToggle = showMoreLimit && (details.length + suffix.length > showMoreLimit); + + const truncatedDetails = showExcessDetailsToggle + ? details.substring(0, showMoreLimit) + suffix + : ''; + return { + showExcessDetailsToggle, + truncatedDetails + }; + } + validateDataForRender(data) { if (!data){ console.error('Error: nothing returned from dataForRender'); diff --git a/cards/faq-accordion/component.js b/cards/faq-accordion/component.js index 657614ec6..1286f47a0 100644 --- a/cards/faq-accordion/component.js +++ b/cards/faq-accordion/component.js @@ -21,7 +21,7 @@ class faq_accordionCardComponent extends BaseCard['faq-accordion'] { // If the card's details are longer than a certain character count, you can truncate the // text. A toggle will be supplied that can show or hide the truncated text. // showMoreDetails: { - // showMoreLimit: null, // Character count limit + // truncatedDetails: profile.answer ? ANSWERS.formatRichText(profile.answer, "answer", linkTarget, 500) : null, // The truncated rich text // showMoreText: '', // Label when toggle will show truncated text // showLessText: '' // Label when toggle will hide truncated text // }, @@ -111,6 +111,19 @@ class faq_accordionCardComponent extends BaseCard['faq-accordion'] { } }); + const showExcessDetailsToggleEls = this._container.querySelectorAll('.js-HitchhikerFaqAccordion-detailsToggle'); + const excessDetailsEls = this._container.querySelectorAll('.js-HitchhikerFaqAccordion-detailsText'); + if (showExcessDetailsToggleEls && excessDetailsEls) { + showExcessDetailsToggleEls.forEach(el => + el.addEventListener('click', () => { + contentEl.style.height = 'auto'; + showExcessDetailsToggleEls.forEach(toggleEl => toggleEl.classList.toggle('js-hidden')); + excessDetailsEls.forEach(detailsEl => detailsEl.classList.toggle('js-hidden')); + contentEl.style.height = `${contentEl.scrollHeight}px`; + }) + ); + } + super.onMount(); } diff --git a/cards/faq-accordion/template.hbs b/cards/faq-accordion/template.hbs index c57bd83c5..fc6e66935 100644 --- a/cards/faq-accordion/template.hbs +++ b/cards/faq-accordion/template.hbs @@ -50,21 +50,21 @@ {{#if card.details}}
{{#if showExcessDetailsToggle}} -
+
{{{truncatedDetails}}}
{{/if}} -
+
{{{card.details}}}
{{#if showExcessDetailsToggle}} - - -
{{> templates/vertical-full-page-map/markup/alternativeresults }} @@ -45,6 +44,7 @@ {{!-- {{> templates/vertical-full-page-map/markup/facets }} --}} {{!-- {{> templates/vertical-full-page-map/markup/filterbox }} --}} {{!--
--}} + {{!-- {{> templates/vertical-full-page-map/collapsible-filters/markup/viewresultsbutton }} --}}
diff --git a/templates/vertical-grid/collapsible-filters/script/filterlink.js b/templates/vertical-grid/collapsible-filters/script/filterlink.js index f04667012..0859913f8 100644 --- a/templates/vertical-grid/collapsible-filters/script/filterlink.js +++ b/templates/vertical-grid/collapsible-filters/script/filterlink.js @@ -11,5 +11,8 @@ ANSWERS.addComponent('FilterLink', { CollapsibleFilters.Helpers.clearSearch(); collapsibleFiltersInteractions.focusSearchBar(); }, + onCreate: () => { + collapsibleFiltersInteractions.setupResposiveFiltersLayout(); + }, ...{{{ json componentSettings.FilterLink }}} }); \ No newline at end of file diff --git a/templates/vertical-grid/page-config.json b/templates/vertical-grid/page-config.json index b311b8dad..c6e2d7c73 100644 --- a/templates/vertical-grid/page-config.json +++ b/templates/vertical-grid/page-config.json @@ -66,7 +66,7 @@ "": { // The vertical key from your search configuration // "label": "", // The name of the vertical in the section header and the navigation bar // "verticalLimit": 15, // The result count limit for vertical search - "universalLimit": 4, // The result count limit for universal search + "universalLimit": 3, // The result count limit for universal search "cardType": "product-prominentimage", // The name of the card to use - e.g. accordion, location, customcard // "icon": "star", // The icon to use on the card for this vertical "universalSectionTemplate": "grid-three-columns" diff --git a/templates/vertical-grid/page.html.hbs b/templates/vertical-grid/page.html.hbs index 1362ae503..ba627632c 100644 --- a/templates/vertical-grid/page.html.hbs +++ b/templates/vertical-grid/page.html.hbs @@ -26,25 +26,29 @@ The overlay partial should only be added to ONE page of your site, e.g. if you uncomment the partial for this page, you should not use it on any other page. --> {{!-- {{> layouts/overlay-suggestions }} --}} -
- {{> templates/vertical-grid/markup/spellcheck }} -
- {{> templates/vertical-grid/markup/verticalresultscount }} - {{> templates/vertical-grid/markup/appliedfilters }} - {{!-- {{> templates/vertical-grid/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-grid/collapsible-filters/markup/viewresultsbutton }} --}} +
+
+ + {{!--
--}} + {{!-- {{> templates/vertical-grid/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-grid/markup/filterbox }} --}} + {{!-- {{> templates/vertical-grid/markup/facets }} --}} + {{!--
--}}
- - {{!--
--}} - {{!-- {{> templates/vertical-grid/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-grid/markup/filterbox }} --}} - {{!-- {{> templates/vertical-grid/markup/facets }} --}} - {{!--
--}} -
- {{> templates/vertical-grid/markup/verticalresults }} - {{> templates/vertical-grid/markup/pagination }} - {{!-- {{> templates/vertical-grid/markup/qasubmission }} --}} +
+ {{> templates/vertical-grid/markup/spellcheck }} +
+ {{> templates/vertical-grid/markup/verticalresultscount }} + {{> templates/vertical-grid/markup/appliedfilters }} + {{!-- {{> templates/vertical-grid/collapsible-filters/markup/filterlink }} --}} +
+
+ {{> templates/vertical-grid/markup/verticalresults }} + {{> templates/vertical-grid/markup/pagination }} + {{!-- {{> templates/vertical-grid/markup/qasubmission }} --}} +
+ {{!-- {{> templates/vertical-grid/collapsible-filters/markup/viewresultsbutton }} --}}
{{!--
--}} @@ -42,6 +41,7 @@ {{!-- {{> templates/vertical-map/markup/facets }} --}} {{!-- {{> templates/vertical-map/markup/filterbox }} --}} {{!--
--}} + {{!-- {{> templates/vertical-map/collapsible-filters/markup/viewresultsbutton }} --}}
{{> templates/vertical-map/markup/verticalresults }} {{> templates/vertical-map/markup/pagination }} diff --git a/templates/vertical-standard/collapsible-filters/script/filterlink.js b/templates/vertical-standard/collapsible-filters/script/filterlink.js index f04667012..0859913f8 100644 --- a/templates/vertical-standard/collapsible-filters/script/filterlink.js +++ b/templates/vertical-standard/collapsible-filters/script/filterlink.js @@ -11,5 +11,8 @@ ANSWERS.addComponent('FilterLink', { CollapsibleFilters.Helpers.clearSearch(); collapsibleFiltersInteractions.focusSearchBar(); }, + onCreate: () => { + collapsibleFiltersInteractions.setupResposiveFiltersLayout(); + }, ...{{{ json componentSettings.FilterLink }}} }); \ No newline at end of file diff --git a/templates/vertical-standard/page.html.hbs b/templates/vertical-standard/page.html.hbs index 767d24184..4e51d87a2 100644 --- a/templates/vertical-standard/page.html.hbs +++ b/templates/vertical-standard/page.html.hbs @@ -29,25 +29,29 @@ partial for this page, you should not use it on any other page. --> {{!-- {{> layouts/overlay-suggestions }} --}}
- {{!-- {{> templates/vertical-standard/markup/directanswer }} --}} - {{> templates/vertical-standard/markup/spellcheck }} -
- {{> templates/vertical-standard/markup/verticalresultscount }} - {{> templates/vertical-standard/markup/appliedfilters }} - {{!-- {{> templates/vertical-standard/collapsible-filters/markup/filterlink }} --}} - {{!-- {{> templates/vertical-standard/collapsible-filters/markup/viewresultsbutton }} --}} +
+ + {{!--
--}} + {{!-- {{> templates/vertical-standard/markup/sortoptions }} --}} + {{!-- {{> templates/vertical-standard/markup/filterbox }} --}} + {{!-- {{> templates/vertical-standard/markup/facets }} --}} + {{!--
--}}
- - {{!--
--}} - {{!-- {{> templates/vertical-standard/markup/sortoptions }} --}} - {{!-- {{> templates/vertical-standard/markup/filterbox }} --}} - {{!-- {{> templates/vertical-standard/markup/facets }} --}} - {{!--
--}} -
- {{> templates/vertical-standard/markup/verticalresults }} - {{> templates/vertical-standard/markup/pagination }} - {{!-- {{> templates/vertical-standard/markup/qasubmission }} --}} +
+ {{!-- {{> templates/vertical-standard/markup/directanswer }} --}} + {{> templates/vertical-standard/markup/spellcheck }} +
+ {{> templates/vertical-standard/markup/verticalresultscount }} + {{> templates/vertical-standard/markup/appliedfilters }} + {{!-- {{> templates/vertical-standard/collapsible-filters/markup/filterlink }} --}} +
+
+ {{> templates/vertical-standard/markup/verticalresults }} + {{> templates/vertical-standard/markup/pagination }} + {{!-- {{> templates/vertical-standard/markup/qasubmission }} --}} +
+ {{!-- {{> templates/vertical-standard/collapsible-filters/markup/viewresultsbutton }} --}}