-
Notifications
You must be signed in to change notification settings - Fork 193
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
Improve usecases in selectlist explainer #918
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,23 +70,23 @@ selectlist::button { | |
|
||
### Rich content in `<option>`s | ||
|
||
This example adds "rich content" inside option elements in the form of country flags. This is a common pattern on the web which isn't possible in the existing `<select>` element because `<select>`'s `<option>`s only render text content. | ||
This example adds "rich content" inside option elements in the form of images next to the options. This is a common pattern on the web which isn't possible in the existing `<select>` element because `<select>`'s `<option>`s only render text content. | ||
|
||
<div className="code-image-container"> | ||
<div> | ||
```html | ||
<selectlist> | ||
<option> | ||
<img src="usa.jpg"> | ||
USA | ||
<img src="swallow.jpg"> | ||
Swallow | ||
</option> | ||
<option> | ||
<img src="germany.jpg"> | ||
Germany | ||
<img src="raven.jpg"> | ||
Raven | ||
</option> | ||
<option> | ||
<img src="spain.jpg"> | ||
Spain | ||
<img src="wasp.jpg"> | ||
Wasp | ||
</option> | ||
</selectlist> | ||
``` | ||
|
@@ -165,18 +165,40 @@ This example has a `<listbox>` which enables it to put arbitrary content into th | |
```html | ||
<selectlist> | ||
<listbox> | ||
<div>Heading</div> | ||
<div>First two options:</div> | ||
<option>one</option> | ||
<option>two</option> | ||
<div>Second two options:</div> | ||
<option>three</option> | ||
<option>four</option> | ||
<div class=container> | ||
<div> | ||
<div role=group>1-2</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a "good" example? I would think we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like using optgroup here would just be asking for people to say that But yeah this example does not actually do anything that optgroup can't do... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I definitely think an example using
|
||
<option>one</option> | ||
<option>two</option> | ||
</div> | ||
<div> | ||
<div role=group>3-4</div> | ||
<option>three</option> | ||
<option>four</option> | ||
</div> | ||
<div> | ||
<div role=group>5-6</div> | ||
<option>five</option> | ||
<option>six</option> | ||
</div> | ||
<div> | ||
<div role=group>7-8</div> | ||
<option>seven</option> | ||
<option>eight</option> | ||
</div> | ||
</div> | ||
</listbox> | ||
</selectlist> | ||
<style> | ||
div { | ||
font-weight: bold; | ||
.container { | ||
josepharhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
display: grid; | ||
grid-template-rows: auto auto; | ||
grid-template-columns: 50px 50px; | ||
grid-column-gap: 10px; | ||
grid-row-gap: 10px; | ||
} | ||
.container > div { | ||
background-color: lightgray; | ||
} | ||
</style> | ||
``` | ||
|
@@ -189,6 +211,23 @@ div { | |
</div> | ||
</div> | ||
|
||
Here is another example with custom content in the listbox: [codepen](https://codepen.io/una/pen/PoXbgVW) | ||
|
||
### Animations | ||
|
||
<div className="code-image-container"> | ||
<div> | ||
This example uses view transitions to animate the opening and closing of the listbox. | ||
[Link to codepen](https://codepen.io/argyleink/pen/wvYrZEV/ab71f1b613db0487f64ff8c6919b0173) | ||
</div> | ||
<div> | ||
<Image | ||
src="/images/selectlist-animation.gif" | ||
alt="A selectlist with a listbox that animates open and closed" | ||
/> | ||
</div> | ||
</div> | ||
|
||
## Testing out the selectlist element | ||
|
||
`<selectlist>` is currently implemented behind a flag in [Chromium](https://chromestatus.com/feature/5737365999976448). To use it, enable the **Experimental Web Platform features** flag in about:flags. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these new images exist in the repo? I don't see them but maybe I missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget
alt=""
oralt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched back to country flags and added alt text.
The images don't exist in the repo, but they don't need to because they aren't actually downloaded or rendered anywhere on the website - the only exist in the demo which I made locally just to create the adjacent screenshot.