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

feat: add progress indicator styles #4019

Merged
Merged
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
29 changes: 23 additions & 6 deletions frontend/src/components/ProgressIndicator/ProgressIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
import { useMemo } from 'react'
import { Box } from '@chakra-ui/react'
import { Box, BoxProps } from '@chakra-ui/react'

import { MotionBox } from '~components/motion'

const ActiveIndicator = (): JSX.Element => (
<Box
// Top required to align it with CircleIndicators
top="0.125rem"
width="1.5rem"
height="0.5rem"
borderRadius="full"
backgroundColor="secondary.500"
position="absolute"
/>
)

interface CircleIndicatorProps {
interface CircleIndicatorProps extends BoxProps {
onClick: () => void
isActiveIndicator: boolean
}

const CircleIndicator = ({
onClick,
isActiveIndicator,
...props
}: CircleIndicatorProps): JSX.Element => {
return (
<Box
width="0.5rem"
height="0.5rem"
width="0.75rem"
height="0.75rem"
padding="0.125rem"
borderRadius="full"
backgroundColor="secondary.200"
marginRight={isActiveIndicator ? '1.5rem' : '0.5rem'}
marginRight={isActiveIndicator ? '1.25rem' : '0.25rem'}
onClick={onClick}
_hover={{ backgroundColor: 'secondary.300' }}
_focus={
isActiveIndicator
? undefined
: {
backgroundColor: 'secondary.300',
boxShadow: `0 0 0 1px var(--chakra-colors-secondary-400)`,
}
}
backgroundClip="content-box"
as="button"
{...props}
/>
)
}
Expand All @@ -51,7 +67,7 @@ export const ProgressIndicator = ({
)

const animationProps = useMemo(() => {
return { x: currActiveIdx.toString() + 'rem' }
return { x: `${currActiveIdx + 0.125}rem` }
}, [currActiveIdx])

return (
Expand All @@ -61,6 +77,7 @@ export const ProgressIndicator = ({
key={idx}
isActiveIndicator={idx === currActiveIdx}
onClick={() => onClick(idx)}
aria-label={`Page ${idx + 1} of ${numIndicators}`}
/>
))}

Expand Down