-
Notifications
You must be signed in to change notification settings - Fork 298
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
[COJ]/account-v2/Likhith/feq-1107/create timeline component #12610
Changes from 57 commits
bb3fc0a
b0a6ac1
6a55442
d969385
2178615
10b03a4
6de5cf8
0b5411b
809f292
35b58ef
26b73d5
927f303
8875015
aa37f8a
97abb10
9f82def
89a747b
357b698
b1e4715
8bee98d
e6cf943
f754411
1e68966
781c75c
2a06437
6ef5b21
a850ff3
0715433
7315fef
e2e464a
96689ad
b4ffc00
890782f
1fc0416
07057d3
7ec24e5
c154f3f
b806843
7fe7d43
144e7bc
65f5ecd
887926b
908d8b5
78968dd
b8cd81a
aa8c3b8
1cbabf3
262e72a
869be22
26b36c3
22fa010
522a5f6
0a3a493
4457870
1888fd5
8268d84
a0b11c4
b94df51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
dist/*.js | ||
*.config.* | ||
*.classnames.ts | ||
*.mock.* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
const stepperBaseStyles = 'z-10 box-border flex h-800 w-800 items-center rounded-pill outline outline-2'; | ||
|
||
export const stepperVariants = cva(stepperBaseStyles, { | ||
variants: { | ||
isActive: { | ||
true: 'transition-all delay-700 duration-700 ease-out outline-solid-coral-700', | ||
false: 'outline-solid-grey-5', | ||
}, | ||
isFilled: { | ||
true: '', | ||
}, | ||
}, | ||
compoundVariants: [ | ||
{ | ||
isActive: false, | ||
isFilled: true, | ||
class: 'bg-solid-grey-5', | ||
}, | ||
{ | ||
isActive: true, | ||
isFilled: true, | ||
class: 'bg-solid-coral-700', | ||
}, | ||
], | ||
}); | ||
|
||
export const desktopStyle = { | ||
stepper: 'lg:flex lg:w-fit lg:items-end lg:gap-800', | ||
likhith-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
connector: | ||
'lg:h-2000 lg:w-100 lg:bg-[length:100%_200%] lg:bg-bottom lg:bg-gradient-to-b lg:aria-[current=true]:bg-top', | ||
}; | ||
|
||
export const mobileStyle = { | ||
connector: 'h-100 bg-[length:200%_100%] bg-right bg-gradient-to-r aria-[current=true]:bg-left w-auto', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import { useBreakpoint } from '@deriv/quill-design'; | ||
import Stepper, { TStep } from './stepper'; | ||
import StepConnector from './step-connector'; | ||
|
||
type TFormProgressProps = { | ||
steps: Array<TStep>; | ||
activeStep: number; // [TODO]:Mock - Enable once isActive comes from Modal | ||
}; | ||
|
||
/** | ||
* @name FormProgress | ||
* @param steps - List of steps to be rendered | ||
* @returns React Component | ||
*/ | ||
export const FormProgress = ({ steps = [] }: TFormProgressProps) => { | ||
const [activeStep, setActiveStep] = React.useState(0); // [TODO]:Mock - remove once isActive comes from Modal | ||
|
||
const { isMobile } = useBreakpoint(); | ||
|
||
// [TODO]:Mock - remove once isActive comes from Modal | ||
const updateStep = (index: number) => { | ||
if (steps[index - 1]?.isFilled || index === 0) { | ||
setActiveStep(index + 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we set active step differently in mobile and desktop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The click functions are just mock. To check the behaviour of the component. I have added ToDO before all the lines that needs to be removed or changed |
||
} | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
{isMobile ? ( | ||
<React.Fragment> | ||
{' '} | ||
{/* [TODO]:Mock - remove Fragment once isActive comes from Modal*/} | ||
<div className='grid grid-flow-col gap-75'> | ||
likhith-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{steps.map((step, index) => ( | ||
<StepConnector isActive={index <= activeStep} key={step.title} /> | ||
))} | ||
</div> | ||
{/* [TODO]:Mock - remove button once isActive comes from Modal*/} | ||
<button | ||
onClick={() => { | ||
updateStep(activeStep); | ||
}} | ||
> | ||
Update | ||
</button> | ||
{/* [TODO]:Mock - remove Fragment once isActive comes from Modal*/} | ||
</React.Fragment> | ||
) : ( | ||
<React.Fragment> | ||
{steps.map((step, index) => ( | ||
<Stepper | ||
key={step.title} | ||
step={step} | ||
stepCount={index} | ||
isActive={index <= activeStep} | ||
onClick={() => { | ||
if (steps[index - 1]?.isFilled || index === 0) setActiveStep(index); | ||
}} | ||
/> | ||
))} | ||
</React.Fragment> | ||
)} | ||
</React.Fragment> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { qtMerge } from '@deriv/quill-design'; | ||
import { desktopStyle, mobileStyle } from './form-progress.classnames'; | ||
|
||
const StepConnector = ({ isActive }: { isActive?: boolean }) => ( | ||
<div | ||
aria-current={isActive} | ||
className={qtMerge( | ||
'via-solid-grey-5 to-solid-grey-5 from-solid-coral-700 from-50% via-50% transition-all duration-700 ease-out', | ||
mobileStyle.connector, | ||
desktopStyle.connector | ||
)} | ||
> | ||
{' '} | ||
</div> | ||
); | ||
|
||
export default StepConnector; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { Text, qtMerge } from '@deriv/quill-design'; | ||
import { StandaloneCheckBoldIcon } from '@deriv/quill-icons'; | ||
import StepConnector from './step-connector'; | ||
import { stepperVariants, desktopStyle } from './form-progress.classnames'; | ||
|
||
export type TStep = { title: string; isFilled: boolean }; | ||
|
||
type TStepperProps = { | ||
isActive: boolean; | ||
step: TStep; | ||
stepCount: number; | ||
onClick: React.MouseEventHandler<HTMLSpanElement>; // [TODO]:Mock - remove once isActive comes from Modal | ||
}; | ||
|
||
const Stepper = ({ isActive, step, stepCount, onClick }: TStepperProps) => ( | ||
<div className={qtMerge('group relative justify-center', desktopStyle.stepper)} aria-current={isActive}> | ||
<div className='flex flex-col items-center'> | ||
{stepCount !== 0 && <StepConnector isActive={isActive} />} | ||
<span className={stepperVariants({ isActive, isFilled: step.isFilled })}> | ||
{step.isFilled ? <StandaloneCheckBoldIcon fill={isActive ? '#fff' : '#000'} /> : null} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this work ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will work (Haven’t tried). I just wanted to be more explicit and handle both flow of if-else |
||
</span> | ||
</div> | ||
<Text bold={isActive} size='sm' className='relative top-200' onClick={onClick}> | ||
{step.title} | ||
</Text> | ||
</div> | ||
); | ||
|
||
export default Stepper; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const stepProgress = [ | ||
{ title: 'Step 1', isFilled: true }, | ||
{ title: 'Step 2', isFilled: true }, | ||
{ title: 'Step 3', isFilled: false }, | ||
{ title: 'Step 4', isFilled: false }, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a file called classnames.ts which is a convention used for keeping variant styles. We can sort it but I think sorting for that file is not necessary. But this can be taken for discussion