Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:IQSS/dataverse-frontend into 456…
Browse files Browse the repository at this point in the history
…-localstack-s3-env
  • Loading branch information
GPortas committed Aug 21, 2024
2 parents 5abff2b + 5832262 commit dd60f36
Show file tree
Hide file tree
Showing 97 changed files with 7,898 additions and 208 deletions.
16 changes: 8 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
**What this PR does / why we need it**:
## What this PR does / why we need it:

**Which issue(s) this PR closes**:
## Which issue(s) this PR closes:

Closes #
- Closes #

**Special notes for your reviewer**:
## Special notes for your reviewer:

**Suggestions on how to test this**:
## Suggestions on how to test this:

**Does this PR introduce a user interface change? If mockups are available, please link/include them here**:
## Does this PR introduce a user interface change? If mockups are available, please link/include them here:

**Is there a release notes update needed for this change?**:
## Is there a release notes update needed for this change?:

**Additional documentation**:
## Additional documentation:
77 changes: 71 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-pr155.be01a3f",
"@iqss/dataverse-client-javascript": "2.0.0-pr169.aa49f06",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/design-system/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **FormTextArea:** extend Props Interface to accept `autoFocus` prop.
- **FormSelect:** extend Props Interface to accept `autoFocus` prop.
- **Stack:** NEW Stack element to manage layouts.
- **TransferList:** NEW TransferList component to transfer items between two list, also sortable.
- **Table:** extend Props Interface to accept `bordered` prop to add or remove borders on all sides of the table and cells. Defaults to true.

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

Expand Down
4 changes: 4 additions & 0 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"test:coverage": "nyc check-coverage"
},
"dependencies": {
"@dnd-kit/core": "6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "8.0.0",
"@dnd-kit/utilities": "3.2.2",
"@types/react": "18.0.27",
"bootstrap": "5.2.3",
"react-bootstrap": "2.7.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Base colors
$dv-brand-color: #C55B28;
$dv-primary-color: #337AB7;
$dv-brand-color: #c55b28;
$dv-primary-color: #337ab7;
$dv-secondary-color: #e0e0e0;
$dv-success-color: #3c763d;
$dv-danger-color: #a94442;
Expand All @@ -10,7 +10,11 @@ $dv-success-box-color: #e0e0e0;
$dv-danger-box-color: #f2dede;
$dv-warning-box-color: #fcf8e3;
$dv-info-box-color: #d9edf7;
$dv-info-border-color: #428BCA;
$dv-info-border-color: #428bca;

$dv-collection-border-color: #c55b28;
$dv-dataset-border-color: #428BCA;
$dv-file-border-color: #808080;

// Text colors
$dv-text-color: #333;
Expand All @@ -22,13 +26,16 @@ $dv-secondary-text-color: $dv-text-color;
$dv-headings-color: #333;

// Link colors
$dv-link-color: #3174AF;
$dv-link-color: #3174af;
$dv-link-hover-color: #23527c;
$dv-tooltip-color: #99bcdb;
$dv-tooltip-hover-color: #337ab7;

// Button colors
$dv-button-border-color: #CCC;
$dv-button-border-color: #ccc;

// Border colors
$dv-border-color: #dee2e6;

:export {
brand: $dv-brand-color;
Expand All @@ -52,4 +59,5 @@ $dv-button-border-color: #CCC;
buttonBorderColor: $dv-button-border-color;
tooltipFillColor: $dv-tooltip-color;
tooltipBorderColor: $dv-tooltip-hover-color;
}
borderColor: $dv-border-color;
}
10 changes: 7 additions & 3 deletions packages/design-system/src/lib/components/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { PropsWithChildren } from 'react'
import { Table as TableBS } from 'react-bootstrap'
import styles from './Table.module.scss'

