Skip to content

Commit

Permalink
#53 - refactor counter-actions to use Tailwind CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
jnahumphreys committed Feb 2, 2024
1 parent 1ae1ea7 commit 5a24849
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/app/counter-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { memo } from "react";
import styled from "@emotion/styled";
import { useCounterState, useCounterActions } from "./counter-provider";
import { Button } from "./button";
import { COUNTER_VALUE_CONTAINER_ID } from "./counter-output";
Expand Down Expand Up @@ -30,44 +28,34 @@ function IncrementCount() {
);
}

const ResetCountButton = memo(
styled(Button)({
backgroundColor: "#bb2c22",
flexBasis: "100%",
}),
);

function ResetCount() {
const count = useCounterState();
const { reset } = useCounterActions();

return (
<ResetCountButton disabled={!(count > 0)} onClick={reset} data-cy="reset">
<Button
disabled={!(count > 0)}
onClick={reset}
data-cy="reset"
className="basis-full bg-[#bb2c22]"
>
Reset
</ResetCountButton>
</Button>
);
}

const Container = styled.div({
display: "flex",
justifyContent: "space-between",
flexWrap: "wrap",
width: "100%",
maxWidth: "20rem",
margin: "0 auto",
});

function CounterActions() {
return (
<Container
<div
aria-label="Counter actions"
role="toolbar"
aria-controls={COUNTER_VALUE_CONTAINER_ID}
className="mx-auto flex w-full max-w-80 flex-wrap justify-between"
>
<DecrementCount />
<IncrementCount />
<ResetCount />
</Container>
</div>
);
}

Expand Down

0 comments on commit 5a24849

Please sign in to comment.