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

[COJ]/account-v2/Likhith/feq-1107/create timeline component #12610

Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bb3fc0a
chore: initial setup
likhith-deriv Dec 17, 2023
b0a6ac1
chore: initial setup
likhith-deriv Dec 17, 2023
6a55442
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 18, 2023
d969385
chore: configured webpack
likhith-deriv Dec 18, 2023
2178615
fix: changed lint rules
likhith-deriv Dec 18, 2023
10b03a4
chore: incorporated build config
likhith-deriv Dec 18, 2023
6de5cf8
chore: added stylelint file
likhith-deriv Dec 18, 2023
0b5411b
chore: updated stylelint
likhith-deriv Dec 18, 2023
809f292
refactor: incorporated review comments
likhith-deriv Dec 18, 2023
35b58ef
fix: reverted webpack types
likhith-deriv Dec 19, 2023
26b73d5
fix: build issue
likhith-deriv Dec 19, 2023
927f303
chore: added sonarlint rules
likhith-deriv Dec 19, 2023
8875015
chore: added a test component
likhith-deriv Dec 19, 2023
aa37f8a
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 19, 2023
97abb10
fix: removed test component
likhith-deriv Dec 20, 2023
9f82def
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 20, 2023
89a747b
chore: copied tailwind from tradershub
likhith-deriv Dec 20, 2023
357b698
fix: dependency version mismatch
likhith-deriv Dec 20, 2023
b1e4715
fix: added missing eslintignore file
likhith-deriv Dec 20, 2023
8bee98d
chore: webpack config refactor (#60)
yauheni-deriv Dec 20, 2023
e6cf943
fix: build failure
likhith-deriv Dec 20, 2023
f754411
Merge branch 'binary-com:master' into likhith/accounts-v2-setup
yauheni-deriv Dec 20, 2023
1e68966
fix: sonarcloud errors
Dec 20, 2023
781c75c
fix: added tailwind styles
likhith-deriv Dec 21, 2023
2a06437
chore: types naming
Dec 21, 2023
6ef5b21
feat: added a test component
likhith-deriv Dec 22, 2023
a850ff3
fix: tailwind-config
likhith-deriv Dec 22, 2023
0715433
refactor: build process
likhith-deriv Dec 22, 2023
7315fef
refactor: build process
likhith-deriv Dec 22, 2023
e2e464a
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 22, 2023
96689ad
fix: removed catastrophic backtracking regex
likhith-deriv Dec 22, 2023
b4ffc00
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 26, 2023
890782f
fix: incoporated review comments
likhith-deriv Dec 27, 2023
1fc0416
Merge branch 'master' into likhith/accounts-v2-setup
likhith-deriv Dec 27, 2023
07057d3
Merge branch 'likhith/accounts-v2-setup' into likhith/FEQ-1107/create…
likhith-deriv Dec 27, 2023
7ec24e5
fix: renamed version
likhith-deriv Dec 27, 2023
c154f3f
feat: added flag to render account-v2
likhith-deriv Dec 27, 2023
b806843
fix: failing testcase
likhith-deriv Dec 27, 2023
7fe7d43
fix: failing testcase
likhith-deriv Dec 27, 2023
144e7bc
Merge branch 'likhith/accounts-v2-setup' into likhith/FEQ-1107/create…
likhith-deriv Dec 27, 2023
65f5ecd
fix: imports
likhith-deriv Dec 28, 2023
887926b
chore: updated packages
likhith-deriv Dec 28, 2023
908d8b5
Merge branch 'master' into likhith/FEQ-1107/create-timeline-component
likhith-deriv Dec 29, 2023
78968dd
fix: added prettier config
likhith-deriv Dec 29, 2023
b8cd81a
chore: created timeline component
likhith-deriv Jan 2, 2024
aa8c3b8
chore: added deriv lib
likhith-deriv Jan 2, 2024
1cbabf3
Merge branch 'likhith/update-account-v2-folder' into likhith/FEQ-1107…
likhith-deriv Jan 2, 2024
262e72a
fix: added mock stepper-form
likhith-deriv Jan 3, 2024
869be22
fix: added styles
likhith-deriv Jan 4, 2024
26b36c3
feat: created timeline component for mobile
likhith-deriv Jan 4, 2024
22fa010
Merge branch 'master' into likhith/FEQ-1107/create-timeline-component
likhith-deriv Jan 4, 2024
522a5f6
fix: remove unintented changes
likhith-deriv Jan 4, 2024
0a3a493
fix: resolved build issues
likhith-deriv Jan 4, 2024
4457870
fix: resolved build issues
likhith-deriv Jan 4, 2024
1888fd5
fix: resolved build issues
likhith-deriv Jan 4, 2024
8268d84
fix: resolved build issues
likhith-deriv Jan 4, 2024
a0b11c4
fix: added regex to remove lint rules for mock and classnames
likhith-deriv Jan 4, 2024
b94df51
fix: incorporated review comments
likhith-deriv Jan 8, 2024
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
2 changes: 2 additions & 0 deletions packages/account-v2/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist/*.js
*.config.*
*.classnames.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor Author

@likhith-deriv likhith-deriv Jan 5, 2024

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

*.mock.*
9 changes: 8 additions & 1 deletion packages/account-v2/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ module.exports = {
'typescript-sort-keys',
],
root: true,
ignorePatterns: ['**/node_modules/**', '**/dist/**', '**/*.js', '**/*.config.*'],
ignorePatterns: [
'**/node_modules/**',
'**/dist/**',
'**/*.js',
'**/*.config.*',
'**/*.classnames.ts',
'**/*.mock.*',
],
rules: {
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
Expand Down
15 changes: 11 additions & 4 deletions packages/account-v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import React from 'react';
import { APIProvider } from '@deriv/api';
import { BrandDerivLogoCoralIcon } from '@deriv/quill-icons';
import './index.scss';
import { BreakpointProvider } from '@deriv/quill-design';
import { FormProgress } from './components/form-progress';
import { stepProgress } from './mocks/form-progress.mock';

const App: React.FC = () => (
<APIProvider standalone>
<div className=' text-solid-slate-500 text-heading-h1'>Account V2</div>
<div className='p-300'>
<BrandDerivLogoCoralIcon height='120px' width='120px' />
</div>
<BreakpointProvider>
<div className='text-heading-h1 text-solid-slate-500'>Account V2</div>
<div className='p-300'>
<BrandDerivLogoCoralIcon height='120px' width='120px' />
</div>
{/* [TODO]:Mock - Remove hardcoded initial value once isActive comes from Modal */}
<FormProgress steps={stepProgress} activeStep={1} />
</BreakpointProvider>
</APIProvider>
);

Expand Down
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',
};
66 changes: 66 additions & 0 deletions packages/account-v2/src/components/form-progress/index.tsx
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we set active step differently in mobile and desktop

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
30 changes: 30 additions & 0 deletions packages/account-v2/src/components/form-progress/stepper.tsx
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work ?
{step.isFilled && <StandaloneCheckBoldIcon fill={isActive ? '#fff' : '#000'} />}

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
6 changes: 6 additions & 0 deletions packages/account-v2/src/mocks/form-progress.mock.ts
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 },
];
12 changes: 11 additions & 1 deletion packages/account-v2/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ export default {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
presets: [QuillTailwindConfig],
theme: {
extend: {},
extend: {
colors: {
solid: {
grey: {
'1': '#999999',
'5': '#d6dadb',
'6': '#d6d6d6',
},
},
},
},
},
plugins: [],
} satisfies Config;