Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ import {
useDocument,
resolveComponentData,
TranslatableString,
YextEntityField,
EntityField,
pt,
Body,
} from "@yext/visual-editor";
import { useTranslation } from "react-i18next";

export interface CopyrightMessageSlotProps {
data: {
text: YextEntityField<TranslatableString>;
text: TranslatableString;
};
/** @internal */
alignment?: "left" | "right";
}

const CopyrightMessageSlotInternal: PuckComponent<CopyrightMessageSlotProps> = (
props
) => {
const { data, puck } = props;
const { data, puck, alignment = "left" } = props;
const streamDocument = useDocument();
const { i18n } = useTranslation();

Expand All @@ -33,15 +32,16 @@ const CopyrightMessageSlotInternal: PuckComponent<CopyrightMessageSlotProps> = (
);

return resolvedText ? (
<EntityField
displayName={pt("copyrightMessage", "Copyright Message")}
fieldId={data.text.field}
constantValueEnabled={data.text.constantValueEnabled}
<Body
variant="xs"
className={
alignment === "right"
? "text-center md:text-right"
: "text-center md:text-left"
}
>
<Body variant="xs" className="text-center md:text-left">
{resolvedText}
</Body>
</EntityField>
{resolvedText}
</Body>
) : puck.isEditing ? (
<div className="h-[20px] min-w-[100px]" />
) : (
Expand All @@ -52,9 +52,8 @@ const CopyrightMessageSlotInternal: PuckComponent<CopyrightMessageSlotProps> = (
export const defaultCopyrightMessageSlotProps: CopyrightMessageSlotProps = {
data: {
text: {
field: "",
constantValue: { en: "", hasLocalizedValue: "true" },
constantValueEnabled: true,
en: "",
hasLocalizedValue: "true",
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ const tests: ComponentTest[] = [
constantValueEnabled: true,
},
},
alignment: "left",
},
},
],
Expand Down Expand Up @@ -888,6 +889,7 @@ const tests: ComponentTest[] = [
constantValueEnabled: true,
},
},
alignment: "right",
},
},
],
Expand Down Expand Up @@ -1041,6 +1043,7 @@ const tests: ComponentTest[] = [
constantValueEnabled: true,
},
},
alignment: "right",
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const FooterLinksSlotInternal: PuckComponent<FooterLinksSlotProps> = (

const secondaryItemsAlignment =
variant === "secondary" && alignment === "right"
? "md:items-end"
: "md:items-start";
? "md:justify-end"
: "md:justify-start";

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const SecondaryFooterSlotWrapper: PuckComponent<SecondaryFooterSlotProps> = ({
puck,
}) => {
const { show } = data;
const { backgroundColor, linksAlignment } = styles;
const { backgroundColor } = styles;
const { t } = useTranslation();

// In edit mode, show minimal clickable placeholder when hidden
Expand Down Expand Up @@ -158,11 +158,7 @@ const SecondaryFooterSlotWrapper: PuckComponent<SecondaryFooterSlotProps> = ({
className={`flex flex-col gap-5`}
>
<slots.SecondaryLinksWrapperSlot style={{ height: "auto" }} allow={[]} />
<div
className={`text-center ${linksAlignment === "left" ? "md:text-left" : "md:text-right"}`}
>
<slots.CopyrightSlot style={{ height: "auto" }} allow={[]} />
</div>
<slots.CopyrightSlot style={{ height: "auto" }} allow={[]} />
</PageSection>
);
};
Expand Down Expand Up @@ -246,6 +242,22 @@ export const SecondaryFooterSlot: ComponentConfig<{
}));
}

// Pass alignment to CopyrightSlot based on parent styles
if (
data?.props?.slots?.CopyrightSlot &&
Array.isArray(data.props.slots.CopyrightSlot)
) {
data.props.slots.CopyrightSlot = data.props.slots.CopyrightSlot.map(
(slot: any) => ({
...slot,
props: {
...slot.props,
alignment: secondaryLinksAlignment,
},
})
);
}

return {
...data,
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export const expandedFooterSlots: Migration = {
constantValueEnabled: true,
},
},
alignment: secondaryLinksAlignment,
},
},
],
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.
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.
6 changes: 3 additions & 3 deletions packages/visual-editor/src/docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ If 'true', the component is visible on the live page; if 'false', it's hidden.

#### Other Props

| Prop | Type | Description | Default |
| :----- | :----------------------------------------------- | :---------- | :------ |
| `data` | `{ text: YextEntityField<TranslatableString>; }` | | |
| Prop | Type | Description | Default |
| :----- | :------------------------------ | :---------- | :------ |
| `data` | `{ text: TranslatableString; }` | | |

---

Expand Down