Skip to content

Commit 27ac1c1

Browse files
committed
Fix: Fix Capabilities screen UI [APP-1003]
1 parent 882c0f4 commit 27ac1c1

File tree

4 files changed

+106
-54
lines changed

4 files changed

+106
-54
lines changed

modules/settings/assets/js/components/bottom-bar/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import Box from '@elementor/ui/Box';
22
import Button from '@elementor/ui/Button';
3+
import { styled } from '@elementor/ui/styles';
34
import { useSettings, useStorage, useToastNotification } from '@ea11y/hooks';
45
import { mixpanelService } from '@ea11y/services';
56
import { __ } from '@wordpress/i18n';
67

8+
const StyledContainer = styled(Box)`
9+
width: 100%;
10+
display: flex;
11+
justify-content: flex-end;
12+
13+
padding: ${({ theme }) => theme.spacing(2)};
14+
border-top: 1px solid ${({ theme }) => theme.palette.divider};
15+
`;
16+
717
const BottomBar = () => {
818
const {
919
selectedMenu,
@@ -51,13 +61,7 @@ const BottomBar = () => {
5161
};
5262

5363
return (
54-
<Box
55-
display="flex"
56-
justifyContent="end"
57-
p={2}
58-
width="100%"
59-
borderTop="1px solid rgba(0, 0, 0, 0.12)"
60-
>
64+
<StyledContainer>
6165
<Button
6266
variant="contained"
6367
color="info"
@@ -66,7 +70,7 @@ const BottomBar = () => {
6670
>
6771
{__('Save changes', 'pojo-accessibility')}
6872
</Button>
69-
</Box>
73+
</StyledContainer>
7074
);
7175
};
7276

modules/settings/assets/js/layouts/menu-settings.js

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CardActions } from '@elementor/ui';
22
import Alert from '@elementor/ui/Alert';
3+
import Box from '@elementor/ui/Box';
34
import Card from '@elementor/ui/Card';
45
import CardContent from '@elementor/ui/CardContent';
56
import CardHeader from '@elementor/ui/CardHeader';
@@ -17,12 +18,32 @@ import { useEffect, useState } from '@wordpress/element';
1718
import { __ } from '@wordpress/i18n';
1819
import { MENU_SETTINGS } from '../constants/menu-settings';
1920

20-
// Customization to override the WP admin global CSS.
21-
const StyledSwitch = styled(Switch)(() => ({
22-
input: {
23-
height: '56px',
24-
},
25-
}));
21+
const StyledSwitch = styled(Switch)`
22+
input {
23+
height: 56px;
24+
}
25+
`;
26+
27+
const StyledCardContent = styled(CardContent)`
28+
height: 50vh;
29+
overflow: auto;
30+
margin-bottom: 61.5px;
31+
padding: 0 ${({ theme }) => theme.spacing(2)};
32+
`;
33+
34+
const StyledCardActions = styled(CardActions)`
35+
position: absolute;
36+
width: 100%;
37+
bottom: 0;
38+
39+
padding: 0;
40+
background: ${({ theme }) => theme.palette.background.paper};
41+
42+
& .MuiBox-root {
43+
padding: ${({ theme }) => theme.spacing(1.5)}
44+
${({ theme }) => theme.spacing(2)};
45+
}
46+
`;
2647

2748
const MenuSettings = () => {
2849
const {
@@ -40,13 +61,13 @@ const MenuSettings = () => {
4061
setDisableOptions(true);
4162
} else {
4263
setDisableOptions(false);
64+
4365
save({ a11y_hide_minimum_active_options_alert: false }).then(() => {
4466
setHideMinimumOptionAlert(false);
4567
});
4668
}
4769
}, [widgetMenuSettings]);
4870

49-
// Toggle the value of a setting
5071
const toggleSetting = (category, option) => {
5172
setWidgetMenuSettings((prevSettings) => {
5273
const newSettings = {
@@ -57,15 +78,16 @@ const MenuSettings = () => {
5778
};
5879

5980
setHasChanges(true);
81+
6082
if (window?.ea11yWidget?.toolsSettings && window?.ea11yWidget?.widget) {
6183
window.ea11yWidget.toolsSettings = newSettings;
6284
window?.ea11yWidget?.widget.updateState();
6385
}
86+
6487
return newSettings;
6588
});
6689
};
6790

68-
// Check if at least two options are enabled
6991
const areAtLeastTwoOptionsEnabled = (settings) => {
7092
let enabledCount = 0;
7193

@@ -87,35 +109,42 @@ const MenuSettings = () => {
87109
setHideMinimumOptionAlert(true);
88110
});
89111
};
112+
113+
const sectionsCount = Object.entries(MENU_SETTINGS).length;
114+
90115
return (
91116
<Card variant="outlined">
92117
<CardHeader
93118
title={__('Feature Menu', 'pojo-accessibility')}
94-
subheader={__(
95-
'Choose which accessibility features and capabilities you want to include.',
96-
'pojo-accessibility',
97-
)}
98-
sx={{ paddingBottom: 0 }}
119+
subheader={
120+
<Typography variant="body2">
121+
{__(
122+
'Choose which accessibility features and capabilities you want to include.',
123+
'pojo-accessibility',
124+
)}
125+
</Typography>
126+
}
99127
/>
128+
100129
{disableOptions && !hideMinimumOptionAlert && (
101130
<Alert severity="info" sx={{ m: 2 }} onClose={handleCloseNotification}>
102131
{__('At least two option must remain active', 'pojo-accessibility')}
103132
</Alert>
104133
)}
105-
<CardContent
106-
sx={{ height: '50vh', overflow: 'auto', marginBottom: '100px' }}
107-
>
134+
135+
<StyledCardContent>
108136
<List>
109-
{Object.entries(MENU_SETTINGS).map(([parentKey, parentItem]) => {
137+
{Object.entries(MENU_SETTINGS).map(([parentKey, parentItem], i) => {
110138
return (
111-
<div key={parentKey}>
139+
<Box key={parentKey}>
112140
<ListItem disableGutters>
113141
<ListItemText>
114142
<Typography variant="subtitle2">
115143
{parentItem.title}
116144
</Typography>
117145
</ListItemText>
118146
</ListItem>
147+
119148
{parentItem.options &&
120149
Object.entries(parentItem.options).map(
121150
([childKey, childValue]) => {
@@ -148,22 +177,17 @@ const MenuSettings = () => {
148177
);
149178
},
150179
)}
151-
<Divider sx={{ my: 2 }} />
152-
</div>
180+
181+
{i + 1 < sectionsCount && <Divider sx={{ my: 2 }} />}
182+
</Box>
153183
);
154184
})}
155185
</List>
156-
</CardContent>
157-
<CardActions
158-
sx={{
159-
position: 'absolute',
160-
bottom: 0,
161-
width: '100%',
162-
background: 'white',
163-
}}
164-
>
186+
</StyledCardContent>
187+
188+
<StyledCardActions>
165189
<BottomBar />
166-
</CardActions>
190+
</StyledCardActions>
167191
</Card>
168192
);
169193
};

modules/settings/assets/js/layouts/widget-preview.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
import Card from '@elementor/ui/Card';
22
import CardContent from '@elementor/ui/CardContent';
33
import CardHeader from '@elementor/ui/CardHeader';
4+
import Typography from '@elementor/ui/Typography';
5+
import { styled } from '@elementor/ui/styles';
46
import { WidgetLoader } from '@ea11y/components';
57
import { __ } from '@wordpress/i18n';
68

9+
const StyledPreview = styled(CardContent)`
10+
margin-right: auto;
11+
margin-left: auto;
12+
margin-top: ${({ theme }) => theme.spacing(4)};
13+
padding: 0 24px;
14+
15+
overflow: auto;
16+
17+
& #ea11y-root {
18+
position: absolute;
19+
top: 0;
20+
left: 0;
21+
right: 0;
22+
23+
transform: scale(70%);
24+
}
25+
`;
26+
727
const WidgetPreview = () => {
828
return (
929
<>
1030
<Card variant="outlined">
1131
<CardHeader
1232
title={__('Preview', 'pojo-accessibility')}
13-
subheader={__(
14-
'This is what the widget will look like to your site viewers.',
15-
'pojo-accessibility',
16-
)}
33+
subheader={
34+
<Typography variant="body2">
35+
{__(
36+
'This is what the widget will look like to your site viewers.',
37+
'pojo-accessibility',
38+
)}
39+
</Typography>
40+
}
1741
/>
18-
<CardContent
19-
id="ea11y-widget-preview--container"
20-
sx={{
21-
overflow: 'auto',
22-
marginRight: 'auto',
23-
marginLeft: 'auto',
24-
marginTop: 4,
25-
padding: '0 24px',
26-
}}
27-
></CardContent>
42+
43+
<StyledPreview id="ea11y-widget-preview--container"></StyledPreview>
2844
</Card>
2945
<WidgetLoader />
3046
</>

modules/settings/assets/js/pages/menu.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import Box from '@elementor/ui/Box';
22
import Container from '@elementor/ui/Container';
33
import Typography from '@elementor/ui/Typography';
4+
import { styled } from '@elementor/ui/styles';
45
import { MenuSettings, WidgetPreview } from '@ea11y/layouts';
56
import { mixpanelService } from '@ea11y/services';
67
import { useEffect } from '@wordpress/element';
78
import { __ } from '@wordpress/i18n';
89

10+
const StyledContainer = styled(Container)`
11+
overflow: auto;
12+
max-height: 100%;
13+
padding: ${({ theme }) => theme.spacing(5)};
14+
`;
15+
916
const Menu = () => {
1017
useEffect(() => {
1118
mixpanelService.sendEvent('page_view', {
@@ -14,15 +21,16 @@ const Menu = () => {
1421
}, []);
1522

1623
return (
17-
<Container sx={{ overflow: 'auto', maxHeight: '100%', p: 5 }}>
24+
<StyledContainer>
1825
<Typography variant="h4" fontWeight="400" marginBottom={4}>
1926
{__('Capabilities', 'pojo-accessibility')}
2027
</Typography>
28+
2129
<Box display="grid" gridTemplateColumns="repeat(2, 1fr)" gap={4}>
2230
<MenuSettings />
2331
<WidgetPreview />
2432
</Box>
25-
</Container>
33+
</StyledContainer>
2634
);
2735
};
2836

0 commit comments

Comments
 (0)