Skip to content

Commit

Permalink
unset default aspect ratio in schema & minor fixes to transform & spa…
Browse files Browse the repository at this point in the history
…cings
  • Loading branch information
danalvrz committed Nov 21, 2024
1 parent 82ab6d9 commit db94556
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const imageBlockSchemaEnhancer = ({ formData, schema, intl }) => {
['1', '1:1'],
['16 / 9', '16/9'],
],
default: '1',
};

schema.properties.description = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const teaserSchemaEnhancer = ({ schema, formData, intl }) => {
['1', '1:1'],
['16 / 9', '16/9'],
],
default: '16 / 9',
};

return schema;
Expand Down
1 change: 0 additions & 1 deletion packages/volto-light-theme/src/theme/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ External link removal for all the blocks.
& > .block.search .searchBlock-container,
& > .block h2.headline,
& > .block.heading .heading-wrapper,
& > .block.introduction .block-container,
& > .block.teaser .teaser-item.default,
& > .block.highlight .teaser-description-title,
& > table,
Expand Down
6 changes: 5 additions & 1 deletion packages/volto-light-theme/src/theme/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,14 @@ $secondary-grey: #ececec !default;
--link-color: #0070a2;
// Comment out following line to turn <a> links the same color as the text
--link-foreground-color: var(--link-color);

// It is possible to set an aspect ratio for all images, using the folowing CSS custom property:
// --image-aspect-ratio: 16/9;
}

// Image Aspect Ratio
$aspect-ratio: var(--image-aspect-ratio, 16/9) !default;
$aspect-ratio: 16/9 !default;


// Weights
$thin: 100 !default;
Expand Down
16 changes: 7 additions & 9 deletions packages/volto-light-theme/src/theme/blocks/_image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ figure {
margin-bottom: 0 !important;
}

&.align.left.has--backgroundColor--grey,
&.align.right.has--backgroundColor--grey {
margin-top: 0;

figure {
// Paddings do not collapse, so we have to substract the ever
// present padding bottom for every block
padding-top: $heading-text-top-spacing - $block-vertical-space;
&.has--block-width--default,
&.has--block-width--narrow,
&.has--block-width--full {
figure:not(.left, .right) {
margin-top: $spacing-large;
margin-bottom: $spacing-large;
}
}

figure {
img {
width: 100% !important;
height: auto;
aspect-ratio: var(--image-aspect-ratio, $aspect-ratio);
aspect-ratio: var(--image-aspect-ratio, auto);
}

&.right {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
margin-bottom: $block-vertical-space;
}

.block-container {
@include default-container-width();
}

h2 {
@include highlight-title();
margin-bottom: $spacing-large;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@include variable-container-width();

&::after {
width: var(--layout-container-width);
width: calc(100cqw - 2 * $horizontal-space-small-screens);
max-width: inherit;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/volto-light-theme/src/theme/blocks/_teaser.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Override the Image component `aspect-ratio`
.teaser-item .image-wrapper img {
aspect-ratio: $aspect-ratio !important;
aspect-ratio: var( --image-aspect-ratio, $aspect-ratio) !important;
}

// Block Teaser Standalone
Expand Down
18 changes: 5 additions & 13 deletions packages/volto-light-theme/src/transforms/to6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,15 @@ export function migrateToVLT6ColorAndWidthModel(data: BlocksFormData) {
delete block.styles.align;
}

if (
block['@type'] === 'image' &&
block?.align &&
(block?.align === 'wide' || block?.align === 'full')
) {
if (block['@type'] === 'image' && !['left', 'right'].includes(block?.align)) {

Check failure on line 74 in packages/volto-light-theme/src/transforms/to6.ts

View workflow job for this annotation

GitHub Actions / codeanalysis

Replace `block['@type']·===·'image'·&&·!['left',·'right'].includes(block?.align)` with `⏎······block['@type']·===·'image'·&&⏎······!['left',·'right'].includes(block?.align)⏎····`
block.styles = {
...block.styles,
'blockWidth:noprefix': findStyleByName(NORMALIZED_WIDTHS, block.align),
'blockWidth:noprefix': block.styles?.['blockWidth:noprefix'] ?? findStyleByName(

Check failure on line 77 in packages/volto-light-theme/src/transforms/to6.ts

View workflow job for this annotation

GitHub Actions / codeanalysis

Replace `·block.styles?.['blockWidth:noprefix']·??` with `⏎··········block.styles?.['blockWidth:noprefix']·??⏎·········`
NORMALIZED_WIDTHS,

Check failure on line 78 in packages/volto-light-theme/src/transforms/to6.ts

View workflow job for this annotation

GitHub Actions / codeanalysis

Insert `··`
block?.align === 'wide' ? 'default' : (block?.align === 'center' ? 'narrow' : block.align),

Check failure on line 79 in packages/volto-light-theme/src/transforms/to6.ts

View workflow job for this annotation

GitHub Actions / codeanalysis

Replace `block?.align·===·'wide'·?·'default'·:·(block?.align·===·'center'·?·'narrow'·:·block.align)` with `··block?.align·===·'wide'⏎··············?·'default'⏎··············:·block?.align·===·'center'⏎················?·'narrow'⏎················:·block.align`
),

Check failure on line 80 in packages/volto-light-theme/src/transforms/to6.ts

View workflow job for this annotation

GitHub Actions / codeanalysis

Insert `··`
};
block.align = 'center';
}

if (block['@type'] === 'image' && !block?.styles?.['blockWidth:noprefix']) {
block.styles = {
...block.styles,
'blockWidth:noprefix': findStyleByName(NORMALIZED_WIDTHS, 'default'),
};
}
}
}

0 comments on commit db94556

Please sign in to comment.