-
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.
Merge pull request #509 from IQSS/feat/484-collection-page-results-of…
…-all-types Feat/484 Collection page results of all types
- Loading branch information
Showing
158 changed files
with
4,383 additions
and
2,103 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
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
41 changes: 41 additions & 0 deletions
41
packages/design-system/src/lib/components/offcanvas/Offcanvas.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,41 @@ | ||
import { Offcanvas as OffcanvasBS } from 'react-bootstrap' | ||
import { OffcanvasHeader } from './OffcanvasHeader' | ||
import { OffcanvasTitle } from './OffcanvasTitle' | ||
import { OffcanvasBody } from './OffcanvasBody' | ||
|
||
// https://react-bootstrap.netlify.app/docs/components/offcanvas | ||
|
||
interface OffcanvasProps { | ||
show: boolean | ||
placement?: 'start' | 'end' | 'top' | 'bottom' | ||
responsive?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | ||
onShow?: () => void | ||
onHide?: () => void | ||
children: React.ReactNode | ||
} | ||
|
||
const Offcanvas = ({ | ||
show, | ||
placement = 'start', | ||
responsive, | ||
onHide, | ||
onShow, | ||
children | ||
}: OffcanvasProps) => { | ||
return ( | ||
<OffcanvasBS | ||
show={show} | ||
onHide={onHide} | ||
onShow={onShow} | ||
placement={placement} | ||
responsive={responsive}> | ||
{children} | ||
</OffcanvasBS> | ||
) | ||
} | ||
|
||
Offcanvas.Header = OffcanvasHeader | ||
Offcanvas.Title = OffcanvasTitle | ||
Offcanvas.Body = OffcanvasBody | ||
|
||
export { Offcanvas } |
10 changes: 10 additions & 0 deletions
10
packages/design-system/src/lib/components/offcanvas/OffcanvasBody.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,10 @@ | ||
import { OffcanvasBody as OffcanvasBodyBS } from 'react-bootstrap' | ||
|
||
export interface OffcanvasBodyProps { | ||
children: React.ReactNode | ||
dataTestId?: string | ||
} | ||
|
||
export const OffcanvasBody = ({ children, dataTestId }: OffcanvasBodyProps) => { | ||
return <OffcanvasBodyBS data-testid={dataTestId}>{children}</OffcanvasBodyBS> | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/design-system/src/lib/components/offcanvas/OffcanvasHeader.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,19 @@ | ||
import { OffcanvasHeader as OffcanvasHeaderBS } from 'react-bootstrap' | ||
|
||
export interface OffcanvasHeaderProps { | ||
closeLabel?: string | ||
closeButton?: boolean | ||
children: React.ReactNode | ||
} | ||
|
||
export const OffcanvasHeader = ({ | ||
closeLabel = 'Close', | ||
closeButton = true, | ||
children | ||
}: OffcanvasHeaderProps) => { | ||
return ( | ||
<OffcanvasHeaderBS closeButton={closeButton} closeLabel={closeLabel}> | ||
{children} | ||
</OffcanvasHeaderBS> | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/design-system/src/lib/components/offcanvas/OffcanvasTitle.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,9 @@ | ||
import { OffcanvasTitle as OffcanvasTitleBS } from 'react-bootstrap' | ||
|
||
export interface OffcanvasTitleProps { | ||
children: React.ReactNode | ||
} | ||
|
||
export const OffcanvasTitle = ({ children }: OffcanvasTitleProps) => { | ||
return <OffcanvasTitleBS>{children}</OffcanvasTitleBS> | ||
} |
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
72 changes: 72 additions & 0 deletions
72
packages/design-system/src/lib/stories/offcanvas/Offcanvas.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,72 @@ | ||
import { useState } from 'react' | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { Offcanvas } from '../../components/offcanvas/Offcanvas' | ||
import { Button } from '../../components/button/Button' | ||
|
||
const meta: Meta<typeof Offcanvas> = { | ||
title: 'Offcanvas', | ||
component: Offcanvas, | ||
tags: ['autodocs'] | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Offcanvas> | ||
|
||
const OffcanvasWithTrigger = ({ | ||
placement = 'start', | ||
responsive | ||
}: { | ||
placement?: 'start' | 'end' | 'top' | 'bottom' | ||
responsive?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | ||
}) => { | ||
const [show, setShow] = useState(responsive ? true : false) | ||
|
||
const handleClose = () => setShow(false) | ||
const handleShow = () => setShow(true) | ||
|
||
return ( | ||
<div> | ||
{!responsive && <Button onClick={handleShow}>Open Offcanvas</Button>} | ||
|
||
<Offcanvas show={show} onHide={handleClose} placement={placement} responsive={responsive}> | ||
<Offcanvas.Header closeButton> | ||
<Offcanvas.Title>Offcanvas Title</Offcanvas.Title> | ||
</Offcanvas.Header> | ||
<Offcanvas.Body> | ||
{responsive ? ( | ||
<div> | ||
<p>Resize your browser to show the responsive offcanvas toggle.</p> | ||
<p> | ||
Responsive offcanvas classes hide content outside the viewport from a specified | ||
breakpoint and down. Above that breakpoint, the contents within will behave as | ||
usual. | ||
</p> | ||
</div> | ||
) : ( | ||
<p>All the content goes here</p> | ||
)} | ||
</Offcanvas.Body> | ||
</Offcanvas> | ||
</div> | ||
) | ||
} | ||
|
||
export const Default: Story = { | ||
render: () => <OffcanvasWithTrigger /> | ||
} | ||
|
||
export const TopPlacement: Story = { | ||
render: () => <OffcanvasWithTrigger placement="top" /> | ||
} | ||
|
||
export const EndPlacement: Story = { | ||
render: () => <OffcanvasWithTrigger placement="end" /> | ||
} | ||
|
||
export const BottomPlacement: Story = { | ||
render: () => <OffcanvasWithTrigger placement="bottom" /> | ||
} | ||
|
||
export const Responsive: Story = { | ||
render: () => <OffcanvasWithTrigger placement="start" responsive="md" /> | ||
} |
79 changes: 79 additions & 0 deletions
79
packages/design-system/tests/component/off-canvas/Offcanvas.spec.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,79 @@ | ||
import { useState } from 'react' | ||
import { Offcanvas } from '../../../src/lib/components/offcanvas/Offcanvas' | ||
|
||
const OffcanvasWithTrigger = ({ | ||
placement, | ||
responsive, | ||
withCloseButton | ||
}: { | ||
placement?: 'start' | 'end' | 'top' | 'bottom' | ||
responsive?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | ||
withCloseButton?: boolean | ||
}) => { | ||
const [show, setShow] = useState(false) | ||
|
||
const handleClose = () => setShow(false) | ||
const handleShow = () => setShow(true) | ||
|
||
return ( | ||
<div> | ||
<button onClick={handleShow}>Open Offcanvas</button> | ||
|
||
<Offcanvas show={show} onHide={handleClose} placement={placement} responsive={responsive}> | ||
<Offcanvas.Header closeButton={withCloseButton}> | ||
<Offcanvas.Title>Offcanvas Title</Offcanvas.Title> | ||
</Offcanvas.Header> | ||
<Offcanvas.Body dataTestId="off-canvas-body"> | ||
{responsive ? ( | ||
<div> | ||
<p>Resize your browser to show the responsive offcanvas toggle.</p> | ||
<p> | ||
Responsive offcanvas classes hide content outside the viewport from a specified | ||
breakpoint and down. Above that breakpoint, the contents within will behave as | ||
usual. | ||
</p> | ||
</div> | ||
) : ( | ||
<p>All the content goes here</p> | ||
)} | ||
</Offcanvas.Body> | ||
</Offcanvas> | ||
</div> | ||
) | ||
} | ||
|
||
describe('Offcanvas', () => { | ||
it('opens and close correctly by a button', () => { | ||
cy.viewport(375, 700) | ||
|
||
cy.mount(<OffcanvasWithTrigger responsive="lg" placement="start" withCloseButton />) | ||
|
||
cy.findByTestId('off-canvas-body').should('not.be.visible') | ||
|
||
cy.findByRole('button', { name: /Open Offcanvas/i }).click() | ||
cy.findByTestId('off-canvas-body').should('be.visible') | ||
|
||
cy.findByLabelText(/Close/).click() | ||
cy.findByTestId('off-canvas-body').should('not.be.visible') | ||
}) | ||
|
||
it('is shown automatically after lg screens (992px)', () => { | ||
cy.viewport(1200, 700) | ||
|
||
cy.mount(<OffcanvasWithTrigger responsive="lg" placement="start" withCloseButton />) | ||
|
||
cy.findByTestId('off-canvas-body').should('be.visible') | ||
}) | ||
|
||
it('is not show an placement start as default props if not passed', () => { | ||
cy.viewport(375, 700) | ||
|
||
cy.mount(<OffcanvasWithTrigger responsive="lg" />) | ||
|
||
cy.findByTestId('off-canvas-body').should('not.be.visible') | ||
|
||
cy.findByRole('button', { name: /Open Offcanvas/i }).click() | ||
|
||
cy.findByRole('dialog').should('have.class', 'offcanvas-start') | ||
}) | ||
}) |
Oops, something went wrong.