Skip to content

Commit

Permalink
Display image in relationship UI (#5857)
Browse files Browse the repository at this point in the history
* Update index.tsx

* Update index.tsx

* Update index.tsx

* Create rotten-keys-check.md

* Update index.tsx

* Tweaks.

* Update index.tsx

* Update index.tsx
  • Loading branch information
bladey committed Jun 4, 2021
1 parent 119c921 commit 881c9ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-keys-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/fields': patch
---

Fixed image not displaying when rendered in card format.
2 changes: 1 addition & 1 deletion packages-next/fields/src/types/image/views/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export function validateImage({
// Styled Components
// ==============================

const ImageWrapper = ({ children }: { children: ReactNode }) => {
export const ImageWrapper = ({ children }: { children: ReactNode }) => {
const theme = useTheme();

return (
Expand Down
8 changes: 6 additions & 2 deletions packages-next/fields/src/types/image/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FieldControllerConfig,
} from '@keystone-next/types';
import { FieldContainer, FieldLabel } from '@keystone-ui/fields';
import { validateImage, validateRef } from './Field';
import { validateImage, validateRef, ImageWrapper } from './Field';

export { Field } from './Field';

Expand All @@ -35,7 +35,11 @@ export const CardValue: CardValueComponent = ({ item, field }) => {
return (
<FieldContainer>
<FieldLabel>{field.label}</FieldLabel>
{data && <img alt={data.filename} src={data.publicUrlTransformed} />}
{data && (
<ImageWrapper>
<img css={{ width: '100%' }} alt={data.filename} src={data.src} />
</ImageWrapper>
)}
</FieldContainer>
);
};
Expand Down

1 comment on commit 881c9ff

@vercel
Copy link

@vercel vercel bot commented on 881c9ff Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.