Skip to content
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
merged 5 commits into from
Jul 1, 2021

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Jun 30, 2021

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

- 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

J=SLAP-1297
TEST=manual,auto

test that custom icons still work, both for section titles on universal
and inside cards
@coveralls
Copy link

coveralls commented Jun 30, 2021

Coverage Status

Coverage decreased (-0.09%) to 6.525% when pulling ff47572 on dev/icon-partial-before-replacements into 00034ef on feature/icon-partial.

@@ -73,14 +73,32 @@
* Determine whether a URL is absolute or not.
* Common examples: "mailto:slapshot@gmail.com", "//yext.com", "https://yext.com"
*/
ANSWERS.registerHelper('isNonRelativeUrl', function(str) {
function isNonRelativeUrl(str) {
Copy link
Collaborator

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 and relativePathUrlHandler. It'd be great if the JS in hbshelpers 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?

Copy link
Contributor Author

@oshi97 oshi97 Jun 30, 2021

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

@oshi97 oshi97 Jun 30, 2021

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)

@@ -1,15 +1,17 @@
public/*
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder

@oshi97 oshi97 merged commit 2acdda1 into feature/icon-partial Jul 1, 2021
@oshi97 oshi97 deleted the dev/icon-partial-before-replacements branch July 1, 2021 15:27
oshi97 added a commit that referenced this pull request Jul 1, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants