-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create reusable CooperationActionBanner component (#2971)
* add reusable CooperationActionModal component * add test for CooperationActionModal component * add usage of CooperationActionModal component * remove unused styles * replace styled component with plain css * add test for icon rendering * rename CooperationActionModal to CooperationActionBanner * fix component import path
- Loading branch information
1 parent
0840e99
commit 53e585f
Showing
5 changed files
with
144 additions
and
48 deletions.
There are no files selected for viewing
26 changes: 2 additions & 24 deletions
26
src/containers/my-cooperations/accept-cooperation-close/AcceptCooperationClosing.styles.ts
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 |
---|---|---|
@@ -1,27 +1,5 @@ | ||
import palette from '~/styles/app-theme/app.pallete' | ||
|
||
export const styles = { | ||
root: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
border: `1px solid ${palette.basic.pinkishRed}`, | ||
backgroundColor: palette.basic.softGray, | ||
borderRadius: '5px', | ||
padding: '24px', | ||
justifyContent: 'space-between', | ||
gap: '16px' | ||
}, | ||
span: { | ||
fontWeight: '500' | ||
}, | ||
title: { | ||
color: palette.basic.mediumRed, | ||
fontWeight: '500', | ||
display: 'flex', | ||
gap: '8px', | ||
mb: '4px' | ||
}, | ||
body: { | ||
color: palette.basic.darkGray | ||
boldText: { | ||
fontWeight: 500 | ||
} | ||
} |
50 changes: 26 additions & 24 deletions
50
src/containers/my-cooperations/accept-cooperation-close/AcceptCooperationClosing.tsx
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
44 changes: 44 additions & 0 deletions
44
src/containers/my-cooperations/cooperation-action-banner/CooperationActionBanner.styles.ts
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,44 @@ | ||
import { type SxProps } from '@mui/material' | ||
|
||
import palette from '~/styles/app-theme/app.pallete' | ||
|
||
export const styles = { | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
rowGap: '20px', | ||
padding: '24px', | ||
border: `1px solid ${palette.basic.pinkishRed}`, | ||
borderRadius: '5px', | ||
backgroundColor: palette.basic.softGray | ||
}, | ||
header: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
columnGap: '8px', | ||
color: palette.basic.mediumRed | ||
}, | ||
description: { | ||
color: palette.basic.darkGray, | ||
marginTop: '4px' | ||
}, | ||
mainContentWrapper: { | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: { | ||
xs: 'column', | ||
sm: 'row' | ||
}, | ||
justifyContent: 'space-between', | ||
gap: '30px' | ||
}, | ||
buttonsWrapper: { | ||
display: 'flex', | ||
columnGap: '15px', | ||
alignItems: 'center', | ||
alignSelf: { | ||
xs: 'end', | ||
sm: 'auto' | ||
} | ||
} | ||
} satisfies Record<string, SxProps> |
38 changes: 38 additions & 0 deletions
38
src/containers/my-cooperations/cooperation-action-banner/CooperationActionBanner.tsx
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,38 @@ | ||
import { Box, Typography } from '@mui/material' | ||
|
||
import { type ReactNode } from 'react' | ||
import { styles } from './CooperationActionBanner.styles' | ||
|
||
type Properties = { | ||
actionButtons?: ReactNode | ||
children?: ReactNode | ||
description: ReactNode | ||
icon?: ReactNode | ||
title: string | ||
} | ||
|
||
const CooperationActionBanner: React.FC<Properties> = ({ | ||
actionButtons, | ||
children, | ||
description, | ||
icon, | ||
title | ||
}) => { | ||
return ( | ||
<Box sx={styles.container}> | ||
<Box sx={styles.mainContentWrapper}> | ||
<Box> | ||
<Box sx={styles.header}> | ||
{icon} | ||
<Typography>{title}</Typography> | ||
</Box> | ||
<Typography sx={styles.description}>{description}</Typography> | ||
</Box> | ||
{actionButtons && <Box sx={styles.buttonsWrapper}>{actionButtons}</Box>} | ||
</Box> | ||
{children && <Box>{children}</Box>} | ||
</Box> | ||
) | ||
} | ||
|
||
export default CooperationActionBanner |
34 changes: 34 additions & 0 deletions
34
...nit/containers/my-cooperations/cooperation-action-banner/CooperationActionBanner.spec.jsx
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,34 @@ | ||
import { ErrorOutlineRounded } from '@mui/icons-material' | ||
import { render, screen } from '@testing-library/react' | ||
import { beforeEach, expect } from 'vitest' | ||
|
||
import CooperationActionBanner from '~/containers/my-cooperations/cooperation-action-banner/CooperationActionBanner' | ||
|
||
describe('CooperationActionBanner', () => { | ||
beforeEach(() => { | ||
render( | ||
<CooperationActionBanner | ||
description='cooperationDetailsPage.closingMessage' | ||
title='titles.acceptCooperationClosing' | ||
children='cooperationDetailsPage.someAdditionalText' | ||
icon={<ErrorOutlineRounded data-testid='icon-example' />} | ||
/> | ||
) | ||
}) | ||
|
||
it('should render the CooperationActionBanner with title, description, icon and children', () => { | ||
const titleText = screen.getByText('titles.acceptCooperationClosing') | ||
const descriptionText = screen.getByText( | ||
'cooperationDetailsPage.closingMessage' | ||
) | ||
const childrenContent = screen.getByText( | ||
'cooperationDetailsPage.someAdditionalText' | ||
) | ||
const icon = screen.getByTestId('icon-example') | ||
|
||
expect(titleText).toBeInTheDocument() | ||
expect(descriptionText).toBeInTheDocument() | ||
expect(childrenContent).toBeInTheDocument() | ||
expect(icon).toBeInTheDocument() | ||
}) | ||
}) |