Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: support data URIs in Image component, clean up stories

Oleg Isonen0107eb8c4dc4
diff --git a/apps/builder/app/builder/features/pages/social-preview.stories.tsx b/apps/builder/app/builder/features/pages/social-preview.stories.tsx
index 2ba0465422..446b78f2ac 100644
--- a/apps/builder/app/builder/features/pages/social-preview.stories.tsx
+++ b/apps/builder/app/builder/features/pages/social-preview.stories.tsx
@@ -1,6 +1,14 @@
import { Box } from "@webstudio-is/design-system";
import { SocialPreview } from "./social-preview";
+const placeholderImage = `data:image/svg+xml,${encodeURIComponent(
+ `<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630">
+ <rect width="1200" height="630" fill="#c0d0e0"/>
+ <text x="600" y="315" text-anchor="middle" dominant-baseline="central"
+ font-family="sans-serif" font-size="48" fill="#4a6a8a">1200 × 630</text>
+ </svg>`
+)}`;
+
export default {
title: "Pages/Social Preview",
component: SocialPreview,
@@ -9,7 +17,7 @@ export default {
export const WithImage = () => (
<Box css={{ width: 600, margin: 20 }}>
<SocialPreview
- ogImageUrl="https://picsum.photos/1200/630"
+ ogImageUrl={placeholderImage}
ogUrl="https://webstudio.is/blog/architecture-overview"
ogTitle="Webstudio's Architecture - An Overview"
ogDescription="This is an introduction for developers who want to contribute to Webstudio Core. However, it may also be an interesting read for ambitious designers."
diff --git a/apps/builder/app/dashboard/shared/thumbnail.stories.tsx b/apps/builder/app/dashboard/shared/thumbnail.stories.tsx
index ad08d63050..7378fd9971 100644
--- a/apps/builder/app/dashboard/shared/thumbnail.stories.tsx
+++ b/apps/builder/app/dashboard/shared/thumbnail.stories.tsx
@@ -1,39 +1,17 @@
-import { Box, theme } from "@webstudio-is/design-system";
import { ThumbnailWithAbbr, ThumbnailLinkWithAbbr } from "./thumbnail";
export default {
title: "Dashboard/Thumbnail",
};
-const ThumbnailWrapper = ({ children }: { children: React.ReactNode }) => (
- <Box
- css={{
- width: theme.spacing[30],
- aspectRatio: "1.91/1",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- background: theme.colors.brandBackgroundProjectCardFront,
- }}
- >
- {children}
- </Box>
-);
-
export const Abbreviation = () => (
- <ThumbnailWrapper>
- <ThumbnailWithAbbr title="My Next Project" onClick={() => {}} />
- </ThumbnailWrapper>
+ <ThumbnailWithAbbr title="My Next Project" onClick={() => {}} />
);
export const AbbreviationLink = () => (
- <ThumbnailWrapper>
- <ThumbnailLinkWithAbbr title="Landing Page" to="#" />
- </ThumbnailWrapper>
+ <ThumbnailLinkWithAbbr title="Landing Page" to="#" />
);
export const SingleWord = () => (
- <ThumbnailWrapper>
- <ThumbnailWithAbbr title="Portfolio" onClick={() => {}} />
- </ThumbnailWrapper>
+ <ThumbnailWithAbbr title="Portfolio" onClick={() => {}} />
);
diff --git a/packages/image/src/image-optimize.ts b/packages/image/src/image-optimize.ts
index 37a839dc68..4359ae93db 100644
--- a/packages/image/src/image-optimize.ts
+++ b/packages/image/src/image-optimize.ts
@@ -267,6 +267,11 @@ export const getImageAttributes = (props: {
);
if (props.src != null && props.src !== "") {
+ // Data URIs should be used as-is without optimization or loader processing
+ if (props.src.startsWith("data:")) {
+ return { src: props.src };
+ }
+
if (props.srcSet == null && props.optimize) {
const sizes =
props.sizes ?? (props.width == null ? DEFAULT_SIZES : undefined);