Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
}
}
}
}
}
146 changes: 146 additions & 0 deletions packages/visual-editor/src/components/header/ExpandedHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,152 @@ const tests: ComponentTest[] = [
},
version: 48,
},
{
name: "version 49 props - no logo",
document: {},
props: {
styles: {
maxWidth: "theme",
headerPosition: "scrollsWithPage",
},
slots: {
PrimaryHeaderSlot: [
{
type: "PrimaryHeaderSlot",
props: {
styles: {
backgroundColor: backgroundColors.background6.value,
},
slots: {
LogoSlot: [],
LinksSlot: [
{
type: "HeaderLinks",
props: {
data: {
links: [
{
linkType: "URL",
label: {
en: "Primary Header Link",
hasLocalizedValue: "true",
},
link: "#",
},
{
linkType: "URL",
label: {
en: "Primary Header Link",
hasLocalizedValue: "true",
},
link: "#",
},
],
},
parentData: {
type: "Primary",
},
},
},
],
PrimaryCTASlot: [
{
type: "CTASlot",
props: {
data: {
show: true,
entityField: {
field: "",
constantValue: {
label: { en: "CTA", hasLocalizedValue: "true" },
link: "#",
linkType: "URL",
},
constantValueEnabled: true,
},
},
styles: {
displayType: "textAndLink",
variant: "primary",
},
},
},
],
SecondaryCTASlot: [
{
type: "CTASlot",
props: {
data: {
show: true,
entityField: {
field: "",
constantValue: {
label: {
en: "Secondary CTA",
hasLocalizedValue: "true",
},
link: "#",
linkType: "URL",
},
constantValueEnabled: true,
},
},
styles: {
displayType: "textAndLink",
variant: "secondary",
},
},
},
],
},
},
},
],
SecondaryHeaderSlot: [
{
type: "SecondaryHeaderSlot",
props: {
data: {
show: true,
showLanguageDropdown: false,
},
styles: {
backgroundColor: backgroundColors.background4.value,
},
slots: {
LinksSlot: [
{
type: "HeaderLinks",
props: {
data: {
links: [
{
linkType: "URL",
label: {
en: "Secondary Header Link",
hasLocalizedValue: "true",
},
link: "#",
},
],
},
parentData: {
type: "Secondary",
},
},
},
],
},
},
},
],
},
analytics: {
scope: "expandedHeader",
},
},
version: 49,
},
];

describe("ExpandedHeader", async () => {
Expand Down
24 changes: 21 additions & 3 deletions packages/visual-editor/src/components/header/PrimaryHeaderSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface PrimaryHeaderSlotProps {
conditionalRender?: {
navContent: boolean;
CTAs: boolean;
hasLogoImage?: boolean;
};

/** @internal */
Expand Down Expand Up @@ -88,15 +89,22 @@ const PrimaryHeaderSlotWrapper: PuckComponent<PrimaryHeaderSlotProps> = ({
const { t } = useTranslation();

const [isMobileMenuOpen, setMobileMenuOpen] = React.useState<boolean>(false);

const containerRef = React.useRef<HTMLDivElement>(null);
const contentRef = React.useRef<HTMLDivElement>(null);
const showHamburger = useOverflow(containerRef, contentRef);

const showCTAs = puck.isEditing || conditionalRender?.CTAs;
const showNavContent = puck.isEditing || conditionalRender?.navContent;

const LogoSlot = <slots.LogoSlot style={{ height: "auto", width: "auto" }} />;
const LogoSlot = (
<div
className="flex-shrink-0"
style={{
minHeight: conditionalRender?.hasLogoImage ? undefined : "100px",
}}
>
<slots.LogoSlot style={{ height: "auto", width: "auto" }} />
</div>
);

const navContent = (
<>
Expand Down Expand Up @@ -323,6 +331,15 @@ export const PrimaryHeaderSlot: ComponentConfig<{
return data;
}

const logoSlotItem = data.props.slots.LogoSlot?.[0];

const hasLogoImage =
logoSlotItem?.type === "ImageSlot" &&
!!(
logoSlotItem?.props?.data?.image?.constantValue ||
logoSlotItem?.props?.data?.image?.field
);

// Check if PrimaryCTA has data to display
const primaryCTA = resolveComponentData(
data.props.slots.PrimaryCTASlot[0]?.props.data
Expand Down Expand Up @@ -366,6 +383,7 @@ export const PrimaryHeaderSlot: ComponentConfig<{
conditionalRender: {
navContent: showNavContent,
CTAs: showPrimaryCTA || showSecondaryCTA,
hasLogoImage,
},
},
};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"rollup": "npm:@rollup/wasm-node"
}
}
}
}