Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/484 Collection page results of all types #509

Merged
merged 44 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
abcf9bf
feat(design system): new Offcanvas component
g-saracca Sep 12, 2024
e18cf47
feat: initial layout
g-saracca Sep 12, 2024
d8be05c
feat(design system): allow passing any react node as label content
g-saracca Sep 13, 2024
ea3a5f3
feat: filters panel ui elements ready
g-saracca Sep 13, 2024
0dbb263
feat: more layout work, separated panels
g-saracca Sep 13, 2024
53e1ac6
chore: renaming file
g-saracca Sep 13, 2024
5603fbc
feat: domain & infra setup
g-saracca Sep 13, 2024
4542881
feat: inital render items, empty items and error message
g-saracca Sep 16, 2024
74d2346
feat: more work on infinite scrolling
g-saracca Sep 16, 2024
5c9d371
feat: read query params from url to set initial search criteria
g-saracca Sep 17, 2024
5f7b9d6
feat: no search matches message
g-saracca Sep 17, 2024
50a7c49
feat: sync url query params
g-saracca Sep 18, 2024
aaa128f
feat: loading states
g-saracca Sep 18, 2024
50eb514
feat(design system): type search to form input
g-saracca Sep 18, 2024
4cd0c53
feat: map and render collections cards done
g-saracca Sep 19, 2024
4034cc7
feat: remove old located collection card in datasets list
g-saracca Sep 20, 2024
e89df02
feat: collection card and dataset cards ready
g-saracca Sep 20, 2024
e7d8163
feat: update to latest version of js-dataverse
g-saracca Sep 23, 2024
7714313
feat: some refactor and cleanup
g-saracca Sep 23, 2024
62ed46b
Merge branch 'develop' into feat/484-collection-page-results-of-all-t…
g-saracca Sep 23, 2024
88e5bec
feat: home navigation to collection updated
g-saracca Sep 23, 2024
338fac5
file card ready
g-saracca Sep 23, 2024
54aff1a
feat: remove file card from dataset-list
g-saracca Sep 23, 2024
12f79a2
feat: load items on back and forward browser navigation
g-saracca Sep 23, 2024
746a19f
chore: add src folder alias to improve imports
g-saracca Sep 24, 2024
dc02536
chore: use alias in imports
g-saracca Sep 24, 2024
491826b
feat: working on stories and mocks
g-saracca Sep 24, 2024
7b0b895
feat: add stories
g-saracca Sep 25, 2024
7a5f3cb
chore: add alias for test folder
g-saracca Sep 25, 2024
ed212de
test: unit test in progress
g-saracca Sep 25, 2024
2b9261b
feat: fix accesibility issues
g-saracca Sep 26, 2024
6e57786
test: finish with unit tests
g-saracca Sep 26, 2024
8fc6508
test: e2e tests done
g-saracca Sep 26, 2024
89d69c4
feat: add locales
g-saracca Sep 26, 2024
0cdbd6b
test: fix e2e test
g-saracca Sep 26, 2024
7b9c3e5
test: unit test for new offcanvas
g-saracca Sep 26, 2024
5b52f8a
test: more robust e2e test
g-saracca Sep 26, 2024
e35605c
feat: update no items message to show correct message based on type o…
g-saracca Sep 26, 2024
7dcead4
feat: add few more stories and remove comments
g-saracca Sep 27, 2024
6c91da8
reset word correction
g-saracca Oct 1, 2024
8ad3f1a
added TODOs for using time tag for displaying dates
g-saracca Oct 1, 2024
b682213
change DatasetPreview to DatasetItemTypePreview
g-saracca Oct 1, 2024
f035fc8
remove comment and unf optional
g-saracca Oct 1, 2024
658a26e
Merge branch 'develop' into feat/484-collection-page-results-of-all-t…
g-saracca Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ dataset/
│ ├── Dataset.ts
│ ├── DatasetFormFields.ts
│ ├── DatasetPaginationInfo.ts
│ ├── DatasetPreview.ts
│ ├── DatasetItemTypePreview.ts
│ ├── DatasetValidationResponse.ts
│ └── TotalDatasetsCount.ts
└── repositories/
Expand Down Expand Up @@ -655,11 +655,11 @@ This means:

import { Home } from '../../../../src/sections/home/Home'
import { DatasetRepository } from '../../../../src/dataset/domain/repositories/DatasetRepository'
import { DatasetPreviewMother } from '../../dataset/domain/models/DatasetPreviewMother'
import { DatasetItemTypePreviewMother } from '../../dataset/domain/models/DatasetItemTypePreviewMother'

const datasetRepository: DatasetRepository = {} as DatasetRepository
const totalDatasetsCount = 10
const datasets = DatasetPreviewMother.createMany(totalDatasetsCount)
const datasets = DatasetItemTypePreviewMother.createMany(totalDatasetsCount)
describe('Home page', () => {
beforeEach(() => {
datasetRepository.getAll = cy.stub().resolves(datasets)
Expand Down
4 changes: 2 additions & 2 deletions dev-env/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ services:
-Ddataverse.files.s3.connection-pool-size=2048
-Ddataverse.files.s3.custom-endpoint-region=us-east-1
-Ddataverse.files.s3.custom-endpoint-url=https://s3.us-east-1.amazonaws.com
expose:
- '8080'
ports:
ekraffmiller marked this conversation as resolved.
Show resolved Hide resolved
- '8080:8080'
networks:
- dataverse
depends_on:
Expand Down
7 changes: 7 additions & 0 deletions dev-env/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import istanbul from 'vite-plugin-istanbul'
import * as path from 'path'

export default defineConfig({
plugins: [
Expand All @@ -20,5 +21,11 @@ export default defineConfig({
hmr: {
clientPort: 8000 // nginx reverse proxy port
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@tests': path.resolve(__dirname, 'tests')
}
}
})
6 changes: 4 additions & 2 deletions packages/design-system/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **FormSelect:** remove withinMultipleFieldsGroup prop.
- **FormText:** remove withinMultipleFieldsGroup prop.
- **FormTextArea:** remove withinMultipleFieldsGroup prop.
- **FormInputGroup:** remove hasVisibleLabel prop.
- **FormInputGroup:** remove hasVisibleLabel prop and accepts className prop.
- **FormInputGroupText:** refactor type.
- **Card:** NEW card element to show header and body.
- **ProgressBar:** NEW progress bar element to show progress.
Expand All @@ -42,7 +42,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **NavbarDropdownItem:** Now accepts `as` prop and takes `as` Element props.
- **FormInputGroup:** extend Props Interface to accept `hasValidation` prop to properly show rounded corners in an <InputGroup> with validation
- **Button:** extend Props Interface to accept `size` prop.
- **FormInput:** extend Props Interface to accept `autoFocus` prop.
- **FormInput:** extend Props Interface to accept `autoFocus` and `type: 'search'` prop.
- **FormTextArea:** extend Props Interface to accept `autoFocus` prop.
- **FormSelect:** extend Props Interface to accept `autoFocus` prop.
- **Stack:** NEW Stack element to manage layouts.
Expand All @@ -51,6 +51,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **Spinner:** New Spinner component.
- **CloseButton:** NEW close button component.
- **Tab:** extend Props Interface to accept `disabled` prop to disable the tab.
- **Offcanvas:** NEW Offcanvas component.
- **FormCheckbox:** modify Props Interface to allow any react node as `label` prop.

# [1.1.0](https://github.com/IQSS/dataverse-frontend/compare/@iqss/[email protected]...@iqss/[email protected]) (2024-03-12)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ $tooltip-max-width: 500px;
// Spinner
@import 'bootstrap/scss/spinners';

// OffCanvas
@import 'bootstrap/scss/offcanvas';

// Navbar

$navbar-light-brand-color: $dv-brand-color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from 'react'
export interface FormCheckboxProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
id: string
label: string
label: React.ReactNode
isValid?: boolean
isInvalid?: boolean
invalidFeedback?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from 'react'
export type FormInputElement = HTMLInputElement | HTMLTextAreaElement

export interface FormInputProps extends React.HTMLAttributes<FormInputElement> {
type?: 'text' | 'email' | 'password'
type?: 'text' | 'email' | 'password' | 'search'
readOnly?: boolean
name?: string
isValid?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { FormInputGroupText } from './FormInputGroupText'
interface FormInputGroupProps {
children: ReactNode
hasValidation?: boolean
className?: string
}

function FormInputGroup({ children, hasValidation }: FormInputGroupProps) {
function FormInputGroup({ children, hasValidation, className = '' }: FormInputGroupProps) {
return (
<InputGroup className="mb-3" hasValidation={hasValidation}>
<InputGroup className={`mb-3 ${className}`} hasValidation={hasValidation}>
{children}
</InputGroup>
)
Expand Down
41 changes: 41 additions & 0 deletions packages/design-system/src/lib/components/offcanvas/Offcanvas.tsx
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 }
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>
}
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>
)
}
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>
}
1 change: 1 addition & 0 deletions packages/design-system/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ export { Stack } from './components/stack/Stack'
export { Spinner } from './components/spinner/Spinner'
export { TransferList, type TransferListItem } from './components/transfer-list/TransferList'
export { CloseButton } from './components/close-button/CloseButton'
export { Offcanvas } from './components/offcanvas/Offcanvas'
9 changes: 9 additions & 0 deletions packages/design-system/src/lib/stories/form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export const AllInputTypes: Story = {
<Form.Group.Input type="password" placeholder="Password" />
</Col>
</Form.Group>

<Form.Group controlId="basic-form-search">
<Form.Group.Label column sm={3}>
Search something
</Form.Group.Label>
<Col sm={9}>
<Form.Group.Input type="search" placeholder="Search..." />
</Col>
</Form.Group>
</Form>
)
}
Expand Down
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" />
}
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')
})
})
Loading
Loading