Skip to content

Commit

Permalink
Drawer UX improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
manojVivek committed May 21, 2020
1 parent a4f207a commit eabfe8b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
4 changes: 2 additions & 2 deletions desktop-app/app/components/Drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cx from 'classnames';

import styles from './styles.css';
import commonStyles from '../common.styles.css';
import {DEVICE_MANAGER, SETTINGS} from '../../constants/DrawerContents';
import {DEVICE_MANAGER, USER_PREFERENCES} from '../../constants/DrawerContents';
import {iconsColor} from '../../constants/colors';
import DoubleLeftArrowIcon from '../icons/DoubleLeftArrow';

Expand Down Expand Up @@ -61,7 +61,7 @@ function getDrawerContent(type) {
switch (type) {
case DEVICE_MANAGER:
return <DeviceDrawerContainer />;
case SETTINGS:
case USER_PREFERENCES:
return <UserPreferencesContainer />;
}
}
Expand Down
38 changes: 26 additions & 12 deletions desktop-app/app/components/LeftIconsPane/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {iconsColor} from '../../constants/colors';
import {
DEVICE_MANAGER,
SCREENSHOT_MANAGER,
SETTINGS,
USER_PREFERENCES,
} from '../../constants/DrawerContents';

const LeftIconsPane = props => {
Expand All @@ -25,6 +25,13 @@ const LeftIconsPane = props => {
height: 30,
width: 30,
};
const toggleState = content => {
if (props.drawer.open && props.drawer.content === content) {
return props.changeDrawerOpenState(false);
}

props.openDrawerAndSetContent(content);
};
return (
<div className={styles.iconsContainer}>
<div className={cx(styles.logo, styles.icon)}>
Expand All @@ -37,23 +44,30 @@ const LeftIconsPane = props => {
alignItems="center"
className={cx(styles.utilitySection)}
>
<Grid item className={cx(commonStyles.icons, styles.icon, commonStyles.enabled)}>
<div onClick={() => props.openDrawerAndSetContent(DEVICE_MANAGER)}>
<Grid
item
className={cx(commonStyles.icons, styles.icon, commonStyles.enabled, {
[commonStyles.selected]:
props.drawer.open && props.drawer.content === DEVICE_MANAGER,
})}
onClick={() => toggleState(DEVICE_MANAGER)}
>
<div>
<DevicesIcon {...iconProps} className="deviceManagerIcon" />
</div>
</Grid>
<Grid item className={cx(commonStyles.icons, styles.icon, commonStyles.enabled)}>
<div onClick={() => props.openDrawerAndSetContent(SETTINGS)}>
<Grid
item
className={cx(commonStyles.icons, styles.icon, commonStyles.enabled, {
[commonStyles.selected]:
props.drawer.open && props.drawer.content === USER_PREFERENCES,
})}
onClick={() => toggleState(USER_PREFERENCES)}
>
<div>
<SettingsIcon {...iconProps} className="settingsIcon" />
</div>
</Grid>
{/*<Grid item className={cx(commonStyles.icons, commonStyles.enabled)}>
<div
onClick={() => props.openDrawerAndSetContent(SCREENSHOT_MANAGER)}
>
<PhotoLibraryIcon {...iconProps} />
</div>
</Grid>*/}
</Grid>
<div style={{position: 'relative'}}>
<div
Expand Down
2 changes: 1 addition & 1 deletion desktop-app/app/components/LeftIconsPane/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

.icon {
margin-bottom: 10px;
margin-bottom: 10px !important;
}

.utilitySection {
Expand Down
4 changes: 2 additions & 2 deletions desktop-app/app/components/common.styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

.icons.enabled:hover {
opacity: 1;
background: #7587ec;
background: #6075ef;
}

.icons.selected {
background: #7587ecf5;
background: #7587ec;
}

.iconDisabler {
Expand Down
2 changes: 1 addition & 1 deletion desktop-app/app/constants/DrawerContents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const DEVICE_MANAGER = 'DEVICE_MANAGER';
export const SCREENSHOT_MANAGER = 'SCREENSHOT_MANAGER';
export const SETTINGS = 'SETTINGS';
export const USER_PREFERENCES = 'USER_PREFERENCES';
23 changes: 21 additions & 2 deletions desktop-app/app/reducers/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type PreviewerType = {

type UserPreferenceType = {
disableSSLValidation: boolean,
drawerState: boolean,
};

type FilterFieldType = FILTER_FIELDS.OS | FILTER_FIELDS.DEVICE_TYPE;
Expand Down Expand Up @@ -89,6 +90,14 @@ function _getActiveDevices() {
return activeDevices;
}

function _getUserPreferences(): UserPreferenceType {
return settings.get(USER_PREFERENCES) || {};
}

function _setUserPreferences(userPreferences) {
settings.set(USER_PREFERENCES, userPreferences);
}

export default function browser(
state: BrowserStateType = {
devices: _getActiveDevices(),
Expand All @@ -98,10 +107,16 @@ export default function browser(
previousZoomLevel: null,
scrollPosition: {x: 0, y: 0},
navigatorStatus: {backEnabled: false, forwardEnabled: false},
drawer: {open: true, content: DEVICE_MANAGER},
drawer: {
open:
_getUserPreferences().drawerState === null
? true
: _getUserPreferences().drawerState,
content: DEVICE_MANAGER,
},
previewer: {layout: FLEXIGRID_LAYOUT},
filters: {[FILTER_FIELDS.OS]: [], [FILTER_FIELDS.DEVICE_TYPE]: []},
userPreferences: settings.get(USER_PREFERENCES) || {},
userPreferences: _getUserPreferences(),
},
action: Action
) {
Expand All @@ -119,6 +134,10 @@ export default function browser(
case NEW_NAVIGATOR_STATUS:
return {...state, navigatorStatus: action.navigatorStatus};
case NEW_DRAWER_CONTENT:
_setUserPreferences({
...state.userPreferences,
drawerState: action.drawer.open,
});
return {...state, drawer: action.drawer};
case NEW_PREVIEWER_CONFIG:
const updateObject = {previewer: action.previewer};
Expand Down

0 comments on commit eabfe8b

Please sign in to comment.