Skip to content

Commit

Permalink
Merge branch 'develop' into feature/jwt-support
Browse files Browse the repository at this point in the history
  • Loading branch information
cea2aj committed Jun 1, 2021
2 parents 1cba1eb + c03b0e4 commit f69587d
Show file tree
Hide file tree
Showing 76 changed files with 3,038 additions and 1,492 deletions.
2 changes: 1 addition & 1 deletion .github/run_browserstack_acceptance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export BROWSERSTACK_BUILD_ID="${GITHUB_BRANCH} - ${GITHUB_RUN_ID}"
COMMIT_MSG_TITLE=$(git log -n 1 --pretty=format:%s)
export BROWSERSTACK_TEST_RUN_NAME=$COMMIT_MSG_TITLE

npm run acceptance -- --browsers browserstack:ie@11.0 browserstack:safari
npm run acceptance -- --browsers browserstack:ie@11.0 browserstack:safari browserstack:firefox
4 changes: 2 additions & 2 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: BrowserStack Acceptance Tests
name: Acceptance Tests

on: push

Expand Down Expand Up @@ -31,4 +31,4 @@ jobs:
- run: npm run setup-test-site
- run: npm run build-test-site
- name: Run Acceptance Tests
run: npm run acceptance -- --browsers chrome:headless firefox:headless
run: npm run acceptance -- --browsers chrome:headless
30 changes: 30 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will run our tests, generate an lcov code coverage file,
# and send that coverage to Coveralls

name: Code Coverage

on:
push:
branches-ignore: dev/*
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 }}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Answers Hitchhiker Theme

<div>
<a href='https://coveralls.io/github/yext/answers-hitchhiker-theme?branch=master'>
<img src='https://coveralls.io/repos/github/yext/answers-hitchhiker-theme/badge.svg?branch=master' alt='Coverage Status' />
</a>
</div>

A [Jambo](https://github.com/yext/jambo) theme for building Answers experiences.

Additonal resources for integrating Answers can be found at https://hitchhikers.yext.com/.
Expand Down
69 changes: 69 additions & 0 deletions cards/document-standard/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{> cards/card_component componentName='document-standard' }}

class document_standardCardComponent extends BaseCard['document-standard'] {
constructor(config = {}, systemConfig = {}) {
super(config, systemConfig);
}

/**
* This returns an object that will be called `card`
* in the template. Put all mapping logic here.
*
* @param profile profile of the entity in the card
*/
dataForRender(profile) {
let detailsData = '';
if (profile?.d_highlightedFields?.s_snippet) {
const { value, matchedSubstrings } = profile.d_highlightedFields.s_snippet;
detailsData = Formatter.highlightField(value, matchedSubstrings);
} else if (profile.s_snippet) {
detailsData = profile.s_snippet;
}

return {
title: profile.name, // The header text of the card
url: profile.website || profile.landingPageUrl, // If the card title is a clickable link, set URL here
target: '_top', // If the title's URL should open in a new tab, etc.
// image: '', // The URL of the image to display on the card
// altText: '', // The alternate text for the image
titleEventOptions: this.addDefaultEventOptions(),
subtitle: profile.externalArticleUpdateDate ? `Last Updated on ${profile.externalArticleUpdateDate}` : '', // The sub-header text of the card
details: detailsData, // The text in the body of the card
// The primary CTA of the card
CTA1: {
label: (profile.c_primaryCTA ? profile.c_primaryCTA.label : null), // The CTA's label
iconName: 'chevron', // The icon to use for the CTA
url: Formatter.generateCTAFieldTypeLink(profile.c_primaryCTA), // The URL a user will be directed to when clicking
target: '_top', // Where the new URL will be opened
eventType: 'CTA_CLICK', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
// ariaLabel: '', // Accessible text providing a descriptive label for the CTA
},
// The secondary CTA of the card
CTA2: {
label: profile.c_secondaryCTA ? profile.c_secondaryCTA.label : null,
iconName: 'chevron',
url: Formatter.generateCTAFieldTypeLink(profile.c_secondaryCTA),
target: '_top',
eventType: 'CTA_CLICK',
eventOptions: this.addDefaultEventOptions(),
// ariaLabel: '',
}
};
}

/**
* The template to render
* @returns {string}
* @override
*/
static defaultTemplateName (config) {
return 'cards/document-standard';
}
}

ANSWERS.registerTemplate(
'cards/document-standard',
{{{stringifyPartial (read 'cards/document-standard/template') }}}
);
ANSWERS.registerComponentType(document_standardCardComponent);
91 changes: 91 additions & 0 deletions cards/document-standard/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<div class="HitchhikerDocumentStandard {{cardName}}">
{{> image }}
<div class="HitchhikerDocumentStandard-body">
{{> title }}
{{> subtitle }}
<div class="HitchhikerDocumentStandard-contentWrapper">
<div class="HitchhikerDocumentStandard-info">
{{> details }}
</div>
{{> ctas }}
</div>
</div>
</div>

{{#*inline 'image'}}
{{#if card.image}}
<div class="HitchhikerDocumentStandard-imgWrapper">
<img class="HitchhikerDocumentStandard-img" src="{{#unless (isNonRelativeUrl card.image)}}{{@root.relativePath}}/{{/unless}}{{card.image}}" alt="{{#if card.altText}}{{card.altText}}{{/if}}"/>
</div>
{{/if}}
{{/inline}}

{{#*inline 'title'}}
{{#if card.title}}
<div class="HitchhikerDocumentStandard-title">
{{#if card.url}}
<a class="HitchhikerDocumentStandard-titleLink js-HitchhikerDocumentStandard-titleLink"
href="{{#unless (isNonRelativeUrl card.url)}}{{@root.relativePath}}/{{/unless}}{{card.url}}"
data-eventtype="TITLE_CLICK"
data-eventoptions='{{json card.titleEventOptions}}'
target={{#if card.target}}"{{card.target}}"{{else}}"_top"{{/if}}>
{{card.title}}
</a>
{{else}}
{{card.title}}
{{/if}}
</div>
{{/if}}
{{/inline}}

{{#*inline 'subtitle'}}
{{#if card.subtitle}}
<div class="HitchhikerDocumentStandard-subtitle">
{{card.subtitle}}
</div>
{{/if}}
{{/inline}}

{{#*inline 'details'}}
{{#if card.details}}
<div class="HitchhikerDocumentStandard-cardDetails">
<div class="HitchhikerDocumentStandard-detailsText js-HitchhikerCard-detailsText">
{{{card.details}}}
</div>
</div>
{{/if}}
{{/inline}}

{{#*inline 'ctas'}}
{{#if (any (all card.CTA1 card.CTA1.url card.CTA1.label) (all card.CTA2 card.CTA2.url card.CTA2.label))}}
<div class="HitchhikerDocumentStandard-ctasWrapper">
{{> CTA card.CTA1 ctaName="primaryCTA" }}
{{> CTA card.CTA2 ctaName="secondaryCTA" }}
</div>
{{/if}}
{{/inline}}

{{#*inline 'CTA'}}
{{#if (all url label)}}
<div class="HitchhikerDocumentStandard-{{ctaName}}">
<a class="HitchhikerCTA js-HitchhikerCTA{{#if modifiers}} {{modifiers}}{{/if}}"
href="{{#unless (isNonRelativeUrl url)}}{{@root.relativePath}}/{{/unless}}{{url}}"
data-eventtype="{{eventType}}"
data-eventoptions='{{json eventOptions}}'
target="{{#if target}}{{target}}{{else}}_top{{/if}}"
{{#if ariaLabel}}aria-label="{{ariaLabel}}"{{/if}}>
{{#if (any iconName iconUrl)}}
<div class="HitchhikerCTA-iconWrapper">
<div class="HitchhikerCTA-icon" data-component="IconComponent" data-opts='{
"iconUrl": "{{#if iconUrl}}{{#unless (isNonRelativeUrl iconUrl)}}{{@root.relativePath}}/{{/unless}}{{iconUrl}}{{/if}}",
"iconName": "{{iconName}}"
}'></div>
</div>
{{/if}}
<div class='HitchhikerCTA-iconLabel'>
{{label}}
</div>
</a>
</div>
{{/if}}
{{/inline}}
2 changes: 1 addition & 1 deletion cards/menuitem-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class menuitem_standardCardComponent extends BaseCard['menuitem-standard'] {
CTA1: {
label: 'Order Now', // The CTA's label
iconName: 'chevron', // The icon to use for the CTA
url: profile.orderUrl, // The URL a user will be directed to when clicking
url: profile.orderUrl && profile.orderUrl.url, // The URL a user will be directed to when clicking
target: linkTarget, // Where the new URL will be opened
eventType: 'CTA_CLICK', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
Expand Down
2 changes: 1 addition & 1 deletion cards/multilang-menuitem-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class multilang_menuitem_standardCardComponent extends BaseCard['multilang-menui
CTA1: {
label: {{ translateJS phrase='Order Now' }}, // The CTA's label
iconName: 'chevron', // The icon to use for the CTA
url: profile.orderUrl, // The URL a user will be directed to when clicking
url: profile.orderUrl && profile.orderUrl.url, // The URL a user will be directed to when clicking
target: linkTarget, // Where the new URL will be opened
eventType: 'CTA_CLICK', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
Expand Down
71 changes: 71 additions & 0 deletions cards/multilang-product-prominentvideo/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{> cards/card_component componentName='multilang-product-prominentvideo' }}

class multilang_product_prominentvideoCardComponent extends BaseCard['multilang-product-prominentvideo'] {
constructor(config = {}, systemConfig = {}) {
super(config, systemConfig);
}

/**
* This returns an object that will be called `card`
* in the template. Put all mapping logic here.
*
* @param profile profile of the entity in the card
*/
dataForRender(profile) {
const youtubeUrl = Formatter.getYoutubeUrl(profile.videos);
// const vimeoUrl = profile.c_vimeo;

return {
title: profile.name, // The header text of the card
url: profile.landingPageUrl, // If the card title is a clickable link, set URL here
target: '_top', // If the title's URL should open in a new tab, etc.
titleEventOptions: this.addDefaultEventOptions(),
subtitle: profile.featuredMessage?.description, // The sub-header text of the card
videoUrl: youtubeUrl,
details: profile.richTextDescription ? ANSWERS.formatRichText(profile.richTextDescription, 'richTextDescription', '_top') : null, // The text in the body of the card
// 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.
// Note: If you are using rich text for the details, you should not enable this feature.
// showMoreDetails: {
// showMoreLimit: 24, // Character count limit
// showMoreText: {{ translateJS phrase='Show more' }}, // Label when toggle will show truncated text
// showLessText: {{ translateJS phrase='Show less' }} // Label when toggle will hide truncated text
// },
// The primary CTA of the card
CTA1: {
label: profile.c_primaryCTA ? profile.c_primaryCTA.label : null, // The CTA's label
iconName: 'chevron', // The icon to use for the CTA
url: Formatter.generateCTAFieldTypeLink(profile.c_primaryCTA), // The URL a user will be directed to when clicking
target: '_top', // Where the new URL will be opened
eventType: 'CTA_CLICK', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
// ariaLabel: '', // Accessible text providing a descriptive label for the CTA
},
// The secondary CTA of the card
CTA2: {
label: profile.c_secondaryCTA ? profile.c_secondaryCTA.label : null,
iconName: 'chevron',
url: Formatter.generateCTAFieldTypeLink(profile.c_secondaryCTA),
target: '_top',
eventType: 'CTA_CLICK',
eventOptions: this.addDefaultEventOptions(),
// ariaLabel: '',
}
};
}

/**
* The template to render
* @returns {string}
* @override
*/
static defaultTemplateName (config) {
return 'cards/multilang-product-prominentvideo';
}
}

ANSWERS.registerTemplate(
'cards/multilang-product-prominentvideo',
{{{stringifyPartial (read 'cards/multilang-product-prominentvideo/template') }}}
);
ANSWERS.registerComponentType(multilang_product_prominentvideoCardComponent);
Loading

0 comments on commit f69587d

Please sign in to comment.