Remove hover effect on mobile in editor (#3163)

* editor: remove background on hover on mobile

* editor: fix task item alignment and size on mobile
This commit is contained in:
Ammar Ahmed
2023-09-04 15:06:41 +05:00
committed by GitHub
parent 1775e0bda1
commit 003b3d2a84
6 changed files with 30 additions and 11 deletions

View File

@@ -107,9 +107,11 @@ export function TaskItemComponent(
mt: "0.40ch", mt: "0.40ch",
marginInlineEnd: 1, marginInlineEnd: 1,
cursor: editor.isEditable ? "pointer" : "unset", cursor: editor.isEditable ? "pointer" : "unset",
":hover": { ":hover": isMobile
borderColor: "accent" ? undefined
}, : {
borderColor: "accent"
},
fontFamily: "inherit" fontFamily: "inherit"
}} }}
onMouseDown={(e) => { onMouseDown={(e) => {
@@ -125,7 +127,7 @@ export function TaskItemComponent(
} }
}} }}
color={checked ? "accent" : "icon"} color={checked ? "accent" : "icon"}
size={isMobile ? "1.66ch" : "1.46ch"} size={isMobile ? "1.70ch" : "1.46ch"}
/> />
<Box <Box
@@ -143,7 +145,8 @@ export function TaskItemComponent(
opacity: 1 opacity: 1
}, },
flex: 1, flex: 1,
mt: "1px" mt: ["3px", "3px", 0],
ml: ["2px", "2px", 0]
}} }}
/> />
<DesktopOnly> <DesktopOnly>

View File

@@ -76,7 +76,7 @@ export function TaskListComponent(
sx={{ sx={{
position: "relative", position: "relative",
bg: "var(--background-secondary)", bg: "var(--background-secondary)",
py: "5px", py: "0.6em",
borderRadius: "default", borderRadius: "default",
mb: 2, mb: 2,
alignItems: "center", alignItems: "center",

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react"; import React from "react";
import { Flex, Text } from "@theme-ui/components"; import { Flex, Text } from "@theme-ui/components";
import { ToolButton } from "./tool-button"; import { ToolButton } from "./tool-button";
import { useIsMobile } from "../stores/toolbar-store";
export type CounterProps = { export type CounterProps = {
title: string; title: string;
@@ -30,6 +31,7 @@ export type CounterProps = {
}; };
function _Counter(props: CounterProps) { function _Counter(props: CounterProps) {
const { title, onDecrease, onIncrease, onReset, value } = props; const { title, onDecrease, onIncrease, onReset, value } = props;
const isMobile = useIsMobile();
return ( return (
<Flex <Flex
@@ -40,7 +42,7 @@ function _Counter(props: CounterProps) {
cursor: "pointer", cursor: "pointer",
height: "100%", height: "100%",
":hover": { ":hover": {
bg: "hover-secondary" bg: isMobile ? "transparent" : "hover-secondary"
} }
}} }}
onClick={onReset} onClick={onReset}

View File

@@ -67,7 +67,12 @@ export function Dropdown(props: DropdownProps) {
alignItems: "center", alignItems: "center",
":last-of-type": { ":last-of-type": {
mr: 0 mr: 0
} },
":hover:not(:disabled):not(:active)": !isMobile
? undefined
: {
bg: "transparent"
}
}} }}
onClick={() => setIsOpen((s) => !s)} onClick={() => setIsOpen((s) => !s)}
onMouseDown={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}
@@ -77,7 +82,7 @@ export function Dropdown(props: DropdownProps) {
sx={{ sx={{
fontSize: "subBody", fontSize: "subBody",
mr: 1, mr: 1,
color: "paragraph", color: isPopupOpen ? "accent" : "paragraph",
flexShrink: 0 flexShrink: 0
}} }}
> >
@@ -96,6 +101,7 @@ export function Dropdown(props: DropdownProps) {
? Icons.chevronUp ? Icons.chevronUp
: Icons.chevronDown : Icons.chevronDown
} }
color={isPopupOpen ? "accent" : "paragraph"}
size={"small"} size={"small"}
/> />
</Button> </Button>

View File

@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { PropsWithChildren, useRef } from "react"; import { PropsWithChildren, useRef } from "react";
import { Flex } from "@theme-ui/components"; import { Flex } from "@theme-ui/components";
import { ToolButton, ToolButtonProps } from "./tool-button"; import { ToolButton, ToolButtonProps } from "./tool-button";
import { useToolbarLocation } from "../stores/toolbar-store"; import { useIsMobile, useToolbarLocation } from "../stores/toolbar-store";
import React from "react"; import React from "react";
export type SplitButtonProps = ToolButtonProps & { export type SplitButtonProps = ToolButtonProps & {
@@ -31,6 +31,7 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const toolbarLocation = useToolbarLocation(); const toolbarLocation = useToolbarLocation();
const isMobile = useIsMobile();
return ( return (
<> <>
@@ -42,7 +43,7 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {
borderRadius: "default", borderRadius: "default",
overflow: "hidden", overflow: "hidden",
":hover": { ":hover": {
bg: "hover-secondary" bg: isMobile ? "transparent" : "hover-secondary"
} }
}} }}
> >

View File

@@ -25,6 +25,7 @@ import { IconNames, Icons } from "../icons";
import { ToolButtonVariant } from "../types"; import { ToolButtonVariant } from "../types";
import { Button } from "../../components/button"; import { Button } from "../../components/button";
import { Icon } from "@notesnook/ui"; import { Icon } from "@notesnook/ui";
import { useIsMobile } from "../stores/toolbar-store";
export type ToolButtonProps = ButtonProps & { export type ToolButtonProps = ButtonProps & {
icon: IconNames; icon: IconNames;
@@ -47,6 +48,7 @@ export const ToolButton = React.memo(
variant = "normal", variant = "normal",
...buttonProps ...buttonProps
} = props; } = props;
const isMobile = useIsMobile();
return ( return (
<Button <Button
@@ -65,6 +67,11 @@ export const ToolButton = React.memo(
":last-of-type": { ":last-of-type": {
mr: 0 mr: 0
}, },
":hover:not(:disabled):not(:active)": !isMobile
? undefined
: {
bg: "transparent"
},
...sx ...sx
}} }}
onMouseDown={(e) => e.preventDefault()} onMouseDown={(e) => e.preventDefault()}