-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [P4PU-338] Storybook components (#90)
- Storybook pinned 8.1.11 - Vite latest - Adds missing components stories - Storybook render tree refactoring
- Loading branch information
Showing
28 changed files
with
2,442 additions
and
940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import AssistanceBackModalComponent from 'components/Modals/AssistanceBackModal'; | ||
|
||
const meta: Meta = { | ||
title: 'Modal', | ||
component: AssistanceBackModalComponent | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<{ open: boolean }> = (args) => <AssistanceBackModalComponent {...args} />; | ||
|
||
export const AssistanceBackModal = Template.bind({}); | ||
AssistanceBackModal.args = { | ||
open: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import { BackButton, BackButtonProps } from 'components/BackButton/BackButton'; | ||
|
||
const meta: Meta<BackButtonProps> = { | ||
title: 'Button/BackButton', | ||
component: BackButton | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<BackButtonProps> = (args) => <BackButton {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
text: 'back' | ||
} as BackButtonProps; | ||
|
||
export const CustomText = Template.bind({}); | ||
CustomText.args = { | ||
text: 'home' | ||
} as BackButtonProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import { ErrorFallback, ErrorFallbackProps } from 'components/ErrorFallback/ErrorFallback'; | ||
|
||
const meta: Meta<ErrorFallbackProps> = { | ||
title: 'Components/ErrorFallback', | ||
component: ErrorFallback | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<ErrorFallbackProps> = (args) => <ErrorFallback {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
message: 'This is a default error message' | ||
}; | ||
|
||
export const WithReset = Template.bind({}); | ||
WithReset.args = { | ||
message: 'This is an error with a reset button', | ||
onReset: () => alert('Reset button clicked!') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import { Header as HeaderComponent, HeaderProps } from 'components/Header'; | ||
|
||
const meta: Meta<HeaderProps> = { | ||
title: 'Layout', | ||
component: HeaderComponent | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<HeaderProps> = (args) => <HeaderComponent {...args} />; | ||
|
||
export const Header = Template.bind({}); | ||
Header.args = { | ||
onAssistanceClick: () => alert('Assistance clicked!') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import PaymentButtonComponent from 'components/PaymentButton'; | ||
|
||
const meta: Meta = { | ||
title: 'Button/PaymentButton', | ||
component: PaymentButtonComponent | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn = (args) => <PaymentButtonComponent {...args} />; | ||
|
||
export const PaymentButton = Template.bind({}); | ||
PaymentButton.args = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Meta } from '@storybook/react'; | ||
import { PaymentNotice } from 'components/PaymentNotice'; | ||
import { PaymentNoticeDetail } from 'models/PaymentNoticeDetail'; | ||
import React from 'react'; | ||
|
||
const mockPaymentNoticeDetail: PaymentNoticeDetail = { | ||
amount: '€100.00', | ||
paFullName: 'John Doe', | ||
subject: 'Invoice for Service', | ||
dueDate: '2024-12-31', | ||
iupd: '12345678901234567890', | ||
paTaxCode: 'ABC12345678', | ||
firstInstallmentDate: '2024-10-01', | ||
firstInstallmentAmount: '€50.00' | ||
}; | ||
|
||
const meta: Meta = { | ||
title: 'Payment Notice', | ||
args: { | ||
paymentNoticeDetail: mockPaymentNoticeDetail | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Detail = { | ||
render: (args: { paymentNoticeDetail: PaymentNoticeDetail }) => <PaymentNotice.Detail {...args} /> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Meta } from '@storybook/react'; | ||
import { PaymentNotice } from 'components/PaymentNotice'; | ||
import { PaymentNotices } from 'components/PaymentNotice/List'; | ||
import React from 'react'; | ||
|
||
// Define mock data | ||
const mockPaymentNoticesList: PaymentNotices[] = [ | ||
{ | ||
id: '1', | ||
payee: { | ||
name: 'Company A', | ||
altImg: 'Company A Logo' | ||
}, | ||
paymentInfo: 'Payment for Service A', | ||
amount: '€150.00', | ||
expiringDate: '2024-09-30' | ||
}, | ||
{ | ||
id: '2', | ||
payee: { | ||
name: 'Company B', | ||
altImg: 'Company B Logo' | ||
}, | ||
paymentInfo: 'Payment for Service B', | ||
amount: '€200.00', | ||
expiringDate: '2024-10-15' | ||
} | ||
]; | ||
|
||
const meta: Meta = { | ||
title: 'Payment Notice', | ||
args: { | ||
paymentNoticesList: mockPaymentNoticesList | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
export const List = { | ||
render: (args: { paymentNoticesList: PaymentNotices[] }) => <PaymentNotice.List {...args} /> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Meta } from '@storybook/react'; | ||
import PullPaymentsModalComponent from 'components/Modals/PullPaymentsModal'; | ||
|
||
const meta: Meta = { | ||
title: 'Modal/PullPayments Modal', | ||
component: PullPaymentsModalComponent, | ||
args: { open: true } | ||
}; | ||
|
||
export default meta; | ||
|
||
export const PullPaymentsModal = { | ||
render: (args: { open: boolean }) => <PullPaymentsModalComponent {...args} /> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import { CircularProgress, Box } from '@mui/material'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import QueryLoader, { QueryLoaderProps } from 'components/QueryLoader'; | ||
|
||
// Create a QueryClient instance | ||
const queryClient = new QueryClient(); | ||
|
||
const MockFetchingComponent = () => { | ||
const [fetching, setFetching] = useState(true); | ||
|
||
// Simulate fetching | ||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
setFetching(false); | ||
}, 2000); // Simulate a 2-second fetch | ||
return () => clearTimeout(timer); | ||
}, []); | ||
|
||
return fetching; | ||
}; | ||
|
||
const QueryLoaderWrapper = ({ queryKey, loaderComponent, children }: QueryLoaderProps) => { | ||
const isFetching = MockFetchingComponent(); | ||
|
||
return ( | ||
<QueryLoader queryKey={queryKey} loaderComponent={loaderComponent}> | ||
{isFetching ? loaderComponent : children} | ||
</QueryLoader> | ||
); | ||
}; | ||
|
||
const MetaData: Meta<typeof QueryLoader> = { | ||
title: 'Components/QueryLoader', | ||
component: QueryLoader, | ||
decorators: [ | ||
(Story) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<Story /> | ||
</QueryClientProvider> | ||
) | ||
] | ||
}; | ||
|
||
export default MetaData; | ||
|
||
const Template: StoryFn<typeof QueryLoader> = (args) => ( | ||
<Box sx={{ width: '100%', mt: '100px', textAlign: 'center' }}> | ||
<QueryLoaderWrapper {...args}> | ||
<div>Content Loaded!</div> | ||
</QueryLoaderWrapper> | ||
</Box> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
loaderComponent: <CircularProgress />, | ||
atLeast: 1000 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Meta } from '@storybook/react'; | ||
import PaymentNoticesList from 'components/Skeleton/PaymentNoticesList'; | ||
|
||
const meta: Meta<typeof PaymentNoticesList> = { | ||
title: 'Payment Notice/Skeletons' | ||
}; | ||
|
||
export default meta; | ||
|
||
export const List = { | ||
render: PaymentNoticesList | ||
}; |
Oops, something went wrong.