-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pre work for replacing IconComponent usages with iconPartial (#870)
This is the work needed before replacing IconComponent usages with iconPartial. Since there are many icon usages, it wouild be hard to see these changes if they were combined with the replacements. - register the relativePathHandler for SDK components so it can be used at runtime - fix bug in relativePathHandler where if the url is undefined, it will return something like "./undefined" instead of the value undefined. In previous usages of the helper, url was guarded from being null/undefined, but this won't be the case for iconPartial - add percy snapshots for a card with custom cta icons - fix test-sites gitignore negations not working properly - point the theme's test-site to the feature/icon-partial-i18n so we get the icon-partial change, and also i18n-ed assets so the spanish snapshots work - also collect code coverage on the hbshelpers folder J=SLAP-1297 TEST=manual,auto test that custom icons still work, both for section titles on universal and inside cards unit tests for relativePathHandler
- Loading branch information
Showing
16 changed files
with
183 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
public/* | ||
config/* | ||
pages/* | ||
cards/* | ||
directanswercards/* | ||
Gruntfile.js | ||
package-lock.json | ||
package.json | ||
webpack-config.js | ||
|
||
!cards/custom-cta-icons/ | ||
!config/global_config.json | ||
!config/locale_config.json | ||
!config/index.json | ||
!pages/index.html.hbs | ||
!public/iframe_test.html | ||
!public/overlay.html | ||
public/ | ||
config/ | ||
pages/ | ||
cards/ | ||
directanswercards/ | ||
Gruntfile.js | ||
package-lock.json | ||
package.json | ||
webpack-config.js | ||
!public/overlay.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{> cards/card_component componentName='custom-cta-icons' }} | ||
|
||
class custom_cta_iconsCardComponent extends BaseCard['custom-cta-icons'] { | ||
constructor(config = {}, systemConfig = {}) { | ||
super(config, systemConfig); | ||
} | ||
|
||
dataForRender(profile) { | ||
const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top'; | ||
|
||
return { | ||
title: profile.name, | ||
url: profile.website, | ||
target: linkTarget, | ||
titleEventOptions: this.addDefaultEventOptions(), | ||
date: Formatter.bigDate(profile), | ||
subtitle: Formatter.dateRange(profile), | ||
details: profile.description, | ||
CTA1: { | ||
label: 'Hitchhiker Thumb!', | ||
/** | ||
* @Test a custom icon url without iconName in the CTA | ||
* @Expect the custom icon to show up | ||
*/ | ||
iconUrl: 'static/assets/hitchhiker-thumb.jpeg', | ||
url: 'testUrl', | ||
target: linkTarget, | ||
eventType: 'RSVP', | ||
eventOptions: this.addDefaultEventOptions(), | ||
}, | ||
CTA2: { | ||
label: 'AYAYA', | ||
iconName: 'star', | ||
/** | ||
* @Test a custom icon url hen an iconName already exists | ||
* @Expect the custom icon to show up | ||
*/ | ||
iconUrl: 'static/assets/ayaya.png', | ||
url: 'testUrl', | ||
target: linkTarget, | ||
eventType: 'DRIVING_DIRECTIONS', | ||
eventOptions: this.addDefaultEventOptions(), | ||
} | ||
}; | ||
} | ||
|
||
static defaultTemplateName (config) { | ||
return 'cards/custom-cta-icons'; | ||
} | ||
} | ||
|
||
ANSWERS.registerTemplate( | ||
'cards/custom-cta-icons', | ||
{{{stringifyPartial (read 'cards/event-standard/template') }}} | ||
); | ||
ANSWERS.registerComponentType(custom_cta_iconsCardComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"verticalsToConfig": { | ||
"events": { | ||
"cardType": "custom-cta-icons", | ||
"label": "Eventos" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"verticalsToConfig": { | ||
"events": { | ||
"cardType": "custom-cta-icons" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import relativePathHandler from '../../hbshelpers/relativePathHandler'; | ||
|
||
it('works for undefined url', () => { | ||
const hash = { | ||
url: undefined, | ||
relativePath: '.' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual(undefined); | ||
}); | ||
|
||
it('works for null url', () => { | ||
const hash = { | ||
url: null, | ||
relativePath: '.' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual(null); | ||
}); | ||
|
||
it('works for blank string url', () => { | ||
const hash = { | ||
url: '', | ||
relativePath: '.' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual(''); | ||
}); | ||
|
||
it('works for relative url with relativePath', () => { | ||
const hash = { | ||
url: 'mySpecialAsset.jpg', | ||
relativePath: '.' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual('./mySpecialAsset.jpg'); | ||
}); | ||
|
||
it('works for relative url with relativePath that points back a level', () => { | ||
const hash = { | ||
url: 'mySpecialAsset.jpg', | ||
relativePath: '../..' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual('../../mySpecialAsset.jpg'); | ||
}); | ||
|
||
it('works when no relativePath', () => { | ||
const hash = { | ||
url: 'mySpecialAsset.jpg' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual('mySpecialAsset.jpg'); | ||
}); | ||
|
||
it('works with absolute url', () => { | ||
const hash = { | ||
url: '/mySpecialAsset.jpg', | ||
relativePath: '../../' | ||
}; | ||
expect(relativePathHandler({ hash })).toEqual('/mySpecialAsset.jpg'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters