Skip to content

Commit

Permalink
Remove hover effect on mobile in editor (streetwriters#3163)
Browse files Browse the repository at this point in the history
* editor: remove background on hover on mobile

* editor: fix task item alignment and size on mobile
  • Loading branch information
ammarahm-ed authored Sep 4, 2023
1 parent 1775e0b commit 003b3d2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
13 changes: 8 additions & 5 deletions packages/editor/src/extensions/task-item/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ export function TaskItemComponent(
mt: "0.40ch",
marginInlineEnd: 1,
cursor: editor.isEditable ? "pointer" : "unset",
":hover": {
borderColor: "accent"
},
":hover": isMobile
? undefined
: {
borderColor: "accent"
},
fontFamily: "inherit"
}}
onMouseDown={(e) => {
Expand All @@ -125,7 +127,7 @@ export function TaskItemComponent(
}
}}
color={checked ? "accent" : "icon"}
size={isMobile ? "1.66ch" : "1.46ch"}
size={isMobile ? "1.70ch" : "1.46ch"}
/>

<Box
Expand All @@ -143,7 +145,8 @@ export function TaskItemComponent(
opacity: 1
},
flex: 1,
mt: "1px"
mt: ["3px", "3px", 0],
ml: ["2px", "2px", 0]
}}
/>
<DesktopOnly>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/extensions/task-list/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function TaskListComponent(
sx={{
position: "relative",
bg: "var(--background-secondary)",
py: "5px",
py: "0.6em",
borderRadius: "default",
mb: 2,
alignItems: "center",
Expand Down
4 changes: 3 additions & 1 deletion packages/editor/src/toolbar/components/counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { Flex, Text } from "@theme-ui/components";
import { ToolButton } from "./tool-button";
import { useIsMobile } from "../stores/toolbar-store";

export type CounterProps = {
title: string;
Expand All @@ -30,6 +31,7 @@ export type CounterProps = {
};
function _Counter(props: CounterProps) {
const { title, onDecrease, onIncrease, onReset, value } = props;
const isMobile = useIsMobile();

return (
<Flex
Expand All @@ -40,7 +42,7 @@ function _Counter(props: CounterProps) {
cursor: "pointer",
height: "100%",
":hover": {
bg: "hover-secondary"
bg: isMobile ? "transparent" : "hover-secondary"
}
}}
onClick={onReset}
Expand Down
10 changes: 8 additions & 2 deletions packages/editor/src/toolbar/components/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export function Dropdown(props: DropdownProps) {
alignItems: "center",
":last-of-type": {
mr: 0
}
},
":hover:not(:disabled):not(:active)": !isMobile
? undefined
: {
bg: "transparent"
}
}}
onClick={() => setIsOpen((s) => !s)}
onMouseDown={(e) => e.preventDefault()}
Expand All @@ -77,7 +82,7 @@ export function Dropdown(props: DropdownProps) {
sx={{
fontSize: "subBody",
mr: 1,
color: "paragraph",
color: isPopupOpen ? "accent" : "paragraph",
flexShrink: 0
}}
>
Expand All @@ -96,6 +101,7 @@ export function Dropdown(props: DropdownProps) {
? Icons.chevronUp
: Icons.chevronDown
}
color={isPopupOpen ? "accent" : "paragraph"}
size={"small"}
/>
</Button>
Expand Down
5 changes: 3 additions & 2 deletions packages/editor/src/toolbar/components/split-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { PropsWithChildren, useRef } from "react";
import { Flex } from "@theme-ui/components";
import { ToolButton, ToolButtonProps } from "./tool-button";
import { useToolbarLocation } from "../stores/toolbar-store";
import { useIsMobile, useToolbarLocation } from "../stores/toolbar-store";
import React from "react";

export type SplitButtonProps = ToolButtonProps & {
Expand All @@ -31,6 +31,7 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {

const ref = useRef<HTMLDivElement>(null);
const toolbarLocation = useToolbarLocation();
const isMobile = useIsMobile();

return (
<>
Expand All @@ -42,7 +43,7 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {
borderRadius: "default",
overflow: "hidden",
":hover": {
bg: "hover-secondary"
bg: isMobile ? "transparent" : "hover-secondary"
}
}}
>
Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/toolbar/components/tool-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IconNames, Icons } from "../icons";
import { ToolButtonVariant } from "../types";
import { Button } from "../../components/button";
import { Icon } from "@notesnook/ui";
import { useIsMobile } from "../stores/toolbar-store";

export type ToolButtonProps = ButtonProps & {
icon: IconNames;
Expand All @@ -47,6 +48,7 @@ export const ToolButton = React.memo(
variant = "normal",
...buttonProps
} = props;
const isMobile = useIsMobile();

return (
<Button
Expand All @@ -65,6 +67,11 @@ export const ToolButton = React.memo(
":last-of-type": {
mr: 0
},
":hover:not(:disabled):not(:active)": !isMobile
? undefined
: {
bg: "transparent"
},
...sx
}}
onMouseDown={(e) => e.preventDefault()}
Expand Down

0 comments on commit 003b3d2

Please sign in to comment.