Skip to content

Commit

Permalink
Use clsx for applying CSS classes
Browse files Browse the repository at this point in the history
  • Loading branch information
SBence committed Apr 22, 2024
1 parent f31291c commit a7aa8d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@reduxjs/toolkit": "^2.0.1",
"@tabler/icons-react": "^3.0.0",
"@types/uuid": "^9.0.2",
"clsx": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^9.0.4",
Expand Down
17 changes: 10 additions & 7 deletions src/components/cards/TallyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
reset,
setName,
} from "../../store/slices/countersSlice";
import clsx from "clsx";

const MAX_COUNT = 99999;
const MAX_NAME_LENGTH = 32;
Expand Down Expand Up @@ -138,9 +139,9 @@ export default function TallyCard({
</Center>
<Group justify="space-between" grow>
<ActionIcon
className={`${
count && `active-red ${canHover && "tally-card-hover-highlight"}`
}`}
className={clsx(
count && ["active-red", canHover && "tally-card-hover-highlight"],
)}
onClick={() => dispatch(decrement({ id }))}
onPointerDown={() => navigator.vibrate(VIBRATION_STRENGTH.weak)}
onContextMenu={() => dispatch(reset({ id }))}
Expand All @@ -157,10 +158,12 @@ export default function TallyCard({
<IconChevronDown size={48} />
</ActionIcon>
<ActionIcon
className={`${
count < MAX_COUNT &&
`active-green ${canHover && "tally-card-hover-highlight"}`
}`}
className={clsx(
count < MAX_COUNT && [
"active-green",
canHover && "tally-card-hover-highlight",
],
)}
onClick={() => dispatch(increment({ id }))}
onPointerDown={() => navigator.vibrate(VIBRATION_STRENGTH.weak)}
onPointerUp={() => navigator.vibrate(VIBRATION_STRENGTH.medium)}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ clone@^1.0.2:
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==

[email protected]:
[email protected], clsx@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.0.tgz#e851283bcb5c80ee7608db18487433f7b23f77cb"
integrity sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==
Expand Down

0 comments on commit a7aa8d4

Please sign in to comment.