Skip to content

Commit

Permalink
Merge branch 'develop' into feature/420-select-single
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Jul 31, 2024
2 parents 6153568 + 55cd353 commit 3eaf7bb
Show file tree
Hide file tree
Showing 82 changed files with 3,530 additions and 245 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ To stay up-to-date with all the latest changes, join the [Google Group][dv_commu
<li><a href="#what-is-dataverse">What is Dataverse?</a></li>
<li><a href="#what-is-dataverse-frontend">What Is Dataverse Frontend &amp; How Do They Differ?</a></li>
<li><a href="#demo-videos">Demo Videos</a></li>
<li><a href="#beta-testing-environemtn">Beta Testing Environment</a></li>
<li><a href="#beta-testing-environment">Beta Testing Environment</a></li>
</ul>
</li>
<li><a href="#roadmap">Roadmap</a></li>
Expand Down Expand Up @@ -178,6 +178,8 @@ The environment is accessible through the following URLs:
> did not reflect the user's current location within the site, our new SPA design now includes this feature in the breadcrumbs.
> Additionally, we have aligned with best practices by positioning all breadcrumbs at the top, before anything else in the UI.
>
> We have also introduced action items as the last item of the breadcrumb, eg: Collection > Dataset Name > Edit Dataset Metadata
>
> This update gives users a clear indication of their current position within the application's hierarchy.
>
> ### Changes in Functionality &amp; Behavior
Expand All @@ -200,11 +202,17 @@ The environment is accessible through the following URLs:
> search, whose search facets are reduced compared to other in-application searches. Therefore, if we find evidence that
> the assumption is incorrect, we will work on extending the search capabilities to support Solr.
>
> We have also introduced infinite scroll pagination here.
>
> #### Dataverses/Datasets list
>
> The original JSF Dataverses/Datasets list on the home page uses normal paging buttons at the bottom of the list.
> We have implemented infinite scrolling in this list, replacing the normal paging buttons, but the goal would be to be
> able to toggle between normal paging and infinite scrolling via a toggle setting or button.
>
> #### Create/Edit Collection Page Identifier Field
>
> A feature has been added to suggest an identifier to the user based on the collection name entered.
</details>

Expand Down
7 changes: 7 additions & 0 deletions packages/design-system/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- **Card:** NEW card element to show header and body.
- **ProgressBar:** NEW progress bar element to show progress.
- **SelectAdvanced:** NEW ehanced select to search across options, and perform both single and multiple selections.
- **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.
- **FormTextArea:** extend Props Interface to accept `autoFocus` prop.
- **FormSelect:** extend Props Interface to accept `autoFocus` prop.
- **Stack:** NEW Stack element to manage layouts.

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

Expand Down
4 changes: 4 additions & 0 deletions packages/design-system/src/lib/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { Button as ButtonBS } from 'react-bootstrap'
import { IconName } from '../icon/IconName'
import { Icon } from '../icon/Icon'

type ButtonSize = 'sm' | 'lg'
type ButtonVariant = 'primary' | 'secondary' | 'link'
type ButtonType = 'button' | 'reset' | 'submit'

interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
size?: ButtonSize
variant?: ButtonVariant
disabled?: boolean
onClick?: (event: MouseEvent<HTMLButtonElement>) => void
Expand All @@ -18,6 +20,7 @@ interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
}

