Skip to content

Commit

Permalink
[App 780] Navigation Sidebar (#115)
Browse files Browse the repository at this point in the history
* Initial refactor commit

* ✅ Added build and tests CI/CD

* update: add src for admin settings

* update: incorrect constant names

* update: namespace

* add: accessibility settings

* update: webpack to output files inside a folder

* update: build output folders

* update: removed commented code

* update: npm scripts

* add: webpack config

* add: hooks

* update: move admin setting to the module folder

* update: assets loading logic

* update: add rule to move jsx props to multiline imporving readability

* add: connect modal

* update: hooks import for better readability

* update: replace functions with hooks

* add: connect module

* add: settings and get settings route

* add: hooks and contexts to get settings

* add: hooks

* add: notification component

* add: data api

* add: settings provider and connect settings

* add: husky

* fix: formatting and text-domain

* update: filter names

* fix: hook import

* add: set function for settings

* add: prop-types package

* update: refactor notification component and context

* update: remove filter for authorize url

* update: imports and exports of hooks

* update: plugin settings context filename and relevant imports

* update: icons and icon imports

* add: sidebar(wip)

* update: fix width of connect screen on mobile

* update: sidebar layout

* add: credit card and user arrow icons

* update: hidden wpfooter and fixed sidebar height

* update: sidebar layout

* add: basic page layouts

* update: sidebar layout

* add: sidebar menu, sidebar app bar and my account menu components

* update: add sidebar and menu settings

* update: add page layouts

* update: admin top bar

* add: bottom bar

* add: bottom bar and top bar

* add: bottom bar and top bar

* update: page content styling

* fix: styling

* fix: styling

* update: text domain

* update: added translations

* fix: admin top bar layout

* update: exports of icons

* update: exports of components

* add: aliases for imports and fix exports

* fix: height and styling of the layout

* fix: unhide wp footer

* update: keep widget menu open on page load (default)

* update: linter rules to move first prop to new line

* update: linter rules to move first prop to new line

---------

Co-authored-by: Ohad <[email protected]>
  • Loading branch information
nirbhayel and bainternet authored Nov 27, 2024
1 parent cf77dbe commit 0c63bac
Show file tree
Hide file tree
Showing 41 changed files with 720 additions and 125 deletions.
16 changes: 15 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"babel",
"react"
],
"settings": {
"import/resolver": {
"node": {
"paths": ["node_modules"]
},
"webpack": {
"config": "webpack.config.js"
}
}
},
"env": {
"browser": true,
"node": true,
Expand All @@ -27,6 +37,7 @@
"no-console": "off",
"react-hooks/exhaustive-deps": "off",
"react/jsx-max-props-per-line": [1, { "maximum": { "single": 2, "multi": 1 } }],
"react/jsx-first-prop-new-line": ["error", "multiline"],
"strict": [ "error", "global" ],
"curly": "warn",
"import/order": [
Expand All @@ -47,7 +58,10 @@
"caseInsensitive": false
}
}
]
],
"import/newline-after-import": ["error", {
"count": 1
}]
},
"parser": "@babel/eslint-parser"
}
15 changes: 4 additions & 11 deletions modules/settings/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
body {
background: #fff;
}

.wrap {
margin-top: 0;
}

html:not([dir='rtl']) #ea11y-app {
margin-left: -20px;
background: white;
height: calc(100vh - 32px);
}

html[dir='rtl'] #ea11y-app {
margin-right: -20px;
background: white;
}

html:not([dir='rtl']) #ea11y-app-top-bar {
margin-left: -20px;
margin-bottom: 20px;
}

html[dir='rtl'] #ea11y-app-top-bar {
margin-right: -20px;
margin-bottom: 20px;
height: calc(100vh - 32px);
}

#ea11y-app * {
Expand All @@ -34,4 +27,4 @@ html[dir='rtl'] #ea11y-app-top-bar {
padding: 8px 12px;
box-shadow: none;
border-color: rgba(12, 13, 14, 0.23);
}
}
12 changes: 1 addition & 11 deletions modules/settings/assets/js/admin.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { ThemeProvider } from '@elementor/ui/styles';
import { SettingsProvider, NotificationsProvider } from '@ea11y/hooks';
import { StrictMode, Fragment, createRoot } from '@wordpress/element';
import App from './app';
import AdminTopBar from './components/admin-top-bar';
import { PluginSettingsProvider } from './contexts/plugin-settings';
import { SettingsProvider, NotificationsProvider } from './hooks';

const rootNode = document.getElementById( 'ea11y-app' );
const topBarNode = document.getElementById( 'ea11y-app-top-bar' );

// Can't use the settings hook in the global scope so accessing directly
const isDevelopment = window?.ea11ySettingsData?.isDevelopment;
const AppWrapper = Boolean( isDevelopment ) ? StrictMode : Fragment;

const root = createRoot( rootNode );
const topBar = createRoot( topBarNode );

topBar.render(
<ThemeProvider colorScheme="light">
<AdminTopBar />
</ThemeProvider>,
);

