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

fix(layout): sidebar height on mobile #84

Merged
merged 3 commits into from
Dec 26, 2023
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
4 changes: 2 additions & 2 deletions src/components/layout/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IntrinsicComponentProps } from "../types";
import { processProps } from "../utilities";
import "./index.scss";

export type LayoutFooterProps = IntrinsicComponentProps<"div", object>;
export type LayoutFooterProps = IntrinsicComponentProps<"footer", object>;

export default function LayoutFooter(props: LayoutFooterProps) {
const [local, others] = processProps({
Expand All @@ -16,5 +16,5 @@ export default function LayoutFooter(props: LayoutFooterProps) {
class: "jdd layout-footer",
});

return <div {...combinedProps} />;
return <footer {...combinedProps} />;
}
4 changes: 2 additions & 2 deletions src/components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IntrinsicComponentProps } from "../types";
import { processProps } from "../utilities";
import "./index.scss";

export type LayoutHeaderProps = IntrinsicComponentProps<"div", object>;
export type LayoutHeaderProps = IntrinsicComponentProps<"header", object>;

export default function LayoutHeader(props: LayoutHeaderProps) {
const [local, others] = processProps({
Expand All @@ -16,5 +16,5 @@ export default function LayoutHeader(props: LayoutHeaderProps) {
class: "jdd layout-header",
});

return <div {...combinedProps} />;
return <header {...combinedProps} />;
}
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
4 changes: 2 additions & 2 deletions src/components/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useLayoutContext } from "./context";
import "./index.scss";

export type LayoutSidebarProps = IntrinsicComponentProps<
"div",
"aside",
{
position?: "right" | "left";
}
Expand All @@ -29,7 +29,7 @@ export default function LayoutSidebar(props: LayoutSidebarProps) {
const [_, set] =
local.position === "left" ? context.sidebarLeft : context.sidebarRight;

set(<div {...combinedProps} />);
set(<aside {...combinedProps} />);

return <></>;
}
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