export function Button({
size,
variant = 'primary',
disabled = false,
onClick,
Expand All @@ -29,6 +32,7 @@ export function Button({
}: ButtonProps) {
return (
<ButtonBS
size={size}
className={withSpacing ? styles.spacing : ''}
variant={variant}
onClick={disabled ? undefined : onClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface FormInputProps extends React.HTMLAttributes<FormInputElement> {
disabled?: boolean
value?: string | number
required?: boolean
autoFocus?: boolean
}

export const FormInput = React.forwardRef(function FormInput(
Expand All @@ -24,6 +25,7 @@ export const FormInput = React.forwardRef(function FormInput(
disabled,
value,
required,
autoFocus,
...props
}: FormInputProps,
ref
Expand All @@ -39,6 +41,7 @@ export const FormInput = React.forwardRef(function FormInput(
disabled={disabled}
value={value}
required={required}
autoFocus={autoFocus}
ref={ref as React.ForwardedRef<HTMLInputElement>}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ export interface FormSelectProps
isInvalid?: boolean
isValid?: boolean
disabled?: boolean
autoFocus?: boolean
}

export const FormSelect = React.forwardRef(function FormSelect(
{ value, isInvalid, isValid, disabled, children, ...props }: PropsWithChildren<FormSelectProps>,
{
value,
isInvalid,
isValid,
disabled,
autoFocus,
children,
...props
}: PropsWithChildren<FormSelectProps>,
ref
) {
return (
Expand All @@ -21,6 +30,7 @@ export const FormSelect = React.forwardRef(function FormSelect(
isInvalid={isInvalid}
isValid={isValid}
disabled={disabled}
autoFocus={autoFocus}
ref={ref as React.ForwardedRef<HTMLSelectElement>}
{...props}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ export interface FormTextAreaProps extends Omit<React.HTMLAttributes<FormInputEl
isValid?: boolean
isInvalid?: boolean
value?: string
autoFocus?: boolean
}

export const FormTextArea = React.forwardRef(function FormTextArea(
{ name, disabled, isValid, isInvalid, value, ...props }: FormTextAreaProps,
{ name, disabled, isValid, isInvalid, value, autoFocus, ...props }: FormTextAreaProps,
ref
) {
return (
Expand All @@ -23,6 +24,7 @@ export const FormTextArea = React.forwardRef(function FormTextArea(
isValid={isValid}
isInvalid={isInvalid}
value={value}
autoFocus={autoFocus}
ref={ref as React.ForwardedRef<HTMLTextAreaElement>}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import { ReactNode } from 'react'
import { InputGroup } from 'react-bootstrap'
import { FormInputGroupText } from './FormInputGroupText'

function FormInputGroup({ children }: { children: ReactNode }) {
return <InputGroup className="mb-3">{children}</InputGroup>
interface FormInputGroupProps {
children: ReactNode
hasValidation?: boolean
}

function FormInputGroup({ children, hasValidation }: FormInputGroupProps) {
return (
<InputGroup className="mb-3" hasValidation={hasValidation}>
{children}
</InputGroup>
)
}

FormInputGroup.Text = FormInputGroupText
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { NavDropdown } from 'react-bootstrap'
import { PropsWithChildren } from 'react'
import { ComponentPropsWithoutRef, ElementType, PropsWithChildren } from 'react'

interface NavbarDropdownItemProps {
href: string
type NavbarDropdownItemProps<T extends ElementType> = {
href?: string
onClick?: () => void
disabled?: boolean
}
as?: T
} & (T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : ComponentPropsWithoutRef<T>)

export function NavbarDropdownItem({
export function NavbarDropdownItem<T extends ElementType = 'a'>({
href,
onClick,
disabled,
children
}: PropsWithChildren<NavbarDropdownItemProps>) {
children,
as,
...props
}: PropsWithChildren<NavbarDropdownItemProps<T>>) {
/* eslint-disable @typescript-eslint/no-explicit-any */
const Component: ElementType<any> | undefined = as

return (
<NavDropdown.Item href={href} onClick={onClick} disabled={disabled}>
<NavDropdown.Item href={href} onClick={onClick} disabled={disabled} as={Component} {...props}>
{children}
</NavDropdown.Item>
)
Expand Down
26 changes: 26 additions & 0 deletions packages/design-system/src/lib/components/stack/Stack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ComponentPropsWithoutRef, ElementType } from 'react'
import { Stack as StackBS } from 'react-bootstrap'

type StackProps<T extends ElementType> = {
direction?: 'horizontal' | 'vertical'
gap?: 0 | 1 | 2 | 3 | 4 | 5
as?: T
children: React.ReactNode
} & (T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : ComponentPropsWithoutRef<T>)

export function Stack<T extends ElementType = 'div'>({
direction = 'vertical',
gap = 3,
as,
children,
...rest
}: StackProps<T>) {
/* eslint-disable @typescript-eslint/no-explicit-any */
const Component: ElementType<any> = as || 'div'

return (
<StackBS direction={direction} gap={gap} as={Component} {...rest}>
{children}
</StackBS>
)
}
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 @@ -27,3 +27,4 @@ export { RequiredInputSymbol } from './components/form/required-input-symbol/Req
export { SelectAdvanced } from './components/select-advanced/SelectAdvanced'
export { Card } from './components/card/Card'
export { ProgressBar } from './components/progress-bar/ProgressBar'
export { Stack } from './components/stack/Stack'
14 changes: 14 additions & 0 deletions packages/design-system/src/lib/stories/button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ export const AllVariantsAtAGlance: Story = {
)
}

export const AllSizesAtAGlance: Story = {
render: () => (
<>
<Button withSpacing size="sm">
Small
</Button>
<Button withSpacing>Default size</Button>
<Button withSpacing size="lg">
Large size
</Button>
</>
)
}

export const Disabled: Story = {
render: () => (
<>
Expand Down
120 changes: 120 additions & 0 deletions packages/design-system/src/lib/stories/stack/Stack.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { CSSProperties } from 'react'
import type { Meta, StoryObj } from '@storybook/react'
import { Stack } from '../../components/stack/Stack'
import { Col } from '../../components/grid/Col'

/**
* ## Description
* Stacks are vertical by default and stacked items are full-width by default. Use the gap prop to add space between items.
*
* Use direction="horizontal" for horizontal layouts. Stacked items are vertically centered by default and only take up their necessary width.
*
* Use the gap prop to add space between items.
*/
const meta: Meta<typeof Stack> = {
tags: ['autodocs'],
title: 'Stack',
component: Stack
}

export default meta
type Story = StoryObj<typeof Stack>

const inlineStyles: CSSProperties = {
backgroundColor: '#337AB7',
color: 'white',
padding: '0.5rem'
}

export const VerticalStack: Story = {
render: () => (
<Stack>
<div style={inlineStyles}>Item 1</div>
<div style={inlineStyles}>Item 2</div>
<div style={inlineStyles}>Item 3</div>
</Stack>
)
}

/**
* Use direction="horizontal" for horizontal layouts.
* Stacked items are vertically centered by default and only take up their necessary width.
*/
export const HorizontalStack: Story = {
render: () => (
<Stack direction="horizontal">
<div style={inlineStyles}>Item 1</div>
<div style={inlineStyles}>Item 2</div>
<div style={inlineStyles}>Item 3</div>
</Stack>
)
}
/**
* By using Columns as childrens of the Stack, you can create a layout with columns that are full-width by default.
*/
export const HorizontalStackWithColumns: Story = {
render: () => (
<Stack direction="horizontal">
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
<Col style={inlineStyles}>Item 3</Col>
</Stack>
)
}
/**
* Gap 0 = 0
*
* Gap 1 = 0.25rem (4px)
*
* Gap 2 = 0.5rem (8px)
*
* Gap 3 = 1rem (16px)
*
* Gap 4 = 1.5rem (24px)
*
* Gap 5 = 3rem (48px)
*/
export const AllGaps: Story = {
render: () => (
<Stack gap={4}>
<Stack direction="horizontal" gap={0}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
<Stack direction="horizontal" gap={1}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
<Stack direction="horizontal" gap={2}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
<Stack direction="horizontal" gap={3}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
<Stack direction="horizontal" gap={4}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
<Stack direction="horizontal" gap={5}>
<Col style={inlineStyles}>Item 1</Col>
<Col style={inlineStyles}>Item 2</Col>
</Stack>
</Stack>
)
}

/**
* Use `as` prop to render the Stack as a different element.
* If you inspect the rendered HTML, you will see that the Stack is rendered as a section element.
*/
export const StackAsSection: Story = {
render: () => (
<Stack as="section">
<div style={inlineStyles}>Item 1</div>
<div style={inlineStyles}>Item 2</div>
<div style={inlineStyles}>Item 3</div>
</Stack>
)
}
Loading

0 comments on commit 3eaf7bb

Please sign in to comment.