-
-
Notifications
You must be signed in to change notification settings - Fork 871
Fix image block alignment #8262
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
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,56 @@ | ||
| /* Image block */ | ||
|
|
||
| .block.image { | ||
| clear: both; | ||
| } | ||
|
|
||
| .block.image.align.left img { | ||
| max-width: 50%; | ||
| margin-right: 1em !important; | ||
| margin-bottom: 1em; | ||
| float: left; | ||
| } | ||
|
|
||
| .block.image.align.right img { | ||
| max-width: 50%; | ||
| margin-bottom: 1em; | ||
| margin-left: 1em !important; | ||
| float: right; | ||
|
Member
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 element with float requires clear: both on the parent.Let's try using a more modern flex box / grid approach. |
||
| } | ||
|
|
||
| .block.image.align.center { | ||
| text-align: center; | ||
| } | ||
|
|
||
| .block.image.align.center img { | ||
| max-width: 100%; | ||
| margin-inline: auto; | ||
| } | ||
|
|
||
| .block.image.align.center img.medium { | ||
| max-width: 50%; | ||
| } | ||
|
|
||
| .block.image.align.center img.small { | ||
| max-width: 25%; | ||
| } | ||
|
|
||
| .block.image.align.left img.large, | ||
| .block.image.align.right img.large { | ||
| max-width: 50%; | ||
| } | ||
|
|
||
| .block.image.align.left img.medium, | ||
| .block.image.align.right img.medium { | ||
| max-width: 25%; | ||
| } | ||
|
|
||
| .block.image.align.left img.small, | ||
| .block.image.align.right img.small { | ||
| max-width: 15%; | ||
| } | ||
|
|
||
| .block.image img.full-width { | ||
| width: 100%; | ||
| max-width: 100%; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,11 @@ import type { | |
| Content, | ||
| RelatedItem, | ||
| } from '@plone/types'; | ||
|
|
||
| import Image from '@plone/layout/components/Image/Image'; | ||
| import clsx from 'clsx'; | ||
| import config from '@plone/registry'; | ||
| import './ImageBlock.css'; | ||
|
Member
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. Aren't we supposed to use tailwind in Seven? |
||
|
|
||
| function flattenToAppUrl(url: string) { | ||
| const apiPath = config.settings.apiPath || ''; | ||
|
|
@@ -66,11 +68,11 @@ const ImageBlockEdit = (props: BlockEditProps) => { | |
| : undefined; | ||
|
|
||
| return ( | ||
| <div | ||
| <figure | ||
|
Member
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. We should re-use ImageView component in the Edit component |
||
| className={clsx( | ||
| 'image align block', | ||
| { | ||
| center: !Boolean(data.align), | ||
| center: !data.align, | ||
| }, | ||
| data.align, | ||
| )} | ||
|
|
@@ -105,7 +107,7 @@ const ImageBlockEdit = (props: BlockEditProps) => { | |
| objectBrowserPickerType="image" | ||
| /> | ||
| ) : null} | ||
| </div> | ||
| </figure> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| import type { BlockViewProps, ContainedItem } from '@plone/types'; | ||
| import Image from '@plone/layout/components/Image/Image'; | ||
| import clsx from 'clsx'; | ||
|
|
||
| import './ImageBlock.css'; | ||
|
|
||
| const ImageBlockView = (props: BlockViewProps) => { | ||
| const { data } = props; | ||
|
|
||
| if (!data.url) return null; | ||
|
|
||
| const item = { | ||
|
|
@@ -12,8 +16,22 @@ const ImageBlockView = (props: BlockViewProps) => { | |
| } as ContainedItem; | ||
|
|
||
| return ( | ||
| <figure> | ||
| <figure | ||
| className={clsx( | ||
| 'image align block', | ||
| { | ||
| center: !data.align, | ||
| }, | ||
| data.align, | ||
| )} | ||
| > | ||
| <Image | ||
| className={clsx({ | ||
| 'full-width': data.align === 'full', | ||
|
Member
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. Add full to the alignment actions |
||
| large: data.size === 'l', | ||
| medium: data.size === 'm', | ||
| small: data.size === 's', | ||
| })} | ||
|
Member
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. We should also have |
||
| item={item} | ||
| alt={(data.alt as string) || ''} | ||
| imageField={data.image_field as string} | ||
|
|
||
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.
@iRohitSingh Why is this using float for alignment?
Can we instead use a modern layout approach (flexbox, grid, or display: flow-root