Skip to content

Commit

Permalink
🎨 improve how actionsCorner option is handled
Browse files Browse the repository at this point in the history
  • Loading branch information
francisashley committed Dec 16, 2019
1 parent df656e6 commit 55a6b1b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/features/action-bar/action-bar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ReloadButton from "../action-bar/reload-button";
import TrayButton from "../action-bar/tray-button";
import classnames from "classnames";
import crel from "crel";

export default function ActionBar({
Expand All @@ -11,11 +10,11 @@ export default function ActionBar({
trayIsOpen,
onToggleTray = () => {}
} = {}) {
const className = classnames(corner && "mde-action-bar-" + corner);
corner = ["tl", "tr"].includes(corner) ? corner : "tl";

return crel(
"div",
{ id: "mde-action-bar", class: className },
{ id: "mde-action-bar", "data-corner": corner },
showReload ? ReloadButton({ onClick: () => location.reload(shouldRefreshCache) }) : null,
showTray ? TrayButton({ isActive: trayIsOpen, onClick: onToggleTray }) : null
);
Expand Down
16 changes: 14 additions & 2 deletions src/mde.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,17 @@ test("MDE shows correct actions", () => {
expect(document.querySelector("#mde-action-bar #mde-toggle-tray")).toBeTruthy();
});

test.todo("MDE shows actions tray on top left");
test.todo("MDE shows actions tray on top right");
test("MDE shows actions tray on top right by default", () => {
mobileDevEnvironment();

expect(document.querySelector("#mde-action-bar[data-corner=tr]")).toBeTruthy();
});
test("MDE shows actions tray on top left", () => {
mobileDevEnvironment({ actionsCorner: "tl" });
expect(document.querySelector("#mde-action-bar[data-corner=tl]")).toBeTruthy();
});
test("MDE shows actions tray on top right", () => {
mobileDevEnvironment({ actionsCorner: "tr" });

expect(document.querySelector("#mde-action-bar[data-corner=tr]")).toBeTruthy();
});
7 changes: 4 additions & 3 deletions src/sass/mde.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.1);
position: fixed;
top: 10px;
left: 10px;
z-index: 1;
border: thin solid #6e6e6e;

&.mde-action-bar-tr {
&[data-corner="tl"] {
left: 10px;
}
&[data-corner="tr"] {
right: 10px;
left: auto;
}

> button {
Expand Down

0 comments on commit 55a6b1b

Please sign in to comment.