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

feat(masthead): introduce web components #2960

Merged
merged 32 commits into from
Jul 6, 2020

Conversation

asudoh
Copy link
Contributor

@asudoh asudoh commented Jun 30, 2020

Related Ticket(s)

Refs #2861.

Description

This change introduces Web Components version of masthead (L0).

This change also introduces:

  • lit-html version of the icons defined in @carbon/ibmdotcom-styles. To do this, needed to hoist carbon-components/carbon-custom-elements dependencies given lit-html version of the icons that is create on-the-fly in development time isn't tied to packages/web-components
  • Several mix-ins for masthead style rules. This required given they are under deeply nested selectors that are hard to define custom elements selectors alongside
  • lint-staged support for TypeScript files

Changelog

New

  • Web Components version of masthead (L0)
  • lit-html version of the icons defined in @carbon/ibmdotcom-styles
  • lint-staged support for TypeScript files

Changed

  • Moved several style rules of masthead to mix-ins

This change introduces Web Components version of masthead (L0).

This change also introduces:

* `lit-html` version of the icons defined in
  `@carbon/ibmdotcom-styles`. To do this, needed to hoist
  `carbon-components`/`carbon-custom-elements` dependencies given
  `lit-html` version of the icons that is create on-the-fly in
  development time isn't tied to `packages/web-components`
* Several mix-ins for masthead style rules. This required given they
  are under deeply nested selectors that are hard to define custom
  elements selectors alongside
* `lit-staged` support for TypeScript files

Refs carbon-design-system#2861.
@asudoh asudoh added the package: web components Work necessary for the IBM.com Library web components package label Jun 30, 2020
@jeffchew
Copy link
Member

@asudoh I was running into a similar problem on another branch, do you know what's causing this?

Screen Shot 2020-06-30 at 8 50 21 AM

@asudoh asudoh force-pushed the web-components-masthead branch from dde7a04 to f82ad7f Compare June 30, 2020 13:00
@asudoh
Copy link
Contributor Author

asudoh commented Jun 30, 2020

@jeffchew Do you have the CircleCI log link? My finding is that it's likely specific to this PR (introduction of latest fetch-mock).

@asudoh asudoh force-pushed the web-components-masthead branch from f82ad7f to 8c9bc06 Compare June 30, 2020 13:05
@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 30, 2020

@jeffchew
Copy link
Member

@jeffchew Do you have the CircleCI log link? My finding is that it's likely specific to this PR (introduction of latest fetch-mock).

This is the PR that's having issues. I actually can replicate locally as well, but haven't had a chance to isolate the issue.

#2667

@asudoh
Copy link
Contributor Author

asudoh commented Jun 30, 2020

Thanks @jeffchew! Let's discuss further there.

@jeffchew
Copy link
Member

Looks great @asudoh!

Are there knobs that we can set for the story, like platform name, etc? It might also be worth creating as separate stories too and treat as a variation.

The masthead content below looks a little odd when you scroll down:

Screen Shot 2020-06-30 at 11 51 51 AM

@jeffchew
Copy link
Member

@asudoh noticed a couple of things with the masthead search. It is supposed to overlay the entire header when opened, but is showing as this:

Screen Shot 2020-06-30 at 11 55 02 AM

Also, when using the search typeahead, it seems to take over the whole storybook screen and can't find a way back:

masthead-search

@asudoh asudoh force-pushed the web-components-masthead branch 3 times, most recently from 37896ec to b403d00 Compare July 1, 2020 08:37
@asudoh asudoh force-pushed the web-components-masthead branch from b403d00 to 4a8bbbb Compare July 1, 2020 08:56
@asudoh
Copy link
Contributor Author

asudoh commented Jul 1, 2020

Thanks @jeffchew for reviewing! Added knobs for brand name and authentication state, and fixed the issues.

@asudoh asudoh force-pushed the web-components-masthead branch from c345ca0 to 1561052 Compare July 1, 2020 14:53
@jeffchew
Copy link
Member

jeffchew commented Jul 1, 2020

Thanks @asudoh ! Looks much better! I am still seeing the black banding when scrolling down though on the page, not sure if that's a storybook thing or the masthead causing it?

Also, I don't see the data-autoid attributes in the rendered markup.

@asudoh
Copy link
Contributor Author

asudoh commented Jul 2, 2020

Thanks @jeffchew!

I am still seeing the black banding when scrolling down though on the page, not sure if that's a storybook thing or the masthead causing it?

