Skip to content

Commit

Permalink
make Image Block use image-aspect-ratio custom prop & minor Transform…
Browse files Browse the repository at this point in the history
… fix
  • Loading branch information
danalvrz committed Nov 20, 2024
1 parent cb56db1 commit d1b843e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const SeparatorStylingSchema = ({ schema, formData, intl }) => {
default: 'default',
filterActions: ['narrow', 'default'],
};

if (formData?.styles?.shortLine) {

Check failure on line 33 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
schema.properties.styles.schema.fieldsets[0].fields = [

Check failure on line 34 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
'align:noprefix',

Check failure on line 35 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
...schema.properties.styles.schema.fieldsets[0].fields,

Check failure on line 36 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
Expand All @@ -42,16 +41,22 @@ export const SeparatorStylingSchema = ({ schema, formData, intl }) => {
title: intl.formatMessage(messages.Alignment),

Check failure on line 41 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
default: 'left',

Check failure on line 42 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
};

Check failure on line 43 in packages/volto-light-theme/src/components/Blocks/Separator/schema.js

View workflow job for this annotation

GitHub Actions / codeanalysis

Delete `··`
}

schema.properties.styles.schema.fieldsets[0].fields = [
'shortLine',
...schema.properties.styles.schema.fieldsets[0].fields,
];
schema.properties.styles.schema.properties.shortLine = {
title: intl.formatMessage(messages.shortline),
type: 'boolean',
};
schema.properties.styles.schema.fieldsets[0].fields = [
'shortLine',
...schema.properties.styles.schema.fieldsets[0].fields,
];

schema.properties.styles.schema.properties.shortLine = {
title: intl.formatMessage(messages.shortline),
type: 'boolean',
};

// schema.properties.styles.schema.properties['align:noprefix'].disabled =
// !formData?.styles?.shortLine;




return schema;
};
1 change: 1 addition & 0 deletions packages/volto-light-theme/src/theme/blocks/_image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ figure {
img {
width: 100% !important;
height: auto;
aspect-ratio: var(--image-aspect-ratio, $aspect-ratio);
}

&.right {
Expand Down
5 changes: 5 additions & 0 deletions packages/volto-light-theme/src/theme/blocks/_separator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
max-width: var(--block-width) !important;
justify-content: var(--block-alignment);
@include variable-container-width();

&::after {
max-width: inherit;
width: var(--layout-container-width);
}
}

@include vertical-space-separator();
Expand Down
37 changes: 32 additions & 5 deletions packages/volto-light-theme/src/transforms/to6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,41 @@ export function migrateToVLT6ColorAndWidthModel(data: BlocksFormData) {
delete block.styles.backgroundColor;
}

if (block?.styles?.buttonAlign) {
block.styles['blockWidth:noprefix'] = findStyleByName(
NORMALIZED_WIDTHS,
block.styles.buttonAlign,
);
if (block['@type'] === '__button') {
block.styles = {
...block.styles,
'blockWidth:noprefix':
block.styles?.['blockWidth:noprefix'] ??
findStyleByName(
NORMALIZED_WIDTHS,
`${block.styles?.buttonAlign === 'wide' ? 'default' : 'narrow'}`,
),
}

delete block.styles.buttonAlign;
}

if (block['@type'] === 'separator') {
block.styles = {
...block.styles,
shortLine:
block.styles?.['shortLine'] ?? block?.styles?.align === 'left'
? true
: false,
'align:noprefix': block.styles?.['align:noprefix'] ?? {
'--block-alignment': 'var(--align-left)',
},
'blockWidth:noprefix':
block.styles?.['blockWidth:noprefix'] ??
findStyleByName(
NORMALIZED_WIDTHS,
`${block.styles?.align === 'full' ? 'default' : 'narrow'}`,
),
};

delete block.styles.align;
}

if (
block['@type'] === 'image' &&
block?.align &&
Expand Down

0 comments on commit d1b843e

Please sign in to comment.