-
Notifications
You must be signed in to change notification settings - Fork 40
feat(evo-marko): evo-combobox #661
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
Open
LuLaValva
wants to merge
6
commits into
main
Choose a base branch
from
evo-combobox
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d4b89d8
feat(evo-marko): evo-combobox
LuLaValva 46b94a9
chore: add changeset
LuLaValva 4234b95
feat(evo-marko): code review tweaks
LuLaValva 090b939
feat(evo-marko): clean up combobox
LuLaValva a58816e
fix(evo-marko): combobox tests
LuLaValva 3526052
feat(evo-marko): remove `value=` from combobox options
LuLaValva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| "@evo-web/marko": patch | ||
| --- | ||
|
|
||
| Add evo-combobox |
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
| <h1 style='display: flex; justify-content: space-between; align-items: center;'> | ||
| <span> | ||
| evo-combobox | ||
| </span> | ||
| <span style='font-weight: normal; font-size: medium; margin-bottom: -15px;'> | ||
| DS v1.0.0 | ||
| </span> | ||
| </h1> | ||
|
|
||
| An accessible combobox input with an optional inline listbox of suggestions. | ||
|
|
||
| ## Examples and Documentation | ||
|
|
||
| - [Storybook](https://ebay.github.io/evo-web/ebayui-core/?path=/story/form-input-evo-combobox) | ||
| - [Storybook Docs](https://ebay.github.io/evo-web/ebayui-core/?path=/docs/form-input-evo-combobox) | ||
| - [Code Examples](https://github.com/eBay/evo-web/tree/main/packages/evo-marko/src/tags/evo-combobox/examples) |
130 changes: 130 additions & 0 deletions
130
packages/evo-marko/src/tags/evo-combobox/combobox.stories.ts
This file contains hidden or 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,130 @@ | ||
| import { buildExtensionTemplate } from "../../common/storybook/utils"; | ||
| import { type Meta } from "@storybook/marko"; | ||
| import Readme from "./README.md"; | ||
| import Component, { type Input } from "./index.marko"; | ||
| import DefaultTemplate from "./examples/default.marko"; | ||
| import DefaultCode from "./examples/default.marko?raw"; | ||
| import ControllableTemplate from "./examples/controllable.marko"; | ||
| import ControllableCode from "./examples/controllable.marko?raw"; | ||
| import AsyncFilteringTemplate from "./examples/async-filtering.marko"; | ||
| import AsyncFilteringCode from "./examples/async-filtering.marko?raw"; | ||
|
|
||
| export default { | ||
| title: "form input/evo-combobox", | ||
| component: Component, | ||
| parameters: { | ||
| docs: { | ||
| description: { component: Readme }, | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| autocomplete: { | ||
| type: "string", | ||
| options: ["none", "list"], | ||
| control: "inline-radio", | ||
| description: | ||
| "`list` filters displayed options to those matching the typed text. `none` always shows all options.", | ||
| }, | ||
| listSelection: { | ||
| type: "string", | ||
| options: ["automatic", "manual"], | ||
| control: "inline-radio", | ||
| description: | ||
| "Whether arrow-key navigation writes the highlighted option text into the input automatically.", | ||
| }, | ||
| floatingLabel: { | ||
| type: "string", | ||
| control: "text", | ||
| description: | ||
| "Floating label text shown above the input when focused or filled.", | ||
| }, | ||
| borderless: { | ||
| type: "boolean", | ||
| control: "boolean", | ||
| description: "Removes the control border.", | ||
| }, | ||
| fluid: { | ||
| type: "boolean", | ||
| control: "boolean", | ||
| description: "Stretches the component to fill its container.", | ||
| }, | ||
| strategy: { | ||
| type: "string", | ||
| options: ["absolute", "fixed"], | ||
| control: "select", | ||
| description: "Listbox CSS position strategy (`absolute` by default).", | ||
| }, | ||
| disabled: { | ||
| type: "boolean", | ||
| control: "boolean", | ||
| description: "Disables the input.", | ||
| }, | ||
| value: { | ||
| controllable: true, | ||
| type: "string", | ||
| control: "text", | ||
| description: "Current input value. Two-way bindable via `:=`.", | ||
| }, | ||
| open: { | ||
| controllable: true, | ||
| type: "boolean", | ||
| control: "boolean", | ||
| description: "Controls listbox visibility. Two-way bindable via `:=`.", | ||
| }, | ||
| option: { | ||
| description: "Repeatable `@option` attribute tag.", | ||
| "@": { | ||
| text: { | ||
| type: { name: "string", required: true }, | ||
| control: "text", | ||
| description: "Display text for the option.", | ||
| }, | ||
| value: { | ||
| type: "string", | ||
| control: "text", | ||
| description: "Optional value; defaults to `text`.", | ||
| }, | ||
| sticky: { | ||
| type: "boolean", | ||
| control: "boolean", | ||
| description: "Always shown regardless of `autocomplete` filter.", | ||
| }, | ||
| ["<div> attributes" as any]: { | ||
| description: | ||
| "All attributes and event handlers from [the native HTML `<div>` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div) will be passed through to `<@option>`.", | ||
| }, | ||
| }, | ||
| }, | ||
| button: { | ||
| description: | ||
| "Optional `@button` attr tag — renders an icon button inside the control.", | ||
| "@": { | ||
| ["<button> attributes" as any]: { | ||
| description: | ||
| "All attributes and event handlers from [the native HTML `<button>` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) will be passed through to `<@button>`.", | ||
| }, | ||
| }, | ||
| }, | ||
| ["<input> attributes" as any]: { | ||
| description: | ||
| "All attributes and event handlers from [the native HTML `<input>` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) will be passed through.", | ||
| }, | ||
| }, | ||
| } satisfies Meta<Input>; | ||
|
|
||
| export const Default = buildExtensionTemplate(DefaultTemplate, DefaultCode, { | ||
| "aria-label": "Campaign", | ||
| placeholder: "Choose a campaign", | ||
| }); | ||
|
|
||
| export const Controllable = buildExtensionTemplate( | ||
| ControllableTemplate, | ||
| ControllableCode, | ||
| { "aria-label": "Campaign", placeholder: "Choose a campaign" }, | ||
| ); | ||
|
|
||
| export const AsyncFiltering = buildExtensionTemplate( | ||
| AsyncFilteringTemplate, | ||
| AsyncFilteringCode, | ||
| { placeholder: "Type a country name..." }, | ||
| ); | ||
24 changes: 24 additions & 0 deletions
24
packages/evo-marko/src/tags/evo-combobox/examples/async-filtering.marko
This file contains hidden or 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,24 @@ | ||
| import countries from "./data.json" with { type: "json" }; | ||
|
|
||
| static async function searchCountries(query: string, signal: AbortSignal) { | ||
| await new Promise((r) => setTimeout(r, 300)); | ||
| if (signal.aborted) return; | ||
| return query | ||
| ? countries.filter((c) => c.name.toLowerCase().startsWith(query.toLowerCase())).slice(0, 10) | ||
| : ([] as typeof countries); | ||
| } | ||
|
|
||
| <let/value=""> | ||
| <let/options=[] as typeof countries> | ||
|
|
||
| <script> | ||
| const results = await searchCountries(value, $signal); | ||
| if (results) options = results; | ||
| </script> | ||
|
|
||
| <evo-combobox ...input value:=value> | ||
| <for|country| of=options> | ||
| <@option data-code=country.code text=country.name/> | ||
| </for> | ||
| </evo-combobox> | ||
| <p>Selected: ${value || "(none)"}</p> |
14 changes: 14 additions & 0 deletions
14
packages/evo-marko/src/tags/evo-combobox/examples/controllable.marko
This file contains hidden or 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,14 @@ | ||
| <let/value=""> | ||
| <p>Current value: ${value}</p> | ||
| <evo-combobox ...input value:=value> | ||
| <@option text="August Campaign"/> | ||
| <@option text="4th of July Sale (paused)"/> | ||
| <@option text="Basic Offer"/> | ||
| <@option text="Basic Offer 1"/> | ||
| <@option text="Basic Offer 3"/> | ||
| <if=value> | ||
| <@button onClick() { value = "" } a11yText="clear"> | ||
| <evo-icon-close-12/> | ||
| </@button> | ||
| </if> | ||
| </evo-combobox> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.