One question here; How did you make the Storybook itself black? I think reproducing the problem requiring to do so. given what I'm seeing is:

image

@asudoh
Copy link
Contributor Author

asudoh commented Jul 2, 2020

Fixed the issue in operating system's dark mode (I guess newer Storybook supports @media (prefers-color-scheme: dark)). Thank you @kennylam and everyone for your help!

@asudoh
Copy link
Contributor Author

asudoh commented Jul 3, 2020

As discussed, added documentation for analytics on how tag names and custom events can be used in Web Components to play the role of data-autoid: https://github.com/carbon-design-system/ibm-dotcom-library/blob/26c948c30cb67c1cea9e8c8c56fb02045058787b/packages/web-components/README.md#web-components-way-for-analytics

Also added missing dds-masthead-search-toggled custom event.

@jeffchew
Copy link
Member

jeffchew commented Jul 6, 2020

As discussed, added documentation for analytics on how tag names and custom events can be used in Web Components to play the role of data-autoid: https://github.com/carbon-design-system/ibm-dotcom-library/blob/26c948c30cb67c1cea9e8c8c56fb02045058787b/packages/web-components/README.md#web-components-way-for-analytics

Also added missing dds-masthead-search-toggled custom event.

Thank you @asudoh ! FYI, I have a separate issue for updating the README to be more adopter focused (#2916), so we an address some of these thoughts there:

  • Once we have the dds-dotcomshell, we should probably swap out the dds-link-with-icon with that.
  • I wonder if we should have a separate developer docs and link out the contents at the end to there?
  • I'm wondering if we should have a quick explanation of what lit-html is and why we're using it, and secondary to that why it's a peer dependency vs regular dependency.
  • Browser support: The url for building ibm.com experiences has the following browser support language (https://www.ibm.com/standards/web/browser-support), but it is also good to mention that IE isn't supported here.


## Web Components way for analytics

`@carbon/ibmdotcom-react`, etc. libraries have `data-autoid` attributes in several places, to convey better context than raw HTML `<div>`, etc. tags and their attributes when analytics libraries captures bubbling events e.g. `click` on `<body>` and inspects `event.target`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At minimum, should we add the data-autoid for the parent level tags? e.g. data-autoid="dds--masthead"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do <dds-masthead data-autoid="dds--masthead">. That said, <dds-masthead> tag name seems to serve the purpose of data-autoid, but did you meant that we'd want to duplicate it...?

Copy link
Member

@jeffchew jeffchew Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if for analytics they are tracking anything across different applications within IBM.com, and if they need to have that consistent stable selector language when going from one part of the site to another? So one IBM.com application is using React, another application is using web components, and another one is using vanilla. I might be overthinking it though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the thought overall makes sense. Given data-autoid inside shadow DOM doesn't make event.target.dataset.audoId work due to event retargeting as discussed, I thought that providing a new set of guidelines makes more sense instead of providing data-autoid that makes it looks like "compatible" but not actually fully.

But if we want to go with "partial compatibility" route I'm all for it.

@asudoh
Copy link
Contributor Author

asudoh commented Jul 6, 2020

Thank you for another review @jeffchew! Good points:

  • Once we have the dds-dotcomshell, we should probably swap out the dds-link-with-icon with that.

Makes sense.

  • I wonder if we should have a separate developer docs and link out the contents at the end to there?
  • I'm wondering if we should have a quick explanation of what lit-html is and why we're using it, and secondary to that why it's a peer dependency vs regular dependency.
  • Browser support: The url for building ibm.com experiences has the following browser support language (https://www.ibm.com/standards/web/browser-support), but it is also good to mention that IE isn't supported here.

All makes sense - Updated.

Copy link
Member

@jeffchew jeffchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this, we can probably get in the stable selectors in a separate PR or maybe sneak this in before merging in. Thank you @asudoh !

@jeffchew jeffchew added the Ready to merge Label for the pull requests that are ready to merge label Jul 6, 2020
@asudoh asudoh merged commit 3e3c3c5 into carbon-design-system:master Jul 6, 2020
@asudoh asudoh deleted the web-components-masthead branch July 6, 2020 22:15
@asudoh
Copy link
Contributor Author

asudoh commented Jul 6, 2020

Thank you @jeffchew for reviewing! Let's queue up stable selector thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: web components Work necessary for the IBM.com Library web components package Ready to merge Label for the pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants