Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SLB-442-preview-tablet-size' int…
Browse files Browse the repository at this point in the history
…o dev
  • Loading branch information
colorfield committed Jun 27, 2024
2 parents 3c8565c + 27ee0cd commit f7e2df8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/drupal/gutenberg_blocks/css/edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
.gutenberg__editor .drupal-preview-sidebar--header select::before,
.gutenberg__editor .drupal-preview-sidebar--header select::after {
--size: 0.3rem;
content: "";
content: '';
position: absolute;
right: 1rem;
pointer-events: none;
Expand Down
17 changes: 9 additions & 8 deletions packages/drupal/gutenberg_blocks/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
];

const previewButton = `<button class="components-button is-primary external-preview">${Drupal.t('Preview')} ↗</button>`
const previewButton = `<button class="components-button is-primary external-preview">${Drupal.t('Preview')} ↗</button>`;

const getPreviewSelect = () => {
let previewSelect = '<select class="external-preview">';
Expand All @@ -49,7 +49,7 @@
});
previewSelect += '</select>';
return previewSelect;
}
};
const previewSelect = getPreviewSelect();

const previewSidebarMarkup = `
Expand Down Expand Up @@ -97,18 +97,19 @@
);

const $previewButton = $('button.external-preview');
$('select.external-preview').on(
'change',
function (event: Event) {
$('select.external-preview')
.on('change', function (event: Event) {
const selectedSize = $(event.target).val();
const size = previewSizes.find((size) => size.id === selectedSize);
const size = previewSizes.find(
(size) => size.id === selectedSize,
);
if (!size) {
return;
}
$previewButton.data('windowHeight', size.height);
$previewButton.data('windowWidth', size.width);
},
).trigger('change');
})
.trigger('change');
$previewButton.on('click', function (event: Event) {
const target = $(event.target);
const windowWidth = target.data('windowWidth');
Expand Down

0 comments on commit f7e2df8

Please sign in to comment.