Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore(web): Add ImageBlock #511

Closed
wants to merge 10 commits into from
39 changes: 39 additions & 0 deletions web/src/beta/components/Blocks/ImageBlock/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Meta, StoryObj } from "@storybook/react";

import ImageBlock from ".";

export default {
component: ImageBlock,
} as Meta;

const Container: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
<div style={{ width: "430px" }}>{children}</div>
);

type Story = StoryObj<typeof ImageBlock>;

export const Default: Story = {
args: {
src: "http://placehold.it/430X260",
},
render: args => {
return (
<Container>
<ImageBlock {...args} />
</Container>
);
},
};

export const Blank: Story = {
args: {
src: "",
},
render: args => {
return (
<Container>
<ImageBlock {...args} />
</Container>
);
},
};
39 changes: 39 additions & 0 deletions web/src/beta/components/Blocks/ImageBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Icon from "@reearth/beta/components/Icon";
import { styled } from "@reearth/services/theme";

type Props = {
src: string;
alt?: string;
};

const ImageBlock: React.FC<Props> = ({ src, alt }) => {
return src ? (
<Wrapper>
<ImageBox src={src} alt={alt} />
</Wrapper>
) : (
<BlankImageBox>
<Icon icon="image" color="#2e2e2e" size={32} />
</BlankImageBox>
);
};

const Wrapper = styled.div`
width: inherit;
`;

const ImageBox = styled.img`
display: flex;
object-fit: cover;
width: 100%;
`;

const BlankImageBox = styled.div`
display: flex;
aspect-ratio: 43/26;
background: #f1f1f1;
align-items: center;
justify-content: center;
`;

export default ImageBlock;
3 changes: 3 additions & 0 deletions web/src/beta/components/Icon/Icons/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions web/src/beta/components/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ import TwoRectangle from "./Icons/two-rectangle.svg";
// Plus
import Plus from "./Icons/plus.svg";

// Image
import Image from "./Icons/image.svg";

export default {
file: File,
dl: InfoTable,
Expand Down Expand Up @@ -87,4 +90,5 @@ export default {
workspaceAdd: WorkspaceAdd,
workspaces: Workspaces,
checkmark: CheckMark,
image: Image,
};
Loading