mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
Merge branch 'main' into 252-fonts-manager-and-fonts-selector
This commit is contained in:
6 files changed
+2618
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,18 @@
|
||||
import React from "react";
|
||||
import type { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Image as ImagePrimitive } from "./image";
|
||||
import argTypes from "./image.props.json";
|
||||
|
||||
export default {
|
||||
title: "Components/Image",
|
||||
component: ImagePrimitive,
|
||||
argTypes,
|
||||
} as ComponentMeta<typeof ImagePrimitive>;
|
||||
|
||||
const Template: ComponentStory<typeof ImagePrimitive> = (args) => (
|
||||
<ImagePrimitive {...args} />
|
||||
);
|
||||
|
||||
export const Image = Template.bind({});
|
||||
|
||||
Image.args = {};
|
||||
@@ -0,0 +1,50 @@
|
||||
import React, { forwardRef, type ElementRef, type ComponentProps } from "react";
|
||||
|
||||
const defaultTag = "img";
|
||||
|
||||
type ImageProps = ComponentProps<typeof defaultTag>;
|
||||
|
||||
export const Image = forwardRef<ElementRef<typeof defaultTag>, ImageProps>(
|
||||
(props, ref) => <img {...props} ref={ref} />
|
||||
);
|
||||
|
||||
Image.defaultProps = {
|
||||
src: "",
|
||||
loading: "lazy",
|
||||
width: "auto",
|
||||
height: "auto",
|
||||
alt: "",
|
||||
};
|
||||
|
||||
Image.displayName = "Image";
|
||||
|
||||
const imagePlaceholderSvg = `<svg
|
||||
width="140"
|
||||
height="140"
|
||||
viewBox="0 0 600 600"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<rect width="600" height="600" fill="#CCCCCC" />
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M450 170H150C141.716 170 135 176.716 135 185V415C135 423.284 141.716 430 150 430H450C458.284 430 465 423.284 465 415V185C465 176.716 458.284 170 450 170ZM150 145C127.909 145 110 162.909 110 185V415C110 437.091 127.909 455 150 455H450C472.091 455 490 437.091 490 415V185C490 162.909 472.091 145 450 145H150Z"
|
||||
fill="#A2A2A2"
|
||||
/>
|
||||
<path
|
||||
d="M237.135 235.012C237.135 255.723 220.345 272.512 199.635 272.512C178.924 272.512 162.135 255.723 162.135 235.012C162.135 214.301 178.924 197.512 199.635 197.512C220.345 197.512 237.135 214.301 237.135 235.012Z"
|
||||
fill="#A2A2A2"
|
||||
/>
|
||||
<path
|
||||
d="M160 405V367.205L221.609 306.364L256.552 338.628L358.161 234L440 316.043V405H160Z"
|
||||
fill="#A2A2A2"
|
||||
/>
|
||||
</svg>`;
|
||||
|
||||
// Defining src here prevents analyzer from putting the image into the UI.
|
||||
// @todo it would be better to have the image hosted like a normal image,
|
||||
// the problem is inside sdk bundler doesn't know how to do that.
|
||||
Image.defaultProps.src = `data:image/svg+xml;base64,${btoa(
|
||||
imagePlaceholderSvg
|
||||
)}`;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { ImageIcon } from "@webstudio-is/icons";
|
||||
import type { WsComponentMeta } from "./component-type";
|
||||
import { Image } from "./image";
|
||||
|
||||
const meta: WsComponentMeta<typeof Image> = {
|
||||
Icon: ImageIcon,
|
||||
Component: Image,
|
||||
canAcceptChildren: false,
|
||||
isContentEditable: false,
|
||||
isInlineOnly: false,
|
||||
isListed: true,
|
||||
label: "Image",
|
||||
};
|
||||
|
||||
export default meta;
|
||||
@@ -9,3 +9,4 @@ export { default as Italic } from "./italic.ws";
|
||||
export { default as Button } from "./button.ws";
|
||||
export { default as Input } from "./input.ws";
|
||||
export { default as Form } from "./form.ws";
|
||||
export { default as Image } from "./image.ws";
|
||||
@@ -9,3 +9,4 @@ export { default as Italic } from "./italic.stories";
|
||||
export { default as Link } from "./link.stories";
|
||||
export { default as Paragraph } from "./paragraph.stories";
|
||||
export { default as TextBlock } from "./text-block.stories";
|
||||
export { default as Image } from "./image.stories";
|
||||
Reference in new issue
Block a user