Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
improvement(image): export themable version of styled image component
Browse files Browse the repository at this point in the history
  • Loading branch information
ostowe committed Apr 30, 2020
1 parent cf27cf3 commit e3a86e9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/styled/components/image/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import createWithUserThemes from '../hoc/createWithUserThemes';
import IrvingPicture from './irvingPicture';
import IrvingImg from './irvingImg';
import {
Caption,
Wrapper,
WrapperElementFigure,
} from './styles';
import * as defaultTheme from './styles';

const Image = (props) => {
const {
Expand All @@ -22,7 +19,13 @@ const Image = (props) => {
srcset,
sizes,
sourceTags,
theme,
} = props;
const {
Caption,
Wrapper,
WrapperElementFigure,
} = theme;
const [error, setError] = useState(false);
const onError = () => setError(true);

Expand Down Expand Up @@ -108,6 +111,10 @@ Image.propTypes = {
PropTypes.bool,
PropTypes.string,
]).isRequired,
/**
* Low Quality Image Placeholder (LQIP) source.
*/
lqipSrc: PropTypes.string,
/**
* Should this component render a `<picture>` element?
*/
Expand Down Expand Up @@ -143,15 +150,21 @@ Image.propTypes = {
media: PropTypes.string.isRequired,
})
),
/**
* Theme for this component
*/
theme: PropTypes.object.isRequired,
};

Image.defaultProps = {
caption: '',
className: '',
lqipSrc: '',
sourceTags: [],
picture: false,
sizes: '',
showCaption: false,
};

export default Image;
export const themeImage = createWithUserThemes(Image, defaultTheme);

0 comments on commit e3a86e9

Please sign in to comment.