forked from uncch-rdmc/dataverse-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
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 IQSS#385 from IQSS/feature/355-select-multiple-com…
…ponent Feature/355 select multiple component
- Loading branch information
Showing
21 changed files
with
1,247 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |
- **FormChecboxGroup:** refactor styles. | ||
- **FormGroupWithMultipleFields:** refactor styles and conditional render logic. | ||
- **FormGroup:** ability to clone children wrapped by react fragments. | ||
- **FormCheckbox:** ability to forward react ref to input. | ||
- **FormInput:** ability to forward react ref to input. | ||
- **FormSelect:** ability to forward react ref to input. | ||
- **FormTextArea:** ability to forward react ref to input. | ||
- **FormCheckbox:** ability to forward react ref to input and export FormCheckboxProps interface. | ||
- **FormInput:** ability to forward react ref to input and export FormInputProps interface. | ||
- **FormSelect:** ability to forward react ref to input, add `isInvalid` `isValid` & `disabled` props and export FormSelectProps interface. | ||
- **FormTextArea:** ability to forward react ref to input and export FormTextAreaProps interface. | ||
- **FormFeedback:** remove `span: 9` from styles. | ||
- **FormGroup:** controlId is now optional. | ||
- **FormLabel:** extend Props Interface to accept `htmlFor` prop. | ||
- **SelectMultiple:** NEW multiple selector for occasions when you can choose more than one option. | ||
- **FormSelectMultiple:** The new multiple selector is added to the "FormGroup" components. | ||
- **DropdownButtonItem:** extend Props Interface to accept `as` prop. | ||
|
||
# [1.1.0](https://github.com/IQSS/dataverse-frontend/compare/@iqss/[email protected]...@iqss/[email protected]) (2024-03-12) | ||
|
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
3 changes: 2 additions & 1 deletion
3
packages/design-system/src/lib/components/form/form-group/form-element/FormCheckbox.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
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
20 changes: 20 additions & 0 deletions
20
...ages/design-system/src/lib/components/form/form-group/form-element/FormSelectMultiple.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,20 @@ | ||
import { PropsWithChildren, forwardRef } from 'react' | ||
import { FormElementLayout } from './FormElementLayout' | ||
import { SelectMultiple, SelectMultipleProps } from '../../../select-multiple/SelectMultiple' | ||
|
||
export interface FormSelectMultipleProps extends SelectMultipleProps { | ||
withinMultipleFieldsGroup?: boolean | ||
inputButtonId: string | ||
} | ||
|
||
export const FormSelectMultiple = forwardRef( | ||
({ withinMultipleFieldsGroup, ...props }: PropsWithChildren<FormSelectMultipleProps>, ref) => { | ||
return ( | ||
<FormElementLayout withinMultipleFieldsGroup={withinMultipleFieldsGroup}> | ||
<SelectMultiple ref={ref as React.ForwardedRef<HTMLInputElement>} {...props} /> | ||
</FormElementLayout> | ||
) | ||
} | ||
) | ||
|
||
FormSelectMultiple.displayName = 'FormSelectMultiple' |
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
159 changes: 159 additions & 0 deletions
159
packages/design-system/src/lib/components/select-multiple/SelectMultiple.module.scss
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,159 @@ | ||
@use 'sass:color'; | ||
@import 'src/lib/assets/styles/design-tokens/colors.module'; | ||
@import 'src/lib/assets/styles/design-tokens/typography.module'; | ||
|
||
:root { | ||
--select-multiple-menu-max-height: 300px; | ||
--toggle-padding: 6px 36px 6px 12px; | ||
} | ||
|
||
.select-multiple-toggle { | ||
position: relative; | ||
display: grid; | ||
background-color: #fff; | ||
|
||
&.disabled { | ||
opacity: 0.6; | ||
pointer-events: none; | ||
} | ||
|
||
// Chevron icon | ||
&::after { | ||
position: absolute; | ||
top: 50%; | ||
right: 1rem; | ||
display: inline-block; | ||
width: 0.45em; | ||
height: 0.45em; | ||
border-color: rgb(0 0 0 / 75%); | ||
border-style: solid; | ||
border-width: 2px 2px 0 0; | ||
transform: translateY(-60%) rotate(-225deg); | ||
content: ''; | ||
} | ||
|
||
&__input-button { | ||
position: relative; | ||
z-index: 1; | ||
display: flex; | ||
grid-area: 1 / 1; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
padding: var(--toggle-padding); | ||
background-color: transparent; | ||
border: solid 1px $dv-secondary-color; | ||
border-radius: 6px; | ||
cursor: pointer; | ||
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; | ||
|
||
&::after { | ||
display: none; | ||
} | ||
|
||
&.invalid { | ||
border-color: $dv-danger-color; | ||
} | ||
|
||
&:focus-within, | ||
&:focus { | ||
border-color: color.adjust($dv-primary-color, $alpha: -0.4); | ||
outline: 0; | ||
box-shadow: 0 0 0 0.25rem color.adjust($dv-primary-color, $alpha: -0.7); | ||
} | ||
|
||
&.invalid:focus-within, | ||
&.invalid:focus { | ||
border-color: color.adjust($dv-danger-color, $alpha: -0.4); | ||
outline: 0; | ||
box-shadow: 0 0 0 0.25rem color.adjust($dv-danger-color, $alpha: -0.7); | ||
} | ||
} | ||
|
||
&__inner-content { | ||
position: relative; | ||
z-index: 2; | ||
grid-area: 1 / 1; | ||
padding: var(--toggle-padding); | ||
pointer-events: none; | ||
|
||
.selected-options-container { | ||
display: inline-flex; | ||
flex: 1; | ||
flex-wrap: wrap; | ||
gap: 0.5rem; | ||
pointer-events: none; | ||
|
||
&__item { | ||
display: flex; | ||
align-items: center; | ||
padding: 0.25rem 0.5rem; | ||
color: $dv-text-color; | ||
font-weight: $dv-font-weight-bold; | ||
font-size: $dv-font-size-sm; | ||
background-color: $dv-secondary-color; | ||
border-radius: 0.25rem; | ||
cursor: pointer; | ||
transition: background-color 0.2s; | ||
pointer-events: all; | ||
|
||
button { | ||
display: grid; | ||
place-items: center; | ||
padding: 0; | ||
border-radius: 50%; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.select-multiple-menu { | ||
width: 100%; | ||
max-width: 100%; | ||
max-height: var(--select-multiple-menu-max-height); | ||
padding-top: 0; | ||
overflow-x: hidden; | ||
overflow-y: auto; | ||
box-shadow: 0 5px 10px rgb(0 0 0 / 15%); | ||
|
||
.menu-header { | ||
position: sticky; | ||
top: 0; | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
margin-bottom: 0.25rem; | ||
font-size: 18px; | ||
background-color: $dv-secondary-color; | ||
|
||
.selected-count { | ||
margin: 0; | ||
color: $dv-text-color; | ||
font-size: $dv-font-size; | ||
} | ||
} | ||
|
||
.option-item { | ||
padding-block: 0; | ||
transition: background-color 0.1s ease-in-out; | ||
|
||
&:active, | ||
&:hover { | ||
color: $dv-text-color; | ||
background-color: color.adjust($dv-secondary-color, $alpha: -0.7); | ||
} | ||
|
||
&:has(input[type='checkbox']:checked) { | ||
background-color: color.adjust($dv-secondary-color, $alpha: -0.4); | ||
} | ||
|
||
&__checkbox-input { | ||
padding-block: 0.25rem; | ||
|
||
label { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.