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

♻️ refactor(select): create new component Combobox #1380

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
37c1fe2
Create PR for #1349
github-actions[bot] Mar 18, 2024
6fe9018
:recycle: refactor(select): create option component (#1356)
github-actions[bot] Mar 18, 2024
b09e821
:recycle: refactor(select): create new component option-list (#1357)
github-actions[bot] Mar 19, 2024
b9489bb
Merge branch 'main' into refactor/select
hirsch88 Mar 19, 2024
c3c9cd5
Merge branch 'refactor/select' into refactor/issue-1349
hirsch88 Mar 19, 2024
aa36f5d
add first dropdown draft
hirsch88 Mar 20, 2024
2171ae7
update spinner
hirsch88 Mar 20, 2024
69f36d2
refactor in to utils
hirsch88 Mar 21, 2024
d5badde
format files
hirsch88 Mar 21, 2024
55a518d
update with prop options
hirsch88 Mar 21, 2024
cb5bd07
add docs
hirsch88 Mar 21, 2024
94d5b7c
format files
hirsch88 Mar 21, 2024
d6ee359
support testing
hirsch88 Mar 26, 2024
c72ac43
chore: Merge branch 'main' into refactor/issue-1349
hirsch88 Mar 26, 2024
8b1c529
chore: Merge branch 'main' into refactor/issue-1349
hirsch88 Mar 26, 2024
f8aa6e7
adjust component testing
hirsch88 Mar 26, 2024
fefcbc8
update component testing
hirsch88 Mar 27, 2024
b74ab9e
add component test for dropdown
hirsch88 Mar 27, 2024
b90c18c
update dropdown
hirsch88 Mar 28, 2024
493bfab
update dropdown
hirsch88 Mar 28, 2024
135a3e3
update dropdown
hirsch88 Mar 28, 2024
8eef573
autocomplete
hirsch88 Mar 28, 2024
b3eb17b
rename
hirsch88 Mar 28, 2024
ad7d07a
update dropdown
hirsch88 Mar 28, 2024
05ca281
update dropdown
hirsch88 Mar 29, 2024
908eaab
format files
hirsch88 Apr 8, 2024
4b8381a
add a11y test
hirsch88 Apr 8, 2024
d76ab4b
add viusal tests
hirsch88 Apr 8, 2024
7d257b6
Merge branch 'main' into refactor/issue-1349
hirsch88 Apr 8, 2024
87bdb6b
update base images
hirsch88 Apr 8, 2024
800b905
format files
hirsch88 Apr 8, 2024
4a42cd7
update angular output
hirsch88 Apr 8, 2024
7e60a01
add testing lib migration
hirsch88 Apr 8, 2024
4c988a5
update docs
hirsch88 Apr 8, 2024
71e2153
add required
hirsch88 Apr 8, 2024
5e6c964
fix tests
hirsch88 Apr 9, 2024
5045f11
fix tests
hirsch88 Apr 9, 2024
7affa27
update docs
hirsch88 Apr 9, 2024
f7f227d
chores
hirsch88 Apr 9, 2024
2fbc25f
merge branch 'main' into refactor/issue-1349
hirsch88 Apr 9, 2024
9a5d8e9
create angular e2e test
hirsch88 Apr 10, 2024
34e01f8
create angular e2e test
hirsch88 Apr 10, 2024
d2d9037
fix doc styles
hirsch88 Apr 10, 2024
cf71f37
update base images
hirsch88 Apr 10, 2024
1e47fb6
update docs
hirsch88 Apr 10, 2024
df15b45
Merge branch 'refactor/issue-1349' of github.com:baloise/design-syste…
hirsch88 Apr 10, 2024
c25fa57
Merge branch 'main' into refactor/issue-1349
hirsch88 Apr 10, 2024
c3ecf19
fix chip hover
hirsch88 Apr 14, 2024
7f6073d
remove old styles
hirsch88 Apr 14, 2024
b3004d4
Create PR for #1350
github-actions[bot] Apr 14, 2024
39dabd1
Merge branch 'refactor/issue-1349' into refactor/issue-1350
hirsch88 Apr 14, 2024
a90e4ab
init
hirsch88 Apr 15, 2024
00e861b
adjust invalid and disabled with chips
hirsch88 Apr 15, 2024
5b95ea3
fix z-index
hirsch88 Apr 15, 2024
4a8d440
Merge branch 'refactor/issue-1349' into refactor/issue-1350
hirsch88 Apr 15, 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
5 changes: 5 additions & 0 deletions .changeset/cuddly-horses-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': minor
---

**dropdown**: add new component to replace bal-select
5 changes: 5 additions & 0 deletions .changeset/modern-bags-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': minor
---

**option-list**: new child component of drop-down components. Option list component will be used by drop-down, combobox and autocomplete.
5 changes: 5 additions & 0 deletions .changeset/ten-teachers-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': minor
---

**option**: new child component of option-list. Option list component will be used by drop-down, combobox and autocomplete.
12 changes: 12 additions & 0 deletions docs/stories/components/bal-combobox/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Testing

The Baloise Design System provides a collection of custom cypress commands for the components. Moreover, some basic cypress commands like `should` or `click` have been overridden to work with the components.

<a class="sb-unstyled button is-primary" href="../?path=/docs/development-testing--documentation">Go to testing guide</a>

<!-- START: human documentation -->



<!-- END: human documentation -->

46 changes: 46 additions & 0 deletions docs/stories/components/bal-combobox/theming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Theming

The component can be customization by changing the CSS variables.

<a class="sb-unstyled button is-primary" href="../?path=/docs/development-theming--page">Go to theming guide</a>

<!-- START: human documentation -->



<!-- END: human documentation -->

### Variables​

| Variable |
| ---------------------------------------------------------------------- |
| `--bal-combobox-control-background` |
| `--bal-combobox-control-background-hover` |
| `--bal-combobox-control-background-invalid` |
| `--bal-combobox-control-background-disabled` |
| `--bal-combobox-control-input-background` |
| `--bal-combobox-control-native-input-background` |
| `--bal-combobox-control-native-input-background-hover` |
| `--bal-combobox-control-input-inverted-footer-background` |
| `--bal-combobox-control-input-inverted-footer-background-hover` |
| `--bal-combobox-control-input-multiple-background` |
| `--bal-combobox-control-input-multiple-background-read-only-selection` |
| `--bal-combobox-control-input-option-background` |
| `--bal-combobox-control-input-option-background-selected` |
| `--bal-combobox-control-input-option-background-focused` |
| `--bal-combobox-control-input-option-background-hover` |
| `--bal-combobox-control-border-radius` |
| `--bal-combobox-popover-border-color` |
| `--bal-combobox-control-border-color` |
| `--bal-combobox-control-border-color-focused` |
| `--bal-combobox-control-border-color-hover` |
| `--bal-combobox-control-border-color-invalid` |
| `--bal-combobox-control-border-color-disabled` |
| `--bal-combobox-control-border-color-focus-within` |
| `--bal-combobox-option-border-top-color` |
| `--bal-combobox-popover-empty-text-color` |
| `--bal-combobox-control-text-color` |
| `--bal-combobox-control-text-color-focused` |
| `--bal-combobox-input-text-color-disabled` |
| `--bal-combobox-control-inverted-footer-native-input-text-color` |
| `--bal-combobox-option-content-label-text-color` |
119 changes: 119 additions & 0 deletions docs/stories/components/bal-dropdown/bal-dropdown.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { Canvas, Meta, Markdown } from '@storybook/blocks'
import { Banner, Lead, PlaygroundBar, StoryHeading, Footer } from '../../../.storybook/blocks'
import * as DropDownStories from './bal-dropdown.stories'

<Meta of={DropDownStories} />

<StoryHeading of={DropDownStories.Basic} hidden></StoryHeading>

<Banner of={DropDownStories} />

<Lead>**Drop-Down** components are used to gather user-provided information from a range of options.</Lead>

The `bal-dropdown` component serves as a alternative to a traditional `<select>` element and is
frequently paired with `bal-field`.

<Canvas of={DropDownStories.Basic} sourceState="shown" className="has-visible-overflow" />

<PlaygroundBar of={DropDownStories.Basic}></PlaygroundBar>

{/* STORIES */}
{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.FieldControl}></StoryHeading>

Combine the component with the `bal-field` components to add a label, validation message and more.

<Canvas of={DropDownStories.FieldControl} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Multiple}></StoryHeading>

The **multiple** prop enables the capability for making multiple selections.

<Canvas of={DropDownStories.Multiple} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.MultipleWithChips}></StoryHeading>

