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): spacing style regression fix and maintainability refactor #11252

Merged
merged 33 commits into from
Jan 11, 2024

Conversation

jkaeser
Copy link
Member

@jkaeser jkaeser commented Dec 19, 2023

Related Ticket(s)

Resolves #11251

Description

This PR mostly refactors masthead source code to be more maintainable and removes dead code. Other than the style fixes, it should result in no visible changes to the masthead.

Changelog

Styles

Changed

  • Makes necessary functions available to Sass stylesheets to fix style regressions.

Removed

  • Removes Cloud-specific masthead styles.

Services Store

Changed

  • Deprecates MastheadProfileContent type.
  • Deprecates Translation.mastheadNav in favor of Translation.masthead.nav.
  • Deprecates Translation.profileMenu in favor of Translation.masthead.profileMenu.

Removed

  • Removes references to v1 data structures that are no longer in use.

IBM.com Web Components

Changed

  • Deprecates the navLinks Masthead Composite property in favor of the more descriptive l0Data property.
  • Splits out the Masthead Composite's main render method into more digestible render methods per logical section.
  • Untangles the knot that was the renderNavItems method by providing dedicated renderTopNav and renderLeftNav methods for the desktop and mobile experiences.
  • Extracts distinct chunks of logic into their own methods for readability and in some cases reuse across the newly split render methods.

Removed

  • Removes Cloud-specific masthead.
  • Removes non-functional customNavLinks property. Use l0Data or l1Data instead.
  • Removes masthead v1's leftover CTA functionality.

@jkaeser jkaeser added package: styles Work necessary for the Carbon for IBM.com styles package package: web components Work necessary for the IBM.com Library web components package owner: Innovation Team used when the engineering work will be done by Hybrid Cloud with DDS engineers as consultants Masthead L0/L1 v2 used when component or pattern is part of the Mashead V2 update effort package: services Work necessary for the Carbon for IBM.com services package labels Dec 19, 2023
@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 19, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Dec 19, 2023

@jkaeser jkaeser marked this pull request as ready for review December 21, 2023 16:06
@jkaeser jkaeser requested a review from a team as a code owner December 21, 2023 16:06
@jkaeser jkaeser requested review from ariellalgilmore and annawen1 and removed request for a team December 21, 2023 16:06
@jkaeser jkaeser requested a review from m4olivei January 5, 2024 14:25
Copy link
Contributor

@m4olivei m4olivei left a comment

Choose a reason for hiding this comment

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

Noticed that the search function is not showing up in the Masthead > Default story with the latest changes. Toggling the knob doesn't make it appear. Also missing from the "Search open onload" story.

image

@jkaeser jkaeser requested a review from m4olivei January 9, 2024 18:27
Copy link
Contributor

@m4olivei m4olivei left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for the search fix.

@kennylam kennylam added the Ready to merge Label for the pull requests that are ready to merge label Jan 9, 2024
@jkaeser jkaeser closed this Jan 10, 2024
@jkaeser jkaeser reopened this Jan 10, 2024
@kodiakhq kodiakhq bot removed the Ready to merge Label for the pull requests that are ready to merge label Jan 11, 2024
Copy link
Contributor

kodiakhq bot commented Jan 11, 2024

This PR currently has a merge conflict. Please resolve this and then re-add the Ready to merge label.

Resolves carbon-design-system#11210

**Changed**

- Updates masthead documentation to match expected behavior in v2.
- Fixes incorrect React wrapper Masthead demonstrations in Storybook.

**Removed**

- Removes docs specific to IBM Cloud that have been made unnecessary in v2.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
@jkaeser jkaeser added Ready to merge Label for the pull requests that are ready to merge and removed 👀 eyes needed labels Jan 11, 2024
@kodiakhq kodiakhq bot merged commit 67cc49b into carbon-design-system:main Jan 11, 2024
12 of 20 checks passed
@jkaeser jkaeser deleted the feat/masthead-v2-cleanup branch January 11, 2024 17:59
kodiakhq bot pushed a commit that referenced this pull request Feb 1, 2024
### Related Ticket(s)

Previously fixed in #10986, but that was unwittingly wiped away by #11252

### Description

Fixes an issue where `<c4d-masthead-container>` wipes away user-set L0 data with translations fetched from an API.

This PR takes a different approach from the original fix. The root problem is that the masthead container isn't aware of any `l0Data` passed in before setting that property with translation data. I figured we can make the container a little smarter and handle the logic internally rather than adding another property to the masthead composite and complicating the public API.

In order to facilitate this, I needed the `ConnectMixin` to pass a reference to the class instance into the `mapStateToProps` function it expects classes to define. This empowers the container to first check if it has L0 data before resorting to the translations API data.

As a result, users can reliably set the `l0Data` property on either `<c4d-masthead-container>` or `<c4d-masthead-composite>` and expect the same outcome.

### Changelog

**New**

- `ConnectMixin` passes a class instance reference as an argument in the `mapStateToProps` function.

**Changed**

- `<c4d-masthead-container>` will prefer using L0 data passed by user before resorting to automatically fetched translation data.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
kennylam pushed a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Mar 21, 2024
…ctor (carbon-design-system#11252)

Resolves carbon-design-system#11251

This PR mostly refactors masthead source code to be more maintainable and removes dead code. Other than the style fixes, it should result in no visible changes to the masthead.

- Makes necessary functions available to Sass stylesheets to fix style regressions.

- Removes Cloud-specific masthead styles.
---
- Deprecates `MastheadProfileContent` type.
- Deprecates `Translation.mastheadNav` in favor of `Translation.masthead.nav`.
- Deprecates `Translation.profileMenu` in favor of `Translation.masthead.profileMenu`.

- Removes references to v1 data structures that are no longer in use.
---
- Deprecates the `navLinks` Masthead Composite property in favor of the more descriptive `l0Data` property.
- Splits out the Masthead Composite's main `render` method into more digestible render methods per logical section.
- Untangles the knot that was the `renderNavItems` method by providing dedicated `renderTopNav` and `renderLeftNav` methods for the desktop and mobile experiences.
- Extracts distinct chunks of logic into their own methods for readability and in some cases reuse across the newly split render methods.

- Removes Cloud-specific masthead.
- Removes non-functional `customNavLinks` property. Use `l0Data` or `l1Data` instead.
- Removes masthead v1's leftover CTA functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Masthead L0/L1 v2 used when component or pattern is part of the Mashead V2 update effort owner: Innovation Team used when the engineering work will be done by Hybrid Cloud with DDS engineers as consultants package: services Work necessary for the Carbon for IBM.com services package package: styles Work necessary for the Carbon for IBM.com styles package 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.

[web-components]: Masthead has some styling issues
4 participants