Skip to content

Commit 07458f2

Browse files
authored
Improved Button Border Hover CSS Effects (#288)
Replaced button hover border resizing with changing border colors and added corresponding e2e tests.
1 parent 057b861 commit 07458f2

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

app/Components/Home/NavigationButton.tsx

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import React from "react";
2-
import {
3-
Pressable,
4-
Image,
5-
ImageURISource,
6-
useWindowDimensions,
7-
} from "react-native";
2+
import { Pressable, Image, ImageURISource } from "react-native";
83
import { Surface, useTheme } from "react-native-paper";
94
import { useNavigation } from "@react-navigation/native";
105
import { PreferencesContext } from "../../Contexts/PreferencesContext";
@@ -15,7 +10,6 @@ interface navigationButton {
1510
image: ImageURISource;
1611
widthFactor?: number;
1712
heightFactor?: number;
18-
hoverSizeFactor?: number;
1913
testID: string;
2014
}
2115

@@ -28,9 +22,6 @@ const NavigationButton = (props: navigationButton) => {
2822

2923
const WIDTH_FACTOR: number = props.widthFactor ? props.widthFactor : 4.5;
3024
const HEIGHT_FACTOR: number = props.heightFactor ? props.heightFactor : 9;
31-
const HOVER_SIZE_FACTOR: number = props.hoverSizeFactor
32-
? props.hoverSizeFactor
33-
: 1.1;
3425

3526
const WIDTH: number = minWindowSize.width / WIDTH_FACTOR;
3627
const HEIGHT: number = minWindowSize.height / HEIGHT_FACTOR;
@@ -46,10 +37,12 @@ const NavigationButton = (props: navigationButton) => {
4637
return (
4738
<Surface
4839
style={{
49-
width: hovered ? WIDTH * HOVER_SIZE_FACTOR : WIDTH,
50-
height: hovered ? HEIGHT * HOVER_SIZE_FACTOR : HEIGHT,
51-
borderColor: theme.colors.onSurfaceVariant,
52-
borderWidth: 4,
40+
width: WIDTH,
41+
height: HEIGHT,
42+
borderColor: hovered
43+
? theme.colors.outline
44+
: theme.colors.onSurface,
45+
borderWidth: hovered ? 3 : 2,
5346
}}
5447
testID={props.testID}
5548
>

e2e/web/specs/home.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { HomePage } from "./../page/home.page";
2+
import { expect } from "@playwright/test";
3+
import { test } from "../fixture";
4+
5+
test.describe("navigation buttons", () => {
6+
test("hover over navigation buttons", async ({ page }) => {
7+
const homePage = new HomePage(page);
8+
const buttons = [
9+
homePage.startLessons,
10+
homePage.startDrills,
11+
homePage.playSudoku,
12+
];
13+
for (const button of buttons) {
14+
await expect(button).toHaveCSS("border-color", "rgb(242, 242, 242)");
15+
await button.hover();
16+
await expect(button).toHaveCSS("border-color", "rgb(217, 160, 91)");
17+
}
18+
});
19+
});

0 commit comments

Comments
 (0)