Skip to content

Commit

Permalink
Add mobile ObjectMenu styling
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong committed Oct 15, 2020
1 parent 1ab451c commit 275cbdc
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/react-components/icons/ArrowBack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/react-components/icons/ArrowForward.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/react-components/layout/RoomLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export function RoomLayout({
toolbarClassName,
modal,
viewport,
objectFocused,
...rest
}) {
return (
<div className={classNames(styles.roomLayout, className)} {...rest}>
<div className={classNames(styles.roomLayout, { [styles.objectFocused]: objectFocused }, className)} {...rest}>
{sidebar && <div className={classNames(styles.sidebar, sidebarClassName)}>{sidebar}</div>}
<div className={classNames(styles.modalContainer, styles.viewport)}>{modal}</div>
<Toolbar
Expand All @@ -42,5 +43,6 @@ RoomLayout.propTypes = {
toolbarRight: PropTypes.node,
toolbarClassName: PropTypes.string,
modal: PropTypes.node,
viewport: PropTypes.node
viewport: PropTypes.node,
objectFocused: PropTypes.bool
};
10 changes: 10 additions & 0 deletions src/react-components/layout/RoomLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@
right: 450px;
}
}

:local(.object-focused) {
@media(max-width: theme.$breakpoint-md - 1) {
background-color: theme.$black;

:local(.toolbar) {
display: none;
}
}
}
55 changes: 45 additions & 10 deletions src/react-components/room/ObjectMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { joinChildren } from "../misc/joinChildren";
import styles from "./ObjectMenu.scss";
import { IconButton } from "../input/IconButton";
import { ReactComponent as CloseIcon } from "../icons/Close.svg";
import { ReactComponent as ChevronBackIcon } from "../icons/ChevronBack.svg";
import { ReactComponent as ArrowBackIcon } from "../icons/ArrowBack.svg";
import { ReactComponent as ArrowForwardIcon } from "../icons/ArrowForward.svg";

export function ObjectMenuButton({ children, className, ...rest }) {
return (
Expand All @@ -18,22 +21,54 @@ ObjectMenuButton.propTypes = {
children: PropTypes.node
};

export function ObjectMenu({ children, title, onClose }) {
export function ObjectMenu({
children,
title,
onClose,
onBack,
onPrevObject,
onNextObject,
currentObjectIndex,
objectCount
}) {
return (
<div className={styles.objectMenu}>
<div className={styles.header}>
<IconButton className={styles.closeButton} onClick={onClose}>
<CloseIcon width={16} height={16} />
</IconButton>
<h1>{title}</h1>
<>
<IconButton className={styles.backButton} onClick={onBack}>
<ChevronBackIcon width={24} height={24} />
</IconButton>
<div className={styles.objectMenuContainer}>
<div className={styles.objectMenu}>
<div className={styles.header}>
<IconButton className={styles.closeButton} onClick={onClose}>
<CloseIcon width={16} height={16} />
</IconButton>
<h1>{title}</h1>
</div>
<div className={styles.menu}>{joinChildren(children, () => <div className={styles.separator} />)}</div>
</div>
<div className={styles.pagination}>
<IconButton onClick={onPrevObject}>
<ArrowBackIcon width={24} height={24} />
</IconButton>
<p>
{currentObjectIndex}/{objectCount}
</p>
<IconButton onClick={onNextObject}>
<ArrowForwardIcon width={24} height={24} />
</IconButton>
</div>
</div>
<div className={styles.menu}>{joinChildren(children, () => <div className={styles.separator} />)}</div>
</div>
</>
);
}

ObjectMenu.propTypes = {
currentObjectIndex: PropTypes.number.isRequired,
objectCount: PropTypes.number.isRequired,
onPrevObject: PropTypes.func,
onNextObject: PropTypes.func,
children: PropTypes.node,
title: PropTypes.node,
onClose: PropTypes.func
onClose: PropTypes.func,
onBack: PropTypes.func
};
61 changes: 59 additions & 2 deletions src/react-components/room/ObjectMenu.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
@use "../styles/theme.scss";

:local(.object-menu) {
:local(.back-button) {
position: absolute;
top: 16px;
left: 8px;
pointer-events: auto;

svg {
*[stroke=\#000] {
stroke: theme.$white;
}

*[fill=\#000] {
fill: theme.$white;
}
}

@media(min-width: theme.$breakpoint-md) {
display: none;
}
}

:local(.object-menu-container) {
position: absolute;
bottom: 16px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
background-color: rgba(0, 0, 0, 0.7);
pointer-events: auto;
}

:local(.object-menu) {
display: flex;
flex-direction: column;
background-color: rgba(255, 255, 255, 0.3);
width: max-content;
color: theme.$white;
border-radius: 12px;
Expand All @@ -22,6 +48,10 @@
fill: theme.$white;
}
}

@media(min-width: theme.$breakpoint-md) {
background-color: rgba(0, 0, 0, 0.7);
}
}

:local(.header) {
Expand Down Expand Up @@ -63,4 +93,31 @@
width: 1px;
margin: 0 4px;
background-color: theme.$grey;
}

:local(.pagination) {
display: flex;
align-items: center;
justify-content: space-between;
color: theme.$white;
margin-top: 24px;
padding: 0 4px;

svg {
*[stroke=\#000] {
stroke: theme.$white;
}

*[fill=\#000] {
fill: theme.$white;
}
}
}

@media(max-width: theme.$breakpoint-md - 1) {
:global(.keyboard-user) {
:local(.back-button):focus, :local(.pagination) :focus {
box-shadow: 0 0 0 3px theme.$white;
}
}
}
6 changes: 4 additions & 2 deletions src/react-components/room/ObjectMenu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default {

export const Base = () => (
<RoomLayout
objectFocused
viewport={
<ObjectMenu title="Object">
<ObjectMenu title="Object" currentObjectIndex={1} objectCount={12}>
<ObjectMenuButton>
<PinIcon />
<span>Pin</span>
Expand All @@ -38,8 +39,9 @@ export const Base = () => (

export const WithSidebarOpen = () => (
<RoomLayout
objectFocused
viewport={
<ObjectMenu title="Object">
<ObjectMenu title="Object" currentObjectIndex={1} objectCount={12}>
<ObjectMenuButton>
<PinIcon />
<span>Pin</span>
Expand Down

0 comments on commit 275cbdc

Please sign in to comment.