Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 8 additions & 13 deletions docusaurus/pages/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'

import Downshift from '../../src'
import {type ControllerStateAndHelpers} from '../../src/downshift.types'
import {colors} from '../utils'
import {colors, getExampleLabelClassName} from '../utils'

export default function ComboBox() {
return (
Expand All @@ -22,30 +22,27 @@ export default function ComboBox() {
}: ControllerStateAndHelpers<string>) => (
<div className="container">
<label
style={{
fontWeight: 'bolder',
color: selectedItem ? selectedItem : 'black',
}}
className={getExampleLabelClassName(selectedItem)}
{...getLabelProps()}
>
Choose an element:
</label>
<div {...getRootProps({}, {suppressRefError: true})}>
<input
style={{padding: '4px'}}
className="example-input"
{...getInputProps()}
data-testid="combobox-input"
/>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="toggle menu"
data-testid="combobox-toggle-button"
{...getToggleButtonProps()}
>
{isOpen ? <>&#8593;</> : <>&#8595;</>}
</button>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="toggle menu"
data-testid="clear-button"
onClick={() => clearSelection()}
Expand All @@ -62,11 +59,9 @@ export default function ComboBox() {
: colors
).map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : undefined,
}}
className={`example-menu-item${
highlightedIndex === index ? ' highlighted' : ''
}`}
key={`${item}${index}`}
{...getItemProps({
item,
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'

export default function Docs() {
return (
<div style={{width: '50%', margin: '200px auto'}}>
<div className="docs-index">
Downshift Docs for E2E Testing
<ul>
<li>
Expand Down
168 changes: 168 additions & 0 deletions docusaurus/pages/shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
align-self: center;
}

.docs-index {
width: 50%;
margin: 200px auto;
}

.menu {
list-style: none;
width: 100%;
Expand All @@ -16,6 +21,160 @@
overflow-y: scroll;
}

.example-label {
color: var(--ifm-font-color-base);
font-weight: bolder;
}

.example-color-black {
color: #1c1e21;
}

.example-color-red {
color: #b00020;
}

.example-color-green {
color: #006b3c;
}

.example-color-blue {
color: #0b57d0;
}

.example-color-orange {
color: #9a4d00;
}

.example-color-purple {
color: #6f2da8;
}

.example-color-pink {
color: #b0005a;
}

.example-color-orchid {
color: #8a2a8a;
}

.example-color-aqua {
color: #007c89;
}

.example-color-lime {
color: #4a6f00;
}

.example-color-gray {
color: #606770;
}

.example-color-brown {
color: #7a3e14;
}

.example-color-teal {
color: #00796b;
}

.example-color-skyblue {
color: #0369a1;
}

html[data-theme='dark'] .example-color-black {
color: #f5f6f7;
}

html[data-theme='dark'] .example-color-red {
color: #ff8a80;
}

html[data-theme='dark'] .example-color-green {
color: #7ee787;
}

html[data-theme='dark'] .example-color-blue {
color: #79c0ff;
}

html[data-theme='dark'] .example-color-orange {
color: #ffa657;
}

html[data-theme='dark'] .example-color-purple {
color: #d2a8ff;
}

html[data-theme='dark'] .example-color-pink {
color: #ff99c8;
}

html[data-theme='dark'] .example-color-orchid {
color: #ff9df5;
}

html[data-theme='dark'] .example-color-aqua {
color: #7ee7ff;
}

html[data-theme='dark'] .example-color-lime {
color: #b8ff7a;
}

html[data-theme='dark'] .example-color-gray {
color: #c9d1d9;
}

html[data-theme='dark'] .example-color-brown {
color: #d4a373;
}

html[data-theme='dark'] .example-color-teal {
color: #56d4c6;
}

html[data-theme='dark'] .example-color-skyblue {
color: #9cdcfe;
}

.example-input {
border: 1px solid var(--ifm-color-emphasis-300);
background-color: var(--ifm-background-color);
color: var(--ifm-font-color-base);
padding: 4px;
}

.example-button {
border: 1px solid var(--ifm-color-emphasis-300);
background-color: var(--ifm-color-emphasis-100);
color: var(--ifm-font-color-base);
padding: 4px 8px;
}

.example-select-toggle {
padding: 4px;
text-align: center;
border: 1px solid var(--ifm-color-emphasis-600);
background-color: var(--ifm-color-emphasis-100);
color: var(--ifm-font-color-base);
cursor: pointer;
}

.example-menu-item {
padding: 4px;
}

.example-menu-item.highlighted {
background-color: #bde4ff;
color: #1c1e21;
}

html[data-theme='dark'] .example-menu-item.highlighted {
background-color: #1f6feb;
color: #ffffff;
}

.tag-group {
display: inline-flex;
gap: 8px;
Expand All @@ -27,6 +186,7 @@
.tag {
border: solid 1px darkgreen;
background-color: green;
color: #ffffff;
padding: 0 6px;
margin: 0 2px;
border-radius: 10px;
Expand All @@ -49,8 +209,16 @@
background-color: transparent;
}

.tag-remove-control {
padding: 4px;
cursor: pointer;
}

.item-to-add {
border: 1px solid var(--ifm-color-emphasis-300);
background-color: var(--ifm-color-emphasis-100);
cursor: pointer;
color: var(--ifm-font-color-base);
}

.selected-tag {
Expand Down
21 changes: 8 additions & 13 deletions docusaurus/pages/useCombobox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'

import {useCombobox} from '../../src'
import {colors} from '../utils'
import {colors, getExampleLabelClassName} from '../utils'

export default function DropdownCombobox() {
const [inputItems, setInputItems] = React.useState(colors)
Expand All @@ -28,30 +28,27 @@ export default function DropdownCombobox() {
return (
<div className="container">
<label
style={{
fontWeight: 'bolder',
color: selectedItem ? selectedItem : 'black',
}}
className={getExampleLabelClassName(selectedItem)}
{...getLabelProps()}
>
Choose an element:
</label>
<div>
<input
style={{padding: '4px'}}
className="example-input"
{...getInputProps()}
data-testid="combobox-input"
/>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="toggle menu"
data-testid="combobox-toggle-button"
{...getToggleButtonProps()}
>
{isOpen ? <>&#8593;</> : <>&#8595;</>}
</button>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="clear selection"
data-testid="clear-button"
onClick={() => selectItem(null)}
Expand All @@ -63,11 +60,9 @@ export default function DropdownCombobox() {
{isOpen
? inputItems.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : undefined,
}}
className={`example-menu-item${
highlightedIndex === index ? ' highlighted' : ''
}`}
key={`${item}${index}`}
{...getItemProps({
item,
Expand Down
23 changes: 9 additions & 14 deletions docusaurus/pages/useMultipleCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'

import {useCombobox, useMultipleSelection} from '../../src'
import {type UseMultipleSelectionReturnValue} from '../../src/hooks/useMultipleSelection/index.types'
import {colors} from '../utils'
import {colors, getExampleLabelClassName} from '../utils'

const initialSelectedItems = colors.slice(0, 2)

Expand Down Expand Up @@ -79,10 +79,7 @@ export default function DropdownMultipleCombobox() {
return (
<div className="container">
<label
style={{
fontWeight: 'bolder',
color: selectedItem ? selectedItem : 'black',
}}
className={getExampleLabelClassName(selectedItem)}
{...getLabelProps()}
>
Choose an element:
Expand All @@ -104,7 +101,7 @@ export default function DropdownMultipleCombobox() {
{selectedItemForRender}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
<span
style={{padding: '4px', cursor: 'pointer'}}
className="tag-remove-control"
onClick={e => {
e.stopPropagation()
removeSelectedItem(selectedItemForRender)
Expand All @@ -117,20 +114,20 @@ export default function DropdownMultipleCombobox() {
})}
<div>
<input
style={{padding: '4px'}}
className="example-input"
{...getInputProps(getDropdownProps({preventKeyAction: isOpen}))}
data-testid="combobox-input"
/>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="toggle menu"
data-testid="combobox-toggle-button"
{...getToggleButtonProps()}
>
{isOpen ? <>&#8593;</> : <>&#8595;</>}
</button>
<button
style={{padding: '4px 8px'}}
className="example-button"
aria-label="clear selection"
data-testid="clear-button"
onClick={() => reset()}
Expand All @@ -143,11 +140,9 @@ export default function DropdownMultipleCombobox() {
{isOpen
? items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : undefined,
}}
className={`example-menu-item${
highlightedIndex === index ? ' highlighted' : ''
}`}
key={`${item}${index}`}
{...getItemProps({
item,
Expand Down
Loading
Loading