Skip to content

Commit

Permalink
Implement dot navigation (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag authored Feb 9, 2024
1 parent 369e5a0 commit 9d24a27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/berlin/src/components/dots/Dots.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ type DotProps = {
export const Dot = styled.div<DotProps>`
background-color: ${(props) => (props.$active ? 'var(--color-black)' : 'var(--color-gray)')};
border-radius: 50%;
cursor: pointer;
height: 0.5rem;
transition: 0.2s ease-in;
width: 0.5rem;
&:hover {
background-color: var(--color-black);
}
`;
5 changes: 3 additions & 2 deletions packages/berlin/src/components/dots/Dots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Dot } from './Dots.styled';
type DotsProps = {
dots: number;
activeDotIndex: number;
setStep: React.Dispatch<React.SetStateAction<number>>;
};

function Dots({ dots, activeDotIndex }: DotsProps) {
function Dots({ dots, activeDotIndex, setStep }: DotsProps) {
return (
<FlexRow>
{Array.from({ length: dots }).map((_, index) => (
<Dot key={index} $active={index === activeDotIndex} />
<Dot key={index} $active={index === activeDotIndex} onClick={() => setStep(index)} />
))}
</FlexRow>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/berlin/src/pages/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Onboarding() {
<FlexColumn $gap="3rem">
<Title>{data[step].title}</Title>
<BodyContent content={data[step].body} />
<Dots dots={data.length} activeDotIndex={step} />
<Dots dots={data.length} activeDotIndex={step} setStep={setStep} />
<FlexRow>
<Button onClick={handleSkip} $color="secondary">
Skip
Expand Down

0 comments on commit 9d24a27

Please sign in to comment.