-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pre work for replacing IconComponent usages with iconPartial #870
Merged
oshi97
merged 5 commits into
feature/icon-partial
from
dev/icon-partial-before-replacements
Jul 1, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9f93fef
pre work for replacing IconComponent usages with iconPartial
oshi97 2c7ebb2
also collect coverage from hbshelpers
oshi97 d918a3c
make label Eventos
oshi97 9beee66
point to feature/icon-partial-i18n for now
oshi97 ff47572
support feature/<blah>-i18n branches
oshi97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for reasons apparently git is finicky and whether or not you put a star at the end of a path matters |
||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of crummy that we have to basically duplicate
isNonRelativeUrl
andrelativePathUrlHandler
. It'd be great if the JS inhbshelpers
could be inlined as a partial here. Would save us having to update the same code-block twice. Is there any non-janky way to do that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, at first I thought this was going to be hard because it's hard to get the path from entry.js to the hbshelpers folder. That path depends on the jambo config, and we don't want to use dynamic imports here (with like a require.resolve or something). BUT I'm remembering now that webpack lets you add resolve aliases. Will add in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lied. Webpack doesn't like it when you mix ES6 and commonjs, and unfortunately jambo only understands hbs helpers that are commonjs. So putting it into the bundle is probably out of the window for now.
I tried thinking about how to do the inlining method as well with just HBS, but obviously module.exports is not something hbs understands. We could do jank where we create an empty object called "module", then loop over the desired helpers, continually reassigning the value of module.exports and calling ANSWERS.registerHelper on it. jank !== not janky though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sad developer noises this was the pr #871
For whatever reason it works fine with our dev webpack build, just borks on prod ("it" being the first commit before I started trying random ideas)