-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1437 from kianamcc/PORTALS-3312
PORTALS-3312: New Portal feature highlights component
- Loading branch information
Showing
9 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
29 changes: 29 additions & 0 deletions
29
...e-react-client/src/components/PortalFeatureHighlights/PortalFeatureHighlights.stories.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,29 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import PortalFeatureHighlights from './PortalFeatureHighlights' | ||
import { MemoryRouter } from 'react-router-dom' | ||
|
||
const meta = { | ||
title: 'Home Page/PortalFeatureHighlights', | ||
component: PortalFeatureHighlights, | ||
parameters: { | ||
chromatic: { viewports: [600, 1200] }, | ||
}, | ||
} satisfies Meta | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Demo: Story = { | ||
render: args => ( | ||
<MemoryRouter> | ||
<PortalFeatureHighlights {...args} /> | ||
</MemoryRouter> | ||
), | ||
args: { | ||
title: 'Section Title', | ||
summaryText: 'Section summary text.', | ||
buttonText: 'Section button', | ||
image: 'https://link-to-image.png', | ||
link: 'https://example.com', | ||
}, | ||
} |
42 changes: 42 additions & 0 deletions
42
...apse-react-client/src/components/PortalFeatureHighlights/PortalFeatureHighlights.test.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,42 @@ | ||
import PortalFeatureHighlights, { | ||
PortalFeatureHighlightsProps, | ||
} from './PortalFeatureHighlights' | ||
import { MemoryRouter } from 'react-router-dom' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
describe('PortalFeatureHighlights component', () => { | ||
const props: PortalFeatureHighlightsProps = { | ||
title: 'Test Title', | ||
image: 'test-image.jpg', | ||
buttonText: 'Click me', | ||
summaryText: 'This is a test summary', | ||
link: '/test-link', | ||
reverseOrder: false, | ||
} | ||
|
||
const renderComponent = (props: PortalFeatureHighlightsProps) => { | ||
return render( | ||
<MemoryRouter> | ||
<PortalFeatureHighlights {...props} /> | ||
</MemoryRouter>, | ||
) | ||
} | ||
|
||
it('renders the title', () => { | ||
renderComponent(props) | ||
expect(screen.getByText('Test Title')) | ||
}) | ||
|
||
it('renders image with correct src', () => { | ||
renderComponent(props) | ||
const image = screen.getByRole('img') | ||
expect(image).toHaveAttribute('src', 'test-image.jpg') | ||
}) | ||
|
||
it('renders the button with the correct text and link', () => { | ||
renderComponent(props) | ||
const button = screen.getByRole('link', { name: 'Click me' }) | ||
expect(button).toBeInTheDocument() | ||
expect(button).toHaveAttribute('href', '/test-link') | ||
}) | ||
}) |
93 changes: 93 additions & 0 deletions
93
...s/synapse-react-client/src/components/PortalFeatureHighlights/PortalFeatureHighlights.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,93 @@ | ||
import { Typography, Button, CardMedia, Stack, Box } from '@mui/material' | ||
import React from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
export type PortalFeatureHighlightsProps = { | ||
reverseOrder?: boolean | ||
title?: string | ||
image?: string | ||
buttonText?: string | ||
summaryText?: React.ReactNode | ||
link?: string | ||
} | ||
|
||
const PortalFeatureHighlights = (props: PortalFeatureHighlightsProps) => { | ||
const { reverseOrder, image, title, buttonText, summaryText, link } = props | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: 'grid', | ||
padding: { xs: '40px', lg: '80px' }, | ||
gap: { xs: '38px', md: '80px' }, | ||
gridTemplateColumns: { | ||
xs: 'minmax(100px, 1fr)', | ||
lg: reverseOrder | ||
? 'minmax(150px, 1fr) minmax(300px, 2fr)' | ||
: 'minmax(300px, 2fr) minmax(150px, 1fr)', | ||
}, | ||
gridTemplateAreas: { | ||
xs: `'image' 'content'`, | ||
lg: reverseOrder ? `'content image'` : `'image content'`, | ||
}, | ||
}} | ||
> | ||
<CardMedia | ||
component="img" | ||
image={image} | ||
sx={{ | ||
gridArea: 'image', | ||
borderRadius: '12px', | ||
height: '100%', | ||
width: '100%', | ||
objectFit: 'cover', | ||
}} | ||
/> | ||
<Stack | ||
sx={{ | ||
gridArea: 'content', | ||
gap: '16px', | ||
borderTop: '3px solid', | ||
borderColor: 'grey.400', | ||
}} | ||
> | ||
<Typography | ||
variant="headline2" | ||
paddingTop="30px" | ||
paddingBottom="10px" | ||
color="grey.1000" | ||
fontSize={'31px'} | ||
> | ||
{title} | ||
</Typography> | ||
<Button | ||
variant="contained" | ||
component={Link} | ||
to={link || ''} | ||
sx={{ | ||
minWidth: '265px', | ||
whiteSpace: 'nowrap', | ||
padding: '6px 24px', | ||
fontWeight: '600', | ||
fontSize: '16px', | ||
}} | ||
> | ||
{buttonText} | ||
</Button> | ||
<Typography | ||
variant="body1" | ||
sx={{ | ||
fontStyle: 'italic', | ||
color: 'grey.800', | ||
fontSize: '18px', | ||
lineHeight: '27px', | ||
}} | ||
> | ||
{summaryText} | ||
</Typography> | ||
</Stack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default PortalFeatureHighlights |
4 changes: 4 additions & 0 deletions
4
packages/synapse-react-client/src/components/PortalFeatureHighlights/index.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,4 @@ | ||
import PortalFeatureHighlights from './PortalFeatureHighlights' | ||
import type { PortalFeatureHighlightsProps } from './PortalFeatureHighlights' | ||
export { PortalFeatureHighlights, PortalFeatureHighlightsProps } | ||
export default PortalFeatureHighlights |
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