Skip to content
Draft
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
2 changes: 1 addition & 1 deletion apps/seven/acceptance/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from '../../../../packages/tooling/playwright/test';

test.describe('Basic Playwright Test', () => {
test('should visit the root URL', async ({ page }) => {
await page.goto('/');
await page.goto('http://localhost:3000/');
await expect(page).toHaveURL(/\/$/);
await expect(page.getByText('Home')).toBeVisible();
});
Expand Down
4 changes: 4 additions & 0 deletions packages/blocks/Image/Image.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.block {
max-width: var(--block-size);
float: var(--block-align);
}
9 changes: 3 additions & 6 deletions packages/blocks/Image/ImageBlockEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
} from '@plone/types';
import Image from '@plone/layout/components/Image/Image';
import clsx from 'clsx';
import styles from './Image.module.css';
import config from '@plone/registry';

function flattenToAppUrl(url: string) {
Expand Down Expand Up @@ -72,17 +73,13 @@ const ImageBlockEdit = (props: BlockEditProps) => {
{
center: !Boolean(data.align),
},
styles['block'],
data.align,
data.size,
)}
>
{data.url ? (
<Image
className={clsx({
'full-width': data.align === 'full',
large: data.size === 'l',
medium: data.size === 'm',
small: data.size === 's',
})}
item={imageItem}
src={
data.image_scales
Expand Down
25 changes: 18 additions & 7 deletions packages/blocks/Image/ImageBlockView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { BlockViewProps, ContainedItem } from '@plone/types';
import Image from '@plone/layout/components/Image/Image';
import clsx from 'clsx';
import styles from './Image.module.css';

const ImageBlockView = (props: BlockViewProps) => {
const { data } = props;
Expand All @@ -10,14 +12,23 @@ const ImageBlockView = (props: BlockViewProps) => {
image_field: data.image_field,
image_scales: data.image_scales,
} as ContainedItem;

return (
<figure>
<Image
item={item}
alt={(data.alt as string) || ''}
imageField={data.image_field as string}
/>
<figure className={clsx(styles['block'])}>
<div
className={clsx(
'image align block',
// {
// center: !Boolean(data.align),
// },
styles['block'],
)}
>
<Image
item={item}
alt={(data.alt as string) || ''}
imageField={data.image_field as string}
/>
</div>
</figure>
);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/blocks/Image/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ export function ImageSchema({
widget: 'align',
default: 'center',
actions: ['left', 'right', 'center'],
styleField: true,
},
size: {
title: 'Image size',
widget: 'size',
default: 'l',
styleField: true,
},
href: {
title: 'Link to',
Expand Down
35 changes: 35 additions & 0 deletions packages/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,41 @@ export default function install(config: ConfigType) {
},
];

const alignment = [
{
name: 'default',
label: 'Default',
style: {},
},
{
name: 'left',
label: 'Left',
style: {
'--block-align': 'left',
},
},
{
name: 'right',
label: 'Right',
style: {
'--block-align': 'right',
},
},
{
name: 'l',
label: 'L',
style: {
'--block-size': '500px',
},
},
];

config.registerUtility({
type: 'styleFieldDefinition',
name: 'align',
method: () => alignment,
});

config.blocks.blocksConfig.image =
ImageBlockInfo as unknown as BlockConfigBase;
config.blocks.blocksConfig.teaser =
Expand Down
Loading