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: 2 additions & 0 deletions packages/visual-editor/locales/cs/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/da/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/de/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/en-GB/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/en/visual-editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@
"siteColors": "Site Colors",
"spacingDefaultLabel": "Default",
"staticContent": "Static content",
"staticMapEmptyStateAddApiKey": "Add an API key to preview your map",
"staticMapEmptyStateSectionHidden": "Section hidden for all locations",
"sunday": "Sunday",
"teamMember": "Team Member",
"temporarilyClosed": "Temporarily Closed",
Expand Down
2 changes: 2 additions & 0 deletions packages/visual-editor/locales/es/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/et/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/fi/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/fr/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/hr/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/hu/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/it/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/ja/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/lt/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/lv/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/nb/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/nl/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/pl/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/pt/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/ro/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/sk/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/sv/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/tr/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/zh-TW/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/visual-editor/locales/zh/visual-editor.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import {
YextField,
msg,
pt,
themeManagerCn,
Body,
} from "@yext/visual-editor";
import { ComponentConfig, Field, Fields } from "@measured/puck";
import { ComponentConfig, Field, Fields, PuckComponent } from "@measured/puck";
import { StreamDocument } from "../../utils/applyTheme";
import mapboxLogo from "../assets/mapbox-logo-black.svg";
import { Map } from "lucide-react";

export type MapboxStaticProps = {
apiKey: string;
Expand Down Expand Up @@ -78,12 +81,13 @@ const getPrimaryColor = (streamDocument: StreamDocument) => {
}
};

export const MapboxStaticMapComponent = ({
export const MapboxStaticMapComponent: PuckComponent<MapboxStaticProps> = ({
apiKey,
coordinate: coordinateField,
zoom = 14,
mapStyle = "light-v11",
}: MapboxStaticProps) => {
puck,
}) => {
const { t, i18n } = useTranslation();
const streamDocument = useDocument<any>();

Expand All @@ -93,12 +97,40 @@ export const MapboxStaticMapComponent = ({
streamDocument
);

// Show empty state in editor mode when API key is missing
if (!apiKey) {
if (puck?.isEditing) {
return (
<div
className={themeManagerCn(
"relative h-[300px] w-full bg-gray-100 rounded-lg border border-gray-200 flex flex-col items-center justify-center py-8 gap-2.5"
)}
>
<Map className="w-12 h-12 text-gray-400" />
<div className="flex flex-col items-center gap-0">
<Body variant="base" className="text-gray-500 font-medium">
{t(
"staticMapEmptyStateSectionHidden",
"Section hidden for all locations"
)}
</Body>
<Body variant="base" className="text-gray-500 font-normal">
{t(
"staticMapEmptyStateAddApiKey",
"Add an API key to preview your map"
)}
</Body>
</div>
</div>
);
}
console.warn("API Key is required for MapboxStaticMap");
return <></>;
}

if (!coordinate) {
console.warn(`${coordinateField.field} is not present in the stream`);
return <></>;
} else if (!apiKey) {
console.warn("API Key is required for MapboxStaticMap");
return <></>;
}

const marker = `pin-l+${getPrimaryColor(streamDocument)}(${coordinate.longitude},${coordinate.latitude})`;
Expand Down Expand Up @@ -169,5 +201,5 @@ export const MapboxStaticMap: ComponentConfig<{ props: MapboxStaticProps }> = {
},
mapStyle: "streets-v12",
},
render: (props: MapboxStaticProps) => <MapboxStaticMapComponent {...props} />,
render: (props) => <MapboxStaticMapComponent {...props} />,
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
MapboxStaticMapComponent,
mapStyleField,
} from "../contentBlocks/MapboxStaticMap.tsx";
import { ComponentConfig, Fields } from "@measured/puck";
import { ComponentConfig, Fields, PuckComponent } from "@measured/puck";

export interface StaticMapData {
/**
Expand Down Expand Up @@ -88,7 +88,12 @@ const staticMapSectionFields: Fields<StaticMapSectionProps> = {
}),
};

const StaticMapSectionWrapper = ({ data, styles }: StaticMapSectionProps) => {
const StaticMapSectionWrapper: PuckComponent<StaticMapSectionProps> = ({
data,
styles,
puck,
id,
}) => {
return (
<PageSection
background={styles?.backgroundColor}
Expand All @@ -104,6 +109,8 @@ const StaticMapSectionWrapper = ({ data, styles }: StaticMapSectionProps) => {
},
}}
mapStyle={styles?.mapStyle}
puck={puck}
id={id}
/>
</PageSection>
);
Expand Down