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

add width and height in <img> #1105

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- add width and height in the images editable via site-editor

## [3.175.1] - 2024-09-11

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion docs/InfoCard.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ The `info-card` component groups information on a single topic. It often include
"blockClass": "info-card-example",
"textAlignment": "center",
"fetchpriority": "auto",
"preload": true
"preload": true,
"imageWidth": "100px",
"imageHeight": "80px",
}
},
```
Expand All @@ -50,6 +52,8 @@ The `info-card` component groups information on a single topic. It often include
| `htmlId` | `string` | ID of the container element. | `null` |
| `imageUrl` | `string` | Path to the image used on desktop devices. | `""` |
| `imageActionUrl` | `string` | Redirect URL used when the image component is clicked. | `""` |
| `imageWidth` | `string` | Width set in the tag `<img>` | `""` |
| `imageHeight` | `string` | Height set in the tag `<img>` | `""` |
| `isFullModeStyle` | `boolean` | Style of the Info Card component. If `true`, the image component is used as the background, and text is displayed over it. | `false` |
| `linkTarget` | `LinkTargetEnum` | Where to display the linked URL when the Info Card component is clicked. | `"_self"` |
| `mobileImageUrl` | `string` | Path to the image used on mobile devices. If empty, the desktop image is used. | `null` |
Expand Down
346 changes: 176 additions & 170 deletions messages/ar.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/bg.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions messages/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
"admin/editor.notification-bar.content.description": "Text of the bar",
"admin/editor.blockClass.title": "CSS Block Class",
"admin/editor.blockClass.description": "Adds an extra class name to ease styling",
"admin/editor.imageWidth.title": "Image Width",
"admin/editor.imageWidth.description": "Adds width in the tag <img>",
"admin/editor.imageHeight.title": "Image Height",
"admin/editor.imageHeight.description": "Adds height in the tag <img>",
"admin/editor.image.title": "Image",
"admin/editor.image.description": "Show any image",
"admin/editor.image.src.title": "Image",
Expand Down
346 changes: 176 additions & 170 deletions messages/de.json

Large diffs are not rendered by default.

348 changes: 176 additions & 172 deletions messages/en.json

Large diffs are not rendered by default.

348 changes: 176 additions & 172 deletions messages/es.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/fr.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/id.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/it.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/ja.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/ko.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/nl.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/nn.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/no.json

Large diffs are not rendered by default.

348 changes: 176 additions & 172 deletions messages/pt.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/ro.json

Large diffs are not rendered by default.

346 changes: 176 additions & 170 deletions messages/th.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions react/components/InfoCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const InfoCard = ({
textPosition,
textAlignment,
imageUrl,
imageWidth,
imageHeight,
mobileImageUrl,
imageActionUrl,
intl,
Expand Down Expand Up @@ -244,6 +246,8 @@ const InfoCard = ({
style={{ objectFit: 'cover' }}
alt={formatIOMessage({ id: callToActionText, intl })}
data-testid="half-image"
width={imageWidth}
height={imageHeight}
fetchPriority={fetchpriority}
{...(preload
? {
Expand Down Expand Up @@ -272,6 +276,8 @@ MemoizedInfoCard.propTypes = {
callToActionText: string,
callToActionUrl: string,
imageUrl: string,
imageWidth: string,
imageHeight: string,
mobileImageUrl: string,
textAlignment: oneOf(getEnumValues(textAlignmentTypes)),
imageActionUrl: string,
Expand All @@ -294,6 +300,8 @@ MemoizedInfoCard.defaultProps = {
callToActionUrl: '',
imageUrl: '',
mobileImageUrl: '',
imageWidth: '',
imageHeight: '',
textAlignment: textAlignmentTypes.TEXT_ALIGNMENT_LEFT.value,
textMode: textModeTypes.TEXT_MODE_HTML.value,
linkTarget: '_self',
Expand Down Expand Up @@ -356,6 +364,18 @@ MemoizedInfoCard.schema = {
type: 'string',
isLayout: true,
},
imageWidth: {
title: 'admin/editor.imageWidth.title',
description: 'admin/editor.imageWidth.description',
type: 'string',
isLayout: true,
},
imageHeight: {
title: 'admin/editor.imageHeight.title',
description: 'admin/editor.imageHeight.description',
type: 'string',
isLayout: true,
},
},
}

Expand Down
12 changes: 12 additions & 0 deletions store/contentSchemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@
"title": "admin/editor.blockClass.title",
"description": "admin/editor.blockClass.description",
"type": "string"
},
"imageWidth": {
"title": "admin/editor.imageWidth.title",
"description": "admin/editor.imageWidth.description",
"$ref": "app:vtex.native-types#/definitions/text",
"default": ""
},
"imageHeight": {
"title": "admin/editor.imageHeight.title",
"description": "admin/editor.imageHeight.description",
"$ref": "app:vtex.native-types#/definitions/text",
"default": ""
}
}
},
Expand Down
Loading