-
Notifications
You must be signed in to change notification settings - Fork 1
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
Image customCss Implementation #186
Changes from 2 commits
285c83a
d895362
c5b9dcd
6419233
9c7fbd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { StyledCssProps } from 'components/Components.styled.types'; | ||
import styled from 'styled-components'; | ||
import { customCss } from 'utils/customCss'; | ||
|
||
export const StyledSource = styled.source` | ||
user-select: none; | ||
`; | ||
type Props = StyledCssProps; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this type is never used |
||
|
||
export const StyledImage = styled.img` | ||
export const StyledImage = styled.img<StyledCssProps>` | ||
user-select: none; | ||
|
||
${(props) => customCss(props)} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import React from 'react'; | ||
import cn from 'classnames'; | ||
import { Props } from './Image.types'; | ||
import { StyledImage, StyledSource } from './Image.styled'; | ||
import { StyledImage } from './Image.styled'; | ||
|
||
export const Image = ({ | ||
className, | ||
imageClassName, | ||
customCss, | ||
image: { title, url }, | ||
testId = 'image', | ||
onLoad, | ||
}: Props) => { | ||
return ( | ||
<picture className={className}> | ||
<StyledSource | ||
className={imageClassName} | ||
<StyledImage | ||
as="source" | ||
css={customCss} | ||
className={cn(imageClassName, { custom: customCss })} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not necessary with the new approach |
||
data-testid={testId} | ||
type="image/webp" | ||
srcSet={`${url}?fm=webp`} | ||
/> | ||
<StyledImage | ||
data-testid="imageContent" | ||
onLoad={onLoad} | ||
className={imageClassName} | ||
css={customCss} | ||
className={cn(imageClassName, { custom: customCss })} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not necessary with the new approach |
||
alt={title} | ||
src={url} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a valid css that actually modify the component somehow