root.render(
<AppWrapper>
Expand Down
29 changes: 27 additions & 2 deletions modules/settings/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
import '../css/style.css';
import Box from '@elementor/ui/Box';
import DirectionProvider from '@elementor/ui/DirectionProvider';
import Grid from '@elementor/ui/Grid';
import { ThemeProvider } from '@elementor/ui/styles';
import { ConnectModal, Notifications } from './components';
import { ConnectModal, Notifications, MenuItems, AdminTopBar, BottomBar } from '@ea11y/components';
import { useNotificationSettings, useSettings } from '@ea11y/hooks';
import { usePluginSettingsContext } from './contexts/plugin-settings';
import { useNotificationSettings } from './hooks';
import { Sidebar } from './layouts/sidebar';

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

// Accessing the selected menu item
const selectedParent = MenuItems[ selectedMenu.parent ];
const selectedChild = selectedMenu.child ? selectedParent.children[ selectedMenu.child ] : null;
return (
<DirectionProvider rtl={ false /* TODO:Add RTL detection in settings */ }>
<ThemeProvider colorScheme="light">
{ ! isConnected && <ConnectModal /> }
<Grid
display="flex"
flexDirection="row"
height="100%">
<Sidebar />
<Box
width="100%"
display="flex"
flexDirection="column"
justifyContent="space-between"
>
<AdminTopBar />
<Box p={ 1 } height="100%">
{ selectedChild ? selectedChild.page : selectedParent?.page }
</Box>
<BottomBar />
</Box>
</Grid>
<Notifications message={ notificationMessage } type={ notificationType } />
</ThemeProvider>
</DirectionProvider>
Expand Down
34 changes: 13 additions & 21 deletions modules/settings/assets/js/components/admin-top-bar/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import HelpIcon from '@elementor/icons/HelpIcon';
import AppBar from '@elementor/ui/AppBar';
import Grid from '@elementor/ui/Grid';
import Link from '@elementor/ui/Link';
import Toolbar from '@elementor/ui/Toolbar';
import Typography from '@elementor/ui/Typography';
import { __ } from '@wordpress/i18n';
import { HELP_LINK } from '../../constants';
import ElementorLogo from '../../icons/elementor-logo';

const AdminTopBar = () => {
export const AdminTopBar = () => {
const toolBarStyle = {
justifyContent: 'end',
alignItems: 'center',
backgroundColor: 'background.default',
gap: '10px',
borderBottom: '1px solid rgba(0, 0, 0, 0.12)' };
return (
<AppBar position="static"
elevation={ 6 }
sx={ { boxShadow: '0px 3px 16px 0px rgba(35, 38, 42, 0.20)' } } >
<Toolbar direction="row"
sx={ { alignItems: 'center', backgroundColor: 'background.default', gap: '10px' } }
<AppBar position="static">
<Toolbar
direction="row"
sx={ toolBarStyle }
padding={ 2 }>
<Grid container={ true }
alignItems="center"
gap={ 1 }>
<ElementorLogo size="large" />
<Typography color="text.primary">
{ __( 'Accessibility', 'pojo-accessibility' ) }
</Typography>
</Grid>

<Link color="secondary"
<Link
color="secondary"
underline="hover"
href={ HELP_LINK }
target="_blank"
Expand All @@ -37,5 +31,3 @@ const AdminTopBar = () => {
</AppBar>
);
};

export default AdminTopBar;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const AlignmentMatrixControl = () => {
{ __( 'Default Position', 'pojo-accessibility' ) }
</Typography>
</FormLabel>
<Box display="flex"
<Box
display="flex"
justifyContent="center"
padding={ 2 }
width="100%"
Expand All @@ -53,7 +54,8 @@ const AlignmentMatrixControl = () => {
width: '100px',
} }
>
{ options.map( ( option, i ) => <FormControlLabel sx={ { margin: 0 } }
{ options.map( ( option, i ) => <FormControlLabel
sx={ { margin: 0 } }
key={ i }
value={ option.value }
control={ <Radio color="secondary" /> } /> ) }
Expand Down
18 changes: 18 additions & 0 deletions modules/settings/assets/js/components/bottom-bar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Box from '@elementor/ui/Box';
import Button from '@elementor/ui/Button';
import { __ } from '@wordpress/i18n';

export const BottomBar = () => {
return (
<Box
display="flex"
justifyContent="end"
p={ 2 }
width="100%"
borderTop="1px solid rgba(0, 0, 0, 0.12)">
<Button variant="contained" color="info">
{ __( 'Save Changes', 'pojo-accessibility' ) }
</Button>
</Box>
);
};
9 changes: 6 additions & 3 deletions modules/settings/assets/js/components/color-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const ColorPicker = () => {
{ __( 'Color', 'pojo-accessibility' ) }
</Typography>
</FormLabel>
<Grid padding={ 1 }
<Grid
padding={ 1 }
border={ 1 }
borderColor="divider"
borderRadius={ 1 }
Expand All @@ -30,11 +31,13 @@ const ColorPicker = () => {
className="widget-settings-color-picker"
/>
<Grid marginTop={ 2 } display="flex">
<Box padding={ 2 }
<Box
padding={ 2 }
sx={ { backgroundColor: color } }
borderRadius={ 1 }
marginRight={ 1 }></Box>
<HexColorInput color={ color }
<HexColorInput
color={ color }
onChange={ setColor }
style={ {
width: '100%',
Expand Down
Loading

0 comments on commit 0c63bac

Please sign in to comment.