Skip to content

Commit 67cc49b

Browse files
authored
feat(masthead): spacing style regression fix and maintainability refactor (#11252)
## 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.
1 parent 08343f7 commit 67cc49b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+420
-6786
lines changed

packages/services-store/src/actions/__tests__/translateAPI.test.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ const mockTranslation: Partial<Translation> = {
3838
},
3939
{
4040
title: 'menu-title-foo',
41-
menuSections: [
41+
submenu: [
4242
{
43-
menuItems: [
44-
{
45-
title: 'menu-item-title-bar',
46-
url: 'https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/bar',
47-
},
48-
],
43+
title: 'menu-item-title-bar',
44+
url: 'https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/bar',
4945
},
5046
],
5147
},
@@ -54,7 +50,7 @@ const mockTranslation: Partial<Translation> = {
5450
};
5551

5652
const endpoint =
57-
'/common/carbon-for-ibm-dotcom/translations/masthead-footer/v2';
53+
'/common/carbon-for-ibm-dotcom/translations/masthead-footer/v2.1';
5854

5955
describe('Redux actions for `TranslateAPI`', () => {
6056
it('dispatches the action to set translation data', () => {

packages/services-store/src/reducers/__tests__/translateAPI.test.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ const mockTranslation: Partial<Translation> = {
2525
},
2626
{
2727
title: 'menu-title-foo',
28-
menuSections: [
28+
submenu: [
2929
{
30-
menuItems: [
31-
{
32-
title: 'menu-item-title-bar',
33-
url: 'https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/bar',
34-
},
35-
],
30+
title: 'menu-item-title-bar',
31+
url: 'https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/bar',
3632
},
3733
],
3834
},

packages/services-store/src/types/translateAPI.ts

+41-96
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license
33
*
4-
* Copyright IBM Corp. 2020, 2023
4+
* Copyright IBM Corp. 2020, 2024
55
*
66
* This source code is licensed under the Apache-2.0 license found in the
77
* LICENSE file in the root directory of this source tree.
@@ -29,69 +29,29 @@ export interface BasicLinkSet {
2929
links: BasicLink[];
3030
}
3131

32-
/**
33-
* A feature in mega panel.
34-
*/
35-
export interface MegapanelFeature {
36-
heading?: string;
37-
imageUrl?: string;
38-
linkTitle?: string;
39-
linkUrl?: string;
40-
}
41-
42-
/**
43-
* A content in mega panel.
44-
*/
45-
export interface MegapanelContent {
46-
headingTitle?: string;
47-
headingUrl?: string;
48-
description?: string;
49-
quickLinks: BasicLinkSet;
50-
feature: MegapanelFeature;
32+
export interface L0Menu {
33+
items: L0MenuItem[];
5134
}
5235

53-
/**
54-
* A menu item in masthead.
55-
*/
56-
export interface MastheadMenuItem {
57-
title: string;
58-
titleEnglish?: string;
59-
url?: string;
60-
highlighted?: boolean;
61-
megaPanelViewAll?: boolean;
62-
megapanelContent?: MegapanelContent;
36+
export interface L0MenuItem extends BasicLink {
37+
submenu?: L0Megamenu | BasicLink[];
6338
}
6439

65-
/**
66-
* A menu section in masthead.
67-
*/
68-
export interface MastheadMenuSection {
69-
heading?: string;
70-
menuItems: MastheadMenuItem[];
40+
export interface L0Megamenu {
41+
sections: Megapanel[];
42+
highlights?: MegapanelLinkGroup[];
43+
viewAll?: BasicLink;
7144
}
7245

73-
/**
74-
* An item in masthead.
75-
*/
76-
export interface MastheadLink {
77-
title: string;
78-
titleEnglish?: string;
79-
url?: string;
80-
hasMenu?: boolean;
81-
hasMegapanel?: boolean;
82-
megamenuLayout?: 'tab' | 'list';
83-
menuSections?: MastheadMenuSection[];
46+
export interface Megapanel {
47+
heading?: BasicLink;
48+
groups: MegapanelLinkGroup[];
49+
viewAll?: BasicLink;
8450
}
8551

86-
/**
87-
* A menu section for masthead
88-
*
89-
* @deprecated
90-
*/
91-
export interface LegacyMastheadL1 {
92-
title: string;
93-
url?: string;
94-
menuItems?: MastheadLink[];
52+
export interface MegapanelLinkGroup {
53+
heading?: BasicLink;
54+
links?: BasicLink[];
9555
}
9656

9757
/**
@@ -176,12 +136,13 @@ export interface MastheadLogoData {
176136

177137
/**
178138
* Cloud Masthead Profile content
139+
*
140+
* @deprecated
179141
*/
180142
export interface MastheadProfileContent {
181143
iconLabel: string;
182144
links: MastheadProfileItem[];
183145
ctaButtons: MastheadProfileItem[];
184-
contactUsButton: string;
185146
}
186147

187148
/**
@@ -194,11 +155,16 @@ export interface MiscLabels {
194155
* The translation data for ibm.com sites
195156
*/
196157
export interface Translation {
158+
/**
159+
* Main masthead navigation data.
160+
*
161+
* @deprecated Use masthead.nav instead.
162+
*/
197163
mastheadNav: {
198164
/**
199165
* The nav links.
200166
*/
201-
links: MastheadLink[];
167+
links: L0MenuItem[];
202168
};
203169

204170
/**
@@ -211,8 +177,25 @@ export interface Translation {
211177
*/
212178
footerThin: BasicLink[];
213179

180+
/**
181+
* Masthead items other than main navigation
182+
*/
183+
masthead: {
184+
logo: MastheadLogoData;
185+
nav: L0MenuItem[];
186+
contact: MastheadProfileItem;
187+
profileMenu: {
188+
unauthenticated: MastheadProfileItem[];
189+
authenticated: MastheadProfileItem[];
190+
signedin: MastheadProfileContent;
191+
signedout: MastheadProfileContent;
192+
};
193+
};
194+
214195
/**
215196
* The profile menus.
197+
*
198+
* @deprecated Use masthead.profileMenu instead.
216199
*/
217200
profileMenu: {
218201
/**
@@ -226,18 +209,6 @@ export interface Translation {
226209
signedout: MastheadProfileItem[];
227210
};
228211

229-
/**
230-
* Cloud masthead items
231-
*/
232-
masthead: {
233-
logo: MastheadLogoData;
234-
contact: MastheadProfileContent;
235-
profileMenu: {
236-
signedout: MastheadProfileContent;
237-
signedin: MastheadProfileContent;
238-
};
239-
};
240-
241212
/**
242213
* Miscellaneous translations
243214
*/
@@ -296,29 +267,3 @@ export interface TranslateAPIState {
296267
*/
297268
errorsRequestTranslation?: { [language: string]: Error };
298269
}
299-
300-
// New for v2.1.0
301-
export interface L0Menu {
302-
items: L0MenuItem[];
303-
}
304-
305-
export interface L0MenuItem extends BasicLink {
306-
submenu?: L0Megamenu | BasicLink[];
307-
}
308-
309-
export interface L0Megamenu {
310-
sections: Megapanel[];
311-
highlights?: MegapanelLinkGroup[];
312-
viewAll?: BasicLink;
313-
}
314-
315-
export interface Megapanel {
316-
heading?: BasicLink;
317-
groups: MegapanelLinkGroup[];
318-
viewAll?: BasicLink;
319-
}
320-
321-
export interface MegapanelLinkGroup {
322-
heading?: BasicLink;
323-
links?: BasicLink[];
324-
}

packages/styles/scss/components/masthead/_masthead-l1.scss

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
@use '@carbon/styles/scss/themes' as *;
1414
@use '@carbon/styles/scss/type' as *;
1515
@use '@carbon/styles/scss/utilities' as *;
16+
@use '@carbon/styles/scss/utilities/convert' as *;
1617
@use '@carbon/styles/scss/components/button/tokens' as *;
1718
@use '../../globals/vars' as *;
1819
@use 'vars' as *;

packages/styles/scss/components/masthead/_masthead-megamenu.scss

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@use '@carbon/styles/scss/theme' as *;
1313
@use '@carbon/styles/scss/type' as *;
1414
@use '@carbon/styles/scss/utilities' as *;
15+
@use '@carbon/styles/scss/utilities/convert' as *;
1516
@use '../../globals/utils/flex-grid' as *;
1617
@use '../../globals/vars' as *;
1718

@@ -78,7 +79,6 @@
7879
.#{$prefix}--header__menu-title[aria-expanded='false']
7980
+ .#{$prefix}--header__menu {
8081
::slotted(#{$c4d-prefix}-megamenu),
81-
::slotted(#{$c4d-prefix}-cloud-megamenu),
8282
.#{$prefix}--masthead__megamenu {
8383
animation: $transition-expansion motion(standard, expressive) collapse;
8484
}
@@ -99,7 +99,6 @@
9999
visibility: visible;
100100

101101
::slotted(#{$c4d-prefix}-megamenu),
102-
::slotted(#{$c4d-prefix}-cloud-megamenu),
103102
.#{$prefix}--masthead__megamenu {
104103
animation: $transition-expansion motion(standard, expressive) expand;
105104
}
@@ -121,7 +120,6 @@
121120
}
122121

123122
:host(#{$c4d-prefix}-megamenu),
124-
:host(#{$c4d-prefix}-cloud-megamenu),
125123
.#{$prefix}--masthead__megamenu {
126124
@include box-shadow;
127125
--#{$c4d-prefix}-masthead-max-height: calc(

packages/styles/scss/components/masthead/_masthead.scss

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
@use '@carbon/styles/scss/theme' as *;
1818
@use '@carbon/styles/scss/themes' as *;
1919
@use '@carbon/styles/scss/type' as *;
20+
@use '@carbon/styles/scss/layout' as layout;
2021
@use '@carbon/styles/scss/utilities' as *;
22+
@use '@carbon/styles/scss/utilities/convert' as *;
2123
@use '../../globals/vars' as *;
2224
@use '../link-with-icon';
2325
@use 'vars' as *;
@@ -266,8 +268,9 @@
266268
}
267269

268270
:host(#{$c4d-prefix}-masthead-composite),
269-
:host(#{$c4d-prefix}-masthead-container),
270-
:host(#{$c4d-prefix}-cloud-masthead-container) {
271+
:host(#{$c4d-prefix}-masthead-container) {
272+
@include layout.emit-layout-tokens();
273+
271274
position: relative;
272275
z-index: 900;
273276
display: block;

packages/utilities/src/utilities/StickyHeader/StickyHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2024
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.

packages/web-components/.env.example

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ KALTURA_UICONF_ID=<Kaltura uiconf id, e.g. 12905712>
1919

2020
# Feature Flags
2121
C4D_FLAGS_ALL=<Boolean flag to turn on all feature flags>
22-
C4D_CLOUD_MASTHEAD=<Boolean flag to turn on/off cloud masthead>

packages/web-components/examples/stackblitz/components/cloud-masthead/.gitignore

-22
This file was deleted.

packages/web-components/examples/stackblitz/components/cloud-masthead/.sassrc

-5
This file was deleted.

0 commit comments

Comments
 (0)