Skip to content

Commit

Permalink
[COJ]/account-v2/Likhith/feq-1107/create timeline component (#12610)
Browse files Browse the repository at this point in the history
* chore: initial setup

* chore: initial setup

* chore: configured webpack

* fix: changed lint rules

* chore: incorporated build config

* chore: added stylelint file

* chore: updated stylelint

* refactor: incorporated review comments

* fix: reverted webpack types

* fix: build issue

* chore: added sonarlint rules

* chore: added a test component

* fix: removed test component

* chore: copied tailwind from tradershub

* fix: dependency version mismatch

* fix: added missing eslintignore file

* chore: webpack config refactor (#60)

Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
Co-authored-by: Likhith Kolayari <likhith@regentmarkets.com>

* fix: build failure

* fix: sonarcloud errors

* fix: added tailwind styles

* chore: types naming

* feat: added a test component

* fix: tailwind-config

* refactor: build process

* refactor: build process

* fix: removed catastrophic backtracking regex

* fix: incoporated review comments

* fix: renamed version

* feat: added flag to render account-v2

* fix: failing testcase

* fix: failing testcase

* fix: imports

* chore: updated packages

* fix: added prettier config

* chore: created timeline component

* chore: added deriv lib

* fix: added mock stepper-form

* fix: added styles

* feat: created timeline component for mobile

* fix: remove unintented changes

* fix: resolved build issues

* fix: resolved build issues

* fix: resolved build issues

* fix: resolved build issues

* fix: added regex to remove lint rules for mock and classnames

* fix: incorporated review comments

---------

Co-authored-by: yauheni-deriv <103182683+yauheni-deriv@users.noreply.github.com>
Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”>
  • Loading branch information
3 people committed Jan 11, 2024
1 parent 0d357f1 commit c25f331
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 6 deletions.
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
*.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-gap-lg',
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: 'bg-[length:200%_100%] bg-right bg-gradient-to-r aria-[current=true]:bg-left w-auto h-general-2xs',
};
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, { useState } from 'react';
import { useBreakpoint } from '@deriv/quill-design';
import StepConnector from './step-connector';
import Stepper, { TStep } from './stepper';

type TFormProgressProps = {
activeStep: number;
steps: TStep[]; // [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] = 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);
}
};

return (
<React.Fragment>
{isMobile ? (
<React.Fragment>
{' '}
{/* [TODO]:Mock - remove Fragment once isActive comes from Modal*/}
<div className='grid grid-flow-col gap-gap-2xs'>
{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
isActive={index <= activeStep}
key={step.title}
onClick={() => {
if (steps[index - 1]?.isFilled || index === 0) setActiveStep(index);
}}
step={step}
stepCount={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 { qtMerge, Text } from '@deriv/quill-design';
import { StandaloneCheckBoldIcon } from '@deriv/quill-icons';
import { desktopStyle, stepperVariants } from './form-progress.classnames';
import StepConnector from './step-connector';

export type TStep = { isFilled: boolean; title: string };

type TStepperProps = {
isActive: boolean;
onClick: React.MouseEventHandler<HTMLSpanElement>;
step: TStep;
stepCount: number; // [TODO]:Mock - remove once isActive comes from Modal
};

const Stepper = ({ isActive, onClick, step, stepCount }: TStepperProps) => (
<div aria-current={isActive} className={qtMerge('group relative justify-center', desktopStyle.stepper)}>
<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}
</span>
</div>
<Text bold={isActive} className='relative top-200' onClick={onClick} size='sm'>
{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;

1 comment on commit c25f331

@vercel
Copy link

@vercel vercel bot commented on c25f331 Jan 11, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.vercel.app
deriv-app.binary.sx
binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.