Skip to content

Commit

Permalink
fix(layout): sidebar height on mobile (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
jer3m01 authored Dec 26, 2023
1 parent 358379f commit eee69eb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/layout/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
transition: var(--jdd-sidebar-transition);
z-index: 50;
max-width: 90vw;
height: 100dvh;
}

.layout-sidebar:first-child {
Expand Down
18 changes: 13 additions & 5 deletions src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { WindowEventListener } from "@solid-primitives/event-listener";
import { createBreakpoints } from "@solid-primitives/media";
import { combineProps } from "@solid-primitives/props";
import { Show, createEffect, createSignal } from "solid-js";
import { isServer } from "solid-js/web";
import { IntrinsicComponentProps } from "../types";
import { processProps } from "../utilities";
import LayoutContent from "./content";
Expand Down Expand Up @@ -57,6 +58,7 @@ function InnerLayout(props: LayoutProps) {
const [sidebarTransition, setSidebarTransition] = createSignal(false);

createEffect(() => {
if (isServer) return;
setSidebarTransition(true);

setTimeout(() => {
Expand Down Expand Up @@ -88,7 +90,7 @@ function InnerLayout(props: LayoutProps) {
? "transform 0.3s var(--jdd-transition-function), opacity 0.3s var(--jdd-transition-function)"
: "",
get "--jdd-layout-backdrop-opacity"() {
if (leftSidebarOpen() || rightSidebarOpen()) {
if (isServer || leftSidebarOpen() || rightSidebarOpen()) {
return "";
}

Expand Down Expand Up @@ -140,13 +142,19 @@ function InnerLayout(props: LayoutProps) {

let swipeDirection: "left" | "right" | undefined;

// Left swipe
if (swipeStart().x < local.swipeDistanceFromSides) {
// Swipe from left to right
if (
getSidebarLeft() !== undefined &&
swipeStart().x < local.swipeDistanceFromSides
) {
swipeDirection = "right";
}

// Right swipe
if (window.innerWidth - swipeStart().x < local.swipeDistanceFromSides) {
// Swipe from right to left
if (
getSidebarRight() !== undefined &&
window.innerWidth - swipeStart().x < local.swipeDistanceFromSides
) {
swipeDirection = "left";
}

Expand Down
8 changes: 5 additions & 3 deletions src/components/sidenav/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
color: var(--jdd-blue-6);
}

&:hover:not(:disabled):not([aria-disabled]) {
background: var(--jdd-blue-6);
color: var(--jdd-gray-1);
&:not(:disabled):not([aria-disabled]) {
&:hover, &:focus-visible {
background: var(--jdd-blue-6);
color: var(--jdd-gray-1);
}
}

> svg, span > svg {
Expand Down

0 comments on commit eee69eb

Please sign in to comment.