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

Revamp numeric text field #550

Merged
merged 8 commits into from
Nov 5, 2024
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
2 changes: 1 addition & 1 deletion cypress/e2e/route/Oracle.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("/oracle", () => {
describe("Given I want to ask a question to the oracle", () => {
it("should ask questions to the oracle ", () => {
Fari.start();
Fari.getByText("Consult the Oracle").click();
Fari.visit("/oracle");

askOracle();

Expand Down
1 change: 0 additions & 1 deletion lib/components/Page/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export function NavLink(props: {
endIcon?: React.ReactNode;
children: React.ReactNode;
}) {
const theme = useTheme();
if (props.to) {
return (
<Tooltip title={props.tooltip ?? ""}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import Fade from "@mui/material/Fade";
import IconButton from "@mui/material/IconButton";
import { useTheme } from "@mui/material/styles";
import TextField from "@mui/material/TextField";
import React, { useContext, useState } from "react";
import React, { useState } from "react";
import { ConditionalWrapper } from "../../../../../components/ConditionalWrapper/ConditionalWrapper";
import { Delays } from "../../../../../constants/Delays";
import { IDataCyProps } from "../../../../../domains/cypress/types/IDataCyProps";
import { useLazyState } from "../../../../../hooks/useLazyState/useLazyState";
import { MiniThemeContext } from "../MiniThemeContext";

export function CircleTextField(
props: {
Expand All @@ -27,8 +26,6 @@ export function CircleTextField(
onContextMenu?(event: React.MouseEvent<HTMLElement, MouseEvent>): void;
} & IDataCyProps
) {
const miniTheme = useContext(MiniThemeContext);

const theme = useTheme();
const [hover, setHover] = useState(false);
const [focus, setFocus] = useState(false);
Expand Down Expand Up @@ -100,24 +97,18 @@ export function CircleTextField(
setValue("");
} else {
const parsed = parseInt(e.target.value);
if (parsed > 999) {
setValue("999");
} else {
setValue(parsed.toString());
}
setValue(parsed.toString());
}
}}
InputProps={{
sx: {
"cursor": cursor,
"width": "3rem",
"width": "5rem",
"height": "3rem",
"borderRadius": "50%",
"border": `2px solid ${
props.borderColor ?? miniTheme.textPrimary
}`,
"px": "0.5rem",
"font-family": "monospace",
"outline": "none",
"background": props.highlight ? miniTheme.textPrimary : "inherit",
"background": (theme) => theme.palette.action.hover,
"&&": {
color: "inherit",
},
Expand Down Expand Up @@ -164,7 +155,6 @@ export function CircleTextField(
{!props.readonly && props.onDecrement && (
<Fade in={areCounterButtonsVisible}>
<IconButton
size="small"
data-cy={`${props.dataCy}.decrement`}
sx={{
"position": "absolute",
Expand All @@ -177,15 +167,14 @@ export function CircleTextField(
onClick={props.onDecrement}
>
<RemoveCircleOutlineOutlinedIcon
sx={{ width: "1.1rem", height: "1.1rem" }}
sx={{ width: "1.5rem", height: "1.5rem" }}
/>
</IconButton>
</Fade>
)}
{!props.readonly && props.onIncrement && (
<Fade in={areCounterButtonsVisible}>
<IconButton
size="small"
data-cy={`${props.dataCy}.increment`}
sx={{
"position": "absolute",
Expand All @@ -198,7 +187,7 @@ export function CircleTextField(
onClick={props.onIncrement}
>
<AddCircleOutlineOutlinedIcon
sx={{ width: "1.1rem", height: "1.1rem" }}
sx={{ width: "1.5rem", height: "1.5rem" }}
/>
</IconButton>
</Fade>
Expand Down
Loading
Loading