Skip to content

Commit

Permalink
Fix: Fix admin widget previews [n/a]
Browse files Browse the repository at this point in the history
  • Loading branch information
pkniazevych committed Feb 13, 2025
1 parent 3b1e238 commit f562ddb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
26 changes: 0 additions & 26 deletions modules/settings/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,3 @@ html[dir='rtl'] #ea11y-app {
max-width: 100% !important;
}
}

/* Widget style for statement section */

.ea11y-statement--widget-preview {
height: 250px;
position: relative;
padding: 25px;
overflow: hidden;
}

.ea11y-statement--widget-preview .ea11y-widget-container--preview {
position: absolute;
}

.ea11y-statement--widget-preview .ea11y-widget-content::after {
content: '';

position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 40px;

background-color: #FCFDFF;
opacity: 0.6;
}
48 changes: 42 additions & 6 deletions modules/settings/assets/js/layouts/statement-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,46 @@ import { mixpanelService } from '@ea11y/services';
import { useEntityRecords } from '@wordpress/core-data';
import { useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { WIDGET_PREVIEW_ID } from '../constants';

const StyledPreviewContainer = styled(Box)`
padding: 0;
margin-top: ${({ theme }) => theme.spacing(2)};
border-radius: 4px;
border: 1px solid ${({ theme }) => theme.palette.divider};
height: 250px;
position: relative;
padding: 25px;
overflow: hidden;
& .ea11y-widget-container {
transform: translateY(0);
}
& .ea11y-widget-container--preview {
position: absolute;
}
& .ea11y-widget-content::after {
content: '';
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 40px;
background-color: #fcfdff;
opacity: 0.6;
}
@media screen and (min-width: 480px) {
& .ea11y-widget-container--preview {
bottom: 0;
right: 0;
}
}
`;

const StatementLink = () => {
Expand Down Expand Up @@ -224,11 +257,14 @@ const StatementLink = () => {
{__('Preview link in widget', 'pojo-accessibility')}
</Typography>

<StyledPreviewContainer
id="ea11y-widget-preview--container"
className="ea11y-statement--widget-preview"
>
<WidgetLoader />
<StyledPreviewContainer id="ea11y-widget-preview--container">
<WidgetLoader
onLoad={() => {
if (document.getElementById(WIDGET_PREVIEW_ID)) {
window?.ea11yWidget?.widget?.open();
}
}}
/>
</StyledPreviewContainer>
</Box>
</Box>
Expand Down
5 changes: 5 additions & 0 deletions modules/settings/assets/js/layouts/widget-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const StyledPreview = styled(CardContent)`
transform: scale(70%);
}
& #ea11y-root #ea11y-widget-container {
position: initial;
transform: translateY(0);
}
`;

const WidgetPreview = () => {
Expand Down

0 comments on commit f562ddb

Please sign in to comment.