Skip to content
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

Prevent mobile views having elements that are being cut off. #3737

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 17 additions & 21 deletions imports/plugins/core/dashboard/client/components/actionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import { getComponent } from "@reactioncommerce/reaction-components";


const getStyles = (props) => {
let viewSize = 400;
const minWidth = Math.min(props.viewportWidth, 400);
let viewSize = minWidth;
const actionView = props.actionView || {};
const provides = actionView.provides || [];
// legacy provides could be a string, is an array since 1.5.0, check for either.
// prototype.includes has the fortunate side affect of checking string equality as well as array inclusion.
const isBigView = provides.includes("dashboard") ||
(provides.includes("shortcut") && actionView.container === "dashboard");

if (isBigView) {
viewSize = "90vw";
}
Expand All @@ -35,7 +35,7 @@ const getStyles = (props) => {
const isLgView = actionView.meta.actionView.dashboardSize === "lg";

if (isSmView) {
viewSize = "400px";
viewSize = `${minWidth}px`;
}
if (isMdView) {
viewSize = "50vw";
Expand All @@ -51,21 +51,17 @@ const getStyles = (props) => {

return {
base: {
"display": "flex",
"flexDirection": "row",
"height": "100vh",
"position": "relative",
"width": viewSize,
"minWidth": 400,
"@media only screen and (max-width: 949px)": {
width: "100vw"
},
"boxShadow": isBigView ? "0 0 40px rgba(0,0,0,.1)" : "",
"flex": "0 0 auto",
"backgroundColor": "white",
"overflow": "hidden",
"transition": "width 300ms cubic-bezier(0.455, 0.03, 0.515, 0.955))",
"zIndex": 1050
display: "flex",
flexDirection: "row",
height: "100vh",
position: "relative",
width: viewSize,
boxShadow: isBigView ? "0 0 40px rgba(0,0,0,.1)" : "",
flex: "0 0 auto",
backgroundColor: "white",
overflow: "hidden",
transition: "width 300ms cubic-bezier(0.455, 0.03, 0.515, 0.955))",
zIndex: 1050
},
header: {
display: "flex",
Expand All @@ -92,8 +88,7 @@ const getStyles = (props) => {
masterViewPanel: {
display: "flex",
flexDirection: "column",
flex: "1 1 auto",
width: "50%"
flex: "1 1 auto"
},
masterView: {
flex: "1 1 auto",
Expand Down Expand Up @@ -144,7 +139,8 @@ class ActionView extends Component {
handleActionViewDetailClose: PropTypes.func,
isActionViewAtRootView: PropTypes.bool,
isDetailViewAtRootView: PropTypes.bool,
language: PropTypes.string
language: PropTypes.string,
viewportWidth: PropTypes.number
}

constructor(props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function composer(props, onData) {
tooltipPosition: "left middle"
});

// calculated here and not in component, as environment dependent.
const viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);

onData(null, {
isAdminArea: true,
Expand All @@ -60,9 +62,9 @@ function composer(props, onData) {
buttons: items,
isActionViewAtRootView: Reaction.isActionViewAtRootView(),
isDetailViewAtRootView: Reaction.isActionViewDetailAtRootView(),

actionViewIsOpen: Reaction.isActionViewOpen(),
detailViewIsOpen: Reaction.isActionViewDetailOpen(),
viewportWidth,

// Callbacks
handleActionViewBack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ html:not(.rtl) .rui.admin.action-view {

.admin-controls-content {
.flex(1 1 auto);
min-width: 400px;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
Expand Down