export function Table({ children }: PropsWithChildren) {
interface TableProps {
bordered?: boolean
children: React.ReactNode
}

export function Table({ bordered = true, children }: TableProps) {
return (
<TableBS striped bordered className={styles.table}>
<TableBS striped bordered={bordered} className={styles.table}>
{children}
</TableBS>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { ListGroup } from 'react-bootstrap'
import { DndContext, DragEndEvent } from '@dnd-kit/core'
import { arrayMove, SortableContext } from '@dnd-kit/sortable'
import { restrictToVerticalAxis } from '@dnd-kit/modifiers'
import { type TransferListItem } from './TransferList'
import { ListItem } from './ListItem'
import styles from './TransferList.module.scss'

type ListProps =
| {
items: TransferListItem[]
side: 'left'
checked: TransferListItem[]
onToggle: (item: TransferListItem) => () => void
rightItems?: never
setRight?: never
onChange?: never
}
| {
items: TransferListItem[]
side: 'right'
checked: TransferListItem[]
onToggle: (item: TransferListItem) => () => void
rightItems: TransferListItem[]
setRight: React.Dispatch<React.SetStateAction<TransferListItem[]>>
onChange?: (selected: TransferListItem[]) => void
}

export const ItemsList = ({
items,
side,
checked,
onToggle,
rightItems,
setRight,
onChange
}: ListProps) => {
if (side === 'left') {
return (
<ListGroup className={styles['items-list']} data-testid={`${side}-list-group`}>
{items.map((item: TransferListItem) => (
<ListItem
item={item}
side={side}
checked={checked}
onToggle={onToggle}
key={item.value}
/>
))}
</ListGroup>
)
}

const handleDragEnd = (event: DragEndEvent) => {
const { active, over } = event

if (over && active.id !== over.id) {
const oldIndex = rightItems.findIndex((item) => item.id === active.id)
const newIndex = rightItems.findIndex((item) => item.id === over.id)

const newItems = arrayMove(rightItems, oldIndex, newIndex)

setRight(newItems)

onChange && onChange(newItems)
}
}

return (
<DndContext onDragEnd={handleDragEnd} modifiers={[restrictToVerticalAxis]}>
<SortableContext items={items}>
<ListGroup className={styles['items-list']} data-testid={`${side}-list-group`}>
{items.map((item: TransferListItem) => (
<ListItem
item={item}
side={side}
checked={checked}
onToggle={onToggle}
key={item.value}
/>
))}
</ListGroup>
</SortableContext>
</DndContext>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { useId } from 'react'
import { useSortable } from '@dnd-kit/sortable'
import { CSS } from '@dnd-kit/utilities'
import { ListGroup } from 'react-bootstrap'
import { Form } from '../form/Form'
import { TransferListItem } from './TransferList'
import { Stack } from '../stack/Stack'
import styles from './TransferList.module.scss'

interface ListItemProps {
item: TransferListItem
side: 'left' | 'right'
checked: readonly TransferListItem[]
onToggle: (item: TransferListItem) => () => void
}

export const ListItem = ({ item, side, checked, onToggle }: ListItemProps) => {
const { attributes, listeners, transform, transition, setNodeRef, setActivatorNodeRef } =
useSortable({ id: item.id })

const uniqueID = useId()
const labelId = `transfer-list-item-${item.value}-label-${uniqueID}`

if (side === 'left') {
return (
<ListGroup.Item className={styles['list-item']}>
<Form.Group.Checkbox
label={item.label}
onChange={onToggle(item)}
id={labelId}
checked={checked.indexOf(item) !== -1}
/>
</ListGroup.Item>
)
}

const style = {
transform: CSS.Transform.toString(transform),
transition
}

return (
<ListGroup.Item
ref={setNodeRef}
{...attributes}
role=""
style={style}
className={styles['list-item']}>
<Stack direction="horizontal" gap={1}>
<button
type="button"
ref={setActivatorNodeRef}
{...listeners}
className={styles['drag-handle']}
aria-label="press space to select and keys to drag">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
<circle cx="9" cy="6" r="1.5" fill="#777" />
<circle cx="15" cy="6" r="1.5" fill="#777" />
<circle cx="9" cy="12" r="1.5" fill="#777" />
<circle cx="15" cy="12" r="1.5" fill="#777" />
<circle cx="9" cy="18" r="1.5" fill="#777" />
<circle cx="15" cy="18" r="1.5" fill="#777" />
</svg>
</button>
<Form.Group.Checkbox
label={item.label}
onChange={onToggle(item)}
id={labelId}
checked={checked.indexOf(item) !== -1}
/>
</Stack>
</ListGroup.Item>
)
}
Loading

0 comments on commit dd60f36

Please sign in to comment.