-
Notifications
You must be signed in to change notification settings - Fork 386
RI-7213: replace EuiImage with img tag #4760
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
Changes from all commits
de9eb3a
4563f15
60b9bf8
eff80c8
5709eac
1553f1a
cf0fbcd
804fe24
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { RiImageProps, StyledImage } from './image.styles' | ||
|
||
const RiImage = ({ $size, src, alt, ...rest }: RiImageProps) => ( | ||
<StyledImage src={src} alt={alt} $size={$size} {...rest} /> | ||
) | ||
|
||
export default RiImage |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||
import { HTMLAttributes } from 'react' | ||||||
import styled, { css } from 'styled-components' | ||||||
|
||||||
export const SIZES = ['s', 'm', 'l', 'xl', 'original', 'fullWidth'] as const | ||||||
|
||||||
export const imageSizeStyles = { | ||||||
s: css` | ||||||
width: 100px; | ||||||
`, | ||||||
m: css` | ||||||
width: 200px; | ||||||
`, | ||||||
l: css` | ||||||
width: 360px; | ||||||
`, | ||||||
xl: css` | ||||||
width: 600px; | ||||||
`, | ||||||
original: css` | ||||||
width: auto; | ||||||
`, | ||||||
fullWidth: css` | ||||||
width: 100%; | ||||||
`, | ||||||
} | ||||||
|
||||||
export type RiImageSize = (typeof SIZES)[number] | ||||||
|
||||||
export interface RiImageProps extends HTMLAttributes<HTMLImageElement> { | ||||||
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. The interface extends HTMLAttributes but overrides 'src' and 'alt' as required properties. This could cause TypeScript conflicts since HTMLImageElement attributes make these optional. Consider using Omit<HTMLAttributes, 'src' | 'alt'> to avoid conflicts.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
$size?: RiImageSize | ||||||
src: string | ||||||
alt: string | ||||||
} | ||||||
|
||||||
export const StyledImage = styled.img<RiImageProps>` | ||||||
${({ $size = 'original' }) => imageSizeStyles[$size]} | ||||||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import Loader from './loader/Loader' | ||
import ProgressBarLoader from './progress-bar/ProgressBarLoader' | ||
import RiImage from './image/RiImage' | ||
|
||
export { Loader, ProgressBarLoader } | ||
export { Loader, ProgressBarLoader, RiImage } | ||
export { RICollapsibleNavGroup } from './collapsible-nav-group/RICollapsibleNavGroup' | ||
|
||
export type { RICollapsibleNavGroupProps } from './collapsible-nav-group/RICollapsibleNavGroup' |
Uh oh!
There was an error while loading. Please reload this page.