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

Improve usecases in selectlist explainer #918

Merged
merged 3 commits into from Nov 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified site/public/images/selectlist-usecase-listbox.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions site/src/layouts/ComponentLayout.astro
Expand Up @@ -24,6 +24,7 @@ const { name, pathToProposal, pathToResearch } = frontmatter

:global(.code-image-container img) {
height: 100%;
object-fit: contain;
}

@media (max-width: 800px) {
Expand Down
67 changes: 55 additions & 12 deletions site/src/pages/components/selectlist.mdx
Expand Up @@ -77,15 +77,15 @@ This example adds "rich content" inside option elements in the form of country f
```html
<selectlist>
<option>
<img src="usa.jpg">
<img src="usa.jpg" alt="flag of USA">
USA
</option>
<option>
<img src="germany.jpg">
<img src="germany.jpg" alt="flag of Germany">
Germany
</option>
<option>
<img src="spain.jpg">
<img src="spain.jpg" alt="flag of Spain">
Spain
</option>
</selectlist>
Expand Down Expand Up @@ -165,18 +165,44 @@ 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>
<optgroup label="1-2">
<option>one</option>
<option>two</option>
</optgroup>
</div>
<div>
<optgroup label="3-4">
<option>three</option>
<option>four</option>
</optgroup>
</div>
<div>
<optgroup label="5-6">
<option>five</option>
<option>six</option>
</optgroup>
</div>
<div>
<optgroup label="7-8">
<option>seven</option>
<option>eight</option>
</optgroup>
</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>
```
Expand All @@ -189,6 +215,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.
Expand Down