Skip to content
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

[@mantine/core] Image: Add div around placeholder #2675

Merged
merged 2 commits into from Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/docs/theming/theme-object.mdx
Expand Up @@ -259,7 +259,7 @@ Note that you should also import `dayjs/locale/[locale]` to load localization fi

### globalStyles

`theme.globalStyles` adds global styles, see [global styles guide](/styles/global/) to learn more.
`theme.globalStyles` adds global styles, see [global styles guide](/styles/global-styles/) to learn more.

### other

Expand Down
16 changes: 16 additions & 0 deletions src/mantine-core/src/Image/Image.story.tsx
@@ -1,8 +1,10 @@
import React, { useEffect, useState } from 'react';
import { storiesOf } from '@storybook/react';
import { useInterval } from '@mantine/hooks';
import { MantineProvider } from '@mantine/styles';
import { Container } from '../Container';
import { Image } from './Image';
import { AspectRatio } from '../AspectRatio';

const images = [
'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3748&q=80',
Expand Down Expand Up @@ -36,4 +38,18 @@ storiesOf('Image', module)
<Container size={60}>
<Image radius="sm" src={null} withPlaceholder width={50} height={50} />
</Container>
))
.add('Responsive Image with AspectRatio', () => (
<MantineProvider withGlobalStyles withNormalizeCSS>
<div style={{ width: 400, padding: 20, backgroundColor: '#fdf' }}>
<p>Responsive Image with AspectRatio</p>
<AspectRatio ratio={2}>
<Image src="https://picsum.photos/600/600" withPlaceholder />
</AspectRatio>
<p>Responsive Placeholder with AspectRatio</p>
<AspectRatio ratio={2}>
<Image withPlaceholder />
</AspectRatio>
</div>
</MantineProvider>
));
6 changes: 5 additions & 1 deletion src/mantine-core/src/Image/Image.tsx
Expand Up @@ -115,7 +115,11 @@ export const Image = forwardRef<HTMLDivElement, ImageProps>((props: ImageProps,

{isPlaceholder && (
<div className={classes.placeholder} title={alt}>
{placeholder || <ImageIcon style={{ width: 40, height: 40 }} />}
{placeholder || (
<div>
<ImageIcon style={{ width: 40, height: 40 }} />
</div>
)}
</div>
)}
</div>
Expand Down