Skip to content

Commit

Permalink
feat(web-components): convert Image from react-web & add Storybook ex…
Browse files Browse the repository at this point in the history
…ample
  • Loading branch information
zarkoboyadjiev committed Jul 20, 2021
1 parent 9d44ac6 commit 10c9fa7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/components/web-components/src/Image/Image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import reactToWebComponent from 'react-to-webcomponent';
import { Image } from '@compassion-gds/react-web';

const WebImage = reactToWebComponent(Image, React, ReactDOM);

customElements.define("gds-image", WebImage);

57 changes: 57 additions & 0 deletions packages/components/web-components/src/Image/Image.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-disable import/no-extraneous-dependencies */
import { html } from 'lit-html';

import './Image';

export default {
title: 'Global Design System/Image',
args: {
label: 'Image',
src:
'https://images.unsplash.com/photo-1605027628030-9bb6f83535e6?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=375&q=100',
srcPreview:
'https://images.unsplash.com/photo-1605027628030-9bb6f83535e6?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=10&q=100',
srcSet: '',
sizes: '',
alt: 'Arkansas is great.',
caption: '',
isLazyLoaded: true,
width: '500px',
maxWidth: '',
height: '500px',
maxHeight: '',
objectFit: 'cover',
objectPosition: '',
}
}

export const Primary = ({
src,
srcPreview,
srcSet,
sizes,
alt,
caption,
isLazyLoaded,
width,
maxWidth,
height,
maxHeight,
objectFit,
objectPosition,
}) =>
html`<gds-image
src=${src}
srcPreview=${srcPreview}
srcSet=${srcSet}
sizes=${sizes}
alt=${alt}
.caption=${caption}
?isLazyLoaded=${isLazyLoaded}
width=${width}
.maxWidth=${maxWidth}
.height=${height}
.maxHeight=${maxHeight}
.objectFit=${objectFit}
.objectPosition=${objectPosition}
/>`;
1 change: 1 addition & 0 deletions packages/components/web-components/src/Image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './Image';

0 comments on commit 10c9fa7

Please sign in to comment.