Skip to content

Commit

Permalink
Merge branch 'main' into test/e2e-tests-parallel-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m4olivei authored Nov 19, 2024
2 parents 1e469ac + 5eb3f7f commit 670bad9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 20 deletions.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions packages/web-components/src/components/masthead/megamenu-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const { stablePrefix: c4dPrefix } = c4dSettings;
*/
@customElement(`${c4dPrefix}-megamenu-tab`)
class C4DMegaMenuTab extends CDSTab {
/**
* Disable unneeded properties inherited from CDS Content Switcher Item.
*/
closeOnActivation = false;
hideDivider = false;
connectedCallback() {
super.connectedCallback();
this.closeOnActivation = false;
this.hideDivider = false;
}

render() {
const { disabled, selected, value } = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
WithImage as TileWithImage,
} from './tile.stories';
import { CTA_TYPE } from '../../cta/defs';
import { boolean, select, text } from '@storybook/addon-knobs';
import { boolean, number, select, text } from '@storybook/addon-knobs';

const ctaTypeOptions = Object.values(CTA_TYPE).filter((value) => !!value);

Expand Down Expand Up @@ -46,6 +46,11 @@ export default {
false
);

const startSequenceNumber = number(
'Starting sequence number for random label and heading',
0
);

const tocLayout = boolean('Use 3/4 layout', false);

return {
Expand All @@ -55,6 +60,7 @@ export default {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
tocLayout,
};
},
Expand Down Expand Up @@ -94,6 +100,7 @@ export const Default = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
} = args?.TileGroup ?? {};
return html`
<c4d-tile-group>
Expand All @@ -106,6 +113,7 @@ export const Default = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
},
})
)}
Expand All @@ -121,6 +129,7 @@ export const WithImage = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
} = args?.TileGroup ?? {};
return html`
<c4d-tile-group>
Expand All @@ -133,6 +142,7 @@ export const WithImage = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
},
})
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import '../../cta/video-cta-container';
import '../../image';

import { CTA_TYPE } from '../../cta/defs';
import { boolean, select, text } from '@storybook/addon-knobs';
import { boolean, select, text, number } from '@storybook/addon-knobs';

const tagGroupContent = html`
<c4d-tag-group>
Expand Down Expand Up @@ -48,7 +48,14 @@ const pictogramContent = html`

const ctaTypeOptions = Object.values(CTA_TYPE).filter((value) => !!value);

