Skip to content

Commit

Permalink
chore(uikit): Remove Image responsive prop
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiojidev committed Jun 17, 2021
1 parent 697572b commit eead3e2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const StyledBackgroundImage = styled(Wrapper)`
background-size: contain;
`;

const BackgroundImage: React.FC<ImageProps> = ({ src, responsive, width, height, ...props }) => {
const BackgroundImage: React.FC<ImageProps> = ({ src, width, height, ...props }) => {
const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
Expand All @@ -36,7 +36,7 @@ const BackgroundImage: React.FC<ImageProps> = ({ src, responsive, width, height,
};
}, [src]);

return <StyledBackgroundImage ref={ref} responsive={responsive} width={width} height={height} {...props} />;
return <StyledBackgroundImage ref={ref} width={width} height={height} {...props} />;
};

export default BackgroundImage;
4 changes: 2 additions & 2 deletions packages/pancake-uikit/src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Placeholder = styled.div`
width: 100%;
`;

const Image: React.FC<ImageProps> = ({ responsive, src, alt, width, height, ...props }) => {
const Image: React.FC<ImageProps> = ({ src, alt, width, height, ...props }) => {
const imgRef = useRef<HTMLDivElement>(null);
const [isLoaded, setIsLoaded] = useState(false);

Expand Down Expand Up @@ -48,7 +48,7 @@ const Image: React.FC<ImageProps> = ({ responsive, src, alt, width, height, ...p
}, [src]);

return (
<Wrapper ref={imgRef} responsive={responsive} height={height} width={width} {...props}>
<Wrapper ref={imgRef} height={height} width={width} {...props}>
{isLoaded ? <StyledImage src={src} alt={alt} /> : <Placeholder />}
</Wrapper>
);
Expand Down
6 changes: 3 additions & 3 deletions packages/pancake-uikit/src/components/Image/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from "styled-components";
import { space } from "styled-system";
import { WrapperProps } from "./types";

const StyledWrapper = styled.div<{ $width: number; $height: number; responsive: boolean }>`
const StyledWrapper = styled.div<{ $width: number; $height: number }>`
align-self: start;
max-height: ${({ $height }) => $height}px;
max-width: ${({ $width }) => $width}px;
Expand All @@ -19,8 +19,8 @@ const StyledWrapper = styled.div<{ $width: number; $height: number; responsive:
${space}
`;

const Wrapper = forwardRef<HTMLDivElement, WrapperProps>(({ responsive = true, width, height, ...props }, ref) => {
return <StyledWrapper ref={ref} responsive={responsive} $width={width} $height={height} {...props} />;
const Wrapper = forwardRef<HTMLDivElement, WrapperProps>(({ width, height, ...props }, ref) => {
return <StyledWrapper ref={ref} $width={width} $height={height} {...props} />;
});

export default Wrapper;
18 changes: 0 additions & 18 deletions packages/pancake-uikit/src/components/Image/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ export const Image: React.FC = () => {
);
};

export const ImageResponsive: React.FC = () => {
return (
<div>
<Img src="https://via.placeholder.com/800x400" width={800} height={400} />
<div>Image</div>
</div>
);
};

export const Background: React.FC = () => {
return (
<div>
Expand All @@ -41,15 +32,6 @@ export const Background: React.FC = () => {
);
};

export const BackgroundResponsive: React.FC = () => {
return (
<div>
<BackgroundImage src="https://via.placeholder.com/800x400" width={800} height={400} responsive mr="16px" />
<div>Background Image</div>
</div>
);
};

export const LazyImages: React.FC = () => {
return (
<Flex flexWrap="wrap">
Expand Down
2 changes: 0 additions & 2 deletions packages/pancake-uikit/src/components/Image/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { BoxProps } from "../Box";
export interface WrapperProps extends SpaceProps, HTMLAttributes<HTMLDivElement> {
width: number;
height: number;
responsive?: boolean;
}

export interface ImageProps extends ImgHTMLAttributes<HTMLImageElement>, SpaceProps {
width: number;
height: number;
responsive?: boolean;
wrapperProps?: WrapperProps;
}

Expand Down

0 comments on commit eead3e2

Please sign in to comment.