Skip to content

LF-4627 [Nice to have] Implement Add to Map redesign #3715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b95ff09
LF-4627 Render closed drawer inert (cannot be tabbed to)
kathyavini Mar 11, 2025
dad66be
Add left direction option to SIDE_DRAWER variant
kathyavini Mar 13, 2025
05a04f2
Update Stories. Also add story for addBackdrop: false
kathyavini Mar 13, 2025
cab9ede
Remove unnecessary prop (DesktopDrawerVariant has no relevance in mob…
kathyavini Mar 13, 2025
438e513
Make MapDrawer into a left-opening SIDE_DRAWER
kathyavini Mar 13, 2025
431258e
Create and use new styling class to pass to sideDrawer without impact…
kathyavini Mar 13, 2025
33f48be
Update 'add' icon and text
kathyavini Mar 14, 2025
698b9ed
Add a hover state to the map menu items
kathyavini Mar 14, 2025
f653e66
Update the section (area, lines, points) headers
kathyavini Mar 14, 2025
49f7f66
Merge branch 'integration' into LF-4627-nice-to-have-implement-add-to…
kathyavini Mar 14, 2025
bb1593d
LF-4627 Close Add to Map drawer when unmounting the Map component
kathyavini Mar 14, 2025
5558b0b
LF-4627 Fix console error from incorrect capitalization on propTypes
kathyavini Mar 14, 2025
6d1166a
LF-4627 Small adjusts -- comments
kathyavini Mar 14, 2025
ba2de86
LF-4627 Adjust Drawer CSS classes to allow for visual properties to b…
kathyavini Mar 18, 2025
da2ac46
LF-4627 Create option for a drawer with shadow visible on scroll; app…
kathyavini Mar 19, 2025
9d8c503
Revert "LF-4627 Create option for a drawer with shadow visible on scr…
kathyavini Mar 19, 2025
9475217
LF-4627 Give all drawers a border radius of 4px
kathyavini Mar 19, 2025
f59ab3b
LF-4627 Add 'desktop' to sideDrawer classes and props
kathyavini Mar 24, 2025
863e453
Merge branch 'integration' into LF-4627-nice-to-have-implement-add-to…
kathyavini Mar 26, 2025
96017ce
LF-4627 Create union type
kathyavini Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions packages/webapp/src/components/Drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,42 @@ export enum DesktopDrawerVariants {
MODAL = 'modal',
}

interface DrawerProps {
type CommonDrawerProps = {
title: NonNullable<string | React.ReactNode>;
isOpen: boolean;
onClose: () => void;
children: React.ReactNode;
buttonGroup?: React.ReactNode;
fullHeight?: boolean;
desktopVariant?: DesktopDrawerVariants;
addBackdrop?: boolean;
classes?: {
modal?: string;
drawerBackdrop?: string;
drawerHeader?: string;
drawerContent?: string;
drawerContainer?: string;
drawerContainer?: string; // applied to all drawers
desktopSideDrawerContainer?: string;
};
}
};

type DrawerProps = CommonDrawerProps &
(
| {
desktopVariant?: DesktopDrawerVariants.DRAWER | DesktopDrawerVariants.MODAL;
desktopSideDrawerDirection?: never;
isCompactSideMenu?: never;
}
| {
desktopVariant: DesktopDrawerVariants.SIDE_DRAWER;
desktopSideDrawerDirection?: 'right';
isCompactSideMenu?: never;
}
| {
desktopVariant: DesktopDrawerVariants.SIDE_DRAWER;
desktopSideDrawerDirection: 'left';
isCompactSideMenu: boolean;
}
);

const Drawer = ({
title,
Expand All @@ -55,14 +74,19 @@ const Drawer = ({
drawerHeader: '',
drawerContent: '',
drawerContainer: '',
desktopSideDrawerContainer: '',
},
fullHeight,
desktopVariant = DesktopDrawerVariants.MODAL,
desktopSideDrawerDirection = 'right',
isCompactSideMenu,
addBackdrop = true,
}: DrawerProps) => {
const theme = useTheme();
const isDesktop = useMediaQuery(theme.breakpoints.up('sm'));

const isDesktopSideDrawer = isDesktop && desktopVariant === DesktopDrawerVariants.SIDE_DRAWER;

return isDesktop && desktopVariant === DesktopDrawerVariants.MODAL && isOpen ? (
<ModalComponent
className={classes.modal}
Expand All @@ -88,13 +112,17 @@ const Drawer = ({
<div
className={clsx(
styles.drawer,
isDesktop && desktopVariant === DesktopDrawerVariants.SIDE_DRAWER
? styles.sideDrawer
: styles.bottomDrawer,
isDesktopSideDrawer ? styles.sideDrawer : styles.bottomDrawer,
isDesktopSideDrawer && styles[desktopSideDrawerDirection],
desktopSideDrawerDirection === 'left' && isCompactSideMenu
? styles.withCompactSideMenu
: styles.withExpandedSideMenu,
fullHeight && styles.fullHeight,
isOpen ? styles.openD : '',
classes.drawerContainer,
isDesktopSideDrawer && classes.desktopSideDrawerContainer,
)}
inert={!isOpen ? '' : null}
>
<div className={clsx(styles.header, classes.drawerHeader)}>
<div className={styles.title}>{title}</div>
Expand Down
44 changes: 36 additions & 8 deletions packages/webapp/src/components/Drawer/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
position: fixed;
transition: all 0.2s ease-in-out;
background-color: var(--White);
border-top-left-radius: 10px;
padding: 16px;
z-index: 1110;
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.25);
Expand All @@ -54,29 +53,58 @@
}

.bottomDrawer {
bottom: -100%;
border-radius: 4px 4px 0 0;
left: 0;
right: 0;
border-top-right-radius: 10px;
margin: auto;
}

.sideDrawer {
top: var(--global-navbar-height);
max-height: calc(100vh - var(--global-navbar-height));
}

.right {
border-radius: 4px 0 0 4px;
}

.left {
border-radius: 0 4px 4px 0;
}

// Drawer opening properties
.drawer.bottomDrawer {
bottom: -100%;

&.openD {
bottom: 0;
}
}

.sideDrawer {
top: var(--global-navbar-height);
max-height: calc(100vh - var(--global-navbar-height));
.sideDrawer.right {
right: -100%;
border-bottom-left-radius: 10px;
width: 416px;

&.openD {
right: 0;
}
}

.sideDrawer.left.withExpandedSideMenu {
left: -100%;

&.openD {
left: var(--global-side-menu-width);
}
}

.sideDrawer.left.withCompactSideMenu {
left: -100%;

&.openD {
left: var(--global-compact-side-menu-width);
}
}

.header {
display: flex;
justify-content: space-between;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const WithPageTitle = ({
<ClickAwayListener onClickAway={onClickAway} mouseEvent="onMouseDown" touchEvent="onTouchStart">
<div>
<Layout>
{/* @ts-expect-error */}
<MultiStepPageTitle
title={title}
onGoBack={onGoBack}
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/src/components/Map/Footer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default function PureMapFooter({
filterSettings={filterSettings}
availableFilterSettings={availableFilterSettings}
onMenuItemClick={onFilterMenuClick}
isCompactSideMenu={isCompactSideMenu}
/>
<MapDrawer
key={'add'}
Expand All @@ -104,6 +105,7 @@ export default function PureMapFooter({
drawerDefaultHeight={window.innerHeight - 156}
headerTitle={t('FARM_MAP.MAP_FILTER.ADD_TITLE')}
onMenuItemClick={onAddMenuClick}
isCompactSideMenu={isCompactSideMenu}
/>
</TourProviderWrapper>
);
Expand Down
13 changes: 11 additions & 2 deletions packages/webapp/src/components/MapDrawer/MapDrawerMenuItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import ListItem from '@mui/material/ListItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
Expand All @@ -6,18 +8,22 @@ import { colors, DefaultThemeProvider } from '../../assets/theme';
import PropTypes from 'prop-types';
import { Main } from '../Typography';
import styles from './styles.module.scss';
import Icon from '../Icons';

export default function MapDrawerMenuItem({
onClick,
isFilterMenuItem,
isFiltered,
children,
name,
}) {
const { t } = useTranslation();

return (
<DefaultThemeProvider>
<ListItem
button
style={{ backgroundColor: isFiltered ? '#F3F6FB' : 'white' }}
className={clsx(isFiltered ? styles.filteredItem : styles.menuItem)}
onClick={onClick}
>
<ListItemIcon>{children}</ListItemIcon>
Expand All @@ -29,7 +35,10 @@ export default function MapDrawerMenuItem({
{isFilterMenuItem ? (
<EyeToggleIcon isFiltered={isFiltered} />
) : (
<span className={styles.plusIcon}>+</span>
<div className={styles.plusAdd}>
<Icon iconName={'PLUS_CIRCLE'} className={styles.plusIcon} />
{t('common:ADD')}
</div>
)}
</ListItem>
</DefaultThemeProvider>
Expand Down
25 changes: 16 additions & 9 deletions packages/webapp/src/components/MapDrawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
import { locationEnum } from '../../containers/Map/constants';
import MapDrawerMenuItem from './MapDrawerMenuItem';
import Drawer from '../Drawer';
import Drawer, { DesktopDrawerVariants } from '../Drawer';
import styles from './styles.module.scss';

export default function MapDrawer({
Expand All @@ -33,6 +33,7 @@ export default function MapDrawer({
filterSettings,
availableFilterSettings,
headerTitle,
isCompactSideMenu,
}) {
const { t } = useTranslation();

Expand Down Expand Up @@ -200,9 +201,8 @@ export default function MapDrawer({
)}

{!!areaImgDict.length && (
<Label className={styles.label}>
<Label className={clsx(styles.label, !!filterSettings && styles.sectionLabelPadding)}>
{t('FARM_MAP.MAP_FILTER.AREAS')}
<span className={styles.labelDivider} />
</Label>
)}
{areaImgDict.map(({ key, name, icon }) => {
Expand All @@ -220,10 +220,11 @@ export default function MapDrawer({
})}

{!!lineImgDict.length && (
<Label className={styles.label}>
{t('FARM_MAP.MAP_FILTER.LINES')}
<span className={styles.labelDivider} />
</Label>
<>
<Label className={clsx(styles.label, styles.sectionLabelPadding)}>
{t('FARM_MAP.MAP_FILTER.LINES')}
</Label>
</>
)}
{lineImgDict.map(({ key, name, icon }) => (
<MapDrawerMenuItem
Expand All @@ -238,9 +239,8 @@ export default function MapDrawer({
))}

{!!pointImgDict.length && (
<Label className={styles.label}>
<Label className={clsx(styles.label, styles.sectionLabelPadding)}>
{t('FARM_MAP.MAP_FILTER.POINTS')}
<span className={styles.labelDivider} />
</Label>
)}
{pointImgDict.map(({ key, name, icon }) => (
Expand All @@ -264,7 +264,14 @@ export default function MapDrawer({
data-cy="map-drawer"
title={headerTitle}
isOpen={showMapDrawer}
desktopVariant={DesktopDrawerVariants.SIDE_DRAWER}
desktopSideDrawerDirection="left"
isCompactSideMenu={isCompactSideMenu}
addBackdrop={false}
onClose={() => setShowMapDrawer(false)}
classes={{
desktopSideDrawerContainer: styles.sideDrawerContainer,
}}
>
{list()}
</Drawer>
Expand Down
51 changes: 40 additions & 11 deletions packages/webapp/src/components/MapDrawer/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/

.headerContentContainer {
.headerContentContainer {
padding-bottom: 8px;
}

Expand All @@ -34,19 +34,48 @@
}

.label {
height: 24px;
color: var(--Colors-Neutral-Neutral-600);
font-size: 18px;
font-weight: 700;
line-height: 24px;
}

.labelDivider {
display: inline-block;
border-top: 1px solid;
width: calc(100% - 80px);
transform: translate(11px, -3px);
color: #C4C4C4;
.sectionLabelPadding {
padding-top: 32px;
}

// MapDrawerMenuItem.jsx
.menuItem {
background-color: white;
&:hover {
background-color: var(--Colors-Primary-Primary-teal-50);
}
}

.filteredItem {
background-color: #f3f6fb;
}

.plusAdd {
display: flex;
padding: 2px;
align-items: center;
gap: 4px;

color: var(--Colors-Primary-Primary-teal-700);
font-weight: 600;
line-height: 24px;
}

.plusIcon {
color: var(--teal700);
font-size: 42px;
line-height: 16px;
background-color: transparent;
}

// Drawer
.sideDrawerContainer {
top: calc(
var(--global-navbar-height) + var(--global-map-header-height) - 1px /* sm gap without adjust */
);
max-height: calc(100vh - var(--global-navbar-height) - var(--global-map-header-height));
min-width: 432px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { matchPath } from 'react-router-dom';
import useExpandable from '../../Expandable/useExpandableItem';
import { ReactComponent as Logo } from '../../../assets/images/middle_logo.svg';
import { useGetMenuItems } from '../../../hooks/useGetMenuItems';
import Drawer, { DesktopDrawerVariants } from '../../Drawer';
import Drawer from '../../Drawer';
import { ReactComponent as CollapseMenuIcon } from '../../../assets/images/nav/collapse-menu.svg';
import styles from './styles.module.scss';
import { getLanguageFromLocalStorage } from '../../../util/getLanguageFromLocalStorage';
Expand Down Expand Up @@ -235,7 +235,6 @@ const PureSideMenu = ({
isOpen={isDrawerOpen}
onClose={onDrawerClose}
fullHeight
desktopVariant={DesktopDrawerVariants.DRAWER}
classes={{
drawerContainer: styles.drawerContainer,
drawerHeader: styles.drawerHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function CancelButton({ onCancel, showConfirmCancelModal, setShowConfirmC
);
}

CancelButton.PropTypes = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely unrelated but this was my typo from #3710 in two files that was causing a console warning:

Screenshot 2025-03-14 at 3 50 19 PM

CancelButton.propTypes = {
onCancel: PropTypes.func,
showConfirmCancelModal: PropTypes.bool,
setShowConfirmCancelModal: PropTypes.func,
Expand Down
Loading