const randomLabel = () => {
const deterministicSequence = [
2, 5, 7, 4, 6, 0, 6, 4, 7, 4, 6, 6, 0, 4, 4, 3, 0, 0, 1, 6, 7, 7, 3, 0, 0, 0,
1, 7, 4, 5, 4, 6, 7, 4, 1, 4, 5, 0, 6, 7, 5, 3, 7, 0, 3, 3, 5, 2, 5, 3,
];

let steps = 0;

const randomLabel = (startSequenceNumber) => {
const labels = [
'Est tempor per quam',
'Velit vulputat lorem',
Expand All @@ -57,11 +64,19 @@ const randomLabel = () => {
'Quisque non praesent',
'Ornare turpis taciti in',
'Ipsum egestas varius ut torquent',
'Natoque cras dictum nec sociosqu tempus phasellus',
];
return labels[Math.floor(Math.random() * labels.length)];
const label =
labels[
deterministicSequence[
(startSequenceNumber + steps) % deterministicSequence.length
]
];
steps++;
return label;
};

const randomHeadline = () => {
const randomHeadline = (startSequenceNumber) => {
const headlines = [
'Est scelerisque habitant ac aptent ex suspendisse',
'At quisque fringilla elementum adipiscing morbi',
Expand All @@ -72,7 +87,14 @@ const randomHeadline = () => {
'Erat dictumst varius faucibus penatibus dignissim torquent',
'Imperdiet commodo habitasse nisi eget mollis libero blandit tincidunt molestie',
];
return headlines[Math.floor(Math.random() * headlines.length)];
const headline =
headlines[
deterministicSequence[
(startSequenceNumber + steps) % deterministicSequence.length
]
];
steps++;
return headline;
};

export default {
Expand Down Expand Up @@ -100,13 +122,19 @@ export default {
false
);

const startSequenceNumber = number(
'Starting sequence number for random label and heading',
0
);

return {
hasPictogram,
hasTagGroup,
ctaType,
ctaCopy,
alignWithContent,
href,
startSequenceNumber,
};
},
},
Expand Down Expand Up @@ -148,14 +176,16 @@ export const Default = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
} = args?.Tile ?? {};
return html`
<c4d-tile
label="${randomLabel()}"
label="${randomLabel(startSequenceNumber)}"
href="${href}"
cta-type="${ctaType}"
?align-with-content="${alignWithContent}">
${hasPictogram ? pictogramContent : undefined} ${randomHeadline()}
${hasPictogram ? pictogramContent : undefined}
${randomHeadline(startSequenceNumber)}
${hasTagGroup ? tagGroupContent : undefined}
<p slot="cta">${ctaCopy}</p>
Expand All @@ -171,10 +201,11 @@ export const WithImage = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
} = args?.Tile ?? {};
return html`
<c4d-tile
label="${randomLabel()}"
label="${randomLabel(startSequenceNumber)}"
href="${href}"
cta-type="${ctaType}"
?align-with-content="${alignWithContent}">
Expand All @@ -185,7 +216,8 @@ export const WithImage = (args) => {
alt="Image Alt Text"
default-src="https://fakeimg.pl/160x160/F7F3FF/6829C1/?retina=1&text=1:1&font=museo"></c4d-image>
${randomHeadline()} ${hasTagGroup ? tagGroupContent : undefined}
${randomHeadline(startSequenceNumber)}
${hasTagGroup ? tagGroupContent : undefined}
<p slot="cta">${ctaCopy}</p>
</c4d-tile>
Expand All @@ -201,10 +233,11 @@ export const DoubleTile = (args) => {
hasPictogram,
alignWithContent,
href,
startSequenceNumber,
} = args?.Tile ?? {};
return html`
<c4d-tile
label="${randomLabel()}"
label="${randomLabel(startSequenceNumber)}"
href="${href}"
cta-type="${ctaType}"
?align-with-content="${alignWithContent}"
Expand All @@ -216,7 +249,8 @@ export const DoubleTile = (args) => {
alt="Image Alt Text"
default-src="https://fakeimg.pl/160x160/F7F3FF/6829C1/?retina=1&text=1:1&font=museo"
class="c4d-tile__image-double"></c4d-image>
${randomHeadline()} ${hasTagGroup ? tagGroupContent : undefined}
${randomHeadline(startSequenceNumber)}
${hasTagGroup ? tagGroupContent : undefined}
<p slot="cta">${ctaCopy}</p>
</c4d-tile>
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13152,15 +13152,15 @@ __metadata:
linkType: hard

"cross-spawn@npm:^6.0.0, cross-spawn@npm:^6.0.5":
version: 6.0.5
resolution: "cross-spawn@npm:6.0.5"
version: 6.0.6
resolution: "cross-spawn@npm:6.0.6"
dependencies:
nice-try: "npm:^1.0.4"
path-key: "npm:^2.0.1"
semver: "npm:^5.5.0"
shebang-command: "npm:^1.2.0"
which: "npm:^1.2.9"
checksum: 10/f07e643b4875f26adffcd7f13bc68d9dff20cf395f8ed6f43a23f3ee24fc3a80a870a32b246fd074e514c8fd7da5f978ac6a7668346eec57aa87bac89c1ed3a1
checksum: 10/7abf6137b23293103a22bfeaf320f2d63faae70d97ddb4b58597237501d2efdd84cdc69a30246977e0c5f68216593894d41a7f122915dd4edf448db14c74171b
languageName: node
linkType: hard

Expand Down

0 comments on commit 670bad9

Please sign in to comment.