Utilize the **chips** prop to showcase selected items as individual tags, which can be deselected.

<Canvas of={DropDownStories.MultipleWithChips} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Clearable}></StoryHeading>

Applying the **clearable** prop will show a cross in the dropdown to clear the current value of the component.

<Canvas of={DropDownStories.Clearable} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Loading}></StoryHeading>

Applying the **loading** prop will indicate that the component is busy.

<Canvas of={DropDownStories.Loading} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Invalid}></StoryHeading>

Applying the **invalid** prop will indicate a incorrect user input.

<Canvas of={DropDownStories.Invalid} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Disabled}></StoryHeading>

Applying the **disabled** prop will prevent a user from interacting with the component.

<Canvas of={DropDownStories.Disabled} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.FormReset}></StoryHeading>

The component can be used for server-side forms.

<Canvas of={DropDownStories.FormReset} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

<StoryHeading of={DropDownStories.Autocomplete}></StoryHeading>

The component supports **autocomplete** so that the browser can fill out the form control.

<Canvas of={DropDownStories.Autocomplete} className="has-visible-overflow" />

{/* ------------------------------------------------------ */}

## Component API

import api from './api.md?raw'

<Markdown>{api}</Markdown>

import balOptionApi from '../bal-option/api.md?raw'

<Markdown>{balOptionApi}</Markdown>

