Skip to content

Commit

Permalink
[APP-837] Add post connect modal (#120)
Browse files Browse the repository at this point in the history
* add: post connect modal

* update: settings prefix

* fix: connect modal design

* update: connect modal text

* add: connect modal graphics

* update: connect modal icon

* update: post connect modal

* update: sidebar menu text

* update: text of icon settings

* update: text

* update: php compatibility with return types
  • Loading branch information
nirbhayel authored Dec 30, 2024
1 parent c84ff70 commit 680e9ff
Show file tree
Hide file tree
Showing 17 changed files with 275 additions and 333 deletions.
5 changes: 4 additions & 1 deletion modules/settings/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Notifications,
MenuItems,
AdminTopBar,
PostConnectModal,
} from '@ea11y/components';
import {
useNotificationSettings,
Expand All @@ -19,7 +20,8 @@ import { usePluginSettingsContext } from './contexts/plugin-settings';

const App = () => {
useSavedSettings();
const { isConnected, isRTL } = usePluginSettingsContext();
const { isConnected, isRTL, closePostConnectModal } =
usePluginSettingsContext();
const { notificationMessage, notificationType } = useNotificationSettings();
const { selectedMenu } = useSettings();

Expand All @@ -32,6 +34,7 @@ const App = () => {
<DirectionProvider rtl={isRTL}>
<ThemeProvider colorScheme="light">
{!isConnected && <ConnectModal />}
{isConnected && !closePostConnectModal && <PostConnectModal />}
<Grid display="flex" flexDirection="row" height="100%">
<Sidebar />
<Box
Expand Down

This file was deleted.

93 changes: 75 additions & 18 deletions modules/settings/assets/js/components/connect-modal/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { CircleCheckFilledIcon } from '@elementor/icons';
import Box from '@elementor/ui/Box';
import Button from '@elementor/ui/Button';
import Grid from '@elementor/ui/Grid';
import List from '@elementor/ui/List';
import ListItem from '@elementor/ui/ListItem';
import ListItemIcon from '@elementor/ui/ListItemIcon';
import ListItemText from '@elementor/ui/ListItemText';
import Modal from '@elementor/ui/Modal';
import Typography from '@elementor/ui/Typography';
import { useAuth, useModal } from '@ea11y/hooks';
import { ConnectModalIcon } from '@ea11y/icons';
import { __ } from '@wordpress/i18n';

function ConnectModal() {
const { isOpen } = useModal();
const { redirectToConnect } = useAuth();

const ListItemStyle = { margin: '8px', padding: 0 };
const ListItemTextStyle = { color: 'text.secondary', margin: 0, padding: 0 };
const listIconColor = 'info.main';

return (
<Modal open={isOpen}>
<Grid
container
gap={2}
gap={0}
direction="column"
justifyContent="start"
alignItems="center"
Expand All @@ -25,29 +35,76 @@ function ConnectModal() {
transform: 'translate(-50%, -50%)',
width: 600,
maxWidth: '95%',
height: 400,
bgcolor: 'background.paper',
height: 552,
backgroundColor: 'background.paper',
boxShadow: 24,
paddingBottom: 5,
p: 5,
textAlign: 'center',
borderRadius: '4px',
}}
>
<Box
component="div"
sx={{ background: '#000', width: '100%', height: '200px' }}
></Box>
<Typography variant="subtitle1" marginTop={5} marginBottom={3}>
{__('Connect plugin on your site!', 'pojo-accessibility')}
</Typography>
<Button
variant="contained"
color="info"
size="large"
onClick={redirectToConnect}
<ConnectModalIcon />
<Typography
variant="h5"
color="text.primary"
marginTop={5}
marginBottom={1}
>
{__('Connect', 'pojo-accessibility')}
</Button>
{__("Let's improve your site's accessibility", 'pojo-accessibility')}
</Typography>
<Typography variant="body2" color="text.primary" width={400}>
{__(
'Make your site more inclusive with One Click Accessibility.',
'pojo-accessibility',
)}
</Typography>
<Box>
<List dense={true}>
<ListItem disableGutters sx={ListItemStyle}>
<ListItemIcon sx={{ color: listIconColor }}>
<CircleCheckFilledIcon width={20} />
</ListItemIcon>
<ListItemText
sx={ListItemTextStyle}
primary={__('Fully customizable design', 'pojo-accessibility')}
/>
</ListItem>
<ListItem disableGutters sx={ListItemStyle}>
<ListItemIcon sx={{ color: listIconColor }}>
<CircleCheckFilledIcon width={20} />
</ListItemIcon>
<ListItemText
sx={ListItemTextStyle}
primary={__(
'Feature management & control',
'pojo-accessibility',
)}
/>
</ListItem>
<ListItem disableGutters sx={ListItemStyle}>
<ListItemIcon sx={{ color: listIconColor }}>
<CircleCheckFilledIcon width={20} />
</ListItemIcon>
<ListItemText
sx={ListItemTextStyle}
primary={__(
'Accessibility statement generator',
'pojo-accessibility',
)}
/>
</ListItem>
</List>
<Button
variant="contained"
color="info"
size="large"
onClick={redirectToConnect}
fullWidth
sx={{ marginTop: 5 }}
>
{__('Get started', 'pojo-accessibility')}
</Button>
</Box>
</Grid>
</Modal>
);
Expand Down
1 change: 1 addition & 0 deletions modules/settings/assets/js/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export { default as PositionControl } from './position-control';
export { MenuItems } from '../components/sidebar-menu/menu';
export { default as AdminTopBar } from './admin-top-bar';
export { default as BottomBar } from './bottom-bar';
export { default as PostConnectModal } from './post-connect-modal';
75 changes: 75 additions & 0 deletions modules/settings/assets/js/components/post-connect-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Button from '@elementor/ui/Button';
import Grid from '@elementor/ui/Grid';
import Modal from '@elementor/ui/Modal';
import Typography from '@elementor/ui/Typography';
import { useModal, useStorage } from '@ea11y/hooks';
import { PostConnectModalIcon } from '@ea11y/icons';
import { __ } from '@wordpress/i18n';

const PostConnectModal = () => {
const { isOpen, close } = useModal();
const { save } = useStorage();

const onClose = async () => {
await save({
ea11y_close_post_connect_modal: true,
});
close();
};

return (
<Modal open={isOpen}>
<Grid
container
direction="column"
alignItems="center"
justifyContent="center"
sx={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 600,
maxWidth: '100%',
height: 530,
backgroundColor: 'background.paper',
boxShadow: 24,
p: '20px',
textAlign: 'center',
borderRadius: '4px',
}}
>
<PostConnectModalIcon />
<Typography
variant="h5"
color="text.primary"
marginTop={5}
marginBottom={1}
>
{__("You're all set", 'site-mailer')}
</Typography>
<Typography
variant="body2"
sx={{ width: '500px', maxWidth: '100%' }}
color="text.primary"
marginBottom={5}
>
{__(
'The One Click Accessibility widget is now active and ready to use on your site!',
'site-mailer',
)}
</Typography>
<Button
variant="contained"
sx={{ padding: '8px 22px', width: '300px' }}
onClick={onClose}
color="info"
>
{__('Done', 'pojo-accessibility')}
</Button>
</Grid>
</Modal>
);
};

export default PostConnectModal;
8 changes: 4 additions & 4 deletions modules/settings/assets/js/components/sidebar-menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import { __ } from '@wordpress/i18n';

export const MenuItems = {
widget: {
name: __('Widget', 'pojo-accessibility'),
name: __('Accessibility Widget', 'pojo-accessibility'),
key: 'widget',
icon: <WidgetIcon />,
children: {
iconSettings: {
name: __('Icon Settings', 'pojo-accessibility'),
name: __('Design & position', 'pojo-accessibility'),
key: 'icon-settings',
page: <IconSettings />,
},
menu: {
name: __('Menu', 'pojo-accessibility'),
name: __('Feature management', 'pojo-accessibility'),
key: 'menu',
page: <Menu />,
},
},
},
accessibilityStatement: {
name: __('Accessibility Statement', 'pojo-accessibility'),
name: __('Accessibility statement', 'pojo-accessibility'),
key: 'accessibility-statement',
page: <AccessibilityStatement />,
icon: <PagesIcon />,
Expand Down
6 changes: 6 additions & 0 deletions modules/settings/assets/js/contexts/plugin-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const PluginSettingsProvider = ({ children }) => {
settings.isConnected = Boolean(settings.isConnected);
}

if ('closePostConnectModal' in settings) {
settings.closePostConnectModal = Boolean(
settings.closePostConnectModal,
);
}

setPluginSettings(settings);
setLoaded(true);
})
Expand Down
44 changes: 44 additions & 0 deletions modules/settings/assets/js/icons/connect-modal-icon.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions modules/settings/assets/js/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export { default as ReadingPanelIcon } from './reading-panel';
export { default as HideImagesIcon } from './hide-images';
export { default as PauseAnimationsIcon } from './pause-animations';
export { default as ReadableFontIcon } from './readable-font';
export { default as PostConnectModalIcon } from './post-connect-modal-icon';
export { default as ConnectModalIcon } from './connect-modal-icon';
44 changes: 44 additions & 0 deletions modules/settings/assets/js/icons/post-connect-modal-icon.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/settings/assets/js/layouts/icon-design-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const IconDesignSettings = (props) => {
</Typography>
<Typography variant="body2">
{__(
'Customize the design of the button that visitors use to open the widget.',
"Customize your accessibility button's color, icon, and size to match your brand.",
'pojo-accessibility',
)}
</Typography>
Expand Down
4 changes: 2 additions & 2 deletions modules/settings/assets/js/layouts/menu-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ const MenuSettings = () => {
return (
<Card variant="outlined">
<CardHeader
title={__('Menu Items', 'pojo-accessibility')}
title={__('Feature Menu', 'pojo-accessibility')}
subheader={__(
'Select below the items that you want to appear in the widget.',
'Choose which accessibility features and capabilities you want to include.',
'pojo-accessibility',
)}
/>
Expand Down
2 changes: 1 addition & 1 deletion modules/settings/assets/js/layouts/position-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const PositionSettings = (props) => {
</Typography>
<Typography variant="body2">
{__(
'Set where the widget appears on your site. This applies to all pages.',
'Decide where you want your accessibility button to appear across every page of your site so visitors can easily find it.',
'pojo-accessibility',
)}
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion modules/settings/assets/js/pages/icon-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const IconSettings = () => {
<>
<Container p={1} sx={{ overflow: 'auto', maxHeight: '100%', padding: 4 }}>
<Typography variant="h4" fontWeight="400" marginBottom={4}>
{__('Icon Settings', 'pojo-accessibility')}
{__('Design & position', 'pojo-accessibility')}
</Typography>
<IconDesignSettings marginBottom={4} />
<PositionSettings />
Expand Down
2 changes: 1 addition & 1 deletion modules/settings/assets/js/pages/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Menu = () => {
return (
<Container sx={{ overflow: 'auto', maxHeight: '100%', p: 5 }}>
<Typography variant="h4" fontWeight="400" marginBottom={4}>
{__('Menu', 'pojo-accessibility')}
{__('Feature management', 'pojo-accessibility')}
</Typography>
<Box display="grid" gridTemplateColumns="repeat(2, 1fr)" gap={4}>
<MenuSettings />
Expand Down
20 changes: 13 additions & 7 deletions modules/settings/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,30 @@
}

class Settings {
public const CLOSE_POST_CONNECT_MODAL = 'ea11y_close_post_connect_modal';

public const IS_VALID_PLAN_DATA = 'ea11y_is_valid_plan_data';
public const PLAN_DATA = 'ea11y_plan_data';

/**
* Returns plugin settings data by option name typecasted to an appropriate data type.
* Returns plugin settings data by option name
* type cast to an appropriate data type.
*
* @param string $option_name
* @return mixed
*/
public static function get( string $option_name ) {
$data = get_option( $option_name );

switch ( $option_name ) {
default:
return $data;
}
return get_option( $option_name );
}

/**
* Update the settings data by option name.
*
* @param string $option_name
* @param $value
*
* @return bool
*/
public static function set( string $option_name, $value ): bool {
return update_option( $option_name, $value, false );
}
Expand Down
1 change: 1 addition & 0 deletions modules/settings/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static function get_plugin_settings(): array {

return [
'isConnected' => Connect::is_connected(),
'closePostConnectModal' => Settings::get( Settings::CLOSE_POST_CONNECT_MODAL ),
'isRTL' => is_rtl(),
];
}
Expand Down

0 comments on commit 680e9ff

Please sign in to comment.