Skip to content

Commit

Permalink
Merge 919929d into 00034ef
Browse files Browse the repository at this point in the history
  • Loading branch information
oshi97 committed Jun 30, 2021
2 parents 00034ef + 919929d commit 07a01ca
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 35 deletions.
3 changes: 2 additions & 1 deletion cards/event-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class event_standardCardComponent extends BaseCard['event-standard'] {
CTA1: {
label: 'RSVP', // The CTA's label
iconName: 'calendar', // The icon to use for the CTA
url: profile.ticketUrl || profile.website, // The URL a user will be directed to when clicking
iconUrl: 'static/assets/slapshot.png',
url: '123', // The URL a user will be directed to when clicking
target: linkTarget, // Where the new URL will be opened
eventType: 'RSVP', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
Expand Down
7 changes: 4 additions & 3 deletions cards/location-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class location_standardCardComponent extends BaseCard['location-standard'] {
// image: '', // The URL of the image to display on the card
showOrdinal: true, // Show the map pin number on the card. Only supported for universal search
CTA1: { // The primary call to action for the card
label: 'Call', // The label of the CTA
iconName: 'phone', // The icon to use for the CTA
url: Formatter.phoneLink(profile), // The URL a user will be directed to when clicking
label: 'RSVP', // The CTA's label
iconName: 'calendar', // The icon to use for the CTA
iconUrl: 'static/assets/slapshot.png',
url: '123',
target: linkTarget, // If the URL will be opened in a new tab, etc.
eventType: 'TAP_TO_CALL', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(), // The analytics event options for CTA clicks
Expand Down
4 changes: 2 additions & 2 deletions cards/multilang-event-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class multilang_event_standardCardComponent extends BaseCard['multilang-event-st
// },
// The primary CTA of the card
CTA1: {
label: {{ translateJS phrase='RSVP' context='RSVP is a verb' }}, // The CTA's label
label: 'RSVP', // The CTA's label
iconName: 'calendar', // The icon to use for the CTA
url: profile.ticketUrl || profile.website, // The URL a user will be directed to when clicking
iconUrl: 'static/assets/slapshot.png',
target: linkTarget, // Where the new URL will be opened
eventType: 'RSVP', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(),
Expand Down
8 changes: 5 additions & 3 deletions cards/multilang-location-standard/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ class multilang_location_standardCardComponent extends BaseCard['multilang-locat
// image: '', // The URL of the image to display on the card
showOrdinal: true, // Show the map pin number on the card. Only supported for universal search
CTA1: { // The primary call to action for the card
label: {{ translateJS phrase='Call' context='Call is a verb' }}, // The label of the CTA
iconName: 'phone', // The icon to use for the CTA
url: Formatter.phoneLink(profile), // The URL a user will be directed to when clicking

label: 'RSVP', // The CTA's label
iconName: 'calendar', // The icon to use for the CTA
iconUrl: 'static/assets/slapshot.png',
url: '123',
target: linkTarget, // If the URL will be opened in a new tab, etc.
eventType: 'TAP_TO_CALL', // Type of Analytics event fired when clicking the CTA
eventOptions: this.addDefaultEventOptions(), // The analytics event options for CTA clicks
Expand Down
9 changes: 9 additions & 0 deletions hbshelpers/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Returns true if every parameter is truthy.
*
* @param {...any} args
* @returns {boolean}
*/
module.exports = function all(...args) {
return args.filter(item => item).length === args.length;
}
31 changes: 5 additions & 26 deletions script/core.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
},
onReady: () => {
window.AnswersExperience.AnswersInitializedPromise.resolve();
HitchhikerJS.registerHbsHelpers();
ANSWERS.registerHelper('close-card-svg', () => {
return ANSWERS.renderer.SafeString({{{stringifyPartial (read 'static/assets/images/close-card') }}});
});
{{> @partial-block }}
Expand All @@ -55,32 +60,6 @@
{{#if global_config.conversionTrackingEnabled}}
ANSWERS.setConversionsOptIn(true);
{{/if}}
ANSWERS.registerHelper('all', function (...args) {
return args.filter(item => item).length === args.length;
});
ANSWERS.registerHelper('any', function (...args) {
return args.filter(item => item).length > 1;
});
ANSWERS.registerHelper('matches', function(str, regexPattern) {
const regex = new RegExp(regexPattern)
return str && str.match(regex);
});
/**
* Determine whether a URL is absolute or not.
* Common examples: "mailto:slapshot@gmail.com", "//yext.com", "https://yext.com"
*/
ANSWERS.registerHelper('isNonRelativeUrl', function(str) {
const absoluteURLRegex = /^(\/|[a-zA-Z]+:)/;
return str && str.match(absoluteURLRegex);
});
ANSWERS.registerHelper('close-card-svg', () => {
return ANSWERS.renderer.SafeString({{{stringifyPartial (read 'static/assets/images/close-card') }}});
});
}
}).catch(err => {
window.AnswersExperience.AnswersInitializedPromise.reject('Answers failed to initialized.');
Expand Down
3 changes: 3 additions & 0 deletions static/js/HitchhikerJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ const runtimeConfig = new RuntimeConfig();
window.AnswersExperience = new AnswersExperience(runtimeConfig);

export * from './video-apis';

import registerHbsHelpers from './registerHbsHelpers';
export { registerHbsHelpers };
19 changes: 19 additions & 0 deletions static/js/registerHbsHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const all = require('HbsHelpers/all') ;
const any = require('HbsHelpers/any');
const isNonRelativeUrl = require('HbsHelpers/isNonRelativeUrl');
const relativePathHandler = require('HbsHelpers/relativePathHandler');

export default function registerHbsHelpers() {
ANSWERS.registerHelper('all', all);
ANSWERS.registerHelper('any', any);
ANSWERS.registerHelper('isNonRelativeUrl', isNonRelativeUrl);
ANSWERS.registerHelper('relativePathHandler', relativePathHandler);

/**
* @deprecated in favor of isNonRelativeUrl
*/
ANSWERS.registerHelper('matches', function(str, regexPattern) {
const regex = new RegExp(regexPattern)
return str && str.match(regex);
});
}
79 changes: 79 additions & 0 deletions static/package-lock.json

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

1 change: 1 addition & 0 deletions static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@yext/cta-formatter": "^1.0.0",
"babel-loader": "^8.1.0",
"comment-json": "^3.0.2",
"copy-webpack-plugin": "^9.0.1",
"css-loader": "^3.4.2",
"esbuild-loader": "^2.13.1",
"file-loader": "^5.1.0",
Expand Down
12 changes: 12 additions & 0 deletions static/webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,19 @@ module.exports = function () {
jamboInjectedData = getCleanedJamboInjectedData(jamboInjectedData)
jamboInjectedData = JSON.stringify(jamboInjectedData)
}
const baseHbsHelpersPath = path.resolve(
__dirname, jamboConfig.dirs.themes, jamboConfig.defaultTheme, 'hbshelpers');
fs.copySync(baseHbsHelpersPath, path.join(jamboConfig.dirs.output, 'hbshelpers'));

const plugins = [
// new CopyWebpackPlugin({
// patterns: [
// {
// from: path.resolve(__dirname, jamboConfig.dirs.themes, jamboConfig.defaultTheme, 'hbshelpers'),
// to: path.join(jamboConfig.dirs.output, 'hbshelpers')
// },
// ],
// }),
new MiniCssExtractPlugin({
filename: pathData => {
const chunkName = pathData.chunk.name;
Expand Down Expand Up @@ -86,6 +97,7 @@ module.exports = function () {
resolve: {
alias: {
static: path.resolve(__dirname, jamboConfig.dirs.output, 'static'),
HbsHelpers: path.resolve(__dirname, jamboConfig.dirs.output, 'hbshelpers'),
}
},
output: {
Expand Down

0 comments on commit 07a01ca

Please sign in to comment.