## Integration

import integration from '../../snippets/integration.md?raw'

<Markdown>{integration}</Markdown>

import theming from './theming.md?raw'

<Markdown>{theming}</Markdown>

import testing from './testing.md?raw'

<Markdown>{testing}</Markdown>

<Footer />
166 changes: 166 additions & 0 deletions docs/stories/components/bal-dropdown/bal-dropdown.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import type { JSX } from '@baloise/ds-core'
import type { Meta } from '@storybook/html'
import { props, withRender, withComponentControls, StoryFactory } from '../../utils'

type Args = JSX.BalDropdown & { content: string }

const meta: Meta<Args> = {
title: 'Components/Form/DropDown',
argTypes: {
...withComponentControls({ tag: 'bal-dropdown' }),
},
args: {
placeholder: 'Pick a color',
},
...withRender(
({ ...args }) => `<bal-dropdown ${props(args)}>
<bal-option value="green" label="Green">Green</bal-option>
<bal-option value="purple" label="Purple">Purple</bal-option>
<bal-option value="yellow" label="Yellow">Yellow</bal-option>
<bal-option value="red" label="Red">Red</bal-option>
</bal-dropdown>`,
),
}

export default meta

/**
* STORIES
* ------------------------------------------------------
*/

const Story = StoryFactory<Args>(meta)

export const Basic = Story()

export const FieldControl = Story({
args: {
value: 'purple',
},
...withRender(
({ ...args }) => `<bal-field>
<bal-field-label>Color</bal-field-label>
<bal-field-control>
<bal-dropdown ${props(args)}>
<bal-option value="green" label="Green">Green</bal-option>
<bal-option value="purple" label="Purple">Purple</bal-option>
<bal-option value="yellow" label="Yellow">Yellow</bal-option>
<bal-option value="red" label="Red">Red</bal-option>
</bal-dropdown>
</bal-field-control>
<bal-field-message color="hint">Field Message</bal-field-message>
</bal-field>`,
),
})

export const Multiple = Story({
args: {
value: ['green', 'red'],
multiple: true,
},
})

export const MultipleWithChips = Story({
args: {
value: ['green', 'red'],
multiple: true,
chips: true,
},
})

export const Clearable = Story({
args: {
value: ['yellow'],
clearable: true,
},
})

export const Loading = Story({
args: {
loading: true,
},
})

export const Invalid = Story({
args: {
invalid: true,
},
})

export const Disabled = Story({
args: {
disabled: true,
},
})

export const FormReset = Story({
args: {
value: 'purple',
},
...withRender(
({ ...args }) => `<form action="https://www.w3schools.com/action_page.php" target="_blank">
<bal-form-grid>
<bal-form-col>
<bal-field required>
<bal-field-control>
<bal-dropdown ${props(args)}>
<bal-option value="green" label="Green">Green</bal-option>
<bal-option value="purple" label="Purple">Purple</bal-option>
<bal-option value="yellow" label="Yellow">Yellow</bal-option>
<bal-option value="red" label="Red">Red</bal-option>
</bal-dropdown>
</bal-field-control>
</bal-field>
</bal-form-col>
</bal-form-grid>
<bal-button-group>
<bal-button element-type="submit" color="primary">Submit</bal-button>
<bal-button data-testid="button-reset" element-type="reset" color="link">Reset</bal-button>
</bal-button-group>
</form>`,
),
})

export const Autocomplete = Story({
args: {
name: 'country',
autocomplete: 'country',
placeholder: 'Pick your nationality',
},
...withRender(
({ ...args }) => `<form action="https://www.w3schools.com/action_page.php" target="_blank">
<bal-form-grid>
<bal-form-col>
<bal-field>
<bal-field-label>First Name</bal-field-label>
<bal-field-control>
<bal-input name="firstName" placeholder="Enter your firstname" autocomplete="given-name"></bal-input>
</bal-field-control>
</bal-field>
</bal-form-col>
<bal-form-col>
<bal-field>
<bal-field-label>Last Name</bal-field-label>
<bal-field-control>
<bal-input name="lastName" placeholder="Enter your lastname" autocomplete="family-name"></bal-input>
</bal-field-control>
</bal-field>
</bal-form-col>
<bal-form-col>
<bal-field>
<bal-field-label>Country</bal-field-label>
<bal-field-control>
<bal-dropdown ${props(args)}>
<bal-option value="CH" label="Switzerland">Switzerland</bal-option>
<bal-option value="DE" label="Germany">Germany</bal-option>
<bal-option value="IT" label="Italy">Italy</bal-option>
</bal-dropdown>
</bal-field-control>
</bal-field>
</bal-form-col>
</bal-form-grid>
<input type="reset" value="Reset" />
<input type="submit" value="Submit" />
</form>`,
),
})
32 changes: 32 additions & 0 deletions docs/stories/components/bal-dropdown/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Testing

The Baloise Design System provides a collection of custom cypress commands for the components. Moreover, some basic cypress commands like `should` or `click` have been overridden to work with the components.

<a class="sb-unstyled button is-primary" href="../?path=/docs/development-testing--documentation">Go to testing guide</a>

<!-- START: human documentation -->

```ts
describe('Dropdown', () => {
it('should ...', () => {
cy.getByPlaceholder('Pick a color').click()
cy.getByRole('option', { name: 'Red' }).click()

cy.getByPlaceholder('Pick a color').should('be.disabled')
cy.getByPlaceholder('Pick a color').should('have.value', 'Red')
})
})
```

<!-- END: human documentation -->


### Selectors

| Selector | Element |
| ------------------ | ------------------------------------ |
| `dropdown.input` | Native input element. |
| `dropdown.options` | Select option. |
| `dropdown.trigger` | Trigger to open and close the popup. |
| `dropdown.chips` | Multi select tag . |

Loading
Loading