mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-19 07:29:14 +00:00
Compare commits
190 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be1440aee0 | ||
|
|
f00e8c3a65 | ||
|
|
a4f8bf94ee | ||
|
|
8ae1303188 | ||
|
|
ffc0248e4c | ||
|
|
81d3f22da6 | ||
|
|
0fa8e6f550 | ||
|
|
a67d1df89a | ||
|
|
0fe400c6f4 | ||
|
|
fcf0a136f2 | ||
|
|
8acfc4c9de | ||
|
|
4f8417806c | ||
|
|
65cb3175af | ||
|
|
06135e686b | ||
|
|
340351ca4b | ||
|
|
5701bef6e9 | ||
|
|
62417ed1d1 | ||
|
|
545162eaae | ||
|
|
77a8c418ea | ||
|
|
641e92a340 | ||
|
|
3f8535e7b8 | ||
|
|
81a66df7e4 | ||
|
|
ae2480dfe2 | ||
|
|
c95b0b6c66 | ||
|
|
dee01269ad | ||
|
|
e11eb363aa | ||
|
|
0d33cabec4 | ||
|
|
b5d9b49b27 | ||
|
|
1b654c7c85 | ||
|
|
4e53ce870d | ||
|
|
932e2e7566 | ||
|
|
e76a1dc1f6 | ||
|
|
38302a7c28 | ||
|
|
71e5b10f3b | ||
|
|
3eda5510c3 | ||
|
|
32494e783c | ||
|
|
cdf38fe147 | ||
|
|
302c174055 | ||
|
|
fb044aae89 | ||
|
|
bf299d8234 | ||
|
|
30a3164a96 | ||
|
|
2a22fb683c | ||
|
|
325ddafb13 | ||
|
|
fcb2c7868c | ||
|
|
46b198866d | ||
|
|
9a4da9b763 | ||
|
|
7869144f5e | ||
|
|
2d7d400040 | ||
|
|
6f5e5a2433 | ||
|
|
e59a4659d8 | ||
|
|
2f9732fc3d | ||
|
|
fdede79155 | ||
|
|
3277284473 | ||
|
|
b2b8d0d941 | ||
|
|
91bfd38a9a | ||
|
|
f4971456d0 | ||
|
|
cc18a90a86 | ||
|
|
60b6803437 | ||
|
|
2b57157502 | ||
|
|
967208d69b | ||
|
|
3bd13cd7cb | ||
|
|
ebe1904479 | ||
|
|
23356f6e39 | ||
|
|
4958ee41ae | ||
|
|
9784faa32a | ||
|
|
a913c22200 | ||
|
|
95dce95183 | ||
|
|
53f9230354 | ||
|
|
946f08db4b | ||
|
|
4b0ee8907f | ||
|
|
62bb58dc09 | ||
|
|
1d903fab38 | ||
|
|
a458f2a6f0 | ||
|
|
f66e8cec69 | ||
|
|
9fd070639c | ||
|
|
528748155a | ||
|
|
474ffb98d6 | ||
|
|
cb2d5e4eb4 | ||
|
|
3c51262a37 | ||
|
|
7e4dba7af1 | ||
|
|
319705106b | ||
|
|
2416f93a79 | ||
|
|
e398091a36 | ||
|
|
d836bcebbc | ||
|
|
d08f928818 | ||
|
|
c3e74ada39 | ||
|
|
a2e9a3de96 | ||
|
|
b2a99c83e3 | ||
|
|
a4185bc926 | ||
|
|
8e09db9d40 | ||
|
|
07ca5a45ae | ||
|
|
88a8173178 | ||
|
|
5a8c6912dc | ||
|
|
a7c786987d | ||
|
|
1179e48955 | ||
|
|
07f0884462 | ||
|
|
ef3575358e | ||
|
|
5e2762cbc6 | ||
|
|
7e165fa8bd | ||
|
|
33706e0f27 | ||
|
|
e262ed14b0 | ||
|
|
545eb467fc | ||
|
|
2848ab68ef | ||
|
|
fc1aa42c26 | ||
|
|
8baa32d8c9 | ||
|
|
a519077112 | ||
|
|
5219188690 | ||
|
|
267b9eba20 | ||
|
|
9c343ef3fd | ||
|
|
e82b076981 | ||
|
|
97bd88f904 | ||
|
|
21d8cdbb5c | ||
|
|
a5f8c51904 | ||
|
|
94ad43e130 | ||
|
|
1f04cd2a50 | ||
|
|
5a55c240ee | ||
|
|
e02b36873e | ||
|
|
f89ef95d65 | ||
|
|
a65db66005 | ||
|
|
a6e19d0710 | ||
|
|
df02aeef89 | ||
|
|
2d03f60c70 | ||
|
|
e45b44ad03 | ||
|
|
015429e05d | ||
|
|
5628381449 | ||
|
|
0bf3cf2535 | ||
|
|
d4aa9ff99e | ||
|
|
0229c315bb | ||
|
|
67d4458e69 | ||
|
|
67bfbed308 | ||
|
|
2c053b6fd3 | ||
|
|
6156e38a34 | ||
|
|
631df0293c | ||
|
|
b86a6a54ab | ||
|
|
201b32f3fb | ||
|
|
ebed8daee6 | ||
|
|
55be0a557f | ||
|
|
b4c45b480b | ||
|
|
8b9df9871a | ||
|
|
af7682aaca | ||
|
|
883cb161ec | ||
|
|
a2fbe121c3 | ||
|
|
ab770c566e | ||
|
|
1867603225 | ||
|
|
cf195da424 | ||
|
|
0cb6aa5d12 | ||
|
|
7e4d4c3c98 | ||
|
|
b5ef3191b7 | ||
|
|
f30481e229 | ||
|
|
ae010c333b | ||
|
|
43d1f9ee7a | ||
|
|
ec17e8736d | ||
|
|
44b27e791e | ||
|
|
02385027db | ||
|
|
b311072d9b | ||
|
|
87ac077b0a | ||
|
|
87837df35c | ||
|
|
5d72bbd162 | ||
|
|
a4fc1c5b44 | ||
|
|
539eaded73 | ||
|
|
93b2e78092 | ||
|
|
402a00dcd3 | ||
|
|
b63368d5f6 | ||
|
|
74c6d3ee36 | ||
|
|
621aa4362b | ||
|
|
c8919ad11f | ||
|
|
fad76dd1a2 | ||
|
|
b2f6499b87 | ||
|
|
9520e850dd | ||
|
|
4ee5271a83 | ||
|
|
d8de7bcc51 | ||
|
|
7ee31be6d6 | ||
|
|
9cb5ba7ac1 | ||
|
|
c380368b61 | ||
|
|
e298f7e5f4 | ||
|
|
c743561c25 | ||
|
|
e73e32fb71 | ||
|
|
b09a48bec4 | ||
|
|
aeef986cf5 | ||
|
|
6f08f50639 | ||
|
|
8fc5f598d0 | ||
|
|
1383ea3fe8 | ||
|
|
f8c37e0d14 | ||
|
|
cf543ef335 | ||
|
|
a3450a7d83 | ||
|
|
e80b2c9fb9 | ||
|
|
8d617fb98c | ||
|
|
a6e225e47c | ||
|
|
e21943f4fb | ||
|
|
c36df5ecc1 |
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,4 +1,7 @@
|
|||||||
contact_links:
|
contact_links:
|
||||||
|
- name: Feature Requests
|
||||||
|
url: https://github.com/shoelace-style/shoelace/discussions/categories/ideas
|
||||||
|
about: All requests for new features should go here.
|
||||||
- name: Help & Support
|
- name: Help & Support
|
||||||
url: https://github.com/shoelace-style/shoelace/discussions/categories/help
|
url: https://github.com/shoelace-style/shoelace/discussions/categories/help
|
||||||
about: Please don't create issues for personal help requests. Instead, ask your question on the discussion forum.
|
about: Please don't create issues for personal help requests. Instead, ask your question on the discussion forum.
|
||||||
|
|||||||
15
.github/ISSUE_TEMPLATE/feature_request.md
vendored
15
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature Request
|
|
||||||
about: Suggest an idea for this project.
|
|
||||||
title: ''
|
|
||||||
labels: feature
|
|
||||||
---
|
|
||||||
|
|
||||||
### What issue are you having?
|
|
||||||
Provide a clear and concise description of the problem you're facing.
|
|
||||||
|
|
||||||
### Describe the solution you'd like
|
|
||||||
How would you like to see the library solve it?
|
|
||||||
|
|
||||||
### Describe alternatives you've considered
|
|
||||||
In what ways have you tried to solve this with the current version?
|
|
||||||
4
.github/SECURITY.md
vendored
4
.github/SECURITY.md
vendored
@@ -1,7 +1,7 @@
|
|||||||
# Reporting Security Issues
|
# Reporting Security Issues
|
||||||
|
|
||||||
We take security issues in Shoelace very seriously and appreciate your efforts to disclose your findings responsibly.
|
We take security issues in Web Awesome very seriously and appreciate your efforts to disclose your findings responsibly.
|
||||||
|
|
||||||
To report a security issue, email [cory@abeautifulsite.net](mailto:cory@abeautifulsite.net) and include "SHOELACE SECURITY" in the subject line.
|
To report a security issue, email [cory@fontawesome.com](mailto:cory@abeautifulsite.net) and include "WEB AWESOME SECURITY" in the subject line.
|
||||||
|
|
||||||
We'll respond as soon as possible and keep you updated throughout the process.
|
We'll respond as soon as possible and keep you updated throughout the process.
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
|||||||
_site
|
_site
|
||||||
.cache
|
.cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
dist
|
dist
|
||||||
docs/assets/images/sprite.svg
|
docs/assets/images/sprite.svg
|
||||||
node_modules
|
node_modules
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ docs/search.json
|
|||||||
src/components/icon/icons
|
src/components/icon/icons
|
||||||
src/react/index.ts
|
src/react/index.ts
|
||||||
node_modules
|
node_modules
|
||||||
|
package.json
|
||||||
package-lock.json
|
package-lock.json
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
cdn
|
cdn
|
||||||
|
|||||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -2,6 +2,7 @@
|
|||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
}
|
},
|
||||||
|
"debug.enableStatusBarColor": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Contributing to Shoelace
|
# Contributing to Web Awesome
|
||||||
|
|
||||||
Before contributing, please review the contributions guidelines at:
|
Before contributing, please review the contributions guidelines at:
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2020 A Beautiful Site, LLC
|
Copyright (c) 2023 Fonticons, Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|||||||
36
README.md
36
README.md
@@ -1,4 +1,4 @@
|
|||||||
# Shoelace
|
# Web Awesome
|
||||||
|
|
||||||
A forward-thinking library of web components.
|
A forward-thinking library of web components.
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ A forward-thinking library of web components.
|
|||||||
- Built with accessibility in mind ♿️
|
- Built with accessibility in mind ♿️
|
||||||
- Open source 😸
|
- Open source 😸
|
||||||
|
|
||||||
Designed in New Hampshire by [Cory LaViska](https://twitter.com/claviska).
|
Built by the folks behind [Font Awesome](https://fontawesome.com/).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -21,15 +21,15 @@ Twitter: [@shoelace_style](https://twitter.com/shoelace_style)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Shoemakers 🥾
|
## Developers ✨
|
||||||
|
|
||||||
Shoemakers, or "Shoelace developers," can use this documentation to learn how to build Shoelace from source. You will need Node >= 14.17 to build and run the project locally.
|
Developers can use this documentation to learn how to build Web Awesome from source. You will need Node >= 14.17 to build and run the project locally.
|
||||||
|
|
||||||
**You don't need to do any of this to use Shoelace!** This page is for people who want to contribute to the project, tinker with the source, or create a custom build of Shoelace.
|
**You don't need to do any of this to use Web Awesome!** This page is for people who want to contribute to the project, tinker with the source, or create a custom build of Web Awesome.
|
||||||
|
|
||||||
If that's not what you're trying to do, the [documentation website](https://shoelace.style) is where you want to be.
|
If that's not what you're trying to do, the [documentation website](https://shoelace.style) is where you want to be.
|
||||||
|
|
||||||
### What are you using to build Shoelace?
|
### What are you using to build Web Awesome?
|
||||||
|
|
||||||
Components are built with [LitElement](https://lit-element.polymer-project.org/), a custom elements base class that provides an intuitive API and reactive data binding. The build is a custom script with bundling powered by [esbuild](https://esbuild.github.io/).
|
Components are built with [LitElement](https://lit-element.polymer-project.org/), a custom elements base class that provides an intuitive API and reactive data binding. The build is a custom script with bundling powered by [esbuild](https://esbuild.github.io/).
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ Components are built with [LitElement](https://lit-element.polymer-project.org/)
|
|||||||
Start by [forking the repo](https://github.com/shoelace-style/shoelace/fork) on GitHub, then clone it locally and install dependencies.
|
Start by [forking the repo](https://github.com/shoelace-style/shoelace/fork) on GitHub, then clone it locally and install dependencies.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/YOUR_GITHUB_USERNAME/shoelace
|
git clone https://github.com/YOUR_GITHUB_USERNAME/webawesome
|
||||||
cd shoelace
|
cd webawesome
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -63,30 +63,18 @@ npm run build
|
|||||||
|
|
||||||
### Creating New Components
|
### Creating New Components
|
||||||
|
|
||||||
To scaffold a new component, run the following command, replacing `sl-tag-name` with the desired tag name.
|
To scaffold a new component, run the following command, replacing `wa-tag-name` with the desired tag name.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run create sl-tag-name
|
npm run create wa-tag-name
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate a source file, a stylesheet, and a docs page for you. When you start the dev server, you'll find the new component in the "Components" section of the sidebar.
|
This will generate a source file, a stylesheet, and a docs page for you. When you start the dev server, you'll find the new component in the "Components" section of the sidebar.
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
|
|
||||||
Shoelace is an open source project and contributions are encouraged! If you're interesting in contributing, please review the [contribution guidelines](CONTRIBUTING.md) first.
|
Web Awesome is an open source project and contributions are encouraged! If you're interesting in contributing, please review the [contribution guidelines](CONTRIBUTING.md) first.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Shoelace is designed in New Hampshire by [Cory LaViska](https://twitter.com/claviska). It’s available under the terms of the MIT license.
|
Web Awesome is available under the terms of the MIT license.
|
||||||
|
|
||||||
Designing, developing, and supporting this library requires a lot of time, effort, and skill. I’d like to keep it open source so everyone can use it, but that doesn’t provide me with any income.
|
|
||||||
|
|
||||||
**Therefore, if you’re using my software to make a profit,** I respectfully ask that you help [fund its development](https://github.com/sponsors/claviska) by becoming a sponsor. There are multiple tiers to choose from with benefits at every level, including prioritized support, bug fixes, feature requests, and advertising.
|
|
||||||
|
|
||||||
👇 Your support is very much appreciated! 👇
|
|
||||||
|
|
||||||
- [Become a sponsor](https://github.com/sponsors/claviska)
|
|
||||||
- [Star on GitHub](https://github.com/shoelace-style/shoelace/stargazers)
|
|
||||||
- [Follow on Twitter](https://twitter.com/shoelace_style)
|
|
||||||
|
|
||||||
Whether you're building Shoelace or building something _with_ Shoelace — have fun creating! 🥾
|
|
||||||
|
|||||||
15
cspell.json
15
cspell.json
@@ -29,6 +29,7 @@
|
|||||||
"colour",
|
"colour",
|
||||||
"combobox",
|
"combobox",
|
||||||
"Commonmark",
|
"Commonmark",
|
||||||
|
"compat",
|
||||||
"Composability",
|
"Composability",
|
||||||
"Consolas",
|
"Consolas",
|
||||||
"contenteditable",
|
"contenteditable",
|
||||||
@@ -46,11 +47,13 @@
|
|||||||
"dropdowns",
|
"dropdowns",
|
||||||
"easings",
|
"easings",
|
||||||
"endraw",
|
"endraw",
|
||||||
|
"endregion",
|
||||||
"enterkeyhint",
|
"enterkeyhint",
|
||||||
"eqeqeq",
|
"eqeqeq",
|
||||||
"erroneou",
|
"erroneou",
|
||||||
"errormessage",
|
"errormessage",
|
||||||
"esbuild",
|
"esbuild",
|
||||||
|
"exportmaps",
|
||||||
"exportparts",
|
"exportparts",
|
||||||
"fieldsets",
|
"fieldsets",
|
||||||
"formaction",
|
"formaction",
|
||||||
@@ -88,6 +91,7 @@
|
|||||||
"listbox",
|
"listbox",
|
||||||
"listitem",
|
"listitem",
|
||||||
"litelement",
|
"litelement",
|
||||||
|
"longform",
|
||||||
"lowercasing",
|
"lowercasing",
|
||||||
"Lucide",
|
"Lucide",
|
||||||
"maxlength",
|
"maxlength",
|
||||||
@@ -99,6 +103,7 @@
|
|||||||
"monospace",
|
"monospace",
|
||||||
"mousedown",
|
"mousedown",
|
||||||
"mousemove",
|
"mousemove",
|
||||||
|
"mouseout",
|
||||||
"mouseup",
|
"mouseup",
|
||||||
"multiselectable",
|
"multiselectable",
|
||||||
"nextjs",
|
"nextjs",
|
||||||
@@ -108,10 +113,14 @@
|
|||||||
"novalidate",
|
"novalidate",
|
||||||
"npmdir",
|
"npmdir",
|
||||||
"Numberish",
|
"Numberish",
|
||||||
|
"oklab",
|
||||||
|
"oklch",
|
||||||
|
"onscrollend",
|
||||||
"outdir",
|
"outdir",
|
||||||
"ParamagicDev",
|
"ParamagicDev",
|
||||||
"peta",
|
"peta",
|
||||||
"petabit",
|
"petabit",
|
||||||
|
"Preact",
|
||||||
"prismjs",
|
"prismjs",
|
||||||
"progressbar",
|
"progressbar",
|
||||||
"radiogroup",
|
"radiogroup",
|
||||||
@@ -152,19 +161,23 @@
|
|||||||
"tinycolor",
|
"tinycolor",
|
||||||
"transitionend",
|
"transitionend",
|
||||||
"treeitem",
|
"treeitem",
|
||||||
|
"treeshaking",
|
||||||
"Triaging",
|
"Triaging",
|
||||||
"turbolinks",
|
"turbolinks",
|
||||||
"typeof",
|
"typeof",
|
||||||
"unbundles",
|
"unbundles",
|
||||||
"unbundling",
|
"unbundling",
|
||||||
"unicons",
|
"unicons",
|
||||||
|
"unsanitized",
|
||||||
"unsupportive",
|
"unsupportive",
|
||||||
"valpha",
|
"valpha",
|
||||||
"valuenow",
|
"valuenow",
|
||||||
"valuetext",
|
"valuetext",
|
||||||
|
"WCAG",
|
||||||
|
"webawesome",
|
||||||
"WEBP",
|
"WEBP",
|
||||||
"Webpacker",
|
"Webpacker",
|
||||||
"wordmark"
|
"xmark"
|
||||||
],
|
],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
"package.json",
|
"package.json",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { generateCustomData } from 'cem-plugin-vs-code-custom-data-generator';
|
import * as path from 'path';
|
||||||
|
import { customElementJetBrainsPlugin } from 'custom-element-jet-brains-integration';
|
||||||
|
import { customElementVsCodePlugin } from 'custom-element-vs-code-integration';
|
||||||
import { parse } from 'comment-parser';
|
import { parse } from 'comment-parser';
|
||||||
import { pascalCase } from 'pascal-case';
|
import { pascalCase } from 'pascal-case';
|
||||||
import commandLineArgs from 'command-line-args';
|
import commandLineArgs from 'command-line-args';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||||
const { name, description, version, author, homepage, license } = packageData;
|
const { name, description, version, author, homepage, license } = packageData;
|
||||||
@@ -32,14 +33,15 @@ export default {
|
|||||||
plugins: [
|
plugins: [
|
||||||
// Append package data
|
// Append package data
|
||||||
{
|
{
|
||||||
name: 'shoelace-package-data',
|
name: 'wa-package-data',
|
||||||
packageLinkPhase({ customElementsManifest }) {
|
packageLinkPhase({ customElementsManifest }) {
|
||||||
customElementsManifest.package = { name, description, version, author, homepage, license };
|
customElementsManifest.package = { name, description, version, author, homepage, license };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Infer tag names because we no longer use @customElement decorators.
|
// Infer tag names because we no longer use @customElement decorators.
|
||||||
{
|
{
|
||||||
name: 'shoelace-infer-tag-names',
|
name: 'wa-infer-tag-names',
|
||||||
analyzePhase({ ts, node, moduleDoc }) {
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case ts.SyntaxKind.ClassDeclaration: {
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
@@ -54,7 +56,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tagNameWithoutPrefix = path.basename(importPath, '.component.ts');
|
const tagNameWithoutPrefix = path.basename(importPath, '.component.ts');
|
||||||
const tagName = 'sl-' + tagNameWithoutPrefix;
|
const tagName = 'wa-' + tagNameWithoutPrefix;
|
||||||
|
|
||||||
classDoc.tagNameWithoutPrefix = tagNameWithoutPrefix;
|
classDoc.tagNameWithoutPrefix = tagNameWithoutPrefix;
|
||||||
classDoc.tagName = tagName;
|
classDoc.tagName = tagName;
|
||||||
@@ -65,9 +67,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Parse custom jsDoc tags
|
// Parse custom jsDoc tags
|
||||||
{
|
{
|
||||||
name: 'shoelace-custom-tags',
|
name: 'wa-custom-tags',
|
||||||
analyzePhase({ ts, node, moduleDoc }) {
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case ts.SyntaxKind.ClassDeclaration: {
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
@@ -136,8 +139,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'shoelace-react-event-names',
|
name: 'wa-react-event-names',
|
||||||
analyzePhase({ ts, node, moduleDoc }) {
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case ts.SyntaxKind.ClassDeclaration: {
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
@@ -154,8 +158,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'shoelace-translate-module-paths',
|
name: 'wa-translate-module-paths',
|
||||||
packageLinkPhase({ customElementsManifest }) {
|
packageLinkPhase({ customElementsManifest }) {
|
||||||
customElementsManifest?.modules?.forEach(mod => {
|
customElementsManifest?.modules?.forEach(mod => {
|
||||||
//
|
//
|
||||||
@@ -190,10 +195,29 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Generate custom VS Code data
|
// Generate custom VS Code data
|
||||||
generateCustomData({
|
customElementVsCodePlugin({
|
||||||
outdir,
|
outdir,
|
||||||
cssFileName: null
|
cssFileName: null,
|
||||||
|
referencesTemplate: (_, tag) => [
|
||||||
|
{
|
||||||
|
name: 'Documentation',
|
||||||
|
url: `https://shoelace.style/components/${tag.replace('wa-', '')}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
|
||||||
|
customElementJetBrainsPlugin({
|
||||||
|
outdir: './dist',
|
||||||
|
excludeCss: true,
|
||||||
|
packageJson: false,
|
||||||
|
referencesTemplate: (_, tag) => {
|
||||||
|
return {
|
||||||
|
name: 'Documentation',
|
||||||
|
url: `https://shoelace.style/components/${tag.replace('wa-', '')}`
|
||||||
|
};
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
217
custom-elements-manifest.mjs
Normal file
217
custom-elements-manifest.mjs
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
import * as path from 'path';
|
||||||
|
import { customElementJetBrainsPlugin } from 'custom-element-jet-brains-integration';
|
||||||
|
import { customElementVsCodePlugin } from 'custom-element-vs-code-integration';
|
||||||
|
import { parse } from 'comment-parser';
|
||||||
|
import { pascalCase } from 'pascal-case';
|
||||||
|
import commandLineArgs from 'command-line-args';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||||
|
const { name, description, version, author, homepage, license } = packageData;
|
||||||
|
|
||||||
|
const { outdir } = commandLineArgs([
|
||||||
|
{ name: 'litelement', type: String },
|
||||||
|
{ name: 'analyze', defaultOption: true },
|
||||||
|
{ name: 'outdir', type: String }
|
||||||
|
]);
|
||||||
|
|
||||||
|
function noDash(string) {
|
||||||
|
return string.replace(/^\s?-/, '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace(string, terms) {
|
||||||
|
terms.forEach(({ from, to }) => {
|
||||||
|
string = string?.replace(from, to);
|
||||||
|
});
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
globs: ['src/components/**/*.component.ts'],
|
||||||
|
exclude: ['**/*.styles.ts', '**/*.test.ts'],
|
||||||
|
plugins: [
|
||||||
|
// Append package data
|
||||||
|
{
|
||||||
|
name: 'wa-package-data',
|
||||||
|
packageLinkPhase({ customElementsManifest }) {
|
||||||
|
customElementsManifest.package = { name, description, version, author, homepage, license };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Infer tag names because we no longer use @customElement decorators.
|
||||||
|
{
|
||||||
|
name: 'wa-infer-tag-names',
|
||||||
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
|
switch (node.kind) {
|
||||||
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
|
const className = node.name.getText();
|
||||||
|
const classDoc = moduleDoc?.declarations?.find(declaration => declaration.name === className);
|
||||||
|
|
||||||
|
const importPath = moduleDoc.path;
|
||||||
|
|
||||||
|
// This is kind of a best guess at components. "thing.component.ts"
|
||||||
|
if (!importPath.endsWith('.component.ts')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tagNameWithoutPrefix = path.basename(importPath, '.component.ts');
|
||||||
|
const tagName = 'wa-' + tagNameWithoutPrefix;
|
||||||
|
|
||||||
|
classDoc.tagNameWithoutPrefix = tagNameWithoutPrefix;
|
||||||
|
classDoc.tagName = tagName;
|
||||||
|
|
||||||
|
// This used to be set to true by @customElement
|
||||||
|
classDoc.customElement = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Parse custom jsDoc tags
|
||||||
|
{
|
||||||
|
name: 'wa-custom-tags',
|
||||||
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
|
switch (node.kind) {
|
||||||
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
|
const className = node.name.getText();
|
||||||
|
const classDoc = moduleDoc?.declarations?.find(declaration => declaration.name === className);
|
||||||
|
const customTags = ['animation', 'dependency', 'documentation', 'since', 'status', 'title'];
|
||||||
|
let customComments = '/**';
|
||||||
|
|
||||||
|
node.jsDoc?.forEach(jsDoc => {
|
||||||
|
jsDoc?.tags?.forEach(tag => {
|
||||||
|
const tagName = tag.tagName.getText();
|
||||||
|
|
||||||
|
if (customTags.includes(tagName)) {
|
||||||
|
customComments += `\n * @${tagName} ${tag.comment}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// This is what allows us to map JSDOC comments to ReactWrappers.
|
||||||
|
classDoc['jsDoc'] = node.jsDoc?.map(jsDoc => jsDoc.getFullText()).join('\n');
|
||||||
|
|
||||||
|
const parsed = parse(`${customComments}\n */`);
|
||||||
|
parsed[0].tags?.forEach(t => {
|
||||||
|
switch (t.tag) {
|
||||||
|
// Animations
|
||||||
|
case 'animation':
|
||||||
|
if (!Array.isArray(classDoc['animations'])) {
|
||||||
|
classDoc['animations'] = [];
|
||||||
|
}
|
||||||
|
classDoc['animations'].push({
|
||||||
|
name: t.name,
|
||||||
|
description: noDash(t.description)
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
case 'dependency':
|
||||||
|
if (!Array.isArray(classDoc['dependencies'])) {
|
||||||
|
classDoc['dependencies'] = [];
|
||||||
|
}
|
||||||
|
classDoc['dependencies'].push(t.name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Value-only metadata tags
|
||||||
|
case 'documentation':
|
||||||
|
case 'since':
|
||||||
|
case 'status':
|
||||||
|
case 'title':
|
||||||
|
classDoc[t.tag] = t.name;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// All other tags
|
||||||
|
default:
|
||||||
|
if (!Array.isArray(classDoc[t.tag])) {
|
||||||
|
classDoc[t.tag] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
classDoc[t.tag].push({
|
||||||
|
name: t.name,
|
||||||
|
description: t.description,
|
||||||
|
type: t.type || undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'wa-react-event-names',
|
||||||
|
analyzePhase({ ts, node, moduleDoc }) {
|
||||||
|
switch (node.kind) {
|
||||||
|
case ts.SyntaxKind.ClassDeclaration: {
|
||||||
|
const className = node.name.getText();
|
||||||
|
const classDoc = moduleDoc?.declarations?.find(declaration => declaration.name === className);
|
||||||
|
|
||||||
|
if (classDoc?.events) {
|
||||||
|
classDoc.events.forEach(event => {
|
||||||
|
event.reactName = `on${pascalCase(event.name)}`;
|
||||||
|
event.eventName = `${pascalCase(event.name)}Event`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'wa-translate-module-paths',
|
||||||
|
packageLinkPhase({ customElementsManifest }) {
|
||||||
|
customElementsManifest?.modules?.forEach(mod => {
|
||||||
|
//
|
||||||
|
// CEM paths look like this:
|
||||||
|
//
|
||||||
|
// src/components/button/button.ts
|
||||||
|
//
|
||||||
|
// But we want them to look like this:
|
||||||
|
//
|
||||||
|
// components/button/button.js
|
||||||
|
//
|
||||||
|
const terms = [
|
||||||
|
{ from: /^src\//, to: '' }, // Strip the src/ prefix
|
||||||
|
{ from: /\.component.(t|j)sx?$/, to: '.js' } // Convert .ts to .js
|
||||||
|
];
|
||||||
|
|
||||||
|
mod.path = replace(mod.path, terms);
|
||||||
|
|
||||||
|
for (const ex of mod.exports ?? []) {
|
||||||
|
ex.declaration.module = replace(ex.declaration.module, terms);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const dec of mod.declarations ?? []) {
|
||||||
|
if (dec.kind === 'class') {
|
||||||
|
for (const member of dec.members ?? []) {
|
||||||
|
if (member.inheritedFrom) {
|
||||||
|
member.inheritedFrom.module = replace(member.inheritedFrom.module, terms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Generate custom VS Code data
|
||||||
|
customElementVsCodePlugin({
|
||||||
|
outdir,
|
||||||
|
cssFileName: null,
|
||||||
|
referencesTemplate: (_, tag) => [
|
||||||
|
{
|
||||||
|
name: 'Documentation',
|
||||||
|
url: `https://shoelace.style/components/${tag.replace('wa-', '')}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
customElementJetBrainsPlugin({
|
||||||
|
outdir: './dist',
|
||||||
|
excludeCss: true,
|
||||||
|
packageJson: false,
|
||||||
|
referencesTemplate: (_, tag) => {
|
||||||
|
return {
|
||||||
|
name: 'Documentation',
|
||||||
|
url: `https://shoelace.style/components/${tag.replace('wa-', '')}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
{% extends "default.njk" %}
|
{% extends "default.njk" %}
|
||||||
|
|
||||||
{# Find the component based on the `tag` front matter #}
|
{# Find the component based on the `tag` front matter #}
|
||||||
{% set component = getComponent('sl-' + page.fileSlug) %}
|
{% set component = getComponent('wa-' + page.fileSlug) %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{# Determine the badge variant #}
|
{# Determine the badge variant #}
|
||||||
{% if component.status == 'stable' %}
|
{% if component.status == 'stable' %}
|
||||||
{% set badgeVariant = 'primary' %}
|
{% set badgeVariant = 'brand' %}
|
||||||
{% elseif component.status == 'experimental' %}
|
{% elseif component.status == 'experimental' %}
|
||||||
{% set badgeVariant = 'warning' %}
|
{% set badgeVariant = 'warning' %}
|
||||||
{% elseif component.status == 'planned' %}
|
{% elseif component.status == 'planned' %}
|
||||||
@@ -26,12 +26,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="component-header__info">
|
<div class="component-header__info">
|
||||||
<sl-badge variant="neutral" pill>
|
<wa-badge variant="neutral" pill>
|
||||||
Since {{component.since or '?' }}
|
Since {{component.since or '?' }}
|
||||||
</sl-badge>
|
</wa-badge>
|
||||||
<sl-badge variant="{{ badgeVariant }}" pill style="text-transform: capitalize;">
|
<wa-badge variant="{{ badgeVariant }}" pill style="text-transform: capitalize;">
|
||||||
{{ component.status }}
|
{{ component.status }}
|
||||||
</sl-badge>
|
</wa-badge>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -51,42 +51,42 @@
|
|||||||
any of the following snippets to <a href="/getting-started/installation#cherry-picking">cherry pick</a> this component.
|
any of the following snippets to <a href="/getting-started/installation#cherry-picking">cherry pick</a> this component.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<sl-tab-group>
|
<wa-tab-group>
|
||||||
<sl-tab slot="nav" panel="script">Script</sl-tab>
|
<wa-tab slot="nav" panel="script">Script</wa-tab>
|
||||||
<sl-tab slot="nav" panel="import">Import</sl-tab>
|
<wa-tab slot="nav" panel="import">Import</wa-tab>
|
||||||
<sl-tab slot="nav" panel="bundler">Bundler</sl-tab>
|
<wa-tab slot="nav" panel="bundler">Bundler</wa-tab>
|
||||||
<sl-tab slot="nav" panel="react">React</sl-tab>
|
<wa-tab slot="nav" panel="react">React</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="script">
|
<wa-tab-panel name="script">
|
||||||
<p>
|
<p>
|
||||||
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
|
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
|
||||||
using a script tag:
|
using a script tag:
|
||||||
</p>
|
</p>
|
||||||
<pre><code class="language-html"><script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}"></script></code></pre>
|
<pre><code class="language-html"><script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}"></script></code></pre>
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
|
|
||||||
<sl-tab-panel name="import">
|
<wa-tab-panel name="import">
|
||||||
<p>
|
<p>
|
||||||
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
|
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
|
||||||
using a JavaScript import:
|
using a JavaScript import:
|
||||||
</p>
|
</p>
|
||||||
<pre><code class="language-js">import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}';</code></pre>
|
<pre><code class="language-js">import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}';</code></pre>
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
|
|
||||||
<sl-tab-panel name="bundler">
|
<wa-tab-panel name="bundler">
|
||||||
<p>
|
<p>
|
||||||
To import this component using <a href="{{ rootUrl('/getting-started/installation#bundling') }}">a bundler</a>:
|
To import this component using <a href="{{ rootUrl('/getting-started/installation#bundling') }}">a bundler</a>:
|
||||||
</p>
|
</p>
|
||||||
<pre><code class="language-js">import '@shoelace-style/shoelace/{{ meta.npmdir }}/{{ component.path }}';</code></pre>
|
<pre><code class="language-js">import '@shoelace-style/shoelace/{{ meta.npmdir }}/{{ component.path }}';</code></pre>
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
|
|
||||||
<sl-tab-panel name="react">
|
<wa-tab-panel name="react">
|
||||||
<p>
|
<p>
|
||||||
To import this component as a <a href="/frameworks/react">React component</a>:
|
To import this component as a <a href="/frameworks/react">React component</a>:
|
||||||
</p>
|
</p>
|
||||||
<pre><code class="language-js">import {{ component.name }} from '@shoelace-style/shoelace/{{ meta.npmdir }}/react/{{ component.tagNameWithoutPrefix }}';</code></pre>
|
<pre><code class="language-js">import {{ component.name }} from '@shoelace-style/shoelace/{{ meta.npmdir }}/react/{{ component.tagNameWithoutPrefix }}';</code></pre>
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
|
|
||||||
{# Slots #}
|
{# Slots #}
|
||||||
{% if component.slots.length %}
|
{% if component.slots.length %}
|
||||||
@@ -137,15 +137,17 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<code class="nowrap">{{ prop.name }}</code>
|
<code class="nowrap">{{ prop.name }}</code>
|
||||||
{% if prop.attribute != prop.name %}
|
{% if prop.attribute | length > 0 %}
|
||||||
<br>
|
{% if prop.attribute != prop.name %}
|
||||||
<sl-tooltip content="This attribute is different from its property">
|
<br>
|
||||||
<small>
|
<wa-tooltip content="This attribute is different from its property">
|
||||||
<code class="nowrap">
|
<small>
|
||||||
{{ prop.attribute }}
|
<code class="nowrap">
|
||||||
</code>
|
{{ prop.attribute }}
|
||||||
</small>
|
</code>
|
||||||
</sl-tooltip>
|
</small>
|
||||||
|
</wa-tooltip>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -153,12 +155,12 @@
|
|||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
{% if prop.reflects %}
|
{% if prop.reflects %}
|
||||||
<sl-icon label="yes" name="check-lg"></sl-icon>
|
<wa-icon label="yes" name="check" variant="solid"></wa-icon>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if prop.type.text %}
|
{% if prop.type.text %}
|
||||||
<code>{{ prop.type.text | markdownInline | safe }}</code>
|
<code>{{ prop.type.text | trimPipes | markdownInline | safe }}</code>
|
||||||
{% else %}
|
{% else %}
|
||||||
-
|
-
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -185,7 +187,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#properties') }}">attributes and properties</a>.</em></p>
|
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#attributes-and-properties') }}">attributes and properties</a>.</em></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Events #}
|
{# Events #}
|
||||||
@@ -209,7 +211,7 @@
|
|||||||
<td>{{ event.description | markdownInline | safe }}</td>
|
<td>{{ event.description | markdownInline | safe }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if event.type.text %}
|
{% if event.type.text %}
|
||||||
<code>{{ event.type.text }}</code>
|
<code>{{ event.type.text | trimPipes }}</code>
|
||||||
{% else %}
|
{% else %}
|
||||||
-
|
-
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -243,7 +245,7 @@
|
|||||||
{% if method.parameters.length %}
|
{% if method.parameters.length %}
|
||||||
<code>
|
<code>
|
||||||
{% for param in method.parameters %}
|
{% for param in method.parameters %}
|
||||||
{{ param.name }}: {{ param.type.text }}{% if not loop.last %},{% endif %}
|
{{ param.name }}: {{ param.type.text | trimPipes }}{% if not loop.last %},{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</code>
|
</code>
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -305,7 +307,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#component-parts') }}">customizing CSS parts</a>.</em></p>
|
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/customizing/#css-parts') }}">customizing CSS parts</a>.</em></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Animations #}
|
{# Animations #}
|
||||||
@@ -329,7 +331,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#animations') }}">customizing animations</a>.</em></p>
|
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/customizing#animations') }}">customizing animations</a>.</em></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Dependencies #}
|
{# Dependencies #}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html
|
<html
|
||||||
lang="en"
|
lang="en"
|
||||||
data-layout="{{ layout }}"
|
data-layout="{{ layout }}"
|
||||||
data-shoelace-version="{{ meta.version }}"
|
data-wa-version="{{ meta.version }}"
|
||||||
>
|
>
|
||||||
<head>
|
<head>
|
||||||
{# Metadata #}
|
{# Metadata #}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<link rel="stylesheet" href="{{ assetUrl('styles/search.css') }}" />
|
<link rel="stylesheet" href="{{ assetUrl('styles/search.css') }}" />
|
||||||
|
|
||||||
{# Favicons #}
|
{# Favicons #}
|
||||||
<link rel="icon" href="{{ assetUrl('images/logo.svg') }}" type="image/x-icon" />
|
<link rel="icon" href="{{ assetUrl('images/favicon.svg') }}" type="image/x-icon" />
|
||||||
|
|
||||||
{# Twitter Cards #}
|
{# Twitter Cards #}
|
||||||
<meta name="twitter:card" content="summary" />
|
<meta name="twitter:card" content="summary" />
|
||||||
@@ -33,20 +33,26 @@
|
|||||||
<meta property="og:description" content="{{ meta.description }}" />
|
<meta property="og:description" content="{{ meta.description }}" />
|
||||||
<meta property="og:image" content="{{ assetUrl(meta.image, true) }}" />
|
<meta property="og:image" content="{{ assetUrl(meta.image, true) }}" />
|
||||||
|
|
||||||
{# Shoelace #}
|
{# Web Awesome #}
|
||||||
<link rel="stylesheet" href="/dist/themes/light.css" />
|
<link rel="stylesheet" href="/dist/themes/applied.css" />
|
||||||
<link rel="stylesheet" href="/dist/themes/dark.css" />
|
<link rel="stylesheet" href="/dist/themes/forms.css" />
|
||||||
<script type="module" src="/dist/shoelace-autoloader.js"></script>
|
<link id="theme-stylesheet" rel="stylesheet" href="/dist/themes/default.css" />
|
||||||
|
<script type="module" src="/dist/autoloader.js"></script>
|
||||||
|
|
||||||
{# Set the initial theme and menu states here to prevent flashing #}
|
{# Set the initial theme and menu states here to prevent flashing #}
|
||||||
<script>
|
<script>
|
||||||
(() => {
|
(() => {
|
||||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
const theme = localStorage.getItem('theme') || 'auto';
|
const theme = localStorage.getItem('theme') || 'auto';
|
||||||
document.documentElement.classList.toggle('sl-theme-dark', theme === 'dark' || (theme === 'auto' && prefersDark));
|
document.documentElement.classList.toggle('wa-theme-default-dark', theme === 'dark' || (theme === 'auto' && prefersDark));
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{# Web Fonts #}
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=Noto+Sans+Mono&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
{# Turbo + Scroll positioning #}
|
{# Turbo + Scroll positioning #}
|
||||||
<script src="{{ assetUrl('scripts/turbo.js') }}" type="module"></script>
|
<script src="{{ assetUrl('scripts/turbo.js') }}" type="module"></script>
|
||||||
<script src="{{ assetUrl('scripts/docs.js') }}" defer></script>
|
<script src="{{ assetUrl('scripts/docs.js') }}" defer></script>
|
||||||
@@ -55,7 +61,7 @@
|
|||||||
<script src="{{ assetUrl('scripts/search.js') }}" defer></script>
|
<script src="{{ assetUrl('scripts/search.js') }}" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a id="skip-to-main" class="visually-hidden" href="#main-content" data-smooth-link="false">
|
<a id="skip-to-main" class="wa-visually-hidden" href="#main-content" data-smooth-link="false">
|
||||||
Skip to main content
|
Skip to main content
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -68,37 +74,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{# Icon toolbar #}
|
|
||||||
<div id="icon-toolbar">
|
|
||||||
{# GitHub #}
|
|
||||||
<a href="https://github.com/shoelace-style/shoelace" title="View Shoelace on GitHub">
|
|
||||||
<sl-icon name="github"></sl-icon>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{# Twitter #}
|
|
||||||
<a href="https://twitter.com/shoelace_style" title="Follow Shoelace on Twitter">
|
|
||||||
<sl-icon name="twitter"></sl-icon>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{# Theme selector #}
|
|
||||||
<sl-dropdown id="theme-selector" placement="bottom-end" distance="3">
|
|
||||||
<sl-button slot="trigger" size="small" variant="text" caret title="Press \ to toggle">
|
|
||||||
<sl-icon class="only-light" name="sun-fill"></sl-icon>
|
|
||||||
<sl-icon class="only-dark" name="moon-fill"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
<sl-menu>
|
|
||||||
<sl-menu-item type="checkbox" value="light">Light</sl-menu-item>
|
|
||||||
<sl-menu-item type="checkbox" value="dark">Dark</sl-menu-item>
|
|
||||||
<sl-divider></sl-divider>
|
|
||||||
<sl-menu-item type="checkbox" value="auto">System</sl-menu-item>
|
|
||||||
</sl-menu>
|
|
||||||
</sl-dropdown>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="sidebar" data-preserve-scroll>
|
<aside id="sidebar" data-preserve-scroll>
|
||||||
<header>
|
<header>
|
||||||
<a href="/">
|
<a href="/">
|
||||||
<img src="{{ assetUrl('images/wordmark.svg') }}" alt="Shoelace" />
|
{% include 'logo.njk' %}
|
||||||
</a>
|
</a>
|
||||||
<div class="sidebar-version">
|
<div class="sidebar-version">
|
||||||
{{ meta.version }}
|
{{ meta.version }}
|
||||||
@@ -106,19 +85,19 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="sidebar-buttons">
|
<div class="sidebar-buttons">
|
||||||
<sl-button size="small" class="repo-button repo-button--github" href="https://github.com/shoelace-style/shoelace" target="_blank">
|
<wa-button size="small" class="repo-button repo-button--github" href="https://github.com/shoelace-style/shoelace" target="_blank">
|
||||||
<sl-icon slot="prefix" name="github"></sl-icon> Code
|
<wa-icon slot="prefix" name="github" family="brands"></wa-icon> Code
|
||||||
</sl-button>
|
</wa-button>
|
||||||
<sl-button size="small" class="repo-button repo-button--star" href="https://github.com/shoelace-style/shoelace/stargazers" target="_blank">
|
<wa-button size="small" class="repo-button repo-button--star" href="https://github.com/shoelace-style/shoelace/stargazers" target="_blank">
|
||||||
<sl-icon slot="prefix" name="star-fill"></sl-icon> Star
|
<wa-icon slot="prefix" name="star" variant="solid"></wa-icon> Star
|
||||||
</sl-button>
|
</wa-button>
|
||||||
<sl-button size="small" class="repo-button repo-button--twitter" href="https://twitter.com/shoelace_style" target="_blank">
|
<wa-button size="small" class="repo-button repo-button--twitter" href="https://twitter.com/shoelace_style" target="_blank">
|
||||||
<sl-icon slot="prefix" name="twitter"></sl-icon> Follow
|
<wa-icon slot="prefix" name="twitter" family="brands"></wa-icon> Follow
|
||||||
</sl-button>
|
</wa-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="search-box" type="button" title="Press / to search" aria-label="Search" data-plugin="search">
|
<button class="search-box" type="button" title="Press / to search" aria-label="Search" data-plugin="search">
|
||||||
<sl-icon name="search"></sl-icon>
|
<wa-icon name="search"></wa-icon>
|
||||||
<span>Search</span>
|
<span>Search</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
1
docs/_includes/logo.njk
Normal file
1
docs/_includes/logo.njk
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.3 KiB |
@@ -1,4 +1,24 @@
|
|||||||
<ul>
|
<ul>
|
||||||
|
<li>
|
||||||
|
<h2>Experimental</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/experimental/themer">Themer</a></li>
|
||||||
|
<li><a href="/experimental/style-guide">Style Guide</a></li>
|
||||||
|
<li><a href="/experimental/form-validation">Form Validation Styles</a></li>
|
||||||
|
<li style="margin-top: .5rem;"><wa-switch id="theme-toggle">Dark mode</wa-switch></li>
|
||||||
|
<script type="module">
|
||||||
|
// Temporary dark toggle
|
||||||
|
const toggle = document.getElementById('theme-toggle');
|
||||||
|
toggle.checked = document.documentElement.classList.contains('wa-theme-default-dark');
|
||||||
|
|
||||||
|
toggle.addEventListener('wa-change', () => {
|
||||||
|
document.documentElement.classList.toggle('wa-theme-default-dark');
|
||||||
|
localStorage.setItem('theme', toggle.checked ? 'dark' : 'light');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<li><a href="/experimental/sandbox">Sandbox</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<h2>Getting Started</h2>
|
<h2>Getting Started</h2>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -34,7 +54,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{% for component in meta.components %}
|
{% for component in meta.components %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/components/{{ component.tagName | removeSlPrefix }}">
|
<a href="/components/{{ component.tagName | removeWaPrefix }}">
|
||||||
{{ component.name | classNameToComponentName }}
|
{{ component.name | classNameToComponentName }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -47,8 +67,8 @@
|
|||||||
<li><a href="/tokens/typography">Typography</a></li>
|
<li><a href="/tokens/typography">Typography</a></li>
|
||||||
<li><a href="/tokens/color">Color</a></li>
|
<li><a href="/tokens/color">Color</a></li>
|
||||||
<li><a href="/tokens/spacing">Spacing</a></li>
|
<li><a href="/tokens/spacing">Spacing</a></li>
|
||||||
<li><a href="/tokens/elevation">Elevation</a></li>
|
<li><a href="/tokens/borders">Borders</a></li>
|
||||||
<li><a href="/tokens/border-radius">Border Radius</a></li>
|
<li><a href="/tokens/shadows">Shadows</a></li>
|
||||||
<li><a href="/tokens/transition">Transition</a></li>
|
<li><a href="/tokens/transition">Transition</a></li>
|
||||||
<li><a href="/tokens/z-index">Z-index</a></li>
|
<li><a href="/tokens/z-index">Z-index</a></li>
|
||||||
<li><a href="/tokens/more">More Tokens</a></li>
|
<li><a href="/tokens/more">More Tokens</a></li>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ module.exports = function (doc, options) {
|
|||||||
<div class="code-preview__preview">
|
<div class="code-preview__preview">
|
||||||
${code.textContent}
|
${code.textContent}
|
||||||
<div class="code-preview__resizer">
|
<div class="code-preview__resizer">
|
||||||
<sl-icon name="grip-vertical"></sl-icon>
|
<wa-icon name="grip-vertical" variant="solid"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
let codeBlockId = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds copy code buttons to code fields. The provided doc should be a document object provided by JSDOM. The same
|
* Adds copy code buttons to code fields. The provided doc should be a document object provided by JSDOM. The same
|
||||||
* document will be returned with the appropriate DOM manipulations.
|
* document will be returned with the appropriate DOM manipulations.
|
||||||
@@ -5,19 +7,14 @@
|
|||||||
module.exports = function (doc) {
|
module.exports = function (doc) {
|
||||||
doc.querySelectorAll('pre > code').forEach(code => {
|
doc.querySelectorAll('pre > code').forEach(code => {
|
||||||
const pre = code.closest('pre');
|
const pre = code.closest('pre');
|
||||||
const button = doc.createElement('button');
|
const button = doc.createElement('wa-copy-button');
|
||||||
button.setAttribute('type', 'button');
|
|
||||||
button.classList.add('copy-code-button');
|
|
||||||
button.setAttribute('aria-label', 'Copy');
|
|
||||||
button.innerHTML = `
|
|
||||||
<svg class="copy-code-button__copy-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-files" viewBox="0 0 16 16" part="svg">
|
|
||||||
<path d="M13 0H6a2 2 0 0 0-2 2 2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h7a2 2 0 0 0 2-2 2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm0 13V4a2 2 0 0 0-2-2H5a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1zM3 4a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4z"></path>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<svg class="copy-code-button__copied-icon" style="display: none;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-lg" viewBox="0 0 16 16" part="svg">
|
if (!code.id) {
|
||||||
<path d="M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z"></path>
|
code.id = `code-block-${++codeBlockId}`;
|
||||||
</svg>
|
}
|
||||||
`;
|
|
||||||
|
button.classList.add('copy-code-button');
|
||||||
|
button.setAttribute('from', code.id);
|
||||||
|
|
||||||
pre.append(button);
|
pre.append(button);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,12 +23,20 @@ markdown.use(markdownItReplaceIt);
|
|||||||
|
|
||||||
// Callouts
|
// Callouts
|
||||||
['tip', 'warning', 'danger'].forEach(type => {
|
['tip', 'warning', 'danger'].forEach(type => {
|
||||||
|
const variant = type === 'tip' ? 'brand' : type;
|
||||||
|
let icon = 'circle-info';
|
||||||
|
if (type === 'warning') icon = 'circle-exclamation';
|
||||||
|
if (type === 'danger') icon = 'triangle-exclamation';
|
||||||
|
|
||||||
markdown.use(markdownItContainer, type, {
|
markdown.use(markdownItContainer, type, {
|
||||||
render: function (tokens, idx) {
|
render: function (tokens, idx) {
|
||||||
if (tokens[idx].nesting === 1) {
|
if (tokens[idx].nesting === 1) {
|
||||||
return `<div role="alert" class="callout callout--${type}">`;
|
return `
|
||||||
|
<wa-alert class="callout" variant="${variant}" open>
|
||||||
|
<wa-icon slot="icon" name="${icon}" variant="regular"></wa-icon>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
return '</div>\n';
|
return '</wa-alert>\n';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,12 @@
|
|||||||
* @param {Replacements} replacements
|
* @param {Replacements} replacements
|
||||||
*/
|
*/
|
||||||
module.exports = function (content, replacements) {
|
module.exports = function (content, replacements) {
|
||||||
|
/** This seems trivial, but by assigning to a string first, THEN using innerHTML after iterating over every replacement, we reduce the calculations of JSDOM. At the time of writing benchmarks show a reduction from 9seconds to 3 seconds by doing so. */
|
||||||
|
let html = content.body.innerHTML;
|
||||||
|
|
||||||
replacements.forEach(replacement => {
|
replacements.forEach(replacement => {
|
||||||
content.body.innerHTML = content.body.innerHTML.replaceAll(replacement.pattern, replacement.replacement);
|
html = html.replaceAll(replacement.pattern, replacement.replacement);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
content.body.innerHTML = html;
|
||||||
};
|
};
|
||||||
|
|||||||
1
docs/assets/images/favicon.svg
Normal file
1
docs/assets/images/favicon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="186" height="186" viewBox="0 0 186 186"><g fill="none" fill-rule="evenodd"><rect width="186" height="186" fill="#103257" opacity="0"/><path fill="#F6894C" d="M106.95,13.9672306 C106.95,19.1752428 104.10296,23.7175103 99.8823543,26.1190227 L130.2,48.8851296 L159.91784,39.4892184 C158.760743,37.4541707 158.1,35.0993755 158.1,32.5902046 C158.1,24.8763205 164.345703,18.6229741 172.05,18.6229741 C179.754297,18.6229741 186,24.8763205 186,32.5902046 C186,40.3040179 179.754297,46.5574352 172.05,46.5574352 C171.315566,46.5574352 170.594594,46.5006795 169.890983,46.39107 L137.151086,130.163238 C134.361086,137.302399 127.486526,142 119.830057,142 L66.1699429,142 C58.5134743,142 51.6389143,137.302399 48.8489143,130.163238 L16.1089463,46.39107 C15.4052994,46.5006795 14.6842926,46.5574352 13.95,46.5574352 C6.245632,46.5574352 0,40.3040179 0,32.5902046 C0,24.8763205 6.245632,18.6229741 13.95,18.6229741 C21.654368,18.6229741 27.9,24.8763205 27.9,32.5902046 C27.9,35.0993755 27.2391509,37.4541707 26.0822663,39.4892184 L55.8,48.8851296 L86.1176457,26.1190227 C81.89704,23.7175103 79.05,19.1752428 79.05,13.9672306 C79.05,6.25334639 85.2957029,0 93,0 C100.704297,0 106.95,6.25334639 106.95,13.9672306 Z" transform="translate(0 22)"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 8.3 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -1,7 +1,7 @@
|
|||||||
(() => {
|
(() => {
|
||||||
function convertModuleLinks(html) {
|
function convertModuleLinks(html) {
|
||||||
html = html
|
html = html
|
||||||
.replace(/@shoelace-style\/shoelace/g, `https://esm.sh/@shoelace-style/shoelace@${shoelaceVersion}`)
|
.replace(/@shoelace-style\/shoelace/g, `https://esm.sh/@shoelace-style/shoelace@${waVersion}`)
|
||||||
.replace(/from 'react'/g, `from 'https://esm.sh/react@${reactVersion}'`)
|
.replace(/from 'react'/g, `from 'https://esm.sh/react@${reactVersion}'`)
|
||||||
.replace(/from "react"/g, `from "https://esm.sh/react@${reactVersion}"`);
|
.replace(/from "react"/g, `from "https://esm.sh/react@${reactVersion}"`);
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const shoelaceVersion = document.documentElement.getAttribute('data-shoelace-version');
|
const waVersion = document.documentElement.getAttribute('data-wa-version');
|
||||||
const reactVersion = '18.2.0';
|
const reactVersion = '18.2.0';
|
||||||
const cdndir = 'cdn';
|
const cdndir = 'cdn';
|
||||||
const npmdir = 'dist';
|
const npmdir = 'dist';
|
||||||
@@ -72,8 +72,8 @@
|
|||||||
let count = 1;
|
let count = 1;
|
||||||
|
|
||||||
// We need the version to open
|
// We need the version to open
|
||||||
if (!shoelaceVersion) {
|
if (!waVersion) {
|
||||||
throw new Error('The data-shoelace-version attribute is missing from <html>.');
|
throw new Error('The data-wa-version attribute is missing from <html>.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync flavor UI on page load
|
// Sync flavor UI on page load
|
||||||
@@ -166,9 +166,6 @@
|
|||||||
const htmlExample = codeBlock.querySelector('.code-preview__source--html > pre > code')?.textContent;
|
const htmlExample = codeBlock.querySelector('.code-preview__source--html > pre > code')?.textContent;
|
||||||
const reactExample = codeBlock.querySelector('.code-preview__source--react > pre > code')?.textContent;
|
const reactExample = codeBlock.querySelector('.code-preview__source--react > pre > code')?.textContent;
|
||||||
const isReact = flavor === 'react' && typeof reactExample === 'string';
|
const isReact = flavor === 'react' && typeof reactExample === 'string';
|
||||||
const theme = document.documentElement.classList.contains('sl-theme-dark') ? 'dark' : 'light';
|
|
||||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
||||||
const isDark = theme === 'dark' || (theme === 'auto' && prefersDark);
|
|
||||||
const editors = isReact ? '0010' : '1000';
|
const editors = isReact ? '0010' : '1000';
|
||||||
let htmlTemplate = '';
|
let htmlTemplate = '';
|
||||||
let jsTemplate = '';
|
let jsTemplate = '';
|
||||||
@@ -182,7 +179,7 @@
|
|||||||
// HTML templates
|
// HTML templates
|
||||||
if (!isReact) {
|
if (!isReact) {
|
||||||
htmlTemplate =
|
htmlTemplate =
|
||||||
`<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${shoelaceVersion}/${cdndir}/shoelace.js"></script>\n` +
|
`<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${waVersion}/${cdndir}/autoloader.js"></script>\n` +
|
||||||
`\n${htmlExample}`;
|
`\n${htmlExample}`;
|
||||||
jsTemplate = '';
|
jsTemplate = '';
|
||||||
}
|
}
|
||||||
@@ -193,10 +190,10 @@
|
|||||||
jsTemplate =
|
jsTemplate =
|
||||||
`import React from 'https://esm.sh/react@${reactVersion}';\n` +
|
`import React from 'https://esm.sh/react@${reactVersion}';\n` +
|
||||||
`import ReactDOM from 'https://esm.sh/react-dom@${reactVersion}';\n` +
|
`import ReactDOM from 'https://esm.sh/react-dom@${reactVersion}';\n` +
|
||||||
`import { setBasePath } from 'https://esm.sh/@shoelace-style/shoelace@${shoelaceVersion}/${cdndir}/utilities/base-path';\n` +
|
`import { setBasePath } from 'https://esm.sh/@shoelace-style/shoelace@${waVersion}/${cdndir}/utilities/base-path';\n` +
|
||||||
`\n` +
|
`\n` +
|
||||||
`// Set the base path for Shoelace assets\n` +
|
`// Set the base path for Web Awesome assets\n` +
|
||||||
`setBasePath('https://esm.sh/@shoelace-style/shoelace@${shoelaceVersion}/${npmdir}/')\n` +
|
`setBasePath('https://esm.sh/@shoelace-style/shoelace@${waVersion}/${npmdir}/')\n` +
|
||||||
`\n${convertModuleLinks(reactExample)}\n` +
|
`\n${convertModuleLinks(reactExample)}\n` +
|
||||||
`\n` +
|
`\n` +
|
||||||
`ReactDOM.render(<App />, document.getElementById('root'));`;
|
`ReactDOM.render(<App />, document.getElementById('root'));`;
|
||||||
@@ -204,25 +201,22 @@
|
|||||||
|
|
||||||
// CSS templates
|
// CSS templates
|
||||||
cssTemplate =
|
cssTemplate =
|
||||||
`@import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${shoelaceVersion}/${cdndir}/themes/${
|
`@import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${waVersion}/${cdndir}/themes/default.css';\n` +
|
||||||
isDark ? 'dark' : 'light'
|
|
||||||
}.css';\n` +
|
|
||||||
'\n' +
|
'\n' +
|
||||||
'body {\n' +
|
'body {\n' +
|
||||||
' font: 16px sans-serif;\n' +
|
' font: var(--wa-font-size-root) sans-serif;\n' +
|
||||||
' background-color: var(--sl-color-neutral-0);\n' +
|
' background-color: var(--wa-color-surface-default);\n' +
|
||||||
' color: var(--sl-color-neutral-900);\n' +
|
' color: var(--wa-color-text-normal);\n' +
|
||||||
' padding: 1rem;\n' +
|
' padding: var(--wa-space-m);\n' +
|
||||||
'}';
|
'}';
|
||||||
|
|
||||||
// Docs: https://blog.codepen.io/documentation/prefill/
|
// Docs: https://blog.codepen.io/documentation/prefill/
|
||||||
const data = {
|
const data = {
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
tags: ['shoelace', 'web components'],
|
tags: ['web awesome', 'web components'],
|
||||||
editors,
|
editors,
|
||||||
head: `<meta name="viewport" content="width=device-width">`,
|
head: `<meta name="viewport" content="width=device-width">`,
|
||||||
html_classes: `sl-theme-${isDark ? 'dark' : 'light'}`,
|
|
||||||
css_external: ``,
|
css_external: ``,
|
||||||
js_external: ``,
|
js_external: ``,
|
||||||
js_module: true,
|
js_module: true,
|
||||||
|
|||||||
@@ -73,72 +73,6 @@
|
|||||||
updateInert();
|
updateInert();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
//
|
|
||||||
// Theme selector
|
|
||||||
//
|
|
||||||
(() => {
|
|
||||||
function getTheme() {
|
|
||||||
return localStorage.getItem('theme') || 'auto';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isDark() {
|
|
||||||
if (theme === 'auto') {
|
|
||||||
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
||||||
}
|
|
||||||
return theme === 'dark';
|
|
||||||
}
|
|
||||||
|
|
||||||
function setTheme(newTheme) {
|
|
||||||
theme = newTheme;
|
|
||||||
localStorage.setItem('theme', theme);
|
|
||||||
|
|
||||||
// Update the UI
|
|
||||||
updateSelection();
|
|
||||||
|
|
||||||
// Toggle the dark mode class
|
|
||||||
document.documentElement.classList.toggle('sl-theme-dark', isDark());
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSelection() {
|
|
||||||
const menu = document.querySelector('#theme-selector sl-menu');
|
|
||||||
if (!menu) return;
|
|
||||||
[...menu.querySelectorAll('sl-menu-item')].map(item => (item.checked = item.getAttribute('value') === theme));
|
|
||||||
}
|
|
||||||
|
|
||||||
let theme = getTheme();
|
|
||||||
|
|
||||||
// Selection is not preserved when changing page, so update when opening dropdown
|
|
||||||
document.addEventListener('sl-show', event => {
|
|
||||||
const themeSelector = event.target.closest('#theme-selector');
|
|
||||||
if (!themeSelector) return;
|
|
||||||
updateSelection();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Listen for selections
|
|
||||||
document.addEventListener('sl-select', event => {
|
|
||||||
const menu = event.target.closest('#theme-selector sl-menu');
|
|
||||||
if (!menu) return;
|
|
||||||
setTheme(event.detail.item.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update the theme when the preference changes
|
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => setTheme(theme));
|
|
||||||
|
|
||||||
// Toggle with backslash
|
|
||||||
document.addEventListener('keydown', event => {
|
|
||||||
if (
|
|
||||||
event.key === '\\' &&
|
|
||||||
!event.composedPath().some(el => ['input', 'textarea'].includes(el?.tagName?.toLowerCase()))
|
|
||||||
) {
|
|
||||||
event.preventDefault();
|
|
||||||
setTheme(isDark() ? 'light' : 'dark');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set the initial theme and sync the UI
|
|
||||||
setTheme(theme);
|
|
||||||
})();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open details when printing
|
// Open details when printing
|
||||||
//
|
//
|
||||||
@@ -163,32 +97,6 @@
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
//
|
|
||||||
// Copy code buttons
|
|
||||||
//
|
|
||||||
(() => {
|
|
||||||
document.addEventListener('click', event => {
|
|
||||||
const button = event.target.closest('.copy-code-button');
|
|
||||||
const pre = button?.closest('pre');
|
|
||||||
const code = pre?.querySelector('code');
|
|
||||||
const copyIcon = button?.querySelector('.copy-code-button__copy-icon');
|
|
||||||
const copiedIcon = button?.querySelector('.copy-code-button__copied-icon');
|
|
||||||
|
|
||||||
if (button && code) {
|
|
||||||
navigator.clipboard.writeText(code.innerText);
|
|
||||||
copyIcon.style.display = 'none';
|
|
||||||
copiedIcon.style.display = 'inline';
|
|
||||||
button.classList.add('copy-code-button--copied');
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
copyIcon.style.display = 'inline';
|
|
||||||
copiedIcon.style.display = 'none';
|
|
||||||
button.classList.remove('copy-code-button--copied');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Smooth links
|
// Smooth links
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="search__content">
|
<div class="search__content">
|
||||||
<div class="search__header">
|
<div class="search__header">
|
||||||
<div id="search-combobox" class="search__input-wrapper">
|
<div id="search-combobox" class="search__input-wrapper">
|
||||||
<sl-icon name="search"></sl-icon>
|
<wa-icon name="search"></wa-icon>
|
||||||
<input
|
<input
|
||||||
id="search-input"
|
id="search-input"
|
||||||
class="search__input"
|
class="search__input"
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
aria-activedescendant
|
aria-activedescendant
|
||||||
>
|
>
|
||||||
<button type="button" class="search__clear-button" aria-label="Clear entry" tabindex="-1" hidden>
|
<button type="button" class="search__clear-button" aria-label="Clear entry" tabindex="-1" hidden>
|
||||||
<sl-icon name="x-circle-fill"></sl-icon>
|
<wa-icon name="circle-xmark" variant="regular"></wa-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,8 +44,8 @@
|
|||||||
<div class="search__empty">No matching pages</div>
|
<div class="search__empty">No matching pages</div>
|
||||||
</div>
|
</div>
|
||||||
<footer class="search__footer">
|
<footer class="search__footer">
|
||||||
<small><kbd>↑</kbd> <kbd>↓</kbd> Navigate</small>
|
<small><kbd><wa-icon label="Up" name="arrow-up"></wa-icon></kbd> <kbd><wa-icon label="Down" name="arrow-down"></wa-icon></kbd> Navigate</small>
|
||||||
<small><kbd>↲</kbd> Select</small>
|
<small><kbd><wa-icon label="Enter" name="arrow-turn-down-left"></wa-icon></kbd> Select</small>
|
||||||
<small><kbd>Esc</kbd> Close</small>
|
<small><kbd>Esc</kbd> Close</small>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
const input = siteSearch.querySelector('.search__input');
|
const input = siteSearch.querySelector('.search__input');
|
||||||
const clearButton = siteSearch.querySelector('.search__clear-button');
|
const clearButton = siteSearch.querySelector('.search__clear-button');
|
||||||
const results = siteSearch.querySelector('.search__results');
|
const results = siteSearch.querySelector('.search__results');
|
||||||
const version = document.documentElement.getAttribute('data-shoelace-version');
|
const version = document.documentElement.getAttribute('data-wa-version');
|
||||||
const key = `search_${version}`;
|
const key = `search_${version}`;
|
||||||
const searchDebounce = 50;
|
const searchDebounce = 50;
|
||||||
const animationDuration = 150;
|
const animationDuration = 150;
|
||||||
@@ -297,16 +297,16 @@
|
|||||||
icon = 'book';
|
icon = 'book';
|
||||||
}
|
}
|
||||||
if (page.url.includes('components/')) {
|
if (page.url.includes('components/')) {
|
||||||
icon = 'puzzle';
|
icon = 'puzzle-piece';
|
||||||
}
|
}
|
||||||
if (page.url.includes('tokens/')) {
|
if (page.url.includes('tokens/')) {
|
||||||
icon = 'palette2';
|
icon = 'swatchbook';
|
||||||
}
|
}
|
||||||
if (page.url.includes('utilities/')) {
|
if (page.url.includes('utilities/')) {
|
||||||
icon = 'wrench';
|
icon = 'wrench';
|
||||||
}
|
}
|
||||||
if (page.url.includes('tutorials/')) {
|
if (page.url.includes('tutorials/')) {
|
||||||
icon = 'joystick';
|
icon = 'gamepad';
|
||||||
}
|
}
|
||||||
|
|
||||||
li.classList.add('search__result');
|
li.classList.add('search__result');
|
||||||
@@ -317,7 +317,7 @@
|
|||||||
a.href = page.url;
|
a.href = page.url;
|
||||||
a.innerHTML = `
|
a.innerHTML = `
|
||||||
<div class="search__result-icon" aria-hidden="true">
|
<div class="search__result-icon" aria-hidden="true">
|
||||||
<sl-icon name="${icon}"></sl-icon>
|
<wa-icon name="${icon}"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="search__result__details">
|
<div class="search__result__details">
|
||||||
<div class="search__result-title"></div>
|
<div class="search__result-title"></div>
|
||||||
@@ -373,4 +373,12 @@
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// We're using Turbo, so when a user searches for something, visits a result, and presses the back button, the search
|
||||||
|
// UI will still be visible but not interactive. This removes the search UI when Turbo renders a page so they don't
|
||||||
|
// get trapped.
|
||||||
|
window.addEventListener('turbo:render', () => {
|
||||||
|
document.body.classList.remove('search-visible');
|
||||||
|
document.querySelectorAll('.search__overlay, .search__dialog').forEach(el => el.remove());
|
||||||
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/* Interactive code blocks */
|
/* Interactive code blocks */
|
||||||
.code-preview {
|
.code-preview {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: 3px;
|
border-radius: var(--wa-corners-s);
|
||||||
background-color: var(--sl-color-neutral-50);
|
background-color: var(--wa-color-neutral-fill-subtle);
|
||||||
margin-bottom: 1.5rem;
|
margin-bottom: var(--wa-space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__preview {
|
.code-preview__preview {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: solid 1px var(--sl-color-neutral-200);
|
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
border-top-left-radius: 3px;
|
border-top-left-radius: var(--wa-corners-s);
|
||||||
border-top-right-radius: 3px;
|
border-top-right-radius: var(--wa-corners-s);
|
||||||
background-color: var(--sl-color-neutral-0);
|
background-color: var(--wa-color-surface-default);
|
||||||
min-width: 20rem;
|
min-width: 20rem;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
padding: 1.5rem 3.25rem 1.5rem 1.5rem;
|
padding: var(--wa-space-xl) var(--wa-space-3xl) var(--wa-space-xl) var(--wa-space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Block the preview while dragging to prevent iframes from intercepting drag events */
|
/* Block the preview while dragging to prevent iframes from intercepting drag events */
|
||||||
@@ -40,16 +40,16 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 1.75rem;
|
width: 1.75rem;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: var(--sl-color-neutral-600);
|
color: var(--wa-color-text-quiet);
|
||||||
background-color: var(--sl-color-neutral-0);
|
background-color: var(--wa-color-surface-default);
|
||||||
border-left: solid 1px var(--sl-color-neutral-200);
|
border-left: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
border-top-right-radius: 3px;
|
border-top-right-radius: var(--wa-corners-s);
|
||||||
cursor: ew-resize;
|
cursor: ew-resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 600px) {
|
@media screen and (max-width: 600px) {
|
||||||
.code-preview__preview {
|
.code-preview__preview {
|
||||||
padding-right: 1.5rem;
|
padding-right: var(--wa-space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__resizer {
|
.code-preview__resizer {
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__source {
|
.code-preview__source {
|
||||||
border: solid 1px var(--sl-color-neutral-200);
|
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
border-radius: 0 !important;
|
border-radius: 0 !important;
|
||||||
display: none;
|
display: none;
|
||||||
@@ -74,9 +74,9 @@
|
|||||||
|
|
||||||
.code-preview__buttons {
|
.code-preview__buttons {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: solid 1px var(--sl-color-neutral-200);
|
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
border-bottom-left-radius: 3px;
|
border-bottom-left-radius: var(--wa-corners-s);
|
||||||
border-bottom-right-radius: 3px;
|
border-bottom-right-radius: var(--wa-corners-s);
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,18 +86,18 @@
|
|||||||
min-width: 2.5rem;
|
min-width: 2.5rem;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
background: var(--sl-color-neutral-0);
|
background: var(--wa-color-surface-default);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 0.7rem;
|
font-size: var(--wa-font-size-xs);
|
||||||
font-weight: 500;
|
font-weight: var(--wa-font-weight-normal);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: var(--sl-color-neutral-600);
|
color: var(--wa-color-text-quiet);
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button:not(:last-of-type) {
|
.code-preview__button:not(:last-of-type) {
|
||||||
border-right: solid 1px var(--sl-color-neutral-200);
|
border-right: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button--html,
|
.code-preview__button--html,
|
||||||
@@ -109,8 +109,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button--selected {
|
.code-preview__button--selected {
|
||||||
font-weight: 700;
|
font-weight: var(--wa-font-weight-heavy);
|
||||||
color: var(--sl-color-primary-600);
|
color: var(--wa-color-brand-text-on-surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button--codepen {
|
.code-preview__button--codepen {
|
||||||
@@ -120,25 +120,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button:first-of-type {
|
.code-preview__button:first-of-type {
|
||||||
border-bottom-left-radius: 3px;
|
border-bottom-left-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button:last-of-type {
|
.code-preview__button:last-of-type {
|
||||||
border-bottom-right-radius: 3px;
|
border-bottom-right-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button:hover,
|
.code-preview__button:hover,
|
||||||
.code-preview__button:active {
|
.code-preview__button:active {
|
||||||
box-shadow: 0 0 0 1px var(--sl-color-primary-400);
|
box-shadow: 0 0 0 var(--wa-border-width-thin) var(--wa-color-brand-border-subtle);
|
||||||
border-right-color: transparent;
|
border-right-color: transparent;
|
||||||
background-color: var(--sl-color-primary-50);
|
background-color: var(--wa-color-brand-fill-subtle);
|
||||||
color: var(--sl-color-primary-600);
|
color: var(--wa-color-brand-text-on-surface);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-preview__button:focus-visible {
|
.code-preview__button:focus-visible {
|
||||||
outline: none;
|
outline: none;
|
||||||
outline: var(--sl-focus-ring);
|
outline: var(--wa-focus-ring);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: var(--sl-color-neutral-600);
|
color: var(--wa-color-text-quiet);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,32 +1,29 @@
|
|||||||
/* Search plugin */
|
/* Search plugin */
|
||||||
:root,
|
:root {
|
||||||
:root.sl-theme-dark {
|
--docs-search-box-background: var(--wa-form-controls-background);
|
||||||
--docs-search-box-background: var(--sl-color-neutral-0);
|
--docs-search-box-border-width: var(--wa-form-controls-border-width);
|
||||||
--docs-search-box-border-width: 1px;
|
--docs-search-box-border-color: var(--wa-form-controls-resting-color);
|
||||||
--docs-search-box-border-color: var(--sl-color-neutral-300);
|
--docs-search-box-color: var(--wa-form-controls-placeholder-color);
|
||||||
--docs-search-box-color: var(--sl-color-neutral-600);
|
|
||||||
--docs-search-dialog-background: var(--sl-color-neutral-0);
|
|
||||||
--docs-search-border-width: var(--docs-border-width);
|
|
||||||
--docs-search-border-color: var(--docs-border-color);
|
|
||||||
--docs-search-text-color: var(--sl-color-neutral-900);
|
|
||||||
--docs-search-text-color-muted: var(--sl-color-neutral-500);
|
|
||||||
--docs-search-font-weight-normal: var(--sl-font-weight-normal);
|
|
||||||
--docs-search-font-weight-semibold: var(--sl-font-weight-semibold);
|
|
||||||
--docs-search-border-radius: calc(2 * var(--docs-border-radius));
|
|
||||||
--docs-search-accent-color: var(--sl-color-primary-600);
|
|
||||||
--docs-search-icon-color: var(--sl-color-neutral-500);
|
|
||||||
--docs-search-icon-color-active: var(--sl-color-neutral-600);
|
|
||||||
--docs-search-shadow: var(--docs-shadow-x-large);
|
|
||||||
--docs-search-result-background-hover: var(--sl-color-neutral-100);
|
|
||||||
--docs-search-result-color-hover: var(--sl-color-neutral-900);
|
|
||||||
--docs-search-result-background-active: var(--sl-color-primary-600);
|
|
||||||
--docs-search-result-color-active: var(--sl-color-neutral-0);
|
|
||||||
--docs-search-focus-ring: var(--sl-focus-ring);
|
|
||||||
--docs-search-overlay-background: rgb(0 0 0 / 0.33);
|
|
||||||
}
|
|
||||||
|
|
||||||
:root.sl-theme-dark {
|
--docs-search-dialog-background: var(--wa-color-surface-raised);
|
||||||
--docs-search-overlay-background: rgb(71 71 71 / 0.33);
|
--docs-search-border-width: var(--wa-border-width-thin);
|
||||||
|
--docs-search-border-color: var(--wa-color-surface-border);
|
||||||
|
--docs-search-text-color: var(--wa-color-text-normal);
|
||||||
|
--docs-search-text-color-muted: var(--wa-color-text-quiet);
|
||||||
|
--docs-search-font-weight-normal: var(--wa-font-weight-normal);
|
||||||
|
--docs-search-font-weight-semibold: var(--wa-font-weight-medium);
|
||||||
|
--docs-search-border-radius: calc(2 * var(--wa-corners-s));
|
||||||
|
|
||||||
|
--docs-search-accent-color: var(--wa-color-brand-text-on-surface);
|
||||||
|
--docs-search-icon-color: var(--wa-color-neutral-spot);
|
||||||
|
--docs-search-icon-color-active: color-mix(in lch, var(--wa-color-neutral-spot), 8% black);
|
||||||
|
--docs-search-shadow: var(--wa-shadow-level-3);
|
||||||
|
--docs-search-result-background-hover: var(--wa-color-neutral-fill-highlight);
|
||||||
|
--docs-search-result-color-hover: var(--wa-color-neutral-text-on-fill);
|
||||||
|
--docs-search-result-background-active: var(--wa-color-brand-spot);
|
||||||
|
--docs-search-result-color-active: var(--wa-color-brand-text-on-spot);
|
||||||
|
--docs-search-focus-ring: var(--wa-focus-ring);
|
||||||
|
--docs-search-overlay-background: rgb(0 0 0 / 0.33);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.search-visible {
|
body.search-visible {
|
||||||
@@ -47,7 +44,7 @@ body.search-visible {
|
|||||||
font: inherit;
|
font: inherit;
|
||||||
color: var(--docs-search-box-color);
|
color: var(--docs-search-box-color);
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
margin: var(--sl-spacing-large) 0;
|
margin: var(--wa-space-l) 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +147,7 @@ body.search-visible {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search__input-wrapper sl-icon {
|
.search__input-wrapper wa-icon {
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
@@ -172,7 +169,7 @@ body.search-visible {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search__clear-button:active sl-icon {
|
.search__clear-button:active wa-icon {
|
||||||
color: var(--docs-search-icon-color-active);
|
color: var(--docs-search-icon-color-active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +273,7 @@ body.search-visible {
|
|||||||
color: var(--docs-search-text-color-muted);
|
color: var(--docs-search-text-color-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.search__result-icon sl-icon {
|
.search__result-icon wa-icon {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const lunr = require('lunr');
|
|||||||
const { capitalCase } = require('change-case');
|
const { capitalCase } = require('change-case');
|
||||||
const { JSDOM } = require('jsdom');
|
const { JSDOM } = require('jsdom');
|
||||||
const { customElementsManifest, getAllComponents } = require('./_utilities/cem.cjs');
|
const { customElementsManifest, getAllComponents } = require('./_utilities/cem.cjs');
|
||||||
const shoelaceFlavoredMarkdown = require('./_utilities/markdown.cjs');
|
const webAwesomeFlavoredMarkdown = require('./_utilities/markdown.cjs');
|
||||||
const activeLinks = require('./_utilities/active-links.cjs');
|
const activeLinks = require('./_utilities/active-links.cjs');
|
||||||
const anchorHeadings = require('./_utilities/anchor-headings.cjs');
|
const anchorHeadings = require('./_utilities/anchor-headings.cjs');
|
||||||
const codePreviews = require('./_utilities/code-previews.cjs');
|
const codePreviews = require('./_utilities/code-previews.cjs');
|
||||||
@@ -32,7 +32,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
eleventyConfig.addGlobalData('layout', 'default'); // make 'default' the default layout
|
eleventyConfig.addGlobalData('layout', 'default'); // make 'default' the default layout
|
||||||
eleventyConfig.addGlobalData('toc', true); // enable the table of contents
|
eleventyConfig.addGlobalData('toc', true); // enable the table of contents
|
||||||
eleventyConfig.addGlobalData('meta', {
|
eleventyConfig.addGlobalData('meta', {
|
||||||
title: 'Shoelace',
|
title: 'Web Awesome',
|
||||||
description: 'A forward-thinking library of web components.',
|
description: 'A forward-thinking library of web components.',
|
||||||
image: 'images/og-image.png',
|
image: 'images/og-image.png',
|
||||||
version: customElementsManifest.package.version,
|
version: customElementsManifest.package.version,
|
||||||
@@ -74,7 +74,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
if (!component) {
|
if (!component) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find a component called "${tagName}". Make sure the file name is the same as the component's tag ` +
|
`Unable to find a component called "${tagName}". Make sure the file name is the same as the component's tag ` +
|
||||||
`name (minus the sl- prefix).`
|
`name (minus the wa- prefix).`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
@@ -83,27 +83,33 @@ module.exports = function (eleventyConfig) {
|
|||||||
//
|
//
|
||||||
// Custom markdown syntaxes
|
// Custom markdown syntaxes
|
||||||
//
|
//
|
||||||
eleventyConfig.setLibrary('md', shoelaceFlavoredMarkdown);
|
eleventyConfig.setLibrary('md', webAwesomeFlavoredMarkdown);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filters
|
// Filters
|
||||||
//
|
//
|
||||||
eleventyConfig.addFilter('markdown', content => {
|
eleventyConfig.addFilter('markdown', content => {
|
||||||
return shoelaceFlavoredMarkdown.render(content);
|
return webAwesomeFlavoredMarkdown.render(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter('markdownInline', content => {
|
eleventyConfig.addFilter('markdownInline', content => {
|
||||||
return shoelaceFlavoredMarkdown.renderInline(content);
|
return webAwesomeFlavoredMarkdown.renderInline(content);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Trims whitespace and pipes from the start and end of a string. Useful for CEM types, which can be pipe-delimited.
|
||||||
|
// With Prettier 3, this means a leading pipe will exist if the line wraps.
|
||||||
|
eleventyConfig.addFilter('trimPipes', content => {
|
||||||
|
return typeof content === 'string' ? content.replace(/^(\s|\|)/g, '').replace(/(\s|\|)$/g, '') : content;
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter('classNameToComponentName', className => {
|
eleventyConfig.addFilter('classNameToComponentName', className => {
|
||||||
let name = capitalCase(className.replace(/^Sl/, ''));
|
let name = capitalCase(className.replace(/^Wa/, ''));
|
||||||
if (name === 'Qr Code') name = 'QR Code'; // manual override
|
if (name === 'Qr Code') name = 'QR Code'; // manual override
|
||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter('removeSlPrefix', tagName => {
|
eleventyConfig.addFilter('removeWaPrefix', tagName => {
|
||||||
return tagName.replace(/^sl-/, '');
|
return tagName.replace(/^wa-/, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -134,6 +140,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
scrollingTables(doc);
|
scrollingTables(doc);
|
||||||
copyCodeButtons(doc); // must be after codePreviews + highlightCodeBlocks
|
copyCodeButtons(doc); // must be after codePreviews + highlightCodeBlocks
|
||||||
typography(doc, '#content');
|
typography(doc, '#content');
|
||||||
|
|
||||||
replacer(doc, [
|
replacer(doc, [
|
||||||
{ pattern: '%VERSION%', replacement: customElementsManifest.package.version },
|
{ pattern: '%VERSION%', replacement: customElementsManifest.package.version },
|
||||||
{ pattern: '%CDNDIR%', replacement: cdndir },
|
{ pattern: '%CDNDIR%', replacement: cdndir },
|
||||||
|
|||||||
@@ -6,25 +6,25 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-alert open>
|
<wa-alert open>
|
||||||
<sl-icon slot="icon" name="info-circle"></sl-icon>
|
<wa-icon slot="icon" name="info-circle" variant="regular"></wa-icon>
|
||||||
This is a standard alert. You can customize its content and even the icon.
|
This is a standard alert. You can customize its content and even the icon.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAlert open>
|
<WaAlert open>
|
||||||
<SlIcon slot="icon" name="info-circle" />
|
<WaIcon slot="icon" name="info-circle" variant="regular" />
|
||||||
This is a standard alert. You can customize its content and even the icon.
|
This is a standard alert. You can customize its content and even the icon.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::warning
|
||||||
Alerts will not be visible if the `open` attribute is not present.
|
Alerts will not be visible if the `open` attribute is not present.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@@ -35,93 +35,93 @@ Alerts will not be visible if the `open` attribute is not present.
|
|||||||
Set the `variant` attribute to change the alert's variant.
|
Set the `variant` attribute to change the alert's variant.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-alert variant="primary" open>
|
<wa-alert variant="brand" open>
|
||||||
<sl-icon slot="icon" name="info-circle"></sl-icon>
|
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
|
||||||
<strong>This is super informative</strong><br />
|
<strong>This is super informative</strong><br />
|
||||||
You can tell by how pretty the alert is.
|
You can tell by how pretty the alert is.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-alert variant="success" open>
|
<wa-alert variant="success" open>
|
||||||
<sl-icon slot="icon" name="check2-circle"></sl-icon>
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
<strong>Your changes have been saved</strong><br />
|
<strong>Your changes have been saved</strong><br />
|
||||||
You can safely exit the app now.
|
You can safely exit the app now.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-alert variant="neutral" open>
|
<wa-alert variant="neutral" open>
|
||||||
<sl-icon slot="icon" name="gear"></sl-icon>
|
<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>
|
||||||
<strong>Your settings have been updated</strong><br />
|
<strong>Your settings have been updated</strong><br />
|
||||||
Settings will take affect on next login.
|
Settings will take effect on next login.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-alert variant="warning" open>
|
<wa-alert variant="warning" open>
|
||||||
<sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
|
<wa-icon slot="icon" name="exclamation-circle" variant="regular"></wa-icon>
|
||||||
<strong>Your session has ended</strong><br />
|
<strong>Your session has ended</strong><br />
|
||||||
Please login again to continue.
|
Please login again to continue.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-alert variant="danger" open>
|
<wa-alert variant="danger" open>
|
||||||
<sl-icon slot="icon" name="exclamation-octagon"></sl-icon>
|
<wa-icon slot="icon" name="exclamation-triangle" variant="regular"></wa-icon>
|
||||||
<strong>Your account has been deleted</strong><br />
|
<strong>Your account has been deleted</strong><br />
|
||||||
We're very sorry to see you go!
|
We're very sorry to see you go!
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlAlert variant="primary" open>
|
<WaAlert variant="brand" open>
|
||||||
<SlIcon slot="icon" name="info-circle" />
|
<WaIcon slot="icon" name="info-circle" variant="regular" />
|
||||||
<strong>This is super informative</strong>
|
<strong>This is super informative</strong>
|
||||||
<br />
|
<br />
|
||||||
You can tell by how pretty the alert is.
|
You can tell by how pretty the alert is.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlAlert variant="success" open>
|
<WaAlert variant="success" open>
|
||||||
<SlIcon slot="icon" name="check2-circle" />
|
<WaIcon slot="icon" name="check2-circle" variant="regular" />
|
||||||
<strong>Your changes have been saved</strong>
|
<strong>Your changes have been saved</strong>
|
||||||
<br />
|
<br />
|
||||||
You can safely exit the app now.
|
You can safely exit the app now.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlAlert variant="neutral" open>
|
<WaAlert variant="neutral" open>
|
||||||
<SlIcon slot="icon" name="gear" />
|
<WaIcon slot="icon" name="gear" variant="regular" />
|
||||||
<strong>Your settings have been updated</strong>
|
<strong>Your settings have been updated</strong>
|
||||||
<br />
|
<br />
|
||||||
Settings will take affect on next login.
|
Settings will take effect on next login.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlAlert variant="warning" open>
|
<WaAlert variant="warning" open>
|
||||||
<SlIcon slot="icon" name="exclamation-triangle" />
|
<WaIcon slot="icon" name="exclamation-circle" variant="regular" />
|
||||||
<strong>Your session has ended</strong>
|
<strong>Your session has ended</strong>
|
||||||
<br />
|
<br />
|
||||||
Please login again to continue.
|
Please login again to continue.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlAlert variant="danger" open>
|
<WaAlert variant="danger" open>
|
||||||
<SlIcon slot="icon" name="exclamation-octagon" />
|
<WaIcon slot="icon" name="exclamation-triangle" variant="regular" />
|
||||||
<strong>Your account has been deleted</strong>
|
<strong>Your account has been deleted</strong>
|
||||||
<br />
|
<br />
|
||||||
We're very sorry to see you go!
|
We're very sorry to see you go!
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -131,14 +131,14 @@ const App = () => (
|
|||||||
Add the `closable` attribute to show a close button that will hide the alert.
|
Add the `closable` attribute to show a close button that will hide the alert.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-alert variant="primary" open closable class="alert-closable">
|
<wa-alert variant="brand" open closable class="alert-closable">
|
||||||
<sl-icon slot="icon" name="info-circle"></sl-icon>
|
<wa-icon slot="icon" name="info-circle" variant="regular"></wa-icon>
|
||||||
You can close this alert any time!
|
You can close this alert any time!
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const alert = document.querySelector('.alert-closable');
|
const alert = document.querySelector('.alert-closable');
|
||||||
alert.addEventListener('sl-after-hide', () => {
|
alert.addEventListener('wa-after-hide', () => {
|
||||||
setTimeout(() => (alert.open = true), 2000);
|
setTimeout(() => (alert.open = true), 2000);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -146,8 +146,8 @@ Add the `closable` attribute to show a close button that will hide the alert.
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
@@ -158,10 +158,10 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlAlert open={open} closable onSlAfterHide={handleHide}>
|
<WaAlert open={open} closable onWaAfterHide={handleHide}>
|
||||||
<SlIcon slot="icon" name="info-circle" />
|
<WaIcon slot="icon" name="info-circle" variant="regular" />
|
||||||
You can close this alert any time!
|
You can close this alert any time!
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -171,16 +171,16 @@ const App = () => {
|
|||||||
Icons are optional. Simply omit the `icon` slot if you don't want them.
|
Icons are optional. Simply omit the `icon` slot if you don't want them.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-alert variant="primary" open> Nothing fancy here, just a simple alert. </sl-alert>
|
<wa-alert variant="brand" open> Nothing fancy here, just a simple alert. </wa-alert>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAlert variant="primary" open>
|
<WaAlert variant="brand" open>
|
||||||
Nothing fancy here, just a simple alert.
|
Nothing fancy here, just a simple alert.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -190,38 +190,38 @@ Set the `duration` attribute to automatically hide an alert after a period of ti
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="alert-duration">
|
<div class="alert-duration">
|
||||||
<sl-button variant="primary">Show Alert</sl-button>
|
<wa-button variant="brand">Show Alert</wa-button>
|
||||||
|
|
||||||
<sl-alert variant="primary" duration="3000" closable>
|
<wa-alert variant="brand" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="info-circle"></sl-icon>
|
<wa-icon slot="icon" name="info-circle" variant="regular"></wa-icon>
|
||||||
This alert will automatically hide itself after three seconds, unless you interact with it.
|
This alert will automatically hide itself after three seconds, unless you interact with it.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.alert-duration');
|
const container = document.querySelector('.alert-duration');
|
||||||
const button = container.querySelector('sl-button');
|
const button = container.querySelector('wa-button');
|
||||||
const alert = container.querySelector('sl-alert');
|
const alert = container.querySelector('wa-alert');
|
||||||
|
|
||||||
button.addEventListener('click', () => alert.show());
|
button.addEventListener('click', () => alert.show());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.alert-duration sl-alert {
|
.alert-duration wa-alert {
|
||||||
margin-top: var(--sl-spacing-medium);
|
margin-top: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.alert-duration sl-alert {
|
.alert-duration wa-alert {
|
||||||
margin-top: var(--sl-spacing-medium);
|
margin-top: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -231,14 +231,14 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="alert-duration">
|
<div className="alert-duration">
|
||||||
<SlButton variant="primary" onClick={() => setOpen(true)}>
|
<WaButton variant="brand" onClick={() => setOpen(true)}>
|
||||||
Show Alert
|
Show Alert
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlAlert variant="primary" duration="3000" open={open} closable onSlAfterHide={() => setOpen(false)}>
|
<WaAlert variant="brand" duration="3000" open={open} closable onWaAfterHide={() => setOpen(false)}>
|
||||||
<SlIcon slot="icon" name="info-circle" />
|
<WaIcon slot="icon" name="info-circle" variant="regular" />
|
||||||
This alert will automatically hide itself after three seconds, unless you interact with it.
|
This alert will automatically hide itself after three seconds, unless you interact with it.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -255,49 +255,49 @@ You should always use the `closable` attribute so users can dismiss the notifica
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="alert-toast">
|
<div class="alert-toast">
|
||||||
<sl-button variant="primary">Primary</sl-button>
|
<wa-button variant="brand">Brand</wa-button>
|
||||||
<sl-button variant="success">Success</sl-button>
|
<wa-button variant="success">Success</wa-button>
|
||||||
<sl-button variant="neutral">Neutral</sl-button>
|
<wa-button variant="neutral">Neutral</wa-button>
|
||||||
<sl-button variant="warning">Warning</sl-button>
|
<wa-button variant="warning">Warning</wa-button>
|
||||||
<sl-button variant="danger">Danger</sl-button>
|
<wa-button variant="danger">Danger</wa-button>
|
||||||
|
|
||||||
<sl-alert variant="primary" duration="3000" closable>
|
<wa-alert variant="brand" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="info-circle"></sl-icon>
|
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
|
||||||
<strong>This is super informative</strong><br />
|
<strong>This is super informative</strong><br />
|
||||||
You can tell by how pretty the alert is.
|
You can tell by how pretty the alert is.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<sl-alert variant="success" duration="3000" closable>
|
<wa-alert variant="success" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="check2-circle"></sl-icon>
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
<strong>Your changes have been saved</strong><br />
|
<strong>Your changes have been saved</strong><br />
|
||||||
You can safely exit the app now.
|
You can safely exit the app now.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<sl-alert variant="neutral" duration="3000" closable>
|
<wa-alert variant="neutral" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="gear"></sl-icon>
|
<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>
|
||||||
<strong>Your settings have been updated</strong><br />
|
<strong>Your settings have been updated</strong><br />
|
||||||
Settings will take affect on next login.
|
Settings will take effect on next login.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<sl-alert variant="warning" duration="3000" closable>
|
<wa-alert variant="warning" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
|
<wa-icon slot="icon" name="circle-exclamation" variant="regular"></wa-icon>
|
||||||
<strong>Your session has ended</strong><br />
|
<strong>Your session has ended</strong><br />
|
||||||
Please login again to continue.
|
Please login again to continue.
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
|
|
||||||
<sl-alert variant="danger" duration="3000" closable>
|
<wa-alert variant="danger" duration="3000" closable>
|
||||||
<sl-icon slot="icon" name="exclamation-octagon"></sl-icon>
|
<wa-icon slot="icon" name="triangle-exclamation" variant="regular"></wa-icon>
|
||||||
<strong>Your account has been deleted</strong><br />
|
<strong>Your account has been deleted</strong><br />
|
||||||
We're very sorry to see you go!
|
We're very sorry to see you go!
|
||||||
</sl-alert>
|
</wa-alert>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.alert-toast');
|
const container = document.querySelector('.alert-toast');
|
||||||
|
|
||||||
['primary', 'success', 'neutral', 'warning', 'danger'].map(variant => {
|
['brand', 'success', 'neutral', 'warning', 'danger'].map(variant => {
|
||||||
const button = container.querySelector(`sl-button[variant="${variant}"]`);
|
const button = container.querySelector(`wa-button[variant="${variant}"]`);
|
||||||
const alert = container.querySelector(`sl-alert[variant="${variant}"]`);
|
const alert = container.querySelector(`wa-alert[variant="${variant}"]`);
|
||||||
|
|
||||||
button.addEventListener('click', () => alert.toast());
|
button.addEventListener('click', () => alert.toast());
|
||||||
});
|
});
|
||||||
@@ -306,16 +306,16 @@ You should always use the `closable` attribute so users can dismiss the notifica
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import SlAlert from '@shoelace-style/shoelace/dist/react/sl-alert';
|
import WaAlert from '@shoelace-style/shoelace/dist/react/alert';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
function showToast(alert) {
|
function showToast(alert) {
|
||||||
alert.toast();
|
alert.toast();
|
||||||
}
|
}
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const primary = useRef(null);
|
const brand = useRef(null);
|
||||||
const success = useRef(null);
|
const success = useRef(null);
|
||||||
const neutral = useRef(null);
|
const neutral = useRef(null);
|
||||||
const warning = useRef(null);
|
const warning = useRef(null);
|
||||||
@@ -323,60 +323,60 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="primary" onClick={() => primary.current.toast()}>
|
<WaButton variant="brand" onClick={() => brand.current.toast()}>
|
||||||
Primary
|
Brand
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="success" onClick={() => success.current.toast()}>
|
<WaButton variant="success" onClick={() => success.current.toast()}>
|
||||||
Success
|
Success
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="neutral" onClick={() => neutral.current.toast()}>
|
<WaButton variant="neutral" onClick={() => neutral.current.toast()}>
|
||||||
Neutral
|
Neutral
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="warning" onClick={() => warning.current.toast()}>
|
<WaButton variant="warning" onClick={() => warning.current.toast()}>
|
||||||
Warning
|
Warning
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="danger" onClick={() => danger.current.toast()}>
|
<WaButton variant="danger" onClick={() => danger.current.toast()}>
|
||||||
Danger
|
Danger
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlAlert ref={primary} variant="primary" duration="3000" closable>
|
<WaAlert ref={brand} variant="brand" duration="3000" closable>
|
||||||
<SlIcon slot="icon" name="info-circle" />
|
<WaIcon slot="icon" name="circle-info" variant="regular" />
|
||||||
<strong>This is super informative</strong>
|
<strong>This is super informative</strong>
|
||||||
<br />
|
<br />
|
||||||
You can tell by how pretty the alert is.
|
You can tell by how pretty the alert is.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<SlAlert ref={success} variant="success" duration="3000" closable>
|
<WaAlert ref={success} variant="success" duration="3000" closable>
|
||||||
<SlIcon slot="icon" name="check2-circle" />
|
<WaIcon slot="icon" name="circle-check" variant="regular" />
|
||||||
<strong>Your changes have been saved</strong>
|
<strong>Your changes have been saved</strong>
|
||||||
<br />
|
<br />
|
||||||
You can safely exit the app now.
|
You can safely exit the app now.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<SlAlert ref={neutral} variant="neutral" duration="3000" closable>
|
<WaAlert ref={neutral} variant="neutral" duration="3000" closable>
|
||||||
<SlIcon slot="icon" name="gear" />
|
<WaIcon slot="icon" name="gear" variant="regular" />
|
||||||
<strong>Your settings have been updated</strong>
|
<strong>Your settings have been updated</strong>
|
||||||
<br />
|
<br />
|
||||||
Settings will take affect on next login.
|
Settings will take effect on next login.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<SlAlert ref={warning} variant="warning" duration="3000" closable>
|
<WaAlert ref={warning} variant="warning" duration="3000" closable>
|
||||||
<SlIcon slot="icon" name="exclamation-triangle" />
|
<WaIcon slot="icon" name="circle-exclamation" variant="regular" />
|
||||||
<strong>Your session has ended</strong>
|
<strong>Your session has ended</strong>
|
||||||
<br />
|
<br />
|
||||||
Please login again to continue.
|
Please login again to continue.
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
|
|
||||||
<SlAlert ref={danger} variant="danger" duration="3000" closable>
|
<WaAlert ref={danger} variant="danger" duration="3000" closable>
|
||||||
<SlIcon slot="icon" name="exclamation-octagon" />
|
<WaIcon slot="icon" name="triangle-exclamation" variant="regular" />
|
||||||
<strong>Your account has been deleted</strong>
|
<strong>Your account has been deleted</strong>
|
||||||
<br />
|
<br />
|
||||||
We're very sorry to see you go!
|
We're very sorry to see you go!
|
||||||
</SlAlert>
|
</WaAlert>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -388,12 +388,12 @@ For convenience, you can create a utility that emits toast notifications with a
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="alert-toast-wrapper">
|
<div class="alert-toast-wrapper">
|
||||||
<sl-button variant="primary">Create Toast</sl-button>
|
<wa-button variant="brand">Create Toast</wa-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.alert-toast-wrapper');
|
const container = document.querySelector('.alert-toast-wrapper');
|
||||||
const button = container.querySelector('sl-button');
|
const button = container.querySelector('wa-button');
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
// Always escape HTML for text arguments!
|
// Always escape HTML for text arguments!
|
||||||
@@ -404,13 +404,13 @@ For convenience, you can create a utility that emits toast notifications with a
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Custom function to emit toast notifications
|
// Custom function to emit toast notifications
|
||||||
function notify(message, variant = 'primary', icon = 'info-circle', duration = 3000) {
|
function notify(message, variant = 'brand', icon = 'circle-info', duration = 3000) {
|
||||||
const alert = Object.assign(document.createElement('sl-alert'), {
|
const alert = Object.assign(document.createElement('wa-alert'), {
|
||||||
variant,
|
variant,
|
||||||
closable: true,
|
closable: true,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
innerHTML: `
|
innerHTML: `
|
||||||
<sl-icon name="${icon}" slot="icon"></sl-icon>
|
<wa-icon name="${icon}" variant="regular" slot="icon"></wa-icon>
|
||||||
${escapeHtml(message)}
|
${escapeHtml(message)}
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
@@ -429,10 +429,10 @@ For convenience, you can create a utility that emits toast notifications with a
|
|||||||
|
|
||||||
The toast stack is a fixed position singleton element created and managed internally by the alert component. It will be added and removed from the DOM as needed when toasts are shown. When more than one toast is visible, they will stack vertically in the toast stack.
|
The toast stack is a fixed position singleton element created and managed internally by the alert component. It will be added and removed from the DOM as needed when toasts are shown. When more than one toast is visible, they will stack vertically in the toast stack.
|
||||||
|
|
||||||
By default, the toast stack is positioned at the top-right of the viewport. You can change its position by targeting `.sl-toast-stack` in your stylesheet. To make toasts appear at the top-left of the viewport, for example, use the following styles.
|
By default, the toast stack is positioned at the top-right of the viewport. You can change its position by targeting `.wa-toast-stack` in your stylesheet. To make toasts appear at the top-left of the viewport, for example, use the following styles.
|
||||||
|
|
||||||
```css
|
```css
|
||||||
.sl-toast-stack {
|
.wa-toast-stack {
|
||||||
left: 0;
|
left: 0;
|
||||||
right: auto;
|
right: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,17 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-animated-image
|
<wa-animated-image
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
></sl-animated-image>
|
></wa-animated-image>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimatedImage from '@shoelace-style/shoelace/dist/react/sl-animated-image';
|
import WaAnimatedImage from '@shoelace-style/shoelace/dist/react/animated-image';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAnimatedImage
|
<WaAnimatedImage
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
/>
|
/>
|
||||||
@@ -34,17 +34,17 @@ This component uses `<canvas>` to draw freeze frames, so images are subject to [
|
|||||||
Both GIF and WEBP images are supported.
|
Both GIF and WEBP images are supported.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-animated-image
|
<wa-animated-image
|
||||||
src="https://shoelace.style/assets/images/tie.webp"
|
src="https://shoelace.style/assets/images/tie.webp"
|
||||||
alt="Animation of a shoe being tied"
|
alt="Animation of a shoe being tied"
|
||||||
></sl-animated-image>
|
></wa-animated-image>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimatedImage from '@shoelace-style/shoelace/dist/react/sl-animated-image';
|
import WaAnimatedImage from '@shoelace-style/shoelace/dist/react/animated-image';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAnimatedImage src="https://shoelace.style/assets/images/tie.webp" alt="Animation of a shoe being tied" />
|
<WaAnimatedImage src="https://shoelace.style/assets/images/tie.webp" alt="Animation of a shoe being tied" />
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -53,21 +53,21 @@ const App = () => (
|
|||||||
To set a custom size, apply a width and/or height to the host element.
|
To set a custom size, apply a width and/or height to the host element.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-animated-image
|
<wa-animated-image
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
style="width: 150px; height: 200px;"
|
style="width: 150px; height: 200px;"
|
||||||
>
|
>
|
||||||
</sl-animated-image>
|
</wa-animated-image>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimatedImage from '@shoelace-style/shoelace/dist/react/sl-animated-image';
|
import WaAnimatedImage from '@shoelace-style/shoelace/dist/react/animated-image';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAnimatedImage
|
<WaAnimatedImage
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
style={{ width: '150px', height: '200px' }}
|
style={{ width: '150px', height: '200px' }}
|
||||||
@@ -82,11 +82,11 @@ const App = () => (
|
|||||||
You can change the appearance and location of the control box by targeting the `control-box` part in your styles.
|
You can change the appearance and location of the control box by targeting the `control-box` part in your styles.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-animated-image
|
<wa-animated-image
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
class="animated-image-custom-control-box"
|
class="animated-image-custom-control-box"
|
||||||
></sl-animated-image>
|
></wa-animated-image>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.animated-image-custom-control-box::part(control-box) {
|
.animated-image-custom-control-box::part(control-box) {
|
||||||
@@ -102,7 +102,7 @@ You can change the appearance and location of the control box by targeting the `
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimatedImage from '@shoelace-style/shoelace/dist/react/sl-animated-image';
|
import WaAnimatedImage from '@shoelace-style/shoelace/dist/react/animated-image';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.animated-image-custom-control-box::part(control-box) {
|
.animated-image-custom-control-box::part(control-box) {
|
||||||
@@ -118,7 +118,7 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlAnimatedImage
|
<WaAnimatedImage
|
||||||
className="animated-image-custom-control-box"
|
className="animated-image-custom-control-box"
|
||||||
src="https://shoelace.style/assets/images/walk.gif"
|
src="https://shoelace.style/assets/images/walk.gif"
|
||||||
alt="Animation of untied shoes walking on pavement"
|
alt="Animation of untied shoes walking on pavement"
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ meta:
|
|||||||
layout: component
|
layout: component
|
||||||
---
|
---
|
||||||
|
|
||||||
To animate an element, wrap it in `<sl-animation>` and set an animation `name`. The animation will not start until you add the `play` attribute. Refer to the [properties table](#properties) for a list of all animation options.
|
To animate an element, wrap it in `<wa-animation>` and set an animation `name`. The animation will not start until you add the `play` attribute. Refer to the [properties table](#properties) for a list of all animation options.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="animation-overview">
|
<div class="animation-overview">
|
||||||
<sl-animation name="bounce" duration="2000" play><div class="box"></div></sl-animation>
|
<wa-animation name="bounce" duration="2000" play><div class="box"></div></wa-animation>
|
||||||
<sl-animation name="jello" duration="2000" play><div class="box"></div></sl-animation>
|
<wa-animation name="jello" duration="2000" play><div class="box"></div></wa-animation>
|
||||||
<sl-animation name="heartBeat" duration="2000" play><div class="box"></div></sl-animation>
|
<wa-animation name="heartBeat" duration="2000" play><div class="box"></div></wa-animation>
|
||||||
<sl-animation name="flip" duration="2000" play><div class="box"></div></sl-animation>
|
<wa-animation name="flip" duration="2000" play><div class="box"></div></wa-animation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -20,21 +20,21 @@ To animate an element, wrap it in `<sl-animation>` and set an animation `name`.
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
margin: 1.5rem;
|
margin: 1.5rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimation from '@shoelace-style/shoelace/dist/react/sl-animation';
|
import WaAnimation from '@shoelace-style/shoelace/dist/react/animation';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.animation-overview .box {
|
.animation-overview .box {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
margin: 1.5rem;
|
margin: 1.5rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -42,18 +42,18 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div class="animation-overview">
|
<div class="animation-overview">
|
||||||
<SlAnimation name="bounce" duration={2000} play>
|
<WaAnimation name="bounce" duration={2000} play>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
<SlAnimation name="jello" duration={2000} play>
|
<WaAnimation name="jello" duration={2000} play>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
<SlAnimation name="heartBeat" duration={2000} play>
|
<WaAnimation name="heartBeat" duration={2000} play>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
<SlAnimation name="flip" duration={2000} play>
|
<WaAnimation name="flip" duration={2000} play>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -62,7 +62,7 @@ const App = () => (
|
|||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
The animation will only be applied to the first child element found in `<sl-animation>`.
|
The animation will only be applied to the first child element found in `<wa-animation>`.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -73,14 +73,14 @@ This example demonstrates all of the baked-in animations and easings. Animations
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="animation-sandbox">
|
<div class="animation-sandbox">
|
||||||
<sl-animation name="bounce" easing="ease-in-out" duration="2000" play>
|
<wa-animation name="bounce" easing="ease-in-out" duration="2000" play>
|
||||||
<div class="box"></div>
|
<div class="box"></div>
|
||||||
</sl-animation>
|
</wa-animation>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<sl-select label="Animation" value="bounce"></sl-select>
|
<wa-select label="Animation" value="bounce"></wa-select>
|
||||||
<sl-select label="Easing" value="linear"></sl-select>
|
<wa-select label="Easing" value="linear"></wa-select>
|
||||||
<sl-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1"></sl-input>
|
<wa-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1"></wa-input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -88,15 +88,15 @@ This example demonstrates all of the baked-in animations and easings. Animations
|
|||||||
import { getAnimationNames, getEasingNames } from '/dist/utilities/animation.js';
|
import { getAnimationNames, getEasingNames } from '/dist/utilities/animation.js';
|
||||||
|
|
||||||
const container = document.querySelector('.animation-sandbox');
|
const container = document.querySelector('.animation-sandbox');
|
||||||
const animation = container.querySelector('sl-animation');
|
const animation = container.querySelector('wa-animation');
|
||||||
const animationName = container.querySelector('.controls sl-select:nth-child(1)');
|
const animationName = container.querySelector('.controls wa-select:nth-child(1)');
|
||||||
const easingName = container.querySelector('.controls sl-select:nth-child(2)');
|
const easingName = container.querySelector('.controls wa-select:nth-child(2)');
|
||||||
const playbackRate = container.querySelector('sl-input[type="number"]');
|
const playbackRate = container.querySelector('wa-input[type="number"]');
|
||||||
const animations = getAnimationNames();
|
const animations = getAnimationNames();
|
||||||
const easings = getEasingNames();
|
const easings = getEasingNames();
|
||||||
|
|
||||||
animations.map(name => {
|
animations.map(name => {
|
||||||
const option = Object.assign(document.createElement('sl-option'), {
|
const option = Object.assign(document.createElement('wa-option'), {
|
||||||
textContent: name,
|
textContent: name,
|
||||||
value: name
|
value: name
|
||||||
});
|
});
|
||||||
@@ -104,23 +104,23 @@ This example demonstrates all of the baked-in animations and easings. Animations
|
|||||||
});
|
});
|
||||||
|
|
||||||
easings.map(name => {
|
easings.map(name => {
|
||||||
const option = Object.assign(document.createElement('sl-option'), {
|
const option = Object.assign(document.createElement('wa-option'), {
|
||||||
textContent: name,
|
textContent: name,
|
||||||
value: name
|
value: name
|
||||||
});
|
});
|
||||||
easingName.appendChild(option);
|
easingName.appendChild(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
animationName.addEventListener('sl-change', () => (animation.name = animationName.value));
|
animationName.addEventListener('wa-change', () => (animation.name = animationName.value));
|
||||||
easingName.addEventListener('sl-change', () => (animation.easing = easingName.value));
|
easingName.addEventListener('wa-change', () => (animation.easing = easingName.value));
|
||||||
playbackRate.addEventListener('sl-input', () => (animation.playbackRate = playbackRate.value));
|
playbackRate.addEventListener('wa-input', () => (animation.playbackRate = playbackRate.value));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.animation-sandbox .box {
|
.animation-sandbox .box {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
}
|
}
|
||||||
|
|
||||||
.animation-sandbox .controls {
|
.animation-sandbox .controls {
|
||||||
@@ -128,7 +128,7 @@ This example demonstrates all of the baked-in animations and easings. Animations
|
|||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.animation-sandbox .controls sl-select {
|
.animation-sandbox .controls wa-select {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -140,12 +140,12 @@ Use an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="animation-scroll">
|
<div class="animation-scroll">
|
||||||
<sl-animation name="jackInTheBox" duration="2000" iterations="1"><div class="box"></div></sl-animation>
|
<wa-animation name="jackInTheBox" duration="2000" iterations="1"><div class="box"></div></wa-animation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.animation-scroll');
|
const container = document.querySelector('.animation-scroll');
|
||||||
const animation = container.querySelector('sl-animation');
|
const animation = container.querySelector('wa-animation');
|
||||||
const box = animation.querySelector('.box');
|
const box = animation.querySelector('.box');
|
||||||
|
|
||||||
// Watch for the box to enter and exit the viewport. Note that we're observing the box, not the animation element!
|
// Watch for the box to enter and exit the viewport. Note that we're observing the box, not the animation element!
|
||||||
@@ -166,14 +166,14 @@ Use an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import SlAnimation from '@shoelace-style/shoelace/dist/react/sl-animation';
|
import WaAnimation from '@shoelace-style/shoelace/dist/react/animation';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.animation-scroll {
|
.animation-scroll {
|
||||||
@@ -184,7 +184,7 @@ const css = `
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -210,9 +210,9 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class="animation-scroll">
|
<div class="animation-scroll">
|
||||||
<SlAnimation ref={animation} name="jackInTheBox" duration={2000} iterations={1}>
|
<WaAnimation ref={animation} name="jackInTheBox" duration={2000} iterations={1}>
|
||||||
<div ref={box} class="box" />
|
<div ref={box} class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -227,13 +227,13 @@ Supply your own [keyframe formats](https://developer.mozilla.org/en-US/docs/Web/
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="animation-keyframes">
|
<div class="animation-keyframes">
|
||||||
<sl-animation easing="ease-in-out" duration="2000" play>
|
<wa-animation easing="ease-in-out" duration="2000" play>
|
||||||
<div class="box"></div>
|
<div class="box"></div>
|
||||||
</sl-animation>
|
</wa-animation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const animation = document.querySelector('.animation-keyframes sl-animation');
|
const animation = document.querySelector('.animation-keyframes wa-animation');
|
||||||
animation.keyframes = [
|
animation.keyframes = [
|
||||||
{
|
{
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -256,26 +256,26 @@ Supply your own [keyframe formats](https://developer.mozilla.org/en-US/docs/Web/
|
|||||||
.animation-keyframes .box {
|
.animation-keyframes .box {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAnimation from '@shoelace-style/shoelace/dist/react/sl-animation';
|
import WaAnimation from '@shoelace-style/shoelace/dist/react/animation';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.animation-keyframes .box {
|
.animation-keyframes .box {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-brand-spot);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div class="animation-keyframes">
|
<div class="animation-keyframes">
|
||||||
<SlAnimation
|
<WaAnimation
|
||||||
easing="ease-in-out"
|
easing="ease-in-out"
|
||||||
duration={2000}
|
duration={2000}
|
||||||
play
|
play
|
||||||
@@ -297,7 +297,7 @@ const App = () => (
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -311,15 +311,15 @@ Animations won't play until you apply the `play` attribute. You can omit it init
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="animation-form">
|
<div class="animation-form">
|
||||||
<sl-animation name="rubberBand" duration="1000" iterations="1">
|
<wa-animation name="rubberBand" duration="1000" iterations="1">
|
||||||
<sl-button variant="primary">Click me</sl-button>
|
<wa-button variant="brand">Click me</wa-button>
|
||||||
</sl-animation>
|
</wa-animation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.animation-form');
|
const container = document.querySelector('.animation-form');
|
||||||
const animation = container.querySelector('sl-animation');
|
const animation = container.querySelector('wa-animation');
|
||||||
const button = container.querySelector('sl-button');
|
const button = container.querySelector('wa-button');
|
||||||
|
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
animation.play = true;
|
animation.play = true;
|
||||||
@@ -329,19 +329,19 @@ Animations won't play until you apply the `play` attribute. You can omit it init
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlAnimation from '@shoelace-style/shoelace/dist/react/sl-animation';
|
import WaAnimation from '@shoelace-style/shoelace/dist/react/animation';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [play, setPlay] = useState(false);
|
const [play, setPlay] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="animation-form">
|
<div class="animation-form">
|
||||||
<SlAnimation name="rubberBand" duration={1000} iterations={1} play={play} onSlFinish={() => setPlay(false)}>
|
<WaAnimation name="rubberBand" duration={1000} iterations={1} play={play} onWaFinish={() => setPlay(false)}>
|
||||||
<SlButton variant="primary" onClick={() => setPlay(true)}>
|
<WaButton variant="brand" onClick={() => setPlay(true)}>
|
||||||
Click me
|
Click me
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlAnimation>
|
</WaAnimation>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ layout: component
|
|||||||
By default, a generic icon will be shown. You can personalize avatars by adding custom icons, initials, and images. You should always provide a `label` for assistive devices.
|
By default, a generic icon will be shown. You can personalize avatars by adding custom icons, initials, and images. You should always provide a `label` for assistive devices.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-avatar label="User avatar"></sl-avatar>
|
<wa-avatar label="User avatar"></wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
|
|
||||||
const App = () => <SlAvatar label="User avatar" />;
|
const App = () => <WaAvatar label="User avatar" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -25,26 +25,26 @@ To use an image for the avatar, set the `image` and `label` attributes. This wil
|
|||||||
Avatar images can be lazily loaded by setting the `loading` attribute to `lazy`.
|
Avatar images can be lazily loaded by setting the `loading` attribute to `lazy`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
||||||
label="Avatar of a gray tabby kitten looking down"
|
label="Avatar of a gray tabby kitten looking down"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/photo-1591871937573-74dbba515c4c?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
image="https://images.unsplash.com/photo-1591871937573-74dbba515c4c?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
||||||
label="Avatar of a white and grey kitten on grey textile"
|
label="Avatar of a white and grey kitten on grey textile"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
||||||
label="Avatar of a gray tabby kitten looking down"
|
label="Avatar of a gray tabby kitten looking down"
|
||||||
/>
|
/>
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/photo-1591871937573-74dbba515c4c?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
image="https://images.unsplash.com/photo-1591871937573-74dbba515c4c?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80"
|
||||||
label="Avatar of a white and grey kitten on grey textile"
|
label="Avatar of a white and grey kitten on grey textile"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
@@ -57,13 +57,13 @@ const App = () => (
|
|||||||
When you don't have an image to use, you can set the `initials` attribute to show something more personalized than an icon.
|
When you don't have an image to use, you can set the `initials` attribute to show something more personalized than an icon.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-avatar initials="SL" label="Avatar with initials: SL"></sl-avatar>
|
<wa-avatar initials="WA" label="Avatar with initials: SL"></wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
|
|
||||||
const App = () => <SlAvatar initials="SL" label="Avatar with initials: SL" />;
|
const App = () => <WaAvatar initials="WA" label="Avatar with initials: SL" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Icons
|
### Custom Icons
|
||||||
@@ -71,36 +71,36 @@ const App = () => <SlAvatar initials="SL" label="Avatar with initials: SL" />;
|
|||||||
When no image or initials are set, an icon will be shown. The default avatar shows a generic "user" icon, but you can customize this with the `icon` slot.
|
When no image or initials are set, an icon will be shown. The default avatar shows a generic "user" icon, but you can customize this with the `icon` slot.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-avatar label="Avatar with an image icon">
|
<wa-avatar label="Avatar with an image icon">
|
||||||
<sl-icon slot="icon" name="image"></sl-icon>
|
<wa-icon slot="icon" name="image" variant="solid"></wa-icon>
|
||||||
</sl-avatar>
|
</wa-avatar>
|
||||||
|
|
||||||
<sl-avatar label="Avatar with an archive icon">
|
<wa-avatar label="Avatar with an archive icon">
|
||||||
<sl-icon slot="icon" name="archive"></sl-icon>
|
<wa-icon slot="icon" name="archive" variant="solid"></wa-icon>
|
||||||
</sl-avatar>
|
</wa-avatar>
|
||||||
|
|
||||||
<sl-avatar label="Avatar with a briefcase icon">
|
<wa-avatar label="Avatar with a briefcase icon">
|
||||||
<sl-icon slot="icon" name="briefcase"></sl-icon>
|
<wa-icon slot="icon" name="briefcase" variant="solid"></wa-icon>
|
||||||
</sl-avatar>
|
</wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlAvatar label="Avatar with an image icon">
|
<WaAvatar label="Avatar with an image icon">
|
||||||
<SlIcon slot="icon" name="image" />
|
<WaIcon slot="icon" name="image" />
|
||||||
</SlAvatar>
|
</WaAvatar>
|
||||||
|
|
||||||
<SlAvatar label="Avatar with an archive icon">
|
<WaAvatar label="Avatar with an archive icon">
|
||||||
<SlIcon slot="icon" name="archive" />
|
<WaIcon slot="icon" name="archive" />
|
||||||
</SlAvatar>
|
</WaAvatar>
|
||||||
|
|
||||||
<SlAvatar label="Avatar with a briefcase icon">
|
<WaAvatar label="Avatar with a briefcase icon">
|
||||||
<SlIcon slot="icon" name="briefcase" />
|
<WaIcon slot="icon" name="briefcase" />
|
||||||
</SlAvatar>
|
</WaAvatar>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -110,20 +110,20 @@ const App = () => (
|
|||||||
Avatars can be shaped using the `shape` attribute.
|
Avatars can be shaped using the `shape` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-avatar shape="square" label="Square avatar"></sl-avatar>
|
<wa-avatar shape="square" label="Square avatar"></wa-avatar>
|
||||||
<sl-avatar shape="rounded" label="Rounded avatar"></sl-avatar>
|
<wa-avatar shape="rounded" label="Rounded avatar"></wa-avatar>
|
||||||
<sl-avatar shape="circle" label="Circle avatar"></sl-avatar>
|
<wa-avatar shape="circle" label="Circle avatar"></wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlAvatar shape="square" label="Square avatar" />
|
<WaAvatar shape="square" label="Square avatar" />
|
||||||
<SlAvatar shape="rounded" label="Rounded avatar" />
|
<WaAvatar shape="rounded" label="Rounded avatar" />
|
||||||
<SlAvatar shape="circle" label="Circle avatar" />
|
<WaAvatar shape="circle" label="Circle avatar" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -134,71 +134,71 @@ You can group avatars with a few lines of CSS.
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="avatar-group">
|
<div class="avatar-group">
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/photo-1490150028299-bf57d78394e0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&q=80&crop=right"
|
image="https://images.unsplash.com/photo-1490150028299-bf57d78394e0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&q=80&crop=right"
|
||||||
label="Avatar 1 of 4"
|
label="Avatar 1 of 4"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
|
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/photo-1503454537195-1dcabb73ffb9?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
image="https://images.unsplash.com/photo-1503454537195-1dcabb73ffb9?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
||||||
label="Avatar 2 of 4"
|
label="Avatar 2 of 4"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
|
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/photo-1456439663599-95b042d50252?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
image="https://images.unsplash.com/photo-1456439663599-95b042d50252?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
||||||
label="Avatar 3 of 4"
|
label="Avatar 3 of 4"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
|
|
||||||
<sl-avatar
|
<wa-avatar
|
||||||
image="https://images.unsplash.com/flagged/photo-1554078875-e37cb8b0e27d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=top&q=80"
|
image="https://images.unsplash.com/flagged/photo-1554078875-e37cb8b0e27d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=top&q=80"
|
||||||
label="Avatar 4 of 4"
|
label="Avatar 4 of 4"
|
||||||
></sl-avatar>
|
></wa-avatar>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.avatar-group sl-avatar:not(:first-of-type) {
|
.avatar-group wa-avatar:not(:first-of-type) {
|
||||||
margin-left: -1rem;
|
margin-left: calc(-1 * var(--wa-space-m));
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-group sl-avatar::part(base) {
|
.avatar-group wa-avatar::part(base) {
|
||||||
border: solid 2px var(--sl-color-neutral-0);
|
border: solid 2px var(--wa-color-surface-default);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.avatar-group sl-avatar:not(:first-of-type) {
|
.avatar-group wa-avatar:not(:first-of-type) {
|
||||||
margin-left: -1rem;
|
margin-left: calc(-1 * var(--wa-space-m));
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-group sl-avatar::part(base) {
|
.avatar-group wa-avatar::part(base) {
|
||||||
border: solid 2px var(--sl-color-neutral-0);
|
border: solid 2px var(--wa-color-surface-default);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="avatar-group">
|
<div className="avatar-group">
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/photo-1490150028299-bf57d78394e0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&q=80&crop=right"
|
image="https://images.unsplash.com/photo-1490150028299-bf57d78394e0?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&q=80&crop=right"
|
||||||
label="Avatar 1 of 4"
|
label="Avatar 1 of 4"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/photo-1503454537195-1dcabb73ffb9?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
image="https://images.unsplash.com/photo-1503454537195-1dcabb73ffb9?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
||||||
label="Avatar 2 of 4"
|
label="Avatar 2 of 4"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/photo-1456439663599-95b042d50252?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
image="https://images.unsplash.com/photo-1456439663599-95b042d50252?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=left&q=80"
|
||||||
label="Avatar 3 of 4"
|
label="Avatar 3 of 4"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SlAvatar
|
<WaAvatar
|
||||||
image="https://images.unsplash.com/flagged/photo-1554078875-e37cb8b0e27d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=top&q=80"
|
image="https://images.unsplash.com/flagged/photo-1554078875-e37cb8b0e27d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=256&h=256&crop=top&q=80"
|
||||||
label="Avatar 4 of 4"
|
label="Avatar 4 of 4"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-badge>Badge</sl-badge>
|
<wa-badge>Badge</wa-badge>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
|
|
||||||
const App = () => <SlBadge>Badge</SlBadge>;
|
const App = () => <WaBadge>Badge</WaBadge>;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,23 +22,23 @@ const App = () => <SlBadge>Badge</SlBadge>;
|
|||||||
Set the `variant` attribute to change the badge's variant.
|
Set the `variant` attribute to change the badge's variant.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-badge variant="primary">Primary</sl-badge>
|
<wa-badge variant="brand">Brand</wa-badge>
|
||||||
<sl-badge variant="success">Success</sl-badge>
|
<wa-badge variant="success">Success</wa-badge>
|
||||||
<sl-badge variant="neutral">Neutral</sl-badge>
|
<wa-badge variant="neutral">Neutral</wa-badge>
|
||||||
<sl-badge variant="warning">Warning</sl-badge>
|
<wa-badge variant="warning">Warning</wa-badge>
|
||||||
<sl-badge variant="danger">Danger</sl-badge>
|
<wa-badge variant="danger">Danger</wa-badge>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlBadge variant="primary">Primary</SlBadge>
|
<WaBadge variant="brand">Brand</WaBadge>
|
||||||
<SlBadge variant="success">Success</SlBadge>
|
<WaBadge variant="success">Success</WaBadge>
|
||||||
<SlBadge variant="neutral">Neutral</SlBadge>
|
<WaBadge variant="neutral">Neutral</WaBadge>
|
||||||
<SlBadge variant="warning">Warning</SlBadge>
|
<WaBadge variant="warning">Warning</WaBadge>
|
||||||
<SlBadge variant="danger">Danger</SlBadge>
|
<WaBadge variant="danger">Danger</WaBadge>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -48,33 +48,33 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give badges rounded edges.
|
Use the `pill` attribute to give badges rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-badge variant="primary" pill>Primary</sl-badge>
|
<wa-badge variant="brand" pill>Brand</wa-badge>
|
||||||
<sl-badge variant="success" pill>Success</sl-badge>
|
<wa-badge variant="success" pill>Success</wa-badge>
|
||||||
<sl-badge variant="neutral" pill>Neutral</sl-badge>
|
<wa-badge variant="neutral" pill>Neutral</wa-badge>
|
||||||
<sl-badge variant="warning" pill>Warning</sl-badge>
|
<wa-badge variant="warning" pill>Warning</wa-badge>
|
||||||
<sl-badge variant="danger" pill>Danger</sl-badge>
|
<wa-badge variant="danger" pill>Danger</wa-badge>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlBadge variant="primary" pill>
|
<WaBadge variant="brand" pill>
|
||||||
Primary
|
Brand
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="success" pill>
|
<WaBadge variant="success" pill>
|
||||||
Success
|
Success
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="neutral" pill>
|
<WaBadge variant="neutral" pill>
|
||||||
Neutral
|
Neutral
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="warning" pill>
|
<WaBadge variant="warning" pill>
|
||||||
Warning
|
Warning
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="danger" pill>
|
<WaBadge variant="danger" pill>
|
||||||
Danger
|
Danger
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -85,25 +85,25 @@ Use the `pulse` attribute to draw attention to the badge with a subtle animation
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="badge-pulse">
|
<div class="badge-pulse">
|
||||||
<sl-badge variant="primary" pill pulse>1</sl-badge>
|
<wa-badge variant="brand" pill pulse>1</wa-badge>
|
||||||
<sl-badge variant="success" pill pulse>1</sl-badge>
|
<wa-badge variant="success" pill pulse>1</wa-badge>
|
||||||
<sl-badge variant="neutral" pill pulse>1</sl-badge>
|
<wa-badge variant="neutral" pill pulse>1</wa-badge>
|
||||||
<sl-badge variant="warning" pill pulse>1</sl-badge>
|
<wa-badge variant="warning" pill pulse>1</wa-badge>
|
||||||
<sl-badge variant="danger" pill pulse>1</sl-badge>
|
<wa-badge variant="danger" pill pulse>1</wa-badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.badge-pulse sl-badge:not(:last-of-type) {
|
.badge-pulse wa-badge:not(:last-of-type) {
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.badge-pulse sl-badge:not(:last-of-type) {
|
.badge-pulse wa-badge:not(:last-of-type) {
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -111,21 +111,21 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="badge-pulse">
|
<div className="badge-pulse">
|
||||||
<SlBadge variant="primary" pill pulse>
|
<WaBadge variant="brand" pill pulse>
|
||||||
1
|
1
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="success" pill pulse>
|
<WaBadge variant="success" pill pulse>
|
||||||
1
|
1
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="neutral" pill pulse>
|
<WaBadge variant="neutral" pill pulse>
|
||||||
1
|
1
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="warning" pill pulse>
|
<WaBadge variant="warning" pill pulse>
|
||||||
1
|
1
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
<SlBadge variant="danger" pill pulse>
|
<WaBadge variant="danger" pill pulse>
|
||||||
1
|
1
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -138,48 +138,48 @@ const App = () => (
|
|||||||
One of the most common use cases for badges is attaching them to buttons. To make this easier, badges will be automatically positioned at the top-right when they're a child of a button.
|
One of the most common use cases for badges is attaching them to buttons. To make this easier, badges will be automatically positioned at the top-right when they're a child of a button.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button>
|
<wa-button>
|
||||||
Requests
|
Requests
|
||||||
<sl-badge pill>30</sl-badge>
|
<wa-badge pill>30</wa-badge>
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button style="margin-inline-start: 1rem;">
|
<wa-button style="margin-inline-start: 1rem;">
|
||||||
Warnings
|
Warnings
|
||||||
<sl-badge variant="warning" pill>8</sl-badge>
|
<wa-badge variant="warning" pill>8</wa-badge>
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button style="margin-inline-start: 1rem;">
|
<wa-button style="margin-inline-start: 1rem;">
|
||||||
Errors
|
Errors
|
||||||
<sl-badge variant="danger" pill>6</sl-badge>
|
<wa-badge variant="danger" pill>6</wa-badge>
|
||||||
</sl-button>
|
</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton>
|
<WaButton>
|
||||||
Requests
|
Requests
|
||||||
<SlBadge pill>30</SlBadge>
|
<WaBadge pill>30</WaBadge>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton style={{ marginInlineStart: '1rem' }}>
|
<WaButton style={{ marginInlineStart: '1rem' }}>
|
||||||
Warnings
|
Warnings
|
||||||
<SlBadge variant="warning" pill>
|
<WaBadge variant="warning" pill>
|
||||||
8
|
8
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton style={{ marginInlineStart: '1rem' }}>
|
<WaButton style={{ marginInlineStart: '1rem' }}>
|
||||||
Errors
|
Errors
|
||||||
<SlBadge variant="danger" pill>
|
<WaBadge variant="danger" pill>
|
||||||
6
|
6
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -191,44 +191,40 @@ const App = () => (
|
|||||||
When including badges in menu items, use the `suffix` slot to make sure they're aligned correctly.
|
When including badges in menu items, use the `suffix` slot to make sure they're aligned correctly.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 240px;">
|
<wa-menu style="max-width: 240px;">
|
||||||
<sl-menu-label>Messages</sl-menu-label>
|
<wa-menu-label>Messages</wa-menu-label>
|
||||||
<sl-menu-item>Comments <sl-badge slot="suffix" variant="neutral" pill>4</sl-badge></sl-menu-item>
|
<wa-menu-item>Comments <wa-badge slot="suffix" variant="neutral" pill>4</wa-badge></wa-menu-item>
|
||||||
<sl-menu-item>Replies <sl-badge slot="suffix" variant="neutral" pill>12</sl-badge></sl-menu-item>
|
<wa-menu-item>Replies <wa-badge slot="suffix" variant="neutral" pill>12</wa-badge></wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
import SlMenuLabel from '@shoelace-style/shoelace/dist/react/sl-menu-label';
|
import WaMenuLabel from '@shoelace-style/shoelace/dist/react/menu-label';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu
|
<WaMenu
|
||||||
style={{
|
style={{ maxWidth: '240px' }}
|
||||||
maxWidth: '240px',
|
|
||||||
border: 'solid 1px var(--sl-panel-border-color)',
|
|
||||||
borderRadius: 'var(--sl-border-radius-medium)'
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<SlMenuLabel>Messages</SlMenuLabel>
|
<WaMenuLabel>Messages</WaMenuLabel>
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Comments
|
Comments
|
||||||
<SlBadge slot="suffix" variant="neutral" pill>
|
<WaBadge slot="suffix" variant="neutral" pill>
|
||||||
4
|
4
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Replies
|
Replies
|
||||||
<SlBadge slot="suffix" variant="neutral" pill>
|
<WaBadge slot="suffix" variant="neutral" pill>
|
||||||
12
|
12
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -6,30 +6,30 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item>
|
<wa-breadcrumb-item>
|
||||||
<sl-icon slot="prefix" name="house"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
Home
|
Home
|
||||||
</sl-breadcrumb-item>
|
</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Clothing</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Clothing</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Shirts</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Shirts</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem>
|
<WaBreadcrumbItem>
|
||||||
<SlIcon slot="prefix" name="house"></SlIcon>
|
<WaIcon slot="prefix" name="house"></WaIcon>
|
||||||
Home
|
Home
|
||||||
</SlBreadcrumbItem>
|
</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Clothing</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Clothing</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Shirts</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Shirts</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,25 @@ layout: component
|
|||||||
Breadcrumbs are usually placed before a page's main content with the current page shown last to indicate the user's position in the navigation.
|
Breadcrumbs are usually placed before a page's main content with the current page shown last to indicate the user's position in the navigation.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item>Catalog</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Catalog</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Clothing</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Clothing</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Women's</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Women's</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Shirts & Tops</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Shirts & Tops</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem>Catalog</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Catalog</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Clothing</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Clothing</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Women's</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Women's</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Shirts & Tops</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Shirts & Tops</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -39,31 +39,31 @@ By default, breadcrumb items are rendered as buttons so you can use them to navi
|
|||||||
For websites, you'll probably want to use links instead. You can make any breadcrumb item a link by applying an `href` attribute to it. Now, when the user activates it, they'll be taken to the corresponding page — no event listeners required.
|
For websites, you'll probably want to use links instead. You can make any breadcrumb item a link by applying an `href` attribute to it. Now, when the user activates it, they'll be taken to the corresponding page — no event listeners required.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item href="https://example.com/home">Homepage</sl-breadcrumb-item>
|
<wa-breadcrumb-item href="https://example.com/home">Homepage</wa-breadcrumb-item>
|
||||||
|
|
||||||
<sl-breadcrumb-item href="https://example.com/home/services">Our Services</sl-breadcrumb-item>
|
<wa-breadcrumb-item href="https://example.com/home/services">Our Services</wa-breadcrumb-item>
|
||||||
|
|
||||||
<sl-breadcrumb-item href="https://example.com/home/services/digital">Digital Media</sl-breadcrumb-item>
|
<wa-breadcrumb-item href="https://example.com/home/services/digital">Digital Media</wa-breadcrumb-item>
|
||||||
|
|
||||||
<sl-breadcrumb-item href="https://example.com/home/services/digital/web-design">Web Design</sl-breadcrumb-item>
|
<wa-breadcrumb-item href="https://example.com/home/services/digital/web-design">Web Design</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem href="https://example.com/home">Homepage</SlBreadcrumbItem>
|
<WaBreadcrumbItem href="https://example.com/home">Homepage</WaBreadcrumbItem>
|
||||||
|
|
||||||
<SlBreadcrumbItem href="https://example.com/home/services">Our Services</SlBreadcrumbItem>
|
<WaBreadcrumbItem href="https://example.com/home/services">Our Services</WaBreadcrumbItem>
|
||||||
|
|
||||||
<SlBreadcrumbItem href="https://example.com/home/services/digital">Digital Media</SlBreadcrumbItem>
|
<WaBreadcrumbItem href="https://example.com/home/services/digital">Digital Media</WaBreadcrumbItem>
|
||||||
|
|
||||||
<SlBreadcrumbItem href="https://example.com/home/services/digital/web-design">Web Design</SlBreadcrumbItem>
|
<WaBreadcrumbItem href="https://example.com/home/services/digital/web-design">Web Design</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -72,63 +72,63 @@ const App = () => (
|
|||||||
Use the `separator` slot to change the separator that goes between breadcrumb items. Icons work well, but you can also use text or an image.
|
Use the `separator` slot to change the separator that goes between breadcrumb items. Icons work well, but you can also use text or an image.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-icon name="dot" slot="separator"></sl-icon>
|
<wa-icon slot="separator" name="angles-right" variant="solid"></wa-icon>
|
||||||
<sl-breadcrumb-item>First</sl-breadcrumb-item>
|
<wa-breadcrumb-item>First</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Second</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Second</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Third</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Third</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-icon name="arrow-right" slot="separator"></sl-icon>
|
<wa-icon slot="separator" name="arrow-right" variant="solid"></wa-icon>
|
||||||
<sl-breadcrumb-item>First</sl-breadcrumb-item>
|
<wa-breadcrumb-item>First</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Second</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Second</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Third</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Third</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<span slot="separator">/</span>
|
<span slot="separator">/</span>
|
||||||
<sl-breadcrumb-item>First</sl-breadcrumb-item>
|
<wa-breadcrumb-item>First</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Second</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Second</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Third</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Third</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import '@shoelace-style/shoelace/dist/components/icon/icon.js';
|
import '@shoelace-style/shoelace/dist/components/icon/icon.js';
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<sl-icon name="dot" slot="separator" />
|
<wa-icon slot="separator" name="angles-right" variant="solid" />
|
||||||
<SlBreadcrumbItem>First</SlBreadcrumbItem>
|
<WaBreadcrumbItem>First</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Second</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Second</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Third</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Third</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<sl-icon name="arrow-right" slot="separator" />
|
<wa-icon slot="separator" name="arrow-right" variant="solid" />
|
||||||
<SlBreadcrumbItem>First</SlBreadcrumbItem>
|
<WaBreadcrumbItem>First</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Second</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Second</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Third</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Third</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<span slot="separator">/</span>
|
<span slot="separator">/</span>
|
||||||
<SlBreadcrumbItem>First</SlBreadcrumbItem>
|
<WaBreadcrumbItem>First</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Second</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Second</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Third</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Third</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -138,30 +138,30 @@ const App = () => (
|
|||||||
Use the `prefix` slot to add content before any breadcrumb item.
|
Use the `prefix` slot to add content before any breadcrumb item.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item>
|
<wa-breadcrumb-item>
|
||||||
<sl-icon slot="prefix" name="house"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
Home
|
Home
|
||||||
</sl-breadcrumb-item>
|
</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Articles</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Articles</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Traveling</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Traveling</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem>
|
<WaBreadcrumbItem>
|
||||||
<SlIcon slot="prefix" name="house" />
|
<WaIcon slot="prefix" name="house" variant="solid" />
|
||||||
Home
|
Home
|
||||||
</SlBreadcrumbItem>
|
</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Articles</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Articles</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Traveling</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Traveling</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -170,30 +170,30 @@ const App = () => (
|
|||||||
Use the `suffix` slot to add content after any breadcrumb item.
|
Use the `suffix` slot to add content after any breadcrumb item.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item>Documents</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Documents</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Policies</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Policies</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>
|
<wa-breadcrumb-item>
|
||||||
Security
|
Security
|
||||||
<sl-icon slot="suffix" name="shield-lock"></sl-icon>
|
<wa-icon slot="suffix" name="shield" variant="solid"></wa-icon>
|
||||||
</sl-breadcrumb-item>
|
</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBreadcrumb from '@shoelace-style/shoelace/dist/react/sl-breadcrumb';
|
import WaBreadcrumb from '@shoelace-style/shoelace/dist/react/breadcrumb';
|
||||||
import SlBreadcrumbItem from '@shoelace-style/shoelace/dist/react/sl-breadcrumb-item';
|
import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-item';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem>Documents</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Documents</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Policies</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Policies</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>
|
<WaBreadcrumbItem>
|
||||||
Security
|
Security
|
||||||
<SlIcon slot="suffix" name="shield-lock"></SlIcon>
|
<WaIcon slot="suffix" name="shield" variant="solid"></WaIcon>
|
||||||
</SlBreadcrumbItem>
|
</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -202,57 +202,57 @@ const App = () => (
|
|||||||
Dropdown menus can be placed in a prefix or suffix slot to provide additional options.
|
Dropdown menus can be placed in a prefix or suffix slot to provide additional options.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-breadcrumb>
|
<wa-breadcrumb>
|
||||||
<sl-breadcrumb-item>Homepage</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Homepage</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Our Services</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Our Services</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>Digital Media</sl-breadcrumb-item>
|
<wa-breadcrumb-item>Digital Media</wa-breadcrumb-item>
|
||||||
<sl-breadcrumb-item>
|
<wa-breadcrumb-item>
|
||||||
Web Design
|
Web Design
|
||||||
<sl-dropdown slot="suffix">
|
<wa-dropdown slot="suffix">
|
||||||
<sl-button slot="trigger" size="small" circle>
|
<wa-button slot="trigger" size="small" pill>
|
||||||
<sl-icon label="More options" name="three-dots"></sl-icon>
|
<wa-icon label="More options" name="ellipsis" variant="solid"></wa-icon>
|
||||||
</sl-button>
|
</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item type="checkbox" checked>Web Design</sl-menu-item>
|
<wa-menu-item type="checkbox" checked>Web Design</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox">Web Development</sl-menu-item>
|
<wa-menu-item type="checkbox">Web Development</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox">Marketing</sl-menu-item>
|
<wa-menu-item type="checkbox">Marketing</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</sl-breadcrumb-item>
|
</wa-breadcrumb-item>
|
||||||
</sl-breadcrumb>
|
</wa-breadcrumb>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import {
|
import {
|
||||||
SlBreadcrumb,
|
WaBreadcrumb,
|
||||||
SlBreadcrumbItem,
|
WaBreadcrumbItem,
|
||||||
SlButton,
|
WaButton,
|
||||||
SlDropdown,
|
WaDropdown,
|
||||||
SlIcon,
|
WaIcon,
|
||||||
SlMenu,
|
WaMenu,
|
||||||
SlMenuItem
|
WaMenuItem
|
||||||
} from '@shoelace-style/shoelace/dist/react';
|
} from '@shoelace-style/shoelace/dist/react';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlBreadcrumb>
|
<WaBreadcrumb>
|
||||||
<SlBreadcrumbItem>Homepage</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Homepage</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Our Services</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Our Services</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>Digital Media</SlBreadcrumbItem>
|
<WaBreadcrumbItem>Digital Media</WaBreadcrumbItem>
|
||||||
<SlBreadcrumbItem>
|
<WaBreadcrumbItem>
|
||||||
Web Design
|
Web Design
|
||||||
<SlDropdown slot="suffix">
|
<WaDropdown slot="suffix">
|
||||||
<SlButton slot="trigger" size="small" circle>
|
<WaButton slot="trigger" size="small" pill>
|
||||||
<SlIcon label="More options" name="three-dots"></SlIcon>
|
<WaIcon label="More options" name="ellipsis"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem type="checkbox" checked>
|
<WaMenuItem type="checkbox" checked>
|
||||||
Web Design
|
Web Design
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem type="checkbox">Web Development</SlMenuItem>
|
<WaMenuItem type="checkbox">Web Development</WaMenuItem>
|
||||||
<SlMenuItem type="checkbox">Marketing</SlMenuItem>
|
<WaMenuItem type="checkbox">Marketing</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
</SlBreadcrumbItem>
|
</WaBreadcrumbItem>
|
||||||
</SlBreadcrumb>
|
</WaBreadcrumb>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button>Left</sl-button>
|
<wa-button>Left</wa-button>
|
||||||
<sl-button>Center</sl-button>
|
<wa-button>Center</wa-button>
|
||||||
<sl-button>Right</sl-button>
|
<wa-button>Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton>Left</SlButton>
|
<WaButton>Left</WaButton>
|
||||||
<SlButton>Center</SlButton>
|
<WaButton>Center</WaButton>
|
||||||
<SlButton>Right</SlButton>
|
<WaButton>Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -33,58 +33,58 @@ const App = () => (
|
|||||||
All button sizes are supported, but avoid mixing sizes within the same button group.
|
All button sizes are supported, but avoid mixing sizes within the same button group.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="small">Left</sl-button>
|
<wa-button size="small">Left</wa-button>
|
||||||
<sl-button size="small">Center</sl-button>
|
<wa-button size="small">Center</wa-button>
|
||||||
<sl-button size="small">Right</sl-button>
|
<wa-button size="small">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="medium">Left</sl-button>
|
<wa-button size="medium">Left</wa-button>
|
||||||
<sl-button size="medium">Center</sl-button>
|
<wa-button size="medium">Center</wa-button>
|
||||||
<sl-button size="medium">Right</sl-button>
|
<wa-button size="medium">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="large">Left</sl-button>
|
<wa-button size="large">Left</wa-button>
|
||||||
<sl-button size="large">Center</sl-button>
|
<wa-button size="large">Center</wa-button>
|
||||||
<sl-button size="large">Right</sl-button>
|
<wa-button size="large">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="small">Left</SlButton>
|
<WaButton size="small">Left</WaButton>
|
||||||
<SlButton size="small">Center</SlButton>
|
<WaButton size="small">Center</WaButton>
|
||||||
<SlButton size="small">Right</SlButton>
|
<WaButton size="small">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="medium">Left</SlButton>
|
<WaButton size="medium">Left</WaButton>
|
||||||
<SlButton size="medium">Center</SlButton>
|
<WaButton size="medium">Center</WaButton>
|
||||||
<SlButton size="medium">Right</SlButton>
|
<WaButton size="medium">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="large">Left</SlButton>
|
<WaButton size="large">Left</WaButton>
|
||||||
<SlButton size="large">Center</SlButton>
|
<WaButton size="large">Center</WaButton>
|
||||||
<SlButton size="large">Right</SlButton>
|
<WaButton size="large">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -94,92 +94,92 @@ const App = () => (
|
|||||||
Theme buttons are supported through the button's `variant` attribute.
|
Theme buttons are supported through the button's `variant` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button variant="primary">Left</sl-button>
|
<wa-button variant="brand">Left</wa-button>
|
||||||
<sl-button variant="primary">Center</sl-button>
|
<wa-button variant="brand">Center</wa-button>
|
||||||
<sl-button variant="primary">Right</sl-button>
|
<wa-button variant="brand">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button variant="success">Left</sl-button>
|
<wa-button variant="success">Left</wa-button>
|
||||||
<sl-button variant="success">Center</sl-button>
|
<wa-button variant="success">Center</wa-button>
|
||||||
<sl-button variant="success">Right</sl-button>
|
<wa-button variant="success">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button variant="neutral">Left</sl-button>
|
<wa-button>Left</wa-button>
|
||||||
<sl-button variant="neutral">Center</sl-button>
|
<wa-button>Center</wa-button>
|
||||||
<sl-button variant="neutral">Right</sl-button>
|
<wa-button>Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button variant="warning">Left</sl-button>
|
<wa-button variant="warning">Left</wa-button>
|
||||||
<sl-button variant="warning">Center</sl-button>
|
<wa-button variant="warning">Center</wa-button>
|
||||||
<sl-button variant="warning">Right</sl-button>
|
<wa-button variant="warning">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button variant="danger">Left</sl-button>
|
<wa-button variant="danger">Left</wa-button>
|
||||||
<sl-button variant="danger">Center</sl-button>
|
<wa-button variant="danger">Center</wa-button>
|
||||||
<sl-button variant="danger">Right</sl-button>
|
<wa-button variant="danger">Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton variant="primary">Left</SlButton>
|
<WaButton variant="brand">Left</WaButton>
|
||||||
<SlButton variant="primary">Center</SlButton>
|
<WaButton variant="brand">Center</WaButton>
|
||||||
<SlButton variant="primary">Right</SlButton>
|
<WaButton variant="brand">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton variant="success">Left</SlButton>
|
<WaButton variant="success">Left</WaButton>
|
||||||
<SlButton variant="success">Center</SlButton>
|
<WaButton variant="success">Center</WaButton>
|
||||||
<SlButton variant="success">Right</SlButton>
|
<WaButton variant="success">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton variant="neutral">Left</SlButton>
|
<WaButton>Left</WaButton>
|
||||||
<SlButton variant="neutral">Center</SlButton>
|
<WaButton>Center</WaButton>
|
||||||
<SlButton variant="neutral">Right</SlButton>
|
<WaButton>Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton variant="warning">Left</SlButton>
|
<WaButton variant="warning">Left</WaButton>
|
||||||
<SlButton variant="warning">Center</SlButton>
|
<WaButton variant="warning">Center</WaButton>
|
||||||
<SlButton variant="warning">Right</SlButton>
|
<WaButton variant="warning">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton variant="danger">Left</SlButton>
|
<WaButton variant="danger">Left</WaButton>
|
||||||
<SlButton variant="danger">Center</SlButton>
|
<WaButton variant="danger">Center</WaButton>
|
||||||
<SlButton variant="danger">Right</SlButton>
|
<WaButton variant="danger">Right</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -189,121 +189,121 @@ const App = () => (
|
|||||||
Pill buttons are supported through the button's `pill` attribute.
|
Pill buttons are supported through the button's `pill` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="small" pill>Left</sl-button>
|
<wa-button size="small" pill>Left</wa-button>
|
||||||
<sl-button size="small" pill>Center</sl-button>
|
<wa-button size="small" pill>Center</wa-button>
|
||||||
<sl-button size="small" pill>Right</sl-button>
|
<wa-button size="small" pill>Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="medium" pill>Left</sl-button>
|
<wa-button size="medium" pill>Left</wa-button>
|
||||||
<sl-button size="medium" pill>Center</sl-button>
|
<wa-button size="medium" pill>Center</wa-button>
|
||||||
<sl-button size="medium" pill>Right</sl-button>
|
<wa-button size="medium" pill>Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-button size="large" pill>Left</sl-button>
|
<wa-button size="large" pill>Left</wa-button>
|
||||||
<sl-button size="large" pill>Center</sl-button>
|
<wa-button size="large" pill>Center</wa-button>
|
||||||
<sl-button size="large" pill>Right</sl-button>
|
<wa-button size="large" pill>Right</wa-button>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="small" pill>
|
<WaButton size="small" pill>
|
||||||
Left
|
Left
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="small" pill>
|
<WaButton size="small" pill>
|
||||||
Center
|
Center
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="small" pill>
|
<WaButton size="small" pill>
|
||||||
Right
|
Right
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="medium" pill>
|
<WaButton size="medium" pill>
|
||||||
Left
|
Left
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="medium" pill>
|
<WaButton size="medium" pill>
|
||||||
Center
|
Center
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="medium" pill>
|
<WaButton size="medium" pill>
|
||||||
Right
|
Right
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlButton size="large" pill>
|
<WaButton size="large" pill>
|
||||||
Left
|
Left
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="large" pill>
|
<WaButton size="large" pill>
|
||||||
Center
|
Center
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="large" pill>
|
<WaButton size="large" pill>
|
||||||
Right
|
Right
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Dropdowns in Button Groups
|
### Dropdowns in Button Groups
|
||||||
|
|
||||||
Dropdowns can be placed inside button groups as long as the trigger is an `<sl-button>` element.
|
Dropdowns can be placed inside button groups as long as the trigger is an `<wa-button>` element.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Example Button Group">
|
<wa-button-group label="Example Button Group">
|
||||||
<sl-button>Button</sl-button>
|
<wa-button>Button</wa-button>
|
||||||
<sl-button>Button</sl-button>
|
<wa-button>Button</wa-button>
|
||||||
<sl-dropdown>
|
<wa-dropdown>
|
||||||
<sl-button slot="trigger" caret>Dropdown</sl-button>
|
<wa-button slot="trigger" caret>Dropdown</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Item 1</sl-menu-item>
|
<wa-menu-item>Item 1</wa-menu-item>
|
||||||
<sl-menu-item>Item 2</sl-menu-item>
|
<wa-menu-item>Item 2</wa-menu-item>
|
||||||
<sl-menu-item>Item 3</sl-menu-item>
|
<wa-menu-item>Item 3</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlButtonGroup label="Example Button Group">
|
<WaButtonGroup label="Example Button Group">
|
||||||
<SlButton>Button</SlButton>
|
<WaButton>Button</WaButton>
|
||||||
<SlButton>Button</SlButton>
|
<WaButton>Button</WaButton>
|
||||||
<SlDropdown>
|
<WaDropdown>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Dropdown
|
Dropdown
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Item 1</SlMenuItem>
|
<WaMenuItem>Item 1</WaMenuItem>
|
||||||
<SlMenuItem>Item 2</SlMenuItem>
|
<WaMenuItem>Item 2</WaMenuItem>
|
||||||
<SlMenuItem>Item 3</SlMenuItem>
|
<WaMenuItem>Item 3</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -312,40 +312,40 @@ const App = () => (
|
|||||||
Create a split button using a button and a dropdown. Use a [visually hidden](/components/visually-hidden) label to ensure the dropdown is accessible to users with assistive devices.
|
Create a split button using a button and a dropdown. Use a [visually hidden](/components/visually-hidden) label to ensure the dropdown is accessible to users with assistive devices.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Example Button Group">
|
<wa-button-group label="Example Button Group">
|
||||||
<sl-button variant="primary">Save</sl-button>
|
<wa-button variant="brand">Save</wa-button>
|
||||||
<sl-dropdown placement="bottom-end">
|
<wa-dropdown placement="bottom-end">
|
||||||
<sl-button slot="trigger" variant="primary" caret>
|
<wa-button slot="trigger" variant="brand" caret>
|
||||||
<sl-visually-hidden>More options</sl-visually-hidden>
|
<wa-visually-hidden>More options</wa-visually-hidden>
|
||||||
</sl-button>
|
</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Save</sl-menu-item>
|
<wa-menu-item>Save</wa-menu-item>
|
||||||
<sl-menu-item>Save as…</sl-menu-item>
|
<wa-menu-item>Save as…</wa-menu-item>
|
||||||
<sl-menu-item>Save all</sl-menu-item>
|
<wa-menu-item>Save all</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlButtonGroup label="Example Button Group">
|
<WaButtonGroup label="Example Button Group">
|
||||||
<SlButton variant="primary">Save</SlButton>
|
<WaButton variant="brand">Save</WaButton>
|
||||||
<SlDropdown placement="bottom-end">
|
<WaDropdown placement="bottom-end">
|
||||||
<SlButton slot="trigger" variant="primary" caret></SlButton>
|
<WaButton slot="trigger" variant="brand" caret></WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Save</SlMenuItem>
|
<WaMenuItem>Save</WaMenuItem>
|
||||||
<SlMenuItem>Save as…</SlMenuItem>
|
<WaMenuItem>Save as…</WaMenuItem>
|
||||||
<SlMenuItem>Save all</SlMenuItem>
|
<WaMenuItem>Save all</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -354,41 +354,41 @@ const App = () => (
|
|||||||
Buttons can be wrapped in tooltips to provide more detail when the user interacts with them.
|
Buttons can be wrapped in tooltips to provide more detail when the user interacts with them.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-tooltip content="I'm on the left">
|
<wa-tooltip content="I'm on the left">
|
||||||
<sl-button>Left</sl-button>
|
<wa-button>Left</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="I'm in the middle">
|
<wa-tooltip content="I'm in the middle">
|
||||||
<sl-button>Center</sl-button>
|
<wa-button>Center</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="I'm on the right">
|
<wa-tooltip content="I'm on the right">
|
||||||
<sl-button>Right</sl-button>
|
<wa-button>Right</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlTooltip content="I'm on the left">
|
<WaTooltip content="I'm on the left">
|
||||||
<SlButton>Left</SlButton>
|
<WaButton>Left</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="I'm in the middle">
|
<WaTooltip content="I'm in the middle">
|
||||||
<SlButton>Center</SlButton>
|
<WaButton>Center</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="I'm on the right">
|
<WaTooltip content="I'm on the right">
|
||||||
<SlButton>Right</SlButton>
|
<WaButton>Right</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -399,110 +399,110 @@ Create interactive toolbars with button groups.
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="button-group-toolbar">
|
<div class="button-group-toolbar">
|
||||||
<sl-button-group label="History">
|
<wa-button-group label="History">
|
||||||
<sl-tooltip content="Undo">
|
<wa-tooltip content="Undo">
|
||||||
<sl-button><sl-icon name="arrow-counterclockwise" label="Undo"></sl-icon></sl-button>
|
<wa-button><wa-icon name="undo" variant="solid" label="Undo"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
<sl-tooltip content="Redo">
|
<wa-tooltip content="Redo">
|
||||||
<sl-button><sl-icon name="arrow-clockwise" label="Redo"></sl-icon></sl-button>
|
<wa-button><wa-icon name="redo" variant="solid" label="Redo"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<sl-button-group label="Formatting">
|
<wa-button-group label="Formatting">
|
||||||
<sl-tooltip content="Bold">
|
<wa-tooltip content="Bold">
|
||||||
<sl-button><sl-icon name="type-bold" label="Bold"></sl-icon></sl-button>
|
<wa-button><wa-icon name="bold" variant="solid" label="Bold"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
<sl-tooltip content="Italic">
|
<wa-tooltip content="Italic">
|
||||||
<sl-button><sl-icon name="type-italic" label="Italic"></sl-icon></sl-button>
|
<wa-button><wa-icon name="italic" variant="solid" label="Italic"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
<sl-tooltip content="Underline">
|
<wa-tooltip content="Underline">
|
||||||
<sl-button><sl-icon name="type-underline" label="Underline"></sl-icon></sl-button>
|
<wa-button><wa-icon name="underline" variant="solid" label="Underline"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
|
|
||||||
<sl-button-group label="Alignment">
|
<wa-button-group label="Alignment">
|
||||||
<sl-tooltip content="Align Left">
|
<wa-tooltip content="Align Left">
|
||||||
<sl-button><sl-icon name="justify-left" label="Align Left"></sl-icon></sl-button>
|
<wa-button><wa-icon name="align-left" variant="solid" label="Align Left"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
<sl-tooltip content="Align Center">
|
<wa-tooltip content="Align Center">
|
||||||
<sl-button><sl-icon name="justify" label="Align Center"></sl-icon></sl-button>
|
<wa-button><wa-icon name="align-center" variant="solid" label="Align Center"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
<sl-tooltip content="Align Right">
|
<wa-tooltip content="Align Right">
|
||||||
<sl-button><sl-icon name="justify-right" label="Align Right"></sl-icon></sl-button>
|
<wa-button><wa-icon name="align-right" variant="solid" label="Align Right"></wa-icon></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</sl-button-group>
|
</wa-button-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.button-group-toolbar sl-button-group:not(:last-of-type) {
|
.button-group-toolbar wa-button-group:not(:last-of-type) {
|
||||||
margin-right: var(--sl-spacing-x-small);
|
margin-right: var(--wa-space-xs);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlButtonGroup from '@shoelace-style/shoelace/dist/react/sl-button-group';
|
import WaButtonGroup from '@shoelace-style/shoelace/dist/react/button-group';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.button-group-toolbar sl-button-group:not(:last-of-type) {
|
.button-group-toolbar wa-button-group:not(:last-of-type) {
|
||||||
margin-right: var(--sl-spacing-x-small);
|
margin-right: var(--wa-space-xs);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="button-group-toolbar">
|
<div className="button-group-toolbar">
|
||||||
<SlButtonGroup label="History">
|
<WaButtonGroup label="History">
|
||||||
<SlTooltip content="Undo">
|
<WaTooltip content="Undo">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="arrow-counterclockwise"></SlIcon>
|
<WaIcon name="undo" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
<SlTooltip content="Redo">
|
<WaTooltip content="Redo">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="arrow-clockwise"></SlIcon>
|
<WaIcon name="redo" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<SlButtonGroup label="Formatting">
|
<WaButtonGroup label="Formatting">
|
||||||
<SlTooltip content="Bold">
|
<WaTooltip content="Bold">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="type-bold"></SlIcon>
|
<WaIcon name="bold" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
<SlTooltip content="Italic">
|
<WaTooltip content="Italic">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="type-italic"></SlIcon>
|
<WaIcon name="italic" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
<SlTooltip content="Underline">
|
<WaTooltip content="Underline">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="type-underline"></SlIcon>
|
<WaIcon name="underline" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
|
|
||||||
<SlButtonGroup label="Alignment">
|
<WaButtonGroup label="Alignment">
|
||||||
<SlTooltip content="Align Left">
|
<WaTooltip content="Align Left">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="justify-left"></SlIcon>
|
<WaIcon name="align-left" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
<SlTooltip content="Align Center">
|
<WaTooltip content="Align Center">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="justify"></SlIcon>
|
<WaIcon name="align-center" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
<SlTooltip content="Align Right">
|
<WaTooltip content="Align Right">
|
||||||
<SlButton>
|
<WaButton>
|
||||||
<SlIcon name="justify-right"></SlIcon>
|
<WaIcon name="align-right" variant="solid"></WaIcon>
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</SlButtonGroup>
|
</WaButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button>Button</sl-button>
|
<wa-button>Button</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => <SlButton>Button</SlButton>;
|
const App = () => <WaButton>Button</WaButton>;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,25 +22,23 @@ const App = () => <SlButton>Button</SlButton>;
|
|||||||
Use the `variant` attribute to set the button's variant.
|
Use the `variant` attribute to set the button's variant.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default">Default</sl-button>
|
<wa-button variant="brand">Brand</wa-button>
|
||||||
<sl-button variant="primary">Primary</sl-button>
|
<wa-button variant="success">Success</wa-button>
|
||||||
<sl-button variant="success">Success</sl-button>
|
<wa-button variant="neutral">Neutral</wa-button>
|
||||||
<sl-button variant="neutral">Neutral</sl-button>
|
<wa-button variant="warning">Warning</wa-button>
|
||||||
<sl-button variant="warning">Warning</sl-button>
|
<wa-button variant="danger">Danger</wa-button>
|
||||||
<sl-button variant="danger">Danger</sl-button>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default">Default</SlButton>
|
<WaButton variant="brand">Brand</WaButton>
|
||||||
<SlButton variant="primary">Primary</SlButton>
|
<WaButton variant="success">Success</WaButton>
|
||||||
<SlButton variant="success">Success</SlButton>
|
<WaButton variant="neutral">Neutral</WaButton>
|
||||||
<SlButton variant="neutral">Neutral</SlButton>
|
<WaButton variant="warning">Warning</WaButton>
|
||||||
<SlButton variant="warning">Warning</SlButton>
|
<WaButton variant="danger">Danger</WaButton>
|
||||||
<SlButton variant="danger">Danger</SlButton>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -50,19 +48,19 @@ const App = () => (
|
|||||||
Use the `size` attribute to change a button's size.
|
Use the `size` attribute to change a button's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button size="small">Small</sl-button>
|
<wa-button size="small">Small</wa-button>
|
||||||
<sl-button size="medium">Medium</sl-button>
|
<wa-button size="medium">Medium</wa-button>
|
||||||
<sl-button size="large">Large</sl-button>
|
<wa-button size="large">Large</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton size="small">Small</SlButton>
|
<WaButton size="small">Small</WaButton>
|
||||||
<SlButton size="medium">Medium</SlButton>
|
<WaButton size="medium">Medium</WaButton>
|
||||||
<SlButton size="large">Large</SlButton>
|
<WaButton size="large">Large</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -72,37 +70,33 @@ const App = () => (
|
|||||||
Use the `outline` attribute to draw outlined buttons with transparent backgrounds.
|
Use the `outline` attribute to draw outlined buttons with transparent backgrounds.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default" outline>Default</sl-button>
|
<wa-button variant="brand" outline>Brand</wa-button>
|
||||||
<sl-button variant="primary" outline>Primary</sl-button>
|
<wa-button variant="success" outline>Success</wa-button>
|
||||||
<sl-button variant="success" outline>Success</sl-button>
|
<wa-button variant="neutral" outline>Neutral</wa-button>
|
||||||
<sl-button variant="neutral" outline>Neutral</sl-button>
|
<wa-button variant="warning" outline>Warning</wa-button>
|
||||||
<sl-button variant="warning" outline>Warning</sl-button>
|
<wa-button variant="danger" outline>Danger</wa-button>
|
||||||
<sl-button variant="danger" outline>Danger</sl-button>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default" outline>
|
<WaButton variant="brand" outline>
|
||||||
Default
|
Brand
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="primary" outline>
|
<WaButton variant="success" outline>
|
||||||
Primary
|
|
||||||
</SlButton>
|
|
||||||
<SlButton variant="success" outline>
|
|
||||||
Success
|
Success
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="neutral" outline>
|
<WaButton variant="neutral" outline>
|
||||||
Neutral
|
Neutral
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="warning" outline>
|
<WaButton variant="warning" outline>
|
||||||
Warning
|
Warning
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="danger" outline>
|
<WaButton variant="danger" outline>
|
||||||
Danger
|
Danger
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -112,62 +106,25 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give buttons rounded edges.
|
Use the `pill` attribute to give buttons rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button size="small" pill>Small</sl-button>
|
<wa-button size="small" pill>Small</wa-button>
|
||||||
<sl-button size="medium" pill>Medium</sl-button>
|
<wa-button size="medium" pill>Medium</wa-button>
|
||||||
<sl-button size="large" pill>Large</sl-button>
|
<wa-button size="large" pill>Large</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton size="small" pill>
|
<WaButton size="small" pill>
|
||||||
Small
|
Small
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="medium" pill>
|
<WaButton size="medium" pill>
|
||||||
Medium
|
Medium
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="large" pill>
|
<WaButton size="large" pill>
|
||||||
Large
|
Large
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Circle Buttons
|
|
||||||
|
|
||||||
Use the `circle` attribute to create circular icon buttons. When this attribute is set, the button expects a single `<sl-icon>` in the default slot.
|
|
||||||
|
|
||||||
```html:preview
|
|
||||||
<sl-button variant="default" size="small" circle>
|
|
||||||
<sl-icon name="gear" label="Settings"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
|
|
||||||
<sl-button variant="default" size="medium" circle>
|
|
||||||
<sl-icon name="gear" label="Settings"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
|
|
||||||
<sl-button variant="default" size="large" circle>
|
|
||||||
<sl-icon name="gear" label="Settings"></sl-icon>
|
|
||||||
</sl-button>
|
|
||||||
```
|
|
||||||
|
|
||||||
```jsx:react
|
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
|
||||||
|
|
||||||
const App = () => (
|
|
||||||
<>
|
|
||||||
<SlButton variant="default" size="small" circle>
|
|
||||||
<SlIcon name="gear" />
|
|
||||||
</SlButton>
|
|
||||||
<SlButton variant="default" size="medium" circle>
|
|
||||||
<SlIcon name="gear" />
|
|
||||||
</SlButton>
|
|
||||||
<SlButton variant="default" size="large" circle>
|
|
||||||
<SlIcon name="gear" />
|
|
||||||
</SlButton>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -177,25 +134,25 @@ const App = () => (
|
|||||||
Use the `text` variant to create text buttons that share the same size as regular buttons but don't have backgrounds or borders.
|
Use the `text` variant to create text buttons that share the same size as regular buttons but don't have backgrounds or borders.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="text" size="small">Text</sl-button>
|
<wa-button variant="text" size="small">Text</wa-button>
|
||||||
<sl-button variant="text" size="medium">Text</sl-button>
|
<wa-button variant="text" size="medium">Text</wa-button>
|
||||||
<sl-button variant="text" size="large">Text</sl-button>
|
<wa-button variant="text" size="large">Text</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="text" size="small">
|
<WaButton variant="text" size="small">
|
||||||
Text
|
Text
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="text" size="medium">
|
<WaButton variant="text" size="medium">
|
||||||
Text
|
Text
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="text" size="large">
|
<WaButton variant="text" size="large">
|
||||||
Text
|
Text
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -205,27 +162,27 @@ const App = () => (
|
|||||||
It's often helpful to have a button that works like a link. This is possible by setting the `href` attribute, which will make the component render an `<a>` under the hood. This gives you all the default link behavior the browser provides (e.g. [[CMD/CTRL/SHIFT]] + [[CLICK]]) and exposes the `target` and `download` attributes.
|
It's often helpful to have a button that works like a link. This is possible by setting the `href` attribute, which will make the component render an `<a>` under the hood. This gives you all the default link behavior the browser provides (e.g. [[CMD/CTRL/SHIFT]] + [[CLICK]]) and exposes the `target` and `download` attributes.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button href="https://example.com/">Link</sl-button>
|
<wa-button href="https://example.com/">Link</wa-button>
|
||||||
<sl-button href="https://example.com/" target="_blank">New Window</sl-button>
|
<wa-button href="https://example.com/" target="_blank">New Window</wa-button>
|
||||||
<sl-button href="/assets/images/wordmark.svg" download="shoelace.svg">Download</sl-button>
|
<wa-button href="/assets/images/logo.svg" download="shoelace.svg">Download</wa-button>
|
||||||
<sl-button href="https://example.com/" disabled>Disabled</sl-button>
|
<wa-button href="https://example.com/" disabled>Disabled</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton href="https://example.com/">Link</SlButton>
|
<WaButton href="https://example.com/">Link</WaButton>
|
||||||
<SlButton href="https://example.com/" target="_blank">
|
<WaButton href="https://example.com/" target="_blank">
|
||||||
New Window
|
New Window
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton href="/assets/images/wordmark.svg" download="shoelace.svg">
|
<WaButton href="/assets/images/logo.svg" download="shoelace.svg">
|
||||||
Download
|
Download
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton href="https://example.com/" disabled>
|
<WaButton href="https://example.com/" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -239,27 +196,27 @@ When a `target` is set, the link will receive `rel="noreferrer noopener"` for [s
|
|||||||
As expected, buttons can be given a custom width by setting the `width` attribute. This is useful for making buttons span the full width of their container on smaller screens.
|
As expected, buttons can be given a custom width by setting the `width` attribute. This is useful for making buttons span the full width of their container on smaller screens.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default" size="small" style="width: 100%; margin-bottom: 1rem;">Small</sl-button>
|
<wa-button size="small" style="width: 100%; margin-bottom: 1rem;">Small</wa-button>
|
||||||
<sl-button variant="default" size="medium" style="width: 100%; margin-bottom: 1rem;">Medium</sl-button>
|
<wa-button size="medium" style="width: 100%; margin-bottom: 1rem;">Medium</wa-button>
|
||||||
<sl-button variant="default" size="large" style="width: 100%;">Large</sl-button>
|
<wa-button size="large" style="width: 100%;">Large</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default" size="small" style={{ width: '100%', marginBottom: '1rem' }}>
|
<WaButton size="small" style={{ width: '100%', marginBottom: '1rem' }}>
|
||||||
Small
|
Small
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="default" size="medium" style={{ width: '100%', marginBottom: '1rem' }}>
|
<WaButton size="medium" style={{ width: '100%', marginBottom: '1rem' }}>
|
||||||
Medium
|
Medium
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="default" size="large" style={{ width: '100%' }}>
|
<WaButton size="large" style={{ width: '100%' }}>
|
||||||
Large
|
Large
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -271,118 +228,118 @@ const App = () => (
|
|||||||
Use the `prefix` and `suffix` slots to add icons.
|
Use the `prefix` and `suffix` slots to add icons.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default" size="small">
|
<wa-button size="small">
|
||||||
<sl-icon slot="prefix" name="gear"></sl-icon>
|
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
|
||||||
Settings
|
Settings
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default" size="small">
|
<wa-button size="small">
|
||||||
<sl-icon slot="suffix" name="arrow-counterclockwise"></sl-icon>
|
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
|
||||||
Refresh
|
Refresh
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default" size="small">
|
<wa-button size="small">
|
||||||
<sl-icon slot="prefix" name="link-45deg"></sl-icon>
|
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
|
||||||
<sl-icon slot="suffix" name="box-arrow-up-right"></sl-icon>
|
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
|
||||||
Open
|
Open
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button variant="default">
|
<wa-button>
|
||||||
<sl-icon slot="prefix" name="gear"></sl-icon>
|
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
|
||||||
Settings
|
Settings
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default">
|
<wa-button>
|
||||||
<sl-icon slot="suffix" name="arrow-counterclockwise"></sl-icon>
|
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
|
||||||
Refresh
|
Refresh
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default">
|
<wa-button>
|
||||||
<sl-icon slot="prefix" name="link-45deg"></sl-icon>
|
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
|
||||||
<sl-icon slot="suffix" name="box-arrow-up-right"></sl-icon>
|
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
|
||||||
Open
|
Open
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<sl-button variant="default" size="large">
|
<wa-button size="large">
|
||||||
<sl-icon slot="prefix" name="gear"></sl-icon>
|
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
|
||||||
Settings
|
Settings
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default" size="large">
|
<wa-button size="large">
|
||||||
<sl-icon slot="suffix" name="arrow-counterclockwise"></sl-icon>
|
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
|
||||||
Refresh
|
Refresh
|
||||||
</sl-button>
|
</wa-button>
|
||||||
|
|
||||||
<sl-button variant="default" size="large">
|
<wa-button size="large">
|
||||||
<sl-icon slot="prefix" name="link-45deg"></sl-icon>
|
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
|
||||||
<sl-icon slot="suffix" name="box-arrow-up-right"></sl-icon>
|
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
|
||||||
Open
|
Open
|
||||||
</sl-button>
|
</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default" size="small">
|
<WaButton size="small">
|
||||||
<SlIcon slot="prefix" name="gear"></SlIcon>
|
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
|
||||||
Settings
|
Settings
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default" size="small">
|
<WaButton size="small">
|
||||||
<SlIcon slot="suffix" name="arrow-counterclockwise"></SlIcon>
|
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
|
||||||
Refresh
|
Refresh
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default" size="small">
|
<WaButton size="small">
|
||||||
<SlIcon slot="prefix" name="link-45deg"></SlIcon>
|
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
|
||||||
<SlIcon slot="suffix" name="box-arrow-up-right"></SlIcon>
|
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
|
||||||
Open
|
Open
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButton variant="default">
|
<WaButton>
|
||||||
<SlIcon slot="prefix" name="gear"></SlIcon>
|
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
|
||||||
Settings
|
Settings
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default">
|
<WaButton>
|
||||||
<SlIcon slot="suffix" name="arrow-counterclockwise"></SlIcon>
|
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
|
||||||
Refresh
|
Refresh
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default">
|
<WaButton>
|
||||||
<SlIcon slot="prefix" name="link-45deg"></SlIcon>
|
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
|
||||||
<SlIcon slot="suffix" name="box-arrow-up-right"></SlIcon>
|
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
|
||||||
Open
|
Open
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButton variant="default" size="large">
|
<WaButton size="large">
|
||||||
<SlIcon slot="prefix" name="gear"></SlIcon>
|
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
|
||||||
Settings
|
Settings
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default" size="large">
|
<WaButton size="large">
|
||||||
<SlIcon slot="suffix" name="arrow-counterclockwise"></SlIcon>
|
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
|
||||||
Refresh
|
Refresh
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="default" size="large">
|
<WaButton size="large">
|
||||||
<SlIcon slot="prefix" name="link-45deg"></SlIcon>
|
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
|
||||||
<SlIcon slot="suffix" name="box-arrow-up-right"></SlIcon>
|
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
|
||||||
Open
|
Open
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -392,25 +349,25 @@ const App = () => (
|
|||||||
Use the `caret` attribute to add a dropdown indicator when a button will trigger a dropdown, menu, or popover.
|
Use the `caret` attribute to add a dropdown indicator when a button will trigger a dropdown, menu, or popover.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button size="small" caret>Small</sl-button>
|
<wa-button size="small" caret>Small</wa-button>
|
||||||
<sl-button size="medium" caret>Medium</sl-button>
|
<wa-button size="medium" caret>Medium</wa-button>
|
||||||
<sl-button size="large" caret>Large</sl-button>
|
<wa-button size="large" caret>Large</wa-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton size="small" caret>
|
<WaButton size="small" caret>
|
||||||
Small
|
Small
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="medium" caret>
|
<WaButton size="medium" caret>
|
||||||
Medium
|
Medium
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton size="large" caret>
|
<WaButton size="large" caret>
|
||||||
Large
|
Large
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -420,37 +377,33 @@ const App = () => (
|
|||||||
Use the `loading` attribute to make a button busy. The width will remain the same as before, preventing adjacent elements from moving around. Clicks will be suppressed until the loading state is removed.
|
Use the `loading` attribute to make a button busy. The width will remain the same as before, preventing adjacent elements from moving around. Clicks will be suppressed until the loading state is removed.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default" loading>Default</sl-button>
|
<wa-button variant="brand" loading>Brand</wa-button>
|
||||||
<sl-button variant="primary" loading>Primary</sl-button>
|
<wa-button variant="success" loading>Success</wa-button>
|
||||||
<sl-button variant="success" loading>Success</sl-button>
|
<wa-button variant="neutral" loading>Neutral</wa-button>
|
||||||
<sl-button variant="neutral" loading>Neutral</sl-button>
|
<wa-button variant="warning" loading>Warning</wa-button>
|
||||||
<sl-button variant="warning" loading>Warning</sl-button>
|
<wa-button variant="danger" loading>Danger</wa-button>
|
||||||
<sl-button variant="danger" loading>Danger</sl-button>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default" loading>
|
<WaButton variant="brand" loading>
|
||||||
Default
|
Brand
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="primary" loading>
|
<WaButton variant="success" loading>
|
||||||
Primary
|
|
||||||
</SlButton>
|
|
||||||
<SlButton variant="success" loading>
|
|
||||||
Success
|
Success
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="neutral" loading>
|
<WaButton variant="neutral" loading>
|
||||||
Neutral
|
Neutral
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="warning" loading>
|
<WaButton variant="warning" loading>
|
||||||
Warning
|
Warning
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlButton variant="danger" loading>
|
<WaButton variant="danger" loading>
|
||||||
Danger
|
Danger
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -460,61 +413,53 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable a button.
|
Use the `disabled` attribute to disable a button.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button variant="default" disabled>Default</sl-button>
|
<wa-button variant="brand" disabled>Brand</wa-button>
|
||||||
<sl-button variant="primary" disabled>Primary</sl-button>
|
<wa-button variant="success" disabled>Success</wa-button>
|
||||||
<sl-button variant="success" disabled>Success</sl-button>
|
<wa-button variant="neutral" disabled>Neutral</wa-button>
|
||||||
<sl-button variant="neutral" disabled>Neutral</sl-button>
|
<wa-button variant="warning" disabled>Warning</wa-button>
|
||||||
<sl-button variant="warning" disabled>Warning</sl-button>
|
<wa-button variant="danger" disabled>Danger</wa-button>
|
||||||
<sl-button variant="danger" disabled>Danger</sl-button>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlButton variant="default" disabled>
|
<WaButton variant="brand" disabled>
|
||||||
Default
|
Brand
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="primary" disabled>
|
<WaButton variant="success" disabled>
|
||||||
Primary
|
|
||||||
</SlButton>
|
|
||||||
|
|
||||||
<SlButton variant="success" disabled>
|
|
||||||
Success
|
Success
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="neutral" disabled>
|
<WaButton variant="neutral" disabled>
|
||||||
Neutral
|
Neutral
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="warning" disabled>
|
<WaButton variant="warning" disabled>
|
||||||
Warning
|
Warning
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton variant="danger" disabled>
|
<WaButton variant="danger" disabled>
|
||||||
Danger
|
Danger
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Styling Buttons
|
### Styling Buttons
|
||||||
|
|
||||||
This example demonstrates how to style buttons using a custom class. This is the recommended approach if you need to add additional variations. To customize an existing variation, modify the selector to target the button's `variant` attribute instead of a class (e.g. `sl-button[variant="primary"]`).
|
This example demonstrates how to style buttons using a custom class. This is the recommended approach if you need to add additional variations. To customize an existing variation, modify the selector to target the button's `variant` attribute instead of a class (e.g. `wa-button[variant="brand"]`).
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button class="pink">Pink Button</sl-button>
|
<wa-button class="pink">Pink Button</wa-button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
sl-button.pink::part(base) {
|
wa-button.pink::part(base) {
|
||||||
/* Set design tokens for height and border width */
|
border-radius: 6px;
|
||||||
--sl-input-height-medium: 48px;
|
border: solid 2px;
|
||||||
--sl-input-border-width: 4px;
|
background: #ff1493;
|
||||||
|
|
||||||
border-radius: 0;
|
|
||||||
background-color: #ff1493;
|
|
||||||
border-top-color: #ff7ac1;
|
border-top-color: #ff7ac1;
|
||||||
border-left-color: #ff7ac1;
|
border-left-color: #ff7ac1;
|
||||||
border-bottom-color: #ad005c;
|
border-bottom-color: #ad005c;
|
||||||
@@ -522,22 +467,22 @@ This example demonstrates how to style buttons using a custom class. This is the
|
|||||||
color: white;
|
color: white;
|
||||||
font-size: 1.125rem;
|
font-size: 1.125rem;
|
||||||
box-shadow: 0 2px 10px #0002;
|
box-shadow: 0 2px 10px #0002;
|
||||||
transition: var(--sl-transition-medium) transform ease, var(--sl-transition-medium) border ease;
|
transition: var(--wa-transition-normal) all;
|
||||||
}
|
}
|
||||||
|
|
||||||
sl-button.pink::part(base):hover {
|
wa-button.pink::part(base):hover {
|
||||||
transform: scale(1.05) rotate(-1deg);
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
sl-button.pink::part(base):active {
|
wa-button.pink::part(base):active {
|
||||||
border-top-color: #ad005c;
|
border-top-color: #ad005c;
|
||||||
border-right-color: #ff7ac1;
|
border-right-color: #ff7ac1;
|
||||||
border-bottom-color: #ff7ac1;
|
border-bottom-color: #ff7ac1;
|
||||||
border-left-color: #ad005c;
|
border-left-color: #ad005c;
|
||||||
transform: scale(1.05) rotate(-1deg) translateY(2px);
|
transform: translateY(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
sl-button.pink::part(base):focus-visible {
|
wa-button.pink::part(base):focus-visible {
|
||||||
outline: dashed 2px deeppink;
|
outline: dashed 2px deeppink;
|
||||||
outline-offset: 4px;
|
outline-offset: 4px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card class="card-overview">
|
<wa-card class="card-overview">
|
||||||
<img
|
<img
|
||||||
slot="image"
|
slot="image"
|
||||||
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
|
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
|
||||||
@@ -18,10 +18,10 @@ layout: component
|
|||||||
<small>6 weeks old</small>
|
<small>6 weeks old</small>
|
||||||
|
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<sl-button variant="primary" pill>More Info</sl-button>
|
<wa-button variant="brand" pill>More Info</wa-button>
|
||||||
<sl-rating></sl-rating>
|
<wa-rating></wa-rating>
|
||||||
</div>
|
</div>
|
||||||
</sl-card>
|
</wa-card>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.card-overview {
|
.card-overview {
|
||||||
@@ -29,7 +29,7 @@ layout: component
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card-overview small {
|
.card-overview small {
|
||||||
color: var(--sl-color-neutral-500);
|
color: var(--wa-color-text-quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-overview [slot='footer'] {
|
.card-overview [slot='footer'] {
|
||||||
@@ -41,9 +41,9 @@ layout: component
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlCard from '@shoelace-style/shoelace/dist/react/sl-card';
|
import WaCard from '@shoelace-style/shoelace/dist/react/card';
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.card-overview {
|
.card-overview {
|
||||||
@@ -51,7 +51,7 @@ const css = `
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card-overview small {
|
.card-overview small {
|
||||||
color: var(--sl-color-neutral-500);
|
color: var(--wa-color-text-quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-overview [slot="footer"] {
|
.card-overview [slot="footer"] {
|
||||||
@@ -63,7 +63,7 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCard className="card-overview">
|
<WaCard className="card-overview">
|
||||||
<img
|
<img
|
||||||
slot="image"
|
slot="image"
|
||||||
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
|
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
|
||||||
@@ -75,12 +75,12 @@ const App = () => (
|
|||||||
<br />
|
<br />
|
||||||
<small>6 weeks old</small>
|
<small>6 weeks old</small>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<SlButton variant="primary" pill>
|
<WaButton variant="brand" pill>
|
||||||
More Info
|
More Info
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlRating></SlRating>
|
<WaRating></WaRating>
|
||||||
</div>
|
</div>
|
||||||
</SlCard>
|
</WaCard>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -94,9 +94,9 @@ const App = () => (
|
|||||||
Basic cards aren't very exciting, but they can display any content you want them to.
|
Basic cards aren't very exciting, but they can display any content you want them to.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card class="card-basic">
|
<wa-card class="card-basic">
|
||||||
This is just a basic card. No image, no header, and no footer. Just your content.
|
This is just a basic card. No image, no header, and no footer. Just your content.
|
||||||
</sl-card>
|
</wa-card>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.card-basic {
|
.card-basic {
|
||||||
@@ -106,7 +106,7 @@ Basic cards aren't very exciting, but they can display any content you want them
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCard from '@shoelace-style/shoelace/dist/react/sl-card';
|
import WaCard from '@shoelace-style/shoelace/dist/react/card';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.card-basic {
|
.card-basic {
|
||||||
@@ -116,9 +116,9 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCard className="card-basic">
|
<WaCard className="card-basic">
|
||||||
This is just a basic card. No image, no header, and no footer. Just your content.
|
This is just a basic card. No image, no header, and no footer. Just your content.
|
||||||
</SlCard>
|
</WaCard>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -130,14 +130,14 @@ const App = () => (
|
|||||||
Headers can be used to display titles and more.
|
Headers can be used to display titles and more.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card class="card-header">
|
<wa-card class="card-header">
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
Header Title
|
Header Title
|
||||||
<sl-icon-button name="gear" label="Settings"></sl-icon-button>
|
<wa-icon-button name="gear" variant="solid" label="Settings"></wa-icon-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
This card has a header. You can put all sorts of things in it!
|
This card has a header. You can put all sorts of things in it!
|
||||||
</sl-card>
|
</wa-card>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.card-header {
|
.card-header {
|
||||||
@@ -154,15 +154,15 @@ Headers can be used to display titles and more.
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header sl-icon-button {
|
.card-header wa-icon-button {
|
||||||
font-size: var(--sl-font-size-medium);
|
font-size: var(--wa-font-size-m);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCard from '@shoelace-style/shoelace/dist/react/sl-card';
|
import WaCard from '@shoelace-style/shoelace/dist/react/card';
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.card-header {
|
.card-header {
|
||||||
@@ -179,20 +179,20 @@ const css = `
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header sl-icon-button {
|
.card-header wa-icon-button {
|
||||||
font-size: var(--sl-font-size-medium);
|
font-size: var(--wa-font-size-m);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCard className="card-header">
|
<WaCard className="card-header">
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
Header Title
|
Header Title
|
||||||
<SlIconButton name="gear"></SlIconButton>
|
<WaIconButton name="gear" variant="solid"></WaIconButton>
|
||||||
</div>
|
</div>
|
||||||
This card has a header. You can put all sorts of things in it!
|
This card has a header. You can put all sorts of things in it!
|
||||||
</SlCard>
|
</WaCard>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -204,14 +204,14 @@ const App = () => (
|
|||||||
Footers can be used to display actions, summaries, or other relevant content.
|
Footers can be used to display actions, summaries, or other relevant content.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card class="card-footer">
|
<wa-card class="card-footer">
|
||||||
This card has a footer. You can put all sorts of things in it!
|
This card has a footer. You can put all sorts of things in it!
|
||||||
|
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<sl-rating></sl-rating>
|
<wa-rating></wa-rating>
|
||||||
<sl-button variant="primary">Preview</sl-button>
|
<wa-button variant="brand">Preview</wa-button>
|
||||||
</div>
|
</div>
|
||||||
</sl-card>
|
</wa-card>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.card-footer {
|
.card-footer {
|
||||||
@@ -227,9 +227,9 @@ Footers can be used to display actions, summaries, or other relevant content.
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlCard from '@shoelace-style/shoelace/dist/react/sl-card';
|
import WaCard from '@shoelace-style/shoelace/dist/react/card';
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.card-footer {
|
.card-footer {
|
||||||
@@ -245,15 +245,15 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCard className="card-footer">
|
<WaCard className="card-footer">
|
||||||
This card has a footer. You can put all sorts of things in it!
|
This card has a footer. You can put all sorts of things in it!
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<SlRating></SlRating>
|
<WaRating></WaRating>
|
||||||
<SlButton slot="footer" variant="primary">
|
<WaButton slot="footer" variant="brand">
|
||||||
Preview
|
Preview
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</div>
|
</div>
|
||||||
</SlCard>
|
</WaCard>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -265,14 +265,14 @@ const App = () => (
|
|||||||
Cards accept an `image` slot. The image is displayed atop the card and stretches to fit.
|
Cards accept an `image` slot. The image is displayed atop the card and stretches to fit.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card class="card-image">
|
<wa-card class="card-image">
|
||||||
<img
|
<img
|
||||||
slot="image"
|
slot="image"
|
||||||
src="https://images.unsplash.com/photo-1547191783-94d5f8f6d8b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=80"
|
src="https://images.unsplash.com/photo-1547191783-94d5f8f6d8b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=80"
|
||||||
alt="A kitten walks towards camera on top of pallet."
|
alt="A kitten walks towards camera on top of pallet."
|
||||||
/>
|
/>
|
||||||
This is a kitten, but not just any kitten. This kitten likes walking along pallets.
|
This is a kitten, but not just any kitten. This kitten likes walking along pallets.
|
||||||
</sl-card>
|
</wa-card>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.card-image {
|
.card-image {
|
||||||
@@ -282,7 +282,7 @@ Cards accept an `image` slot. The image is displayed atop the card and stretches
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCard from '@shoelace-style/shoelace/dist/react/sl-card';
|
import WaCard from '@shoelace-style/shoelace/dist/react/card';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.card-image {
|
.card-image {
|
||||||
@@ -292,14 +292,14 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCard className="card-image">
|
<WaCard className="card-image">
|
||||||
<img
|
<img
|
||||||
slot="image"
|
slot="image"
|
||||||
src="https://images.unsplash.com/photo-1547191783-94d5f8f6d8b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=80"
|
src="https://images.unsplash.com/photo-1547191783-94d5f8f6d8b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=80"
|
||||||
alt="A kitten walks towards camera on top of pallet."
|
alt="A kitten walks towards camera on top of pallet."
|
||||||
/>
|
/>
|
||||||
This is a kitten, but not just any kitten. This kitten likes walking along pallets.
|
This is a kitten, but not just any kitten. This kitten likes walking along pallets.
|
||||||
</SlCard>
|
</WaCard>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -6,77 +6,77 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-carousel pagination>
|
<wa-carousel pagination>
|
||||||
<sl-carousel-item>
|
<wa-carousel-item>
|
||||||
<img
|
<img
|
||||||
alt="The sun shines on the mountains and trees - Photo by Adam Kool on Unsplash"
|
alt="The sun shines on the mountains and trees - Photo by Adam Kool on Unsplash"
|
||||||
src="/assets/examples/carousel/mountains.jpg"
|
src="/assets/examples/carousel/mountains.jpg"
|
||||||
/>
|
/>
|
||||||
</sl-carousel-item>
|
</wa-carousel-item>
|
||||||
<sl-carousel-item>
|
<wa-carousel-item>
|
||||||
<img
|
<img
|
||||||
alt="A waterfall in the middle of a forest - Photo by Thomas Kelly on Unsplash"
|
alt="A waterfall in the middle of a forest - Photo by Thomas Kelly on Unsplash"
|
||||||
src="/assets/examples/carousel/waterfall.jpg"
|
src="/assets/examples/carousel/waterfall.jpg"
|
||||||
/>
|
/>
|
||||||
</sl-carousel-item>
|
</wa-carousel-item>
|
||||||
<sl-carousel-item>
|
<wa-carousel-item>
|
||||||
<img
|
<img
|
||||||
alt="The sun is setting over a lavender field - Photo by Leonard Cotte on Unsplash"
|
alt="The sun is setting over a lavender field - Photo by Leonard Cotte on Unsplash"
|
||||||
src="/assets/examples/carousel/sunset.jpg"
|
src="/assets/examples/carousel/sunset.jpg"
|
||||||
/>
|
/>
|
||||||
</sl-carousel-item>
|
</wa-carousel-item>
|
||||||
<sl-carousel-item>
|
<wa-carousel-item>
|
||||||
<img
|
<img
|
||||||
alt="A field of grass with the sun setting in the background - Photo by Sapan Patel on Unsplash"
|
alt="A field of grass with the sun setting in the background - Photo by Sapan Patel on Unsplash"
|
||||||
src="/assets/examples/carousel/field.jpg"
|
src="/assets/examples/carousel/field.jpg"
|
||||||
/>
|
/>
|
||||||
</sl-carousel-item>
|
</wa-carousel-item>
|
||||||
<sl-carousel-item>
|
<wa-carousel-item>
|
||||||
<img
|
<img
|
||||||
alt="A scenic view of a mountain with clouds rolling in - Photo by V2osk on Unsplash"
|
alt="A scenic view of a mountain with clouds rolling in - Photo by V2osk on Unsplash"
|
||||||
src="/assets/examples/carousel/valley.jpg"
|
src="/assets/examples/carousel/valley.jpg"
|
||||||
/>
|
/>
|
||||||
</sl-carousel-item>
|
</wa-carousel-item>
|
||||||
</sl-carousel>
|
</wa-carousel>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCarousel from '@shoelace-style/shoelace/dist/react/sl-carousel';
|
import WaCarousel from '@shoelace-style/shoelace/dist/react/carousel';
|
||||||
import SlCarouselItem from '@shoelace-style/shoelace/dist/react/sl-carousel-item';
|
import WaCarouselItem from '@shoelace-style/shoelace/dist/react/carousel-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCarousel pagination>
|
<WaCarousel pagination>
|
||||||
<SlCarouselItem>
|
<WaCarouselItem>
|
||||||
<img
|
<img
|
||||||
alt="The sun shines on the mountains and trees - Photo by Adam Kool on Unsplash"
|
alt="The sun shines on the mountains and trees - Photo by Adam Kool on Unsplash"
|
||||||
src="/assets/examples/carousel/mountains.jpg"
|
src="/assets/examples/carousel/mountains.jpg"
|
||||||
/>
|
/>
|
||||||
</SlCarouselItem>
|
</WaCarouselItem>
|
||||||
<SlCarouselItem>
|
<WaCarouselItem>
|
||||||
<img
|
<img
|
||||||
alt="A waterfall in the middle of a forest - Photo by Thomas Kelly on Unsplash"
|
alt="A waterfall in the middle of a forest - Photo by Thomas Kelly on Unsplash"
|
||||||
src="/assets/examples/carousel/waterfall.jpg"
|
src="/assets/examples/carousel/waterfall.jpg"
|
||||||
/>
|
/>
|
||||||
</SlCarouselItem>
|
</WaCarouselItem>
|
||||||
<SlCarouselItem>
|
<WaCarouselItem>
|
||||||
<img
|
<img
|
||||||
alt="The sun is setting over a lavender field - Photo by Leonard Cotte on Unsplash"
|
alt="The sun is setting over a lavender field - Photo by Leonard Cotte on Unsplash"
|
||||||
src="/assets/examples/carousel/sunset.jpg"
|
src="/assets/examples/carousel/sunset.jpg"
|
||||||
/>
|
/>
|
||||||
</SlCarouselItem>
|
</WaCarouselItem>
|
||||||
<SlCarouselItem>
|
<WaCarouselItem>
|
||||||
<img
|
<img
|
||||||
alt="A field of grass with the sun setting in the background - Photo by Sapan Patel on Unsplash"
|
alt="A field of grass with the sun setting in the background - Photo by Sapan Patel on Unsplash"
|
||||||
src="/assets/examples/carousel/field.jpg"
|
src="/assets/examples/carousel/field.jpg"
|
||||||
/>
|
/>
|
||||||
</SlCarouselItem>
|
</WaCarouselItem>
|
||||||
<SlCarouselItem>
|
<WaCarouselItem>
|
||||||
<img
|
<img
|
||||||
alt="A scenic view of a mountain with clouds rolling in - Photo by V2osk on Unsplash"
|
alt="A scenic view of a mountain with clouds rolling in - Photo by V2osk on Unsplash"
|
||||||
src="/assets/examples/carousel/valley.jpg"
|
src="/assets/examples/carousel/valley.jpg"
|
||||||
/>
|
/>
|
||||||
</SlCarouselItem>
|
</WaCarouselItem>
|
||||||
</SlCarousel>
|
</WaCarousel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-checkbox>Checkbox</sl-checkbox>
|
<wa-checkbox>Checkbox</wa-checkbox>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => <SlCheckbox>Checkbox</SlCheckbox>;
|
const App = () => <WaCheckbox>Checkbox</WaCheckbox>;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,13 +26,13 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `checked` attribute to activate the checkbox.
|
Use the `checked` attribute to activate the checkbox.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-checkbox checked>Checked</sl-checkbox>
|
<wa-checkbox checked>Checked</wa-checkbox>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => <SlCheckbox checked>Checked</SlCheckbox>;
|
const App = () => <WaCheckbox checked>Checked</WaCheckbox>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Indeterminate
|
### Indeterminate
|
||||||
@@ -40,13 +40,13 @@ const App = () => <SlCheckbox checked>Checked</SlCheckbox>;
|
|||||||
Use the `indeterminate` attribute to make the checkbox indeterminate.
|
Use the `indeterminate` attribute to make the checkbox indeterminate.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-checkbox indeterminate>Indeterminate</sl-checkbox>
|
<wa-checkbox indeterminate>Indeterminate</wa-checkbox>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => <SlCheckbox indeterminate>Indeterminate</SlCheckbox>;
|
const App = () => <WaCheckbox indeterminate>Indeterminate</WaCheckbox>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -54,13 +54,13 @@ const App = () => <SlCheckbox indeterminate>Indeterminate</SlCheckbox>;
|
|||||||
Use the `disabled` attribute to disable the checkbox.
|
Use the `disabled` attribute to disable the checkbox.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-checkbox disabled>Disabled</sl-checkbox>
|
<wa-checkbox disabled>Disabled</wa-checkbox>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => <SlCheckbox disabled>Disabled</SlCheckbox>;
|
const App = () => <WaCheckbox disabled>Disabled</WaCheckbox>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sizes
|
### Sizes
|
||||||
@@ -68,23 +68,23 @@ const App = () => <SlCheckbox disabled>Disabled</SlCheckbox>;
|
|||||||
Use the `size` attribute to change a checkbox's size.
|
Use the `size` attribute to change a checkbox's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-checkbox size="small">Small</sl-checkbox>
|
<wa-checkbox size="small">Small</wa-checkbox>
|
||||||
<br />
|
<br />
|
||||||
<sl-checkbox size="medium">Medium</sl-checkbox>
|
<wa-checkbox size="medium">Medium</wa-checkbox>
|
||||||
<br />
|
<br />
|
||||||
<sl-checkbox size="large">Large</sl-checkbox>
|
<wa-checkbox size="large">Large</wa-checkbox>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCheckbox size="small">Small</SlCheckbox>
|
<WaCheckbox size="small">Small</WaCheckbox>
|
||||||
<br />
|
<br />
|
||||||
<SlCheckbox size="medium">Medium</SlCheckbox>
|
<WaCheckbox size="medium">Medium</WaCheckbox>
|
||||||
<br />
|
<br />
|
||||||
<SlCheckbox size="large">Large</SlCheckbox>
|
<WaCheckbox size="large">Large</WaCheckbox>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -95,30 +95,32 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="custom-validity">
|
<form class="custom-validity">
|
||||||
<sl-checkbox>Check me</sl-checkbox>
|
<wa-checkbox>Check me</wa-checkbox>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary" style="margin-top: 1rem;">Submit</sl-button>
|
<wa-button type="submit" variant="brand" style="margin-top: 1rem;">Submit</wa-button>
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
const form = document.querySelector('.custom-validity');
|
const form = document.querySelector('.custom-validity');
|
||||||
const checkbox = form.querySelector('sl-checkbox');
|
const checkbox = form.querySelector('wa-checkbox');
|
||||||
const errorMessage = `Don't forget to check me!`;
|
const errorMessage = `Don't forget to check me!`;
|
||||||
|
|
||||||
// Set initial validity as soon as the element is defined
|
// Set initial validity as soon as the element is defined
|
||||||
customElements.whenDefined('sl-checkbox').then(async () => {
|
customElements.whenDefined('wa-checkbox').then(async () => {
|
||||||
await checkbox.updateComplete;
|
await checkbox.updateComplete;
|
||||||
checkbox.setCustomValidity(errorMessage);
|
checkbox.setCustomValidity(errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update validity on change
|
// Update validity on change
|
||||||
checkbox.addEventListener('sl-change', () => {
|
checkbox.addEventListener('wa-change', () => {
|
||||||
checkbox.setCustomValidity(checkbox.checked ? '' : errorMessage);
|
checkbox.setCustomValidity(checkbox.checked ? '' : errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle submit
|
// Handle submit
|
||||||
form.addEventListener('submit', event => {
|
customElements.whenDefined('wa-checkbox').then(() => {
|
||||||
event.preventDefault();
|
form.addEventListener('submit', event => {
|
||||||
alert('All fields are valid!');
|
event.preventDefault();
|
||||||
|
alert('All fields are valid!');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
@@ -127,8 +129,8 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const checkbox = useRef(null);
|
const checkbox = useRef(null);
|
||||||
@@ -149,13 +151,13 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form class="custom-validity" onSubmit={handleSubmit}>
|
<form class="custom-validity" onSubmit={handleSubmit}>
|
||||||
<SlCheckbox ref={checkbox} onSlChange={handleChange}>
|
<WaCheckbox ref={checkbox} onWaChange={handleChange}>
|
||||||
Check me
|
Check me
|
||||||
</SlCheckbox>
|
</WaCheckbox>
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary" style={{ marginTop: '1rem' }}>
|
<WaButton type="submit" variant="brand" style={{ marginTop: '1rem' }}>
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker label="Select a color"></sl-color-picker>
|
<wa-color-picker label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => <SlColorPicker label="Select a color" />;
|
const App = () => <WaColorPicker label="Select a color" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,13 +26,13 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `value` attribute to set an initial value for the color picker.
|
Use the `value` attribute to set an initial value for the color picker.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker value="#4a90e2" label="Select a color"></sl-color-picker>
|
<wa-color-picker value="#4a90e2" label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => <SlColorPicker value="#4a90e2" label="Select a color" />;
|
const App = () => <WaColorPicker value="#4a90e2" label="Select a color" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Opacity
|
### Opacity
|
||||||
@@ -40,13 +40,13 @@ const App = () => <SlColorPicker value="#4a90e2" label="Select a color" />;
|
|||||||
Use the `opacity` attribute to enable the opacity slider. When this is enabled, the value will be displayed as HEXA, RGBA, HSLA, or HSVA based on `format`.
|
Use the `opacity` attribute to enable the opacity slider. When this is enabled, the value will be displayed as HEXA, RGBA, HSLA, or HSVA based on `format`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker value="#f5a623ff" opacity label="Select a color"></sl-color-picker>
|
<wa-color-picker value="#f5a623ff" opacity label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => <SlColorPicker opacity label="Select a color" />;
|
const App = () => <WaColorPicker opacity label="Select a color" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Formats
|
### Formats
|
||||||
@@ -56,21 +56,21 @@ Set the color picker's format with the `format` attribute. Valid options include
|
|||||||
To prevent users from toggling the format themselves, add the `no-format-toggle` attribute.
|
To prevent users from toggling the format themselves, add the `no-format-toggle` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker format="hex" value="#4a90e2" label="Select a color"></sl-color-picker>
|
<wa-color-picker format="hex" value="#4a90e2" label="Select a color"></wa-color-picker>
|
||||||
<sl-color-picker format="rgb" value="rgb(80, 227, 194)" label="Select a color"></sl-color-picker>
|
<wa-color-picker format="rgb" value="rgb(80, 227, 194)" label="Select a color"></wa-color-picker>
|
||||||
<sl-color-picker format="hsl" value="hsl(290, 87%, 47%)" label="Select a color"></sl-color-picker>
|
<wa-color-picker format="hsl" value="hsl(290, 87%, 47%)" label="Select a color"></wa-color-picker>
|
||||||
<sl-color-picker format="hsv" value="hsv(55, 89%, 97%)" label="Select a color"></sl-color-picker>
|
<wa-color-picker format="hsv" value="hsv(55, 89%, 97%)" label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlColorPicker format="hex" value="#4a90e2" />
|
<WaColorPicker format="hex" value="#4a90e2" />
|
||||||
<SlColorPicker format="rgb" value="rgb(80, 227, 194)" />
|
<WaColorPicker format="rgb" value="rgb(80, 227, 194)" />
|
||||||
<SlColorPicker format="hsl" value="hsl(290, 87%, 47%)" />
|
<WaColorPicker format="hsl" value="hsl(290, 87%, 47%)" />
|
||||||
<SlColorPicker format="hsv" value="hsv(55, 89%, 97%)" />
|
<WaColorPicker format="hsv" value="hsv(55, 89%, 97%)" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -80,20 +80,20 @@ const App = () => (
|
|||||||
Use the `swatches` attribute to add convenient presets to the color picker. Any format the color picker can parse is acceptable (including CSS color names), but each value must be separated by a semicolon (`;`). Alternatively, you can pass an array of color values to this property using JavaScript.
|
Use the `swatches` attribute to add convenient presets to the color picker. Any format the color picker can parse is acceptable (including CSS color names), but each value must be separated by a semicolon (`;`). Alternatively, you can pass an array of color values to this property using JavaScript.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker
|
<wa-color-picker
|
||||||
label="Select a color"
|
label="Select a color"
|
||||||
swatches="
|
swatches="
|
||||||
#d0021b; #f5a623; #f8e71c; #8b572a; #7ed321; #417505; #bd10e0; #9013fe;
|
#d0021b; #f5a623; #f8e71c; #8b572a; #7ed321; #417505; #bd10e0; #9013fe;
|
||||||
#4a90e2; #50e3c2; #b8e986; #000; #444; #888; #ccc; #fff;
|
#4a90e2; #50e3c2; #b8e986; #000; #444; #888; #ccc; #fff;
|
||||||
"
|
"
|
||||||
></sl-color-picker>
|
></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlColorPicker
|
<WaColorPicker
|
||||||
label="Select a color"
|
label="Select a color"
|
||||||
swatches="
|
swatches="
|
||||||
#d0021b; #f5a623; #f8e71c; #8b572a; #7ed321; #417505; #bd10e0; #9013fe;
|
#d0021b; #f5a623; #f8e71c; #8b572a; #7ed321; #417505; #bd10e0; #9013fe;
|
||||||
@@ -108,19 +108,19 @@ const App = () => (
|
|||||||
Use the `size` attribute to change the color picker's trigger size.
|
Use the `size` attribute to change the color picker's trigger size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker size="small" label="Select a color"></sl-color-picker>
|
<wa-color-picker size="small" label="Select a color"></wa-color-picker>
|
||||||
<sl-color-picker size="medium" label="Select a color"></sl-color-picker>
|
<wa-color-picker size="medium" label="Select a color"></wa-color-picker>
|
||||||
<sl-color-picker size="large" label="Select a color"></sl-color-picker>
|
<wa-color-picker size="large" label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlColorPicker size="small" label="Select a color" />
|
<WaColorPicker size="small" label="Select a color" />
|
||||||
<SlColorPicker size="medium" label="Select a color" />
|
<WaColorPicker size="medium" label="Select a color" />
|
||||||
<SlColorPicker size="large" label="Select a color" />
|
<WaColorPicker size="large" label="Select a color" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -130,11 +130,11 @@ const App = () => (
|
|||||||
The color picker can be rendered inline instead of in a dropdown using the `inline` attribute.
|
The color picker can be rendered inline instead of in a dropdown using the `inline` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-color-picker inline label="Select a color"></sl-color-picker>
|
<wa-color-picker inline label="Select a color"></wa-color-picker>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlColorPicker from '@shoelace-style/shoelace/dist/react/sl-color-picker';
|
import WaColorPicker from '@shoelace-style/shoelace/dist/react/color-picker';
|
||||||
|
|
||||||
const App = () => <SlColorPicker inline label="Select a color" />;
|
const App = () => <WaColorPicker inline label="Select a color" />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button value="Shoelace rocks!"></sl-copy-button>
|
<wa-copy-button value="Web Awesome rocks!"></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCopyButton value="Shoelace rocks!" />
|
<WaCopyButton value="Web Awesome rocks!" />
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -24,19 +24,19 @@ const App = () => (
|
|||||||
Copy Buttons display feedback in a tooltip. You can customize the labels using the `copy-label`, `success-label`, and `error-label` attributes.
|
Copy Buttons display feedback in a tooltip. You can customize the labels using the `copy-label`, `success-label`, and `error-label` attributes.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button
|
<wa-copy-button
|
||||||
value="Custom labels are easy"
|
value="Custom labels are easy"
|
||||||
copy-label="Click to copy"
|
copy-label="Click to copy"
|
||||||
success-label="You did it!"
|
success-label="You did it!"
|
||||||
error-label="Whoops, your browser doesn't support this!"
|
error-label="Whoops, your browser doesn't support this!"
|
||||||
></sl-copy-button>
|
></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCopyButton
|
<WaCopyButton
|
||||||
value="Custom labels are easy"
|
value="Custom labels are easy"
|
||||||
copy-label="Click to copy"
|
copy-label="Click to copy"
|
||||||
success-label="You did it!"
|
success-label="You did it!"
|
||||||
@@ -47,27 +47,27 @@ const App = () => (
|
|||||||
|
|
||||||
### Custom Icons
|
### Custom Icons
|
||||||
|
|
||||||
Use the `copy-icon`, `success-icon`, and `error-icon` slots to customize the icons that get displayed for each state. You can use [`<sl-icon>`](/components/icon) or your own images.
|
Use the `copy-icon`, `success-icon`, and `error-icon` slots to customize the icons that get displayed for each state. You can use [`<wa-icon>`](/components/icon) or your own images.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button value="Copied from a custom button">
|
<wa-copy-button value="Copied from a custom button">
|
||||||
<sl-icon slot="copy-icon" name="clipboard"></sl-icon>
|
<wa-icon slot="copy-icon" name="clipboard" variant="regular"></wa-icon>
|
||||||
<sl-icon slot="success-icon" name="clipboard-check"></sl-icon>
|
<wa-icon slot="success-icon" name="thumbs-up" variant="solid"></wa-icon>
|
||||||
<sl-icon slot="error-icon" name="clipboard-x"></sl-icon>
|
<wa-icon slot="error-icon" name="xmark" variant="solid"></wa-icon>
|
||||||
</sl-copy-button>
|
</wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
import { SlIcon } from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import { WaIcon } from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCopyButton value="Copied from a custom button">
|
<WaCopyButton value="Copied from a custom button">
|
||||||
<SlIcon slot="copy-icon" name="clipboard" />
|
<WaIcon slot="copy-icon" name="clipboard" variant="regular" />
|
||||||
<SlIcon slot="success-icon" name="clipboard-check" />
|
<WaIcon slot="success-icon" name="check" variant="solid" />
|
||||||
<SlIcon slot="error-icon" name="clipboard-x" />
|
<WaIcon slot="error-icon" name="xmark" variant="solid" />
|
||||||
</SlCopyButton>
|
</WaCopyButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -83,61 +83,61 @@ To copy data from an attribute, use `from="id[attr]"` where `id` is the id of th
|
|||||||
```html:preview
|
```html:preview
|
||||||
<!-- Copies the span's textContent -->
|
<!-- Copies the span's textContent -->
|
||||||
<span id="my-phone">+1 (234) 456-7890</span>
|
<span id="my-phone">+1 (234) 456-7890</span>
|
||||||
<sl-copy-button from="my-phone"></sl-copy-button>
|
<wa-copy-button from="my-phone"></wa-copy-button>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<!-- Copies the input's "value" property -->
|
<!-- Copies the input's "value" property -->
|
||||||
<sl-input id="my-input" type="text" value="User input" style="display: inline-block; max-width: 300px;"></sl-input>
|
<wa-input id="my-input" type="text" value="User input" style="display: inline-block; max-width: 300px;"></wa-input>
|
||||||
<sl-copy-button from="my-input.value"></sl-copy-button>
|
<wa-copy-button from="my-input.value"></wa-copy-button>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<!-- Copies the link's "href" attribute -->
|
<!-- Copies the link's "href" attribute -->
|
||||||
<a id="my-link" href="https://shoelace.style/">Shoelace Website</a>
|
<a id="my-link" href="https://shoelace.style/">Web Awesome Website</a>
|
||||||
<sl-copy-button from="my-link[href]"></sl-copy-button>
|
<wa-copy-button from="my-link[href]"></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
import { SlInput } from '@shoelace-style/shoelace/dist/react/sl-input';
|
import { WaInput } from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
{/* Copies the span's textContent */}
|
{/* Copies the span's textContent */}
|
||||||
<span id="my-phone">+1 (234) 456-7890</span>
|
<span id="my-phone">+1 (234) 456-7890</span>
|
||||||
<SlCopyButton from="my-phone" />
|
<WaCopyButton from="my-phone" />
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
{/* Copies the input's "value" property */}
|
{/* Copies the input's "value" property */}
|
||||||
<SlInput id="my-input" type="text" />
|
<WaInput id="my-input" type="text" />
|
||||||
<SlCopyButton from="my-input.value" />
|
<WaCopyButton from="my-input.value" />
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
{/* Copies the link's "href" attribute */}
|
{/* Copies the link's "href" attribute */}
|
||||||
<a id="my-link" href="https://shoelace.style/">Shoelace Website</a>
|
<a id="my-link" href="https://shoelace.style/">Web Awesome Website</a>
|
||||||
<SlCopyButton from="my-link[href]" />
|
<WaCopyButton from="my-link[href]" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Handling Errors
|
### Handling Errors
|
||||||
|
|
||||||
A copy error will occur if the value is an empty string, if the `from` attribute points to an id that doesn't exist, or if the browser rejects the operation for any reason. When this happens, the `sl-error` event will be emitted.
|
A copy error will occur if the value is an empty string, if the `from` attribute points to an id that doesn't exist, or if the browser rejects the operation for any reason. When this happens, the `wa-error` event will be emitted.
|
||||||
|
|
||||||
This example demonstrates what happens when a copy error occurs. You can customize the error label and icon using the `error-label` attribute and the `error-icon` slot, respectively.
|
This example demonstrates what happens when a copy error occurs. You can customize the error label and icon using the `error-label` attribute and the `error-icon` slot, respectively.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button from="i-do-not-exist"></sl-copy-button>
|
<wa-copy-button from="i-do-not-exist"></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCopyButton from="i-do-not-exist" />
|
<WaCopyButton from="i-do-not-exist" />
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -146,14 +146,14 @@ const App = () => (
|
|||||||
Copy buttons can be disabled by adding the `disabled` attribute.
|
Copy buttons can be disabled by adding the `disabled` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button value="You can't copy me" disabled></sl-copy-button>
|
<wa-copy-button value="You can't copy me" disabled></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCopyButton value="You can't copy me" disabled />
|
<WaCopyButton value="You can't copy me" disabled />
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -162,14 +162,14 @@ const App = () => (
|
|||||||
A success indicator is briefly shown after copying. You can customize the length of time the indicator is shown using the `feedback-duration` attribute.
|
A success indicator is briefly shown after copying. You can customize the length of time the indicator is shown using the `feedback-duration` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button value="Shoelace rocks!" feedback-duration="250"></sl-copy-button>
|
<wa-copy-button value="Web Awesome rocks!" feedback-duration="250"></wa-copy-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlCopyButton value="Shoelace rocks!" feedback-duration={250} />
|
<WaCopyButton value="Web Awesome rocks!" feedback-duration={250} />
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -178,11 +178,11 @@ const App = () => (
|
|||||||
You can customize the button to your liking with CSS.
|
You can customize the button to your liking with CSS.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-copy-button value="I'm so stylish" class="custom-styles">
|
<wa-copy-button value="I'm so stylish" class="custom-styles">
|
||||||
<sl-icon slot="copy-icon" name="asterisk"></sl-icon>
|
<wa-icon slot="copy-icon" name="clipboard"></wa-icon>
|
||||||
<sl-icon slot="success-icon" name="check-lg"></sl-icon>
|
<wa-icon slot="success-icon" name="thumbs-up"></wa-icon>
|
||||||
<sl-icon slot="error-icon" name="x-lg"></sl-icon>
|
<wa-icon slot="error-icon" name="thumbs-down"></wa-icon>
|
||||||
</sl-copy-button>
|
</wa-copy-button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.custom-styles {
|
.custom-styles {
|
||||||
@@ -193,19 +193,19 @@ You can customize the button to your liking with CSS.
|
|||||||
|
|
||||||
.custom-styles::part(button) {
|
.custom-styles::part(button) {
|
||||||
background-color: #ff1493;
|
background-color: #ff1493;
|
||||||
border: solid 4px #ff7ac1;
|
border: solid 2px #ff7ac1;
|
||||||
border-right-color: #ad005c;
|
border-right-color: #ad005c;
|
||||||
border-bottom-color: #ad005c;
|
border-bottom-color: #ad005c;
|
||||||
border-radius: 0;
|
border-radius: 6px;
|
||||||
transition: 100ms scale ease-in-out, 100ms translate ease-in-out;
|
transition: var(--wa-transition-normal) all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-styles::part(button):hover {
|
.custom-styles::part(button):hover {
|
||||||
scale: 1.1;
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-styles::part(button):active {
|
.custom-styles::part(button):active {
|
||||||
translate: 0 2px;
|
transform: translateY(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-styles::part(button):focus-visible {
|
.custom-styles::part(button):focus-visible {
|
||||||
@@ -216,7 +216,7 @@ You can customize the button to your liking with CSS.
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { SlCopyButton } from '@shoelace-style/shoelace/dist/react/sl-copy-button';
|
import { WaCopyButton } from '@shoelace-style/shoelace/dist/react/copy-button';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.custom-styles {
|
.custom-styles {
|
||||||
@@ -250,7 +250,7 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlCopyButton value="I'm so stylish" className="custom-styles" />
|
<WaCopyButton value="I'm so stylish" className="custom-styles" />
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ layout: component
|
|||||||
<!-- cspell:dictionaries lorem-ipsum -->
|
<!-- cspell:dictionaries lorem-ipsum -->
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-details summary="Toggle Me">
|
<wa-details summary="Toggle Me">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDetails from '@shoelace-style/shoelace/dist/react/sl-details';
|
import WaDetails from '@shoelace-style/shoelace/dist/react/details';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDetails summary="Toggle Me">
|
<WaDetails summary="Toggle Me">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</SlDetails>
|
</WaDetails>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -32,20 +32,20 @@ const App = () => (
|
|||||||
Use the `disable` attribute to prevent the details from expanding.
|
Use the `disable` attribute to prevent the details from expanding.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-details summary="Disabled" disabled>
|
<wa-details summary="Disabled" disabled>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDetails from '@shoelace-style/shoelace/dist/react/sl-details';
|
import WaDetails from '@shoelace-style/shoelace/dist/react/details';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDetails summary="Disabled" disabled>
|
<WaDetails summary="Disabled" disabled>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</SlDetails>
|
</WaDetails>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -54,16 +54,16 @@ const App = () => (
|
|||||||
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `summary-icon` part as shown below.
|
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `summary-icon` part as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-details summary="Toggle Me" class="custom-icons">
|
<wa-details summary="Toggle Me" class="custom-icons">
|
||||||
<sl-icon name="plus-square" slot="expand-icon"></sl-icon>
|
<wa-icon name="square-plus" slot="expand-icon" variant="regular"></wa-icon>
|
||||||
<sl-icon name="dash-square" slot="collapse-icon"></sl-icon>
|
<wa-icon name="square-minus" slot="collapse-icon" variant="regular"></wa-icon>
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
sl-details.custom-icons::part(summary-icon) {
|
wa-details.custom-icons::part(summary-icon) {
|
||||||
/* Disable the expand/collapse animation */
|
/* Disable the expand/collapse animation */
|
||||||
rotate: none;
|
rotate: none;
|
||||||
}
|
}
|
||||||
@@ -71,11 +71,11 @@ Use the `expand-icon` and `collapse-icon` slots to change the expand and collaps
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDetails from '@shoelace-style/shoelace/dist/react/sl-details';
|
import WaDetails from '@shoelace-style/shoelace/dist/react/details';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
sl-details.custom-icon::part(summary-icon) {
|
wa-details.custom-icon::part(summary-icon) {
|
||||||
/* Disable the expand/collapse animation */
|
/* Disable the expand/collapse animation */
|
||||||
rotate: none;
|
rotate: none;
|
||||||
}
|
}
|
||||||
@@ -83,13 +83,13 @@ const css = `
|
|||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlDetails summary="Toggle Me" class="custom-icon">
|
<WaDetails summary="Toggle Me" class="custom-icon">
|
||||||
<SlIcon name="plus-square" slot="expand-icon" />
|
<WaIcon name="square-plus" slot="expand-icon" />
|
||||||
<SlIcon name="dash-square" slot="collapse-icon" />
|
<WaIcon name="square-minus" slot="collapse-icon" />
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
||||||
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
||||||
consequat.
|
consequat.
|
||||||
</SlDetails>
|
</WaDetails>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -98,38 +98,40 @@ const App = () => (
|
|||||||
|
|
||||||
### Grouping Details
|
### Grouping Details
|
||||||
|
|
||||||
Details are designed to function independently, but you can simulate a group or "accordion" where only one is shown at a time by listening for the `sl-show` event.
|
Details are designed to function independently, but you can simulate a group or "accordion" where only one is shown at a time by listening for the `wa-show` event.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="details-group-example">
|
<div class="details-group-example">
|
||||||
<sl-details summary="First" open>
|
<wa-details summary="First" open>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
|
|
||||||
<sl-details summary="Second">
|
<wa-details summary="Second">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
|
|
||||||
<sl-details summary="Third">
|
<wa-details summary="Third">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
</sl-details>
|
</wa-details>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.details-group-example');
|
const container = document.querySelector('.details-group-example');
|
||||||
|
|
||||||
// Close all other details when one is shown
|
// Close all other details when one is shown
|
||||||
container.addEventListener('sl-show', event => {
|
container.addEventListener('wa-show', event => {
|
||||||
[...container.querySelectorAll('sl-details')].map(details => (details.open = event.target === details));
|
if (event.target.localName === 'wa-details') {
|
||||||
|
[...container.querySelectorAll('wa-details')].map(details => (details.open = event.target === details));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.details-group-example sl-details:not(:last-of-type) {
|
.details-group-example wa-details:not(:last-of-type) {
|
||||||
margin-bottom: var(--sl-spacing-2x-small);
|
margin-bottom: var(--wa-space-2xs);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -8,17 +8,17 @@ layout: component
|
|||||||
<!-- cspell:dictionaries lorem-ipsum -->
|
<!-- cspell:dictionaries lorem-ipsum -->
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-overview">
|
<wa-dialog label="Dialog" class="dialog-overview">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-overview');
|
const dialog = document.querySelector('.dialog-overview');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
closeButton.addEventListener('click', () => dialog.hide());
|
closeButton.addEventListener('click', () => dialog.hide());
|
||||||
@@ -27,22 +27,22 @@ layout: component
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -55,17 +55,17 @@ const App = () => {
|
|||||||
Use the `--width` custom property to set the dialog's width.
|
Use the `--width` custom property to set the dialog's width.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-width" style="--width: 50vw;">
|
<wa-dialog label="Dialog" class="dialog-width" style="--width: 50vw;">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-width');
|
const dialog = document.querySelector('.dialog-width');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
closeButton.addEventListener('click', () => dialog.hide());
|
closeButton.addEventListener('click', () => dialog.hide());
|
||||||
@@ -76,22 +76,22 @@ Use the `--width` custom property to set the dialog's width.
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} style={{ '--width': '50vw' }} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} style={{ '--width': '50vw' }} onWaAfterHide={() => setOpen(false)}>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -104,19 +104,19 @@ const App = () => {
|
|||||||
By design, a dialog's height will never exceed that of the viewport. As such, dialogs will not scroll with the page ensuring the header and footer are always accessible to the user.
|
By design, a dialog's height will never exceed that of the viewport. As such, dialogs will not scroll with the page ensuring the header and footer are always accessible to the user.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-scrolling">
|
<wa-dialog label="Dialog" class="dialog-scrolling">
|
||||||
<div style="height: 150vh; border: dashed 2px var(--sl-color-neutral-200); padding: 0 1rem;">
|
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-border); padding: 0 1rem;">
|
||||||
<p>Scroll down and give it a try! 👇</p>
|
<p>Scroll down and give it a try! 👇</p>
|
||||||
</div>
|
</div>
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-scrolling');
|
const dialog = document.querySelector('.dialog-scrolling');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
closeButton.addEventListener('click', () => dialog.hide());
|
closeButton.addEventListener('click', () => dialog.hide());
|
||||||
@@ -127,31 +127,31 @@ By design, a dialog's height will never exceed that of the viewport. As such, di
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
height: '150vh',
|
height: '150vh',
|
||||||
border: 'dashed 2px var(--sl-color-neutral-200)',
|
border: 'dashed 2px var(--wa-color-surface-border)',
|
||||||
padding: '0 1rem'
|
padding: '0 1rem'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p>Scroll down and give it a try! 👇</p>
|
<p>Scroll down and give it a try! 👇</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -164,18 +164,18 @@ const App = () => {
|
|||||||
The header shows a functional close button by default. You can use the `header-actions` slot to add additional [icon buttons](/components/icon-button) if needed.
|
The header shows a functional close button by default. You can use the `header-actions` slot to add additional [icon buttons](/components/icon-button) if needed.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-header-actions">
|
<wa-dialog label="Dialog" class="dialog-header-actions">
|
||||||
<sl-icon-button class="new-window" slot="header-actions" name="box-arrow-up-right"></sl-icon-button>
|
<wa-icon-button class="new-window" slot="header-actions" name="arrow-up-right-from-square" variant="solid"></wa-icon-button>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-header-actions');
|
const dialog = document.querySelector('.dialog-header-actions');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
const newWindowButton = dialog.querySelector('.new-window');
|
const newWindowButton = dialog.querySelector('.new-window');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
@@ -186,29 +186,29 @@ The header shows a functional close button by default. You can use the `header-a
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<SlIconButton
|
<WaIconButton
|
||||||
class="new-window"
|
class="new-window"
|
||||||
slot="header-actions"
|
slot="header-actions"
|
||||||
name="box-arrow-up-right"
|
name="arrow-up-right-from-square"
|
||||||
onClick={() => window.open(location.href)}
|
onClick={() => window.open(location.href)}
|
||||||
/>
|
/>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -218,28 +218,28 @@ const App = () => {
|
|||||||
|
|
||||||
By default, dialogs will close when the user clicks the close button, clicks the overlay, or presses the [[Escape]] key. In most cases, the default behavior is the best behavior in terms of UX. However, there are situations where this may be undesirable, such as when data loss will occur.
|
By default, dialogs will close when the user clicks the close button, clicks the overlay, or presses the [[Escape]] key. In most cases, the default behavior is the best behavior in terms of UX. However, there are situations where this may be undesirable, such as when data loss will occur.
|
||||||
|
|
||||||
To keep the dialog open in such cases, you can cancel the `sl-request-close` event. When canceled, the dialog will remain open and pulse briefly to draw the user's attention to it.
|
To keep the dialog open in such cases, you can cancel the `wa-request-close` event. When canceled, the dialog will remain open and pulse briefly to draw the user's attention to it.
|
||||||
|
|
||||||
You can use `event.detail.source` to determine what triggered the request to close. This example prevents the dialog from closing when the overlay is clicked, but allows the close button or [[Escape]] to dismiss it.
|
You can use `event.detail.source` to determine what triggered the request to close. This example prevents the dialog from closing when the overlay is clicked, but allows the close button or [[Escape]] to dismiss it.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-deny-close">
|
<wa-dialog label="Dialog" class="dialog-deny-close">
|
||||||
This dialog will not close when you click on the overlay.
|
This dialog will not close when you click on the overlay.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-deny-close');
|
const dialog = document.querySelector('.dialog-deny-close');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
closeButton.addEventListener('click', () => dialog.hide());
|
closeButton.addEventListener('click', () => dialog.hide());
|
||||||
|
|
||||||
// Prevent the dialog from closing when the user clicks on the overlay
|
// Prevent the dialog from closing when the user clicks on the overlay
|
||||||
dialog.addEventListener('sl-request-close', event => {
|
dialog.addEventListener('wa-request-close', event => {
|
||||||
if (event.detail.source === 'overlay') {
|
if (event.detail.source === 'overlay') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -249,8 +249,8 @@ You can use `event.detail.source` to determine what triggered the request to clo
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -264,14 +264,14 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} onSlRequestClose={handleRequestClose} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} onWaRequestClose={handleRequestClose} onWaAfterHide={() => setOpen(false)}>
|
||||||
This dialog will not close when you click on the overlay.
|
This dialog will not close when you click on the overlay.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -282,18 +282,18 @@ const App = () => {
|
|||||||
By default, the dialog's panel will gain focus when opened. This allows a subsequent tab press to focus on the first tabbable element in the dialog. If you want a different element to have focus, add the `autofocus` attribute to it as shown below.
|
By default, the dialog's panel will gain focus when opened. This allows a subsequent tab press to focus on the first tabbable element in the dialog. If you want a different element to have focus, add the `autofocus` attribute to it as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dialog label="Dialog" class="dialog-focus">
|
<wa-dialog label="Dialog" class="dialog-focus">
|
||||||
<sl-input autofocus placeholder="I will have focus when the dialog is opened"></sl-input>
|
<wa-input autofocus placeholder="I will have focus when the dialog is opened"></wa-input>
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-dialog>
|
</wa-dialog>
|
||||||
|
|
||||||
<sl-button>Open Dialog</sl-button>
|
<wa-button>Open Dialog</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const dialog = document.querySelector('.dialog-focus');
|
const dialog = document.querySelector('.dialog-focus');
|
||||||
const input = dialog.querySelector('sl-input');
|
const input = dialog.querySelector('wa-input');
|
||||||
const openButton = dialog.nextElementSibling;
|
const openButton = dialog.nextElementSibling;
|
||||||
const closeButton = dialog.querySelector('sl-button[slot="footer"]');
|
const closeButton = dialog.querySelector('wa-button[slot="footer"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => dialog.show());
|
openButton.addEventListener('click', () => dialog.show());
|
||||||
closeButton.addEventListener('click', () => dialog.hide());
|
closeButton.addEventListener('click', () => dialog.hide());
|
||||||
@@ -302,28 +302,28 @@ By default, the dialog's panel will gain focus when opened. This allows a subseq
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDialog from '@shoelace-style/shoelace/dist/react/sl-dialog';
|
import WaDialog from '@shoelace-style/shoelace/dist/react/dialog';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDialog label="Dialog" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDialog label="Dialog" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<SlInput autofocus placeholder="I will have focus when the dialog is opened" />
|
<WaInput autofocus placeholder="I will have focus when the dialog is opened" />
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDialog>
|
</WaDialog>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Dialog</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Dialog</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
You can further customize initial focus behavior by canceling the `sl-initial-focus` event and setting focus yourself inside the event handler.
|
You can further customize initial focus behavior by canceling the `wa-initial-focus` event and setting focus yourself inside the event handler.
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
|
||||||
const App = () => <SlDivider />;
|
const App = () => <WaDivider />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,15 +22,15 @@ const App = () => <SlDivider />;
|
|||||||
Use the `--width` custom property to change the width of the divider.
|
Use the `--width` custom property to change the width of the divider.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-divider style="--width: 4px;"></sl-divider>
|
<wa-divider style="--width: 4px;"></wa-divider>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
|
||||||
const App = () => <SlDivider style={{ '--width': '4px' }} />;
|
const App = () => <WaDivider style={{ '--width': '4px' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -40,15 +40,15 @@ const App = () => <SlDivider style={{ '--width': '4px' }} />;
|
|||||||
Use the `--color` custom property to change the color of the divider.
|
Use the `--color` custom property to change the color of the divider.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-divider style="--color: tomato;"></sl-divider>
|
<wa-divider style="--color: tomato;"></wa-divider>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
|
||||||
const App = () => <SlDivider style={{ '--color': 'tomato' }} />;
|
const App = () => <WaDivider style={{ '--color': 'tomato' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -60,7 +60,7 @@ Use the `--spacing` custom property to change the amount of space between the di
|
|||||||
```html:preview
|
```html:preview
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
Above
|
Above
|
||||||
<sl-divider style="--spacing: 2rem;"></sl-divider>
|
<wa-divider style="--spacing: 2rem;"></wa-divider>
|
||||||
Below
|
Below
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
@@ -68,12 +68,12 @@ Use the `--spacing` custom property to change the amount of space between the di
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
Above
|
Above
|
||||||
<SlDivider style={{ '--spacing': '2rem' }} />
|
<WaDivider style={{ '--spacing': '2rem' }} />
|
||||||
Below
|
Below
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -88,9 +88,9 @@ Add the `vertical` attribute to draw the divider in a vertical orientation. The
|
|||||||
```html:preview
|
```html:preview
|
||||||
<div style="display: flex; align-items: center; height: 2rem;">
|
<div style="display: flex; align-items: center; height: 2rem;">
|
||||||
First
|
First
|
||||||
<sl-divider vertical></sl-divider>
|
<wa-divider vertical></wa-divider>
|
||||||
Middle
|
Middle
|
||||||
<sl-divider vertical></sl-divider>
|
<wa-divider vertical></wa-divider>
|
||||||
Last
|
Last
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
@@ -98,7 +98,7 @@ Add the `vertical` attribute to draw the divider in a vertical orientation. The
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<div
|
<div
|
||||||
@@ -109,9 +109,9 @@ const App = () => (
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
First
|
First
|
||||||
<SlDivider vertical />
|
<WaDivider vertical />
|
||||||
Middle
|
Middle
|
||||||
<SlDivider vertical />
|
<WaDivider vertical />
|
||||||
Last
|
Last
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -124,34 +124,34 @@ const App = () => (
|
|||||||
Use dividers in [menus](/components/menu) to visually group menu items.
|
Use dividers in [menus](/components/menu) to visually group menu items.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item value="1">Option 1</sl-menu-item>
|
<wa-menu-item value="1">Option 1</wa-menu-item>
|
||||||
<sl-menu-item value="2">Option 2</sl-menu-item>
|
<wa-menu-item value="2">Option 2</wa-menu-item>
|
||||||
<sl-menu-item value="3">Option 3</sl-menu-item>
|
<wa-menu-item value="3">Option 3</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item value="4">Option 4</sl-menu-item>
|
<wa-menu-item value="4">Option 4</wa-menu-item>
|
||||||
<sl-menu-item value="5">Option 5</sl-menu-item>
|
<wa-menu-item value="5">Option 5</wa-menu-item>
|
||||||
<sl-menu-item value="6">Option 6</sl-menu-item>
|
<wa-menu-item value="6">Option 6</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem value="1">Option 1</SlMenuItem>
|
<WaMenuItem value="1">Option 1</WaMenuItem>
|
||||||
<SlMenuItem value="2">Option 2</SlMenuItem>
|
<WaMenuItem value="2">Option 2</WaMenuItem>
|
||||||
<SlMenuItem value="3">Option 3</SlMenuItem>
|
<WaMenuItem value="3">Option 3</WaMenuItem>
|
||||||
<sl-divider />
|
<wa-divider />
|
||||||
<SlMenuItem value="4">Option 4</SlMenuItem>
|
<WaMenuItem value="4">Option 4</WaMenuItem>
|
||||||
<SlMenuItem value="5">Option 5</SlMenuItem>
|
<WaMenuItem value="5">Option 5</WaMenuItem>
|
||||||
<SlMenuItem value="6">Option 6</SlMenuItem>
|
<WaMenuItem value="6">Option 6</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,17 @@ layout: component
|
|||||||
<!-- cspell:dictionaries lorem-ipsum -->
|
<!-- cspell:dictionaries lorem-ipsum -->
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-overview">
|
<wa-drawer label="Drawer" class="drawer-overview">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-overview');
|
const drawer = document.querySelector('.drawer-overview');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -27,22 +27,22 @@ layout: component
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -55,17 +55,17 @@ const App = () => {
|
|||||||
By default, drawers slide in from the end. To make the drawer slide in from the start, set the `placement` attribute to `start`.
|
By default, drawers slide in from the end. To make the drawer slide in from the start, set the `placement` attribute to `start`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" placement="start" class="drawer-placement-start">
|
<wa-drawer label="Drawer" placement="start" class="drawer-placement-start">
|
||||||
This drawer slides in from the start.
|
This drawer slides in from the start.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-placement-start');
|
const drawer = document.querySelector('.drawer-placement-start');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -74,22 +74,22 @@ By default, drawers slide in from the end. To make the drawer slide in from the
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" placement="start" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" placement="start" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
This drawer slides in from the start.
|
This drawer slides in from the start.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -100,17 +100,17 @@ const App = () => {
|
|||||||
To make the drawer slide in from the top, set the `placement` attribute to `top`.
|
To make the drawer slide in from the top, set the `placement` attribute to `top`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" placement="top" class="drawer-placement-top">
|
<wa-drawer label="Drawer" placement="top" class="drawer-placement-top">
|
||||||
This drawer slides in from the top.
|
This drawer slides in from the top.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-placement-top');
|
const drawer = document.querySelector('.drawer-placement-top');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -119,22 +119,22 @@ To make the drawer slide in from the top, set the `placement` attribute to `top`
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" placement="top" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" placement="top" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
This drawer slides in from the top.
|
This drawer slides in from the top.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -145,17 +145,17 @@ const App = () => {
|
|||||||
To make the drawer slide in from the bottom, set the `placement` attribute to `bottom`.
|
To make the drawer slide in from the bottom, set the `placement` attribute to `bottom`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" placement="bottom" class="drawer-placement-bottom">
|
<wa-drawer label="Drawer" placement="bottom" class="drawer-placement-bottom">
|
||||||
This drawer slides in from the bottom.
|
This drawer slides in from the bottom.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-placement-bottom');
|
const drawer = document.querySelector('.drawer-placement-bottom');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -164,22 +164,22 @@ To make the drawer slide in from the bottom, set the `placement` attribute to `b
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" placement="bottom" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" placement="bottom" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
This drawer slides in from the bottom.
|
This drawer slides in from the bottom.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -193,22 +193,22 @@ Unlike normal drawers, contained drawers are not modal. This means they do not s
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div
|
<div
|
||||||
style="position: relative; border: solid 2px var(--sl-panel-border-color); height: 300px; padding: 1rem; margin-bottom: 1rem;"
|
style="position: relative; border: solid 2px var(--wa-color-surface-border); height: 300px; padding: 1rem; margin-bottom: 1rem;"
|
||||||
>
|
>
|
||||||
The drawer will be contained to this box. This content won't shift or be affected in any way when the drawer opens.
|
The drawer will be contained to this box. This content won't shift or be affected in any way when the drawer opens.
|
||||||
|
|
||||||
<sl-drawer label="Drawer" contained class="drawer-contained" style="--size: 50%;">
|
<wa-drawer label="Drawer" contained class="drawer-contained" style="--size: 50%;">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<sl-button>Toggle Drawer</sl-button>
|
<wa-button>Toggle Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-contained');
|
const drawer = document.querySelector('.drawer-contained');
|
||||||
const openButton = drawer.parentElement.nextElementSibling;
|
const openButton = drawer.parentElement.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => (drawer.open = !drawer.open));
|
openButton.addEventListener('click', () => (drawer.open = !drawer.open));
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -219,8 +219,8 @@ Unlike normal drawers, contained drawers are not modal. This means they do not s
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -230,7 +230,7 @@ const App = () => {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
border: 'solid 2px var(--sl-panel-border-color)',
|
border: 'solid 2px var(--wa-color-surface-border)',
|
||||||
height: '300px',
|
height: '300px',
|
||||||
padding: '1rem',
|
padding: '1rem',
|
||||||
marginBottom: '1rem'
|
marginBottom: '1rem'
|
||||||
@@ -238,22 +238,22 @@ const App = () => {
|
|||||||
>
|
>
|
||||||
The drawer will be contained to this box. This content won't shift or be affected in any way when the drawer
|
The drawer will be contained to this box. This content won't shift or be affected in any way when the drawer
|
||||||
opens.
|
opens.
|
||||||
<SlDrawer
|
<WaDrawer
|
||||||
label="Drawer"
|
label="Drawer"
|
||||||
contained
|
contained
|
||||||
no-modal
|
no-modal
|
||||||
open={open}
|
open={open}
|
||||||
onSlAfterHide={() => setOpen(false)}
|
onWaAfterHide={() => setOpen(false)}
|
||||||
style={{ '--size': '50%' }}
|
style={{ '--size': '50%' }}
|
||||||
>
|
>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -266,17 +266,17 @@ const App = () => {
|
|||||||
Use the `--size` custom property to set the drawer's size. This will be applied to the drawer's width or height depending on its `placement`.
|
Use the `--size` custom property to set the drawer's size. This will be applied to the drawer's width or height depending on its `placement`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-custom-size" style="--size: 50vw;">
|
<wa-drawer label="Drawer" class="drawer-custom-size" style="--size: 50vw;">
|
||||||
This drawer is always 50% of the viewport.
|
This drawer is always 50% of the viewport.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-custom-size');
|
const drawer = document.querySelector('.drawer-custom-size');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -287,22 +287,22 @@ Use the `--size` custom property to set the drawer's size. This will be applied
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlAfterHide={() => setOpen(false)} style={{ '--size': '50vw' }}>
|
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)} style={{ '--size': '50vw' }}>
|
||||||
This drawer is always 50% of the viewport.
|
This drawer is always 50% of the viewport.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -315,19 +315,19 @@ const App = () => {
|
|||||||
By design, a drawer's height will never exceed 100% of its container. As such, drawers will not scroll with the page to ensure the header and footer are always accessible to the user.
|
By design, a drawer's height will never exceed 100% of its container. As such, drawers will not scroll with the page to ensure the header and footer are always accessible to the user.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-scrolling">
|
<wa-drawer label="Drawer" class="drawer-scrolling">
|
||||||
<div style="height: 150vh; border: dashed 2px var(--sl-color-neutral-200); padding: 0 1rem;">
|
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-border); padding: 0 1rem;">
|
||||||
<p>Scroll down and give it a try! 👇</p>
|
<p>Scroll down and give it a try! 👇</p>
|
||||||
</div>
|
</div>
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-scrolling');
|
const drawer = document.querySelector('.drawer-scrolling');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -338,30 +338,30 @@ By design, a drawer's height will never exceed 100% of its container. As such, d
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
height: '150vh',
|
height: '150vh',
|
||||||
border: 'dashed 2px var(--sl-color-neutral-200)',
|
border: 'dashed 2px var(--wa-color-surface-border)',
|
||||||
padding: '0 1rem'
|
padding: '0 1rem'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p>Scroll down and give it a try! 👇</p>
|
<p>Scroll down and give it a try! 👇</p>
|
||||||
</div>
|
</div>
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -374,18 +374,18 @@ const App = () => {
|
|||||||
The header shows a functional close button by default. You can use the `header-actions` slot to add additional [icon buttons](/components/icon-button) if needed.
|
The header shows a functional close button by default. You can use the `header-actions` slot to add additional [icon buttons](/components/icon-button) if needed.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-header-actions">
|
<wa-drawer label="Drawer" class="drawer-header-actions">
|
||||||
<sl-icon-button class="new-window" slot="header-actions" name="box-arrow-up-right"></sl-icon-button>
|
<wa-icon-button class="new-window" slot="header-actions" name="arrow-up-right-from-square" variant="solid"></wa-icon-button>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-header-actions');
|
const drawer = document.querySelector('.drawer-header-actions');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
const newWindowButton = drawer.querySelector('.new-window');
|
const newWindowButton = drawer.querySelector('.new-window');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
@@ -396,24 +396,24 @@ The header shows a functional close button by default. You can use the `header-a
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<SlIconButton slot="header-actions" name="box-arrow-up-right" onClick={() => window.open(location.href)} />
|
<WaIconButton slot="header-actions" name="arrow-up-right-from-square" onClick={() => window.open(location.href)} />
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -423,28 +423,28 @@ const App = () => {
|
|||||||
|
|
||||||
By default, drawers will close when the user clicks the close button, clicks the overlay, or presses the [[Escape]] key. In most cases, the default behavior is the best behavior in terms of UX. However, there are situations where this may be undesirable, such as when data loss will occur.
|
By default, drawers will close when the user clicks the close button, clicks the overlay, or presses the [[Escape]] key. In most cases, the default behavior is the best behavior in terms of UX. However, there are situations where this may be undesirable, such as when data loss will occur.
|
||||||
|
|
||||||
To keep the drawer open in such cases, you can cancel the `sl-request-close` event. When canceled, the drawer will remain open and pulse briefly to draw the user's attention to it.
|
To keep the drawer open in such cases, you can cancel the `wa-request-close` event. When canceled, the drawer will remain open and pulse briefly to draw the user's attention to it.
|
||||||
|
|
||||||
You can use `event.detail.source` to determine what triggered the request to close. This example prevents the drawer from closing when the overlay is clicked, but allows the close button or [[Escape]] to dismiss it.
|
You can use `event.detail.source` to determine what triggered the request to close. This example prevents the drawer from closing when the overlay is clicked, but allows the close button or [[Escape]] to dismiss it.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-deny-close">
|
<wa-drawer label="Drawer" class="drawer-deny-close">
|
||||||
This drawer will not close when you click on the overlay.
|
This drawer will not close when you click on the overlay.
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-deny-close');
|
const drawer = document.querySelector('.drawer-deny-close');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
|
|
||||||
// Prevent the drawer from closing when the user clicks on the overlay
|
// Prevent the drawer from closing when the user clicks on the overlay
|
||||||
drawer.addEventListener('sl-request-close', event => {
|
drawer.addEventListener('wa-request-close', event => {
|
||||||
if (event.detail.source === 'overlay') {
|
if (event.detail.source === 'overlay') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -454,8 +454,8 @@ You can use `event.detail.source` to determine what triggered the request to clo
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -469,14 +469,14 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlRequestClose={handleRequestClose} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" open={open} onWaRequestClose={handleRequestClose} onWaAfterHide={() => setOpen(false)}>
|
||||||
This drawer will not close when you click on the overlay.
|
This drawer will not close when you click on the overlay.
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Save & Close
|
Save & Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -487,18 +487,18 @@ const App = () => {
|
|||||||
By default, the drawer's panel will gain focus when opened. This allows a subsequent tab press to focus on the first tabbable element in the drawer. If you want a different element to have focus, add the `autofocus` attribute to it as shown below.
|
By default, the drawer's panel will gain focus when opened. This allows a subsequent tab press to focus on the first tabbable element in the drawer. If you want a different element to have focus, add the `autofocus` attribute to it as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-drawer label="Drawer" class="drawer-focus">
|
<wa-drawer label="Drawer" class="drawer-focus">
|
||||||
<sl-input autofocus placeholder="I will have focus when the drawer is opened"></sl-input>
|
<wa-input autofocus placeholder="I will have focus when the drawer is opened"></wa-input>
|
||||||
<sl-button slot="footer" variant="primary">Close</sl-button>
|
<wa-button slot="footer" variant="brand">Close</wa-button>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
|
|
||||||
<sl-button>Open Drawer</sl-button>
|
<wa-button>Open Drawer</wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const drawer = document.querySelector('.drawer-focus');
|
const drawer = document.querySelector('.drawer-focus');
|
||||||
const input = drawer.querySelector('sl-input');
|
const input = drawer.querySelector('wa-input');
|
||||||
const openButton = drawer.nextElementSibling;
|
const openButton = drawer.nextElementSibling;
|
||||||
const closeButton = drawer.querySelector('sl-button[variant="primary"]');
|
const closeButton = drawer.querySelector('wa-button[variant="brand"]');
|
||||||
|
|
||||||
openButton.addEventListener('click', () => drawer.show());
|
openButton.addEventListener('click', () => drawer.show());
|
||||||
closeButton.addEventListener('click', () => drawer.hide());
|
closeButton.addEventListener('click', () => drawer.hide());
|
||||||
@@ -507,28 +507,28 @@ By default, the drawer's panel will gain focus when opened. This allows a subseq
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDrawer from '@shoelace-style/shoelace/dist/react/sl-drawer';
|
import WaDrawer from '@shoelace-style/shoelace/dist/react/drawer';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlDrawer label="Drawer" open={open} onSlAfterHide={() => setOpen(false)}>
|
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)}>
|
||||||
<SlInput autofocus placeholder="I will have focus when the drawer is opened" />
|
<WaInput autofocus placeholder="I will have focus when the drawer is opened" />
|
||||||
<SlButton slot="footer" variant="primary" onClick={() => setOpen(false)}>
|
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlDrawer>
|
</WaDrawer>
|
||||||
|
|
||||||
<SlButton onClick={() => setOpen(true)}>Open Drawer</SlButton>
|
<WaButton onClick={() => setOpen(true)}>Open Drawer</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
You can further customize initial focus behavior by canceling the `sl-initial-focus` event and setting focus yourself inside the event handler.
|
You can further customize initial focus behavior by canceling the `wa-initial-focus` event and setting focus yourself inside the event handler.
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -10,61 +10,61 @@ Dropdowns consist of a trigger and a panel. By default, activating the trigger w
|
|||||||
Dropdowns are designed to work well with [menus](/components/menu) to provide a list of options the user can select from. However, dropdowns can also be used in lower-level applications (e.g. [color picker](/components/color-picker)). The API gives you complete control over showing, hiding, and positioning the panel.
|
Dropdowns are designed to work well with [menus](/components/menu) to provide a list of options the user can select from. However, dropdowns can also be used in lower-level applications (e.g. [color picker](/components/color-picker)). The API gives you complete control over showing, hiding, and positioning the panel.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dropdown>
|
<wa-dropdown>
|
||||||
<sl-button slot="trigger" caret>Dropdown</sl-button>
|
<wa-button slot="trigger" caret>Dropdown</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Dropdown Item 1</sl-menu-item>
|
<wa-menu-item>Dropdown Item 1</wa-menu-item>
|
||||||
<sl-menu-item>Dropdown Item 2</sl-menu-item>
|
<wa-menu-item>Dropdown Item 2</wa-menu-item>
|
||||||
<sl-menu-item>Dropdown Item 3</sl-menu-item>
|
<wa-menu-item>Dropdown Item 3</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item type="checkbox" checked>Checkbox</sl-menu-item>
|
<wa-menu-item type="checkbox" checked>Checkbox</wa-menu-item>
|
||||||
<sl-menu-item disabled>Disabled</sl-menu-item>
|
<wa-menu-item disabled>Disabled</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
Prefix
|
Prefix
|
||||||
<sl-icon slot="prefix" name="gift"></sl-icon>
|
<wa-icon slot="prefix" name="gift" variant="solid"></wa-icon>
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
Suffix Icon
|
Suffix Icon
|
||||||
<sl-icon slot="suffix" name="heart"></sl-icon>
|
<wa-icon slot="suffix" name="heart" variant="solid"></wa-icon>
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDropdown>
|
<WaDropdown>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Dropdown
|
Dropdown
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Dropdown Item 1</SlMenuItem>
|
<WaMenuItem>Dropdown Item 1</WaMenuItem>
|
||||||
<SlMenuItem>Dropdown Item 2</SlMenuItem>
|
<WaMenuItem>Dropdown Item 2</WaMenuItem>
|
||||||
<SlMenuItem>Dropdown Item 3</SlMenuItem>
|
<WaMenuItem>Dropdown Item 3</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem type="checkbox" checked>
|
<WaMenuItem type="checkbox" checked>
|
||||||
Checkbox
|
Checkbox
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem disabled>Disabled</SlMenuItem>
|
<WaMenuItem disabled>Disabled</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Prefix
|
Prefix
|
||||||
<SlIcon slot="prefix" name="gift" />
|
<WaIcon slot="prefix" name="gift" />
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Suffix Icon
|
Suffix Icon
|
||||||
<SlIcon slot="suffix" name="heart" />
|
<WaIcon slot="suffix" name="heart" />
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -72,25 +72,25 @@ const App = () => (
|
|||||||
|
|
||||||
### Getting the Selected Item
|
### Getting the Selected Item
|
||||||
|
|
||||||
When dropdowns are used with [menus](/components/menu), you can listen for the [`sl-select`](/components/menu#events) event to determine which menu item was selected. The menu item element will be exposed in `event.detail.item`. You can set `value` props to make it easier to identify commands.
|
When dropdowns are used with [menus](/components/menu), you can listen for the [`wa-select`](/components/menu#events) event to determine which menu item was selected. The menu item element will be exposed in `event.detail.item`. You can set `value` props to make it easier to identify commands.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="dropdown-selection">
|
<div class="dropdown-selection">
|
||||||
<sl-dropdown>
|
<wa-dropdown>
|
||||||
<sl-button slot="trigger" caret>Edit</sl-button>
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item value="cut">Cut</sl-menu-item>
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
<sl-menu-item value="copy">Copy</sl-menu-item>
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
<sl-menu-item value="paste">Paste</sl-menu-item>
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.dropdown-selection');
|
const container = document.querySelector('.dropdown-selection');
|
||||||
const dropdown = container.querySelector('sl-dropdown');
|
const dropdown = container.querySelector('wa-dropdown');
|
||||||
|
|
||||||
dropdown.addEventListener('sl-select', event => {
|
dropdown.addEventListener('wa-select', event => {
|
||||||
const selectedItem = event.detail.item;
|
const selectedItem = event.detail.item;
|
||||||
console.log(selectedItem.value);
|
console.log(selectedItem.value);
|
||||||
});
|
});
|
||||||
@@ -98,10 +98,10 @@ When dropdowns are used with [menus](/components/menu), you can listen for the [
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSelect(event) {
|
function handleSelect(event) {
|
||||||
@@ -110,16 +110,16 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlDropdown>
|
<WaDropdown>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Edit
|
Edit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu onSlSelect={handleSelect}>
|
<WaMenu onWaSelect={handleSelect}>
|
||||||
<SlMenuItem value="cut">Cut</SlMenuItem>
|
<WaMenuItem value="cut">Cut</WaMenuItem>
|
||||||
<SlMenuItem value="copy">Copy</SlMenuItem>
|
<WaMenuItem value="copy">Copy</WaMenuItem>
|
||||||
<SlMenuItem value="paste">Paste</SlMenuItem>
|
<WaMenuItem value="paste">Paste</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -128,21 +128,21 @@ Alternatively, you can listen for the `click` event on individual menu items. No
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="dropdown-selection-alt">
|
<div class="dropdown-selection-alt">
|
||||||
<sl-dropdown>
|
<wa-dropdown>
|
||||||
<sl-button slot="trigger" caret>Edit</sl-button>
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item value="cut">Cut</sl-menu-item>
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
<sl-menu-item value="copy">Copy</sl-menu-item>
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
<sl-menu-item value="paste">Paste</sl-menu-item>
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.dropdown-selection-alt');
|
const container = document.querySelector('.dropdown-selection-alt');
|
||||||
const cut = container.querySelector('sl-menu-item[value="cut"]');
|
const cut = container.querySelector('wa-menu-item[value="cut"]');
|
||||||
const copy = container.querySelector('sl-menu-item[value="copy"]');
|
const copy = container.querySelector('wa-menu-item[value="copy"]');
|
||||||
const paste = container.querySelector('sl-menu-item[value="paste"]');
|
const paste = container.querySelector('wa-menu-item[value="paste"]');
|
||||||
|
|
||||||
cut.addEventListener('click', () => console.log('cut'));
|
cut.addEventListener('click', () => console.log('cut'));
|
||||||
copy.addEventListener('click', () => console.log('copy'));
|
copy.addEventListener('click', () => console.log('copy'));
|
||||||
@@ -151,10 +151,10 @@ Alternatively, you can listen for the `click` event on individual menu items. No
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleCut() {
|
function handleCut() {
|
||||||
@@ -170,16 +170,16 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlDropdown>
|
<WaDropdown>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Edit
|
Edit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem onClick={handleCut}>Cut</SlMenuItem>
|
<WaMenuItem onClick={handleCut}>Cut</WaMenuItem>
|
||||||
<SlMenuItem onClick={handleCopy}>Copy</SlMenuItem>
|
<WaMenuItem onClick={handleCopy}>Copy</WaMenuItem>
|
||||||
<SlMenuItem onClick={handlePaste}>Paste</SlMenuItem>
|
<WaMenuItem onClick={handlePaste}>Paste</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -189,40 +189,40 @@ const App = () => {
|
|||||||
The preferred placement of the dropdown can be set with the `placement` attribute. Note that the actual position may vary to ensure the panel remains in the viewport.
|
The preferred placement of the dropdown can be set with the `placement` attribute. Note that the actual position may vary to ensure the panel remains in the viewport.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dropdown placement="top-start">
|
<wa-dropdown placement="top-start">
|
||||||
<sl-button slot="trigger" caret>Edit</sl-button>
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Cut</sl-menu-item>
|
<wa-menu-item>Cut</wa-menu-item>
|
||||||
<sl-menu-item>Copy</sl-menu-item>
|
<wa-menu-item>Copy</wa-menu-item>
|
||||||
<sl-menu-item>Paste</sl-menu-item>
|
<wa-menu-item>Paste</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item>Find</sl-menu-item>
|
<wa-menu-item>Find</wa-menu-item>
|
||||||
<sl-menu-item>Replace</sl-menu-item>
|
<wa-menu-item>Replace</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDropdown placement="top-start">
|
<WaDropdown placement="top-start">
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Edit
|
Edit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Cut</SlMenuItem>
|
<WaMenuItem>Cut</WaMenuItem>
|
||||||
<SlMenuItem>Copy</SlMenuItem>
|
<WaMenuItem>Copy</WaMenuItem>
|
||||||
<SlMenuItem>Paste</SlMenuItem>
|
<WaMenuItem>Paste</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem>Find</SlMenuItem>
|
<WaMenuItem>Find</WaMenuItem>
|
||||||
<SlMenuItem>Replace</SlMenuItem>
|
<WaMenuItem>Replace</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -231,40 +231,40 @@ const App = () => (
|
|||||||
The distance from the panel to the trigger can be customized using the `distance` attribute. This value is specified in pixels.
|
The distance from the panel to the trigger can be customized using the `distance` attribute. This value is specified in pixels.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dropdown distance="30">
|
<wa-dropdown distance="30">
|
||||||
<sl-button slot="trigger" caret>Edit</sl-button>
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Cut</sl-menu-item>
|
<wa-menu-item>Cut</wa-menu-item>
|
||||||
<sl-menu-item>Copy</sl-menu-item>
|
<wa-menu-item>Copy</wa-menu-item>
|
||||||
<sl-menu-item>Paste</sl-menu-item>
|
<wa-menu-item>Paste</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item>Find</sl-menu-item>
|
<wa-menu-item>Find</wa-menu-item>
|
||||||
<sl-menu-item>Replace</sl-menu-item>
|
<wa-menu-item>Replace</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDropdown distance={30}>
|
<WaDropdown distance={30}>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Edit
|
Edit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Cut</SlMenuItem>
|
<WaMenuItem>Cut</WaMenuItem>
|
||||||
<SlMenuItem>Copy</SlMenuItem>
|
<WaMenuItem>Copy</WaMenuItem>
|
||||||
<SlMenuItem>Paste</SlMenuItem>
|
<WaMenuItem>Paste</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem>Find</SlMenuItem>
|
<WaMenuItem>Find</WaMenuItem>
|
||||||
<SlMenuItem>Replace</SlMenuItem>
|
<WaMenuItem>Replace</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -273,90 +273,179 @@ const App = () => (
|
|||||||
The offset of the panel along the trigger can be customized using the `skidding` attribute. This value is specified in pixels.
|
The offset of the panel along the trigger can be customized using the `skidding` attribute. This value is specified in pixels.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-dropdown skidding="30">
|
<wa-dropdown skidding="30">
|
||||||
<sl-button slot="trigger" caret>Edit</sl-button>
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Cut</sl-menu-item>
|
<wa-menu-item>Cut</wa-menu-item>
|
||||||
<sl-menu-item>Copy</sl-menu-item>
|
<wa-menu-item>Copy</wa-menu-item>
|
||||||
<sl-menu-item>Paste</sl-menu-item>
|
<wa-menu-item>Paste</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item>Find</sl-menu-item>
|
<wa-menu-item>Find</wa-menu-item>
|
||||||
<sl-menu-item>Replace</sl-menu-item>
|
<wa-menu-item>Replace</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlDropdown skidding={30}>
|
<WaDropdown skidding={30}>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Edit
|
Edit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Cut</SlMenuItem>
|
<WaMenuItem>Cut</WaMenuItem>
|
||||||
<SlMenuItem>Copy</SlMenuItem>
|
<WaMenuItem>Copy</WaMenuItem>
|
||||||
<SlMenuItem>Paste</SlMenuItem>
|
<WaMenuItem>Paste</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem>Find</SlMenuItem>
|
<WaMenuItem>Find</WaMenuItem>
|
||||||
<SlMenuItem>Replace</SlMenuItem>
|
<WaMenuItem>Replace</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Submenus
|
||||||
|
|
||||||
|
To create a submenu, nest an `<wa-menu slot="submenu">` element in a [menu item](/components/menu-item).
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-dropdown>
|
||||||
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
|
|
||||||
|
<wa-menu style="max-width: 200px;">
|
||||||
|
<wa-menu-item value="undo">Undo</wa-menu-item>
|
||||||
|
<wa-menu-item value="redo">Redo</wa-menu-item>
|
||||||
|
<wa-divider></wa-divider>
|
||||||
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
|
<wa-divider></wa-divider>
|
||||||
|
<wa-menu-item>
|
||||||
|
Find
|
||||||
|
<wa-menu slot="submenu">
|
||||||
|
<wa-menu-item value="find">Find…</wa-menu-item>
|
||||||
|
<wa-menu-item value="find-previous">Find Next</wa-menu-item>
|
||||||
|
<wa-menu-item value="find-next">Find Previous</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-menu-item>
|
||||||
|
<wa-menu-item>
|
||||||
|
Transformations
|
||||||
|
<wa-menu slot="submenu">
|
||||||
|
<wa-menu-item value="uppercase">Make uppercase</wa-menu-item>
|
||||||
|
<wa-menu-item value="lowercase">Make lowercase</wa-menu-item>
|
||||||
|
<wa-menu-item value="capitalize">Capitalize</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-dropdown>
|
||||||
|
```
|
||||||
|
|
||||||
|
```jsx:react
|
||||||
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
|
const css = `
|
||||||
|
.dropdown-hoist {
|
||||||
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
|
padding: var(--wa-space-m);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const App = () => (
|
||||||
|
<>
|
||||||
|
<WaDropdown>
|
||||||
|
<WaButton slot="trigger" caret>Edit</WaButton>
|
||||||
|
|
||||||
|
<WaMenu style="max-width: 200px;">
|
||||||
|
<WaMenuItem value="undo">Undo</WaMenuItem>
|
||||||
|
<WaMenuItem value="redo">Redo</WaMenuItem>
|
||||||
|
<WaDivider />
|
||||||
|
<WaMenuItem value="cut">Cut</WaMenuItem>
|
||||||
|
<WaMenuItem value="copy">Copy</WaMenuItem>
|
||||||
|
<WaMenuItem value="paste">Paste</WaMenuItem>
|
||||||
|
<WaDivider />
|
||||||
|
<WaMenuItem>
|
||||||
|
Find
|
||||||
|
<WaMenu slot="submenu">
|
||||||
|
<WaMenuItem value="find">Find…</WaMenuItem>
|
||||||
|
<WaMenuItem value="find-previous">Find Next</WaMenuItem>
|
||||||
|
<WaMenuItem value="find-next">Find Previous</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaMenuItem>
|
||||||
|
<WaMenuItem>
|
||||||
|
Transformations
|
||||||
|
<WaMenu slot="submenu">
|
||||||
|
<WaMenuItem value="uppercase">Make uppercase</WaMenuItem>
|
||||||
|
<WaMenuItem value="lowercase">Make lowercase</WaMenuItem>
|
||||||
|
<WaMenuItem value="capitalize">Capitalize</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaDropdown>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
As a UX best practice, avoid using more than one level of submenu when possible.
|
||||||
|
:::
|
||||||
|
|
||||||
### Hoisting
|
### Hoisting
|
||||||
|
|
||||||
Dropdown panels will be clipped if they're inside a container that has `overflow: auto|hidden`. The `hoist` attribute forces the panel to use a fixed positioning strategy, allowing it to break out of the container. In this case, the panel will be positioned relative to its [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#Identifying_the_containing_block), which is usually the viewport unless an ancestor uses a `transform`, `perspective`, or `filter`. [Refer to this page](https://developer.mozilla.org/en-US/docs/Web/CSS/position#fixed) for more details.
|
Dropdown panels will be clipped if they're inside a container that has `overflow: auto|hidden`. The `hoist` attribute forces the panel to use a fixed positioning strategy, allowing it to break out of the container. In this case, the panel will be positioned relative to its [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#Identifying_the_containing_block), which is usually the viewport unless an ancestor uses a `transform`, `perspective`, or `filter`. [Refer to this page](https://developer.mozilla.org/en-US/docs/Web/CSS/position#fixed) for more details.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="dropdown-hoist">
|
<div class="dropdown-hoist">
|
||||||
<sl-dropdown>
|
<wa-dropdown>
|
||||||
<sl-button slot="trigger" caret>No Hoist</sl-button>
|
<wa-button slot="trigger" caret>No Hoist</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Item 1</sl-menu-item>
|
<wa-menu-item>Item 1</wa-menu-item>
|
||||||
<sl-menu-item>Item 2</sl-menu-item>
|
<wa-menu-item>Item 2</wa-menu-item>
|
||||||
<sl-menu-item>Item 3</sl-menu-item>
|
<wa-menu-item>Item 3</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
|
|
||||||
<sl-dropdown hoist>
|
<wa-dropdown hoist>
|
||||||
<sl-button slot="trigger" caret>Hoist</sl-button>
|
<wa-button slot="trigger" caret>Hoist</wa-button>
|
||||||
<sl-menu>
|
<wa-menu>
|
||||||
<sl-menu-item>Item 1</sl-menu-item>
|
<wa-menu-item>Item 1</wa-menu-item>
|
||||||
<sl-menu-item>Item 2</sl-menu-item>
|
<wa-menu-item>Item 2</wa-menu-item>
|
||||||
<sl-menu-item>Item 3</sl-menu-item>
|
<wa-menu-item>Item 3</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
</sl-dropdown>
|
</wa-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.dropdown-hoist {
|
.dropdown-hoist {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: solid 2px var(--sl-panel-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
padding: var(--sl-spacing-medium);
|
padding: var(--wa-space-m);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlDropdown from '@shoelace-style/shoelace/dist/react/sl-dropdown';
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.dropdown-hoist {
|
.dropdown-hoist {
|
||||||
border: solid 2px var(--sl-panel-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
padding: var(--sl-spacing-medium);
|
padding: var(--wa-space-m);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -364,27 +453,27 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="dropdown-hoist">
|
<div className="dropdown-hoist">
|
||||||
<SlDropdown>
|
<WaDropdown>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
No Hoist
|
No Hoist
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Item 1</SlMenuItem>
|
<WaMenuItem>Item 1</WaMenuItem>
|
||||||
<SlMenuItem>Item 2</SlMenuItem>
|
<WaMenuItem>Item 2</WaMenuItem>
|
||||||
<SlMenuItem>Item 3</SlMenuItem>
|
<WaMenuItem>Item 3</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
|
|
||||||
<SlDropdown hoist>
|
<WaDropdown hoist>
|
||||||
<SlButton slot="trigger" caret>
|
<WaButton slot="trigger" caret>
|
||||||
Hoist
|
Hoist
|
||||||
</SlButton>
|
</WaButton>
|
||||||
<SlMenu>
|
<WaMenu>
|
||||||
<SlMenuItem>Item 1</SlMenuItem>
|
<WaMenuItem>Item 1</WaMenuItem>
|
||||||
<SlMenuItem>Item 2</SlMenuItem>
|
<WaMenuItem>Item 2</WaMenuItem>
|
||||||
<SlMenuItem>Item 3</SlMenuItem>
|
<WaMenuItem>Item 3</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ layout: component
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="format-bytes-overview">
|
<div class="format-bytes-overview">
|
||||||
The file is <sl-format-bytes value="1000"></sl-format-bytes> in size. <br /><br />
|
The file is <wa-format-bytes value="1000"></wa-format-bytes> in size. <br /><br />
|
||||||
<sl-input type="number" value="1000" label="Number to Format" style="max-width: 180px;"></sl-input>
|
<wa-input type="number" value="1000" label="Number to Format" style="max-width: 180px;"></wa-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.format-bytes-overview');
|
const container = document.querySelector('.format-bytes-overview');
|
||||||
const formatter = container.querySelector('sl-format-bytes');
|
const formatter = container.querySelector('wa-format-bytes');
|
||||||
const input = container.querySelector('sl-input');
|
const input = container.querySelector('wa-input');
|
||||||
|
|
||||||
input.addEventListener('sl-input', () => (formatter.value = input.value || 0));
|
input.addEventListener('wa-input', () => (formatter.value = input.value || 0));
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -24,24 +24,24 @@ layout: component
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlFormatBytes from '@shoelace-style/shoelace/dist/react/sl-format-bytes';
|
import WaFormatBytes from '@shoelace-style/shoelace/dist/react/format-bytes';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [value, setValue] = useState(1000);
|
const [value, setValue] = useState(1000);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
The file is <SlFormatBytes value={value} /> in size.
|
The file is <WaFormatBytes value={value} /> in size.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<SlInput
|
<WaInput
|
||||||
type="number"
|
type="number"
|
||||||
value={value}
|
value={value}
|
||||||
label="Number to Format"
|
label="Number to Format"
|
||||||
style={{ maxWidth: '180px' }}
|
style={{ maxWidth: '180px' }}
|
||||||
onSlInput={event => setValue(event.target.value)}
|
onWaInput={event => setValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -57,24 +57,24 @@ const App = () => {
|
|||||||
Set the `value` attribute to a number to get the value in bytes.
|
Set the `value` attribute to a number to get the value in bytes.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-bytes value="12"></sl-format-bytes><br />
|
<wa-format-bytes value="12"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200"></sl-format-bytes><br />
|
<wa-format-bytes value="1200"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000"></sl-format-bytes><br />
|
<wa-format-bytes value="1200000"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000000"></sl-format-bytes>
|
<wa-format-bytes value="1200000000"></wa-format-bytes>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatBytes from '@shoelace-style/shoelace/dist/react/sl-format-bytes';
|
import WaFormatBytes from '@shoelace-style/shoelace/dist/react/format-bytes';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatBytes value="12" />
|
<WaFormatBytes value="12" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200" />
|
<WaFormatBytes value="1200" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000" />
|
<WaFormatBytes value="1200000" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000000" />
|
<WaFormatBytes value="1200000000" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -84,24 +84,24 @@ const App = () => (
|
|||||||
To get the value in bits, set the `unit` attribute to `bit`.
|
To get the value in bits, set the `unit` attribute to `bit`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-bytes value="12" unit="bit"></sl-format-bytes><br />
|
<wa-format-bytes value="12" unit="bit"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200" unit="bit"></sl-format-bytes><br />
|
<wa-format-bytes value="1200" unit="bit"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000" unit="bit"></sl-format-bytes><br />
|
<wa-format-bytes value="1200000" unit="bit"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000000" unit="bit"></sl-format-bytes>
|
<wa-format-bytes value="1200000000" unit="bit"></wa-format-bytes>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatBytes from '@shoelace-style/shoelace/dist/react/sl-format-bytes';
|
import WaFormatBytes from '@shoelace-style/shoelace/dist/react/format-bytes';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatBytes value="12" unit="bit" />
|
<WaFormatBytes value="12" unit="bit" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200" unit="bit" />
|
<WaFormatBytes value="1200" unit="bit" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000" unit="bit" />
|
<WaFormatBytes value="1200000" unit="bit" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000000" unit="bit" />
|
<WaFormatBytes value="1200000000" unit="bit" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -111,24 +111,24 @@ const App = () => (
|
|||||||
Use the `lang` attribute to set the number formatting locale.
|
Use the `lang` attribute to set the number formatting locale.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-bytes value="12" lang="de"></sl-format-bytes><br />
|
<wa-format-bytes value="12" lang="de"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200" lang="de"></sl-format-bytes><br />
|
<wa-format-bytes value="1200" lang="de"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000" lang="de"></sl-format-bytes><br />
|
<wa-format-bytes value="1200000" lang="de"></wa-format-bytes><br />
|
||||||
<sl-format-bytes value="1200000000" lang="de"></sl-format-bytes>
|
<wa-format-bytes value="1200000000" lang="de"></wa-format-bytes>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatBytes from '@shoelace-style/shoelace/dist/react/sl-format-bytes';
|
import WaFormatBytes from '@shoelace-style/shoelace/dist/react/format-bytes';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatBytes value="12" lang="de" />
|
<WaFormatBytes value="12" lang="de" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200" lang="de" />
|
<WaFormatBytes value="1200" lang="de" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000" lang="de" />
|
<WaFormatBytes value="1200000" lang="de" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatBytes value="1200000000" lang="de" />
|
<WaFormatBytes value="1200000000" lang="de" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ layout: component
|
|||||||
Localization is handled by the browser's [`Intl.DateTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat). No language packs are required.
|
Localization is handled by the browser's [`Intl.DateTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat). No language packs are required.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<!-- Shoelace 2 release date 🎉 -->
|
<!-- Web Awesome 2 release date 🎉 -->
|
||||||
<sl-format-date date="2020-07-15T09:17:00-04:00"></sl-format-date>
|
<wa-format-date date="2020-07-15T09:17:00-04:00"></wa-format-date>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatDate from '@shoelace-style/shoelace/dist/react/sl-format-date';
|
import WaFormatDate from '@shoelace-style/shoelace/dist/react/format-date';
|
||||||
|
|
||||||
const App = () => <SlFormatDate date="2020-07-15T09:17:00-04:00" />;
|
const App = () => <WaFormatDate date="2020-07-15T09:17:00-04:00" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
The `date` attribute determines the date/time to use when formatting. It must be a string that [`Date.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) can interpret or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object set via JavaScript. If omitted, the current date/time will be assumed.
|
The `date` attribute determines the date/time to use when formatting. It must be a string that [`Date.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) can interpret or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object set via JavaScript. If omitted, the current date/time will be assumed.
|
||||||
@@ -32,51 +32,51 @@ Formatting options are based on those found in the [`Intl.DateTimeFormat` API](h
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<!-- Human-readable date -->
|
<!-- Human-readable date -->
|
||||||
<sl-format-date month="long" day="numeric" year="numeric"></sl-format-date><br />
|
<wa-format-date month="long" day="numeric" year="numeric"></wa-format-date><br />
|
||||||
|
|
||||||
<!-- Time -->
|
<!-- Time -->
|
||||||
<sl-format-date hour="numeric" minute="numeric"></sl-format-date><br />
|
<wa-format-date hour="numeric" minute="numeric"></wa-format-date><br />
|
||||||
|
|
||||||
<!-- Weekday -->
|
<!-- Weekday -->
|
||||||
<sl-format-date weekday="long"></sl-format-date><br />
|
<wa-format-date weekday="long"></wa-format-date><br />
|
||||||
|
|
||||||
<!-- Month -->
|
<!-- Month -->
|
||||||
<sl-format-date month="long"></sl-format-date><br />
|
<wa-format-date month="long"></wa-format-date><br />
|
||||||
|
|
||||||
<!-- Year -->
|
<!-- Year -->
|
||||||
<sl-format-date year="numeric"></sl-format-date><br />
|
<wa-format-date year="numeric"></wa-format-date><br />
|
||||||
|
|
||||||
<!-- No formatting options -->
|
<!-- No formatting options -->
|
||||||
<sl-format-date></sl-format-date>
|
<wa-format-date></wa-format-date>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatDate from '@shoelace-style/shoelace/dist/react/sl-format-date';
|
import WaFormatDate from '@shoelace-style/shoelace/dist/react/format-date';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
{/* Human-readable date */}
|
{/* Human-readable date */}
|
||||||
<SlFormatDate month="long" day="numeric" year="numeric" />
|
<WaFormatDate month="long" day="numeric" year="numeric" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
{/* Time */}
|
{/* Time */}
|
||||||
<SlFormatDate hour="numeric" minute="numeric" />
|
<WaFormatDate hour="numeric" minute="numeric" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
{/* Weekday */}
|
{/* Weekday */}
|
||||||
<SlFormatDate weekday="long" />
|
<WaFormatDate weekday="long" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
{/* Month */}
|
{/* Month */}
|
||||||
<SlFormatDate month="long" />
|
<WaFormatDate month="long" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
{/* Year */}
|
{/* Year */}
|
||||||
<SlFormatDate year="numeric" />
|
<WaFormatDate year="numeric" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
{/* No formatting options */}
|
{/* No formatting options */}
|
||||||
<SlFormatDate />
|
<WaFormatDate />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -86,18 +86,18 @@ const App = () => (
|
|||||||
By default, the browser will determine whether to use 12-hour or 24-hour time. To force one or the other, set the `hour-format` attribute to `12` or `24`.
|
By default, the browser will determine whether to use 12-hour or 24-hour time. To force one or the other, set the `hour-format` attribute to `12` or `24`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-date hour="numeric" minute="numeric" hour-format="12"></sl-format-date><br />
|
<wa-format-date hour="numeric" minute="numeric" hour-format="12"></wa-format-date><br />
|
||||||
<sl-format-date hour="numeric" minute="numeric" hour-format="24"></sl-format-date>
|
<wa-format-date hour="numeric" minute="numeric" hour-format="24"></wa-format-date>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatDate from '@shoelace-style/shoelace/dist/react/sl-format-date';
|
import WaFormatDate from '@shoelace-style/shoelace/dist/react/format-date';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatDate hour="numeric" minute="numeric" hour-format="12" />
|
<WaFormatDate hour="numeric" minute="numeric" hour-format="12" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatDate hour="numeric" minute="numeric" hour-format="24" />
|
<WaFormatDate hour="numeric" minute="numeric" hour-format="24" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -107,21 +107,21 @@ const App = () => (
|
|||||||
Use the `lang` attribute to set the date/time formatting locale.
|
Use the `lang` attribute to set the date/time formatting locale.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
English: <sl-format-date lang="en"></sl-format-date><br />
|
English: <wa-format-date lang="en"></wa-format-date><br />
|
||||||
French: <sl-format-date lang="fr"></sl-format-date><br />
|
French: <wa-format-date lang="fr"></wa-format-date><br />
|
||||||
Russian: <sl-format-date lang="ru"></sl-format-date>
|
Russian: <wa-format-date lang="ru"></wa-format-date>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatDate from '@shoelace-style/shoelace/dist/react/sl-format-date';
|
import WaFormatDate from '@shoelace-style/shoelace/dist/react/format-date';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
English: <SlFormatDate lang="en" />
|
English: <WaFormatDate lang="en" />
|
||||||
<br />
|
<br />
|
||||||
French: <SlFormatDate lang="fr" />
|
French: <WaFormatDate lang="fr" />
|
||||||
<br />
|
<br />
|
||||||
Russian: <SlFormatDate lang="ru" />
|
Russian: <WaFormatDate lang="ru" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -9,17 +9,17 @@ Localization is handled by the browser's [`Intl.NumberFormat` API](https://devel
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="format-number-overview">
|
<div class="format-number-overview">
|
||||||
<sl-format-number value="1000"></sl-format-number>
|
<wa-format-number value="1000"></wa-format-number>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<sl-input type="number" value="1000" label="Number to Format" style="max-width: 180px;"></sl-input>
|
<wa-input type="number" value="1000" label="Number to Format" style="max-width: 180px;"></wa-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.format-number-overview');
|
const container = document.querySelector('.format-number-overview');
|
||||||
const formatter = container.querySelector('sl-format-number');
|
const formatter = container.querySelector('wa-format-number');
|
||||||
const input = container.querySelector('sl-input');
|
const input = container.querySelector('wa-input');
|
||||||
|
|
||||||
input.addEventListener('sl-input', () => (formatter.value = input.value || 0));
|
input.addEventListener('wa-input', () => (formatter.value = input.value || 0));
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -27,23 +27,23 @@ Localization is handled by the browser's [`Intl.NumberFormat` API](https://devel
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
import WaFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [value, setValue] = useState(1000);
|
const [value, setValue] = useState(1000);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlFormatNumber value={value} />
|
<WaFormatNumber value={value} />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<SlInput
|
<WaInput
|
||||||
type="number"
|
type="number"
|
||||||
value={value}
|
value={value}
|
||||||
label="Number to Format"
|
label="Number to Format"
|
||||||
style={{ maxWidth: '180px' }}
|
style={{ maxWidth: '180px' }}
|
||||||
onSlInput={event => setValue(event.target.value)}
|
onWaInput={event => setValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -59,27 +59,27 @@ const App = () => {
|
|||||||
To get the value as a percent, set the `type` attribute to `percent`.
|
To get the value as a percent, set the `type` attribute to `percent`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-number type="percent" value="0"></sl-format-number><br />
|
<wa-format-number type="percent" value="0"></wa-format-number><br />
|
||||||
<sl-format-number type="percent" value="0.25"></sl-format-number><br />
|
<wa-format-number type="percent" value="0.25"></wa-format-number><br />
|
||||||
<sl-format-number type="percent" value="0.50"></sl-format-number><br />
|
<wa-format-number type="percent" value="0.50"></wa-format-number><br />
|
||||||
<sl-format-number type="percent" value="0.75"></sl-format-number><br />
|
<wa-format-number type="percent" value="0.75"></wa-format-number><br />
|
||||||
<sl-format-number type="percent" value="1"></sl-format-number>
|
<wa-format-number type="percent" value="1"></wa-format-number>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
import WaFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatNumber type="percent" value={0} />
|
<WaFormatNumber type="percent" value={0} />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="percent" value={0.25} />
|
<WaFormatNumber type="percent" value={0.25} />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="percent" value={0.5} />
|
<WaFormatNumber type="percent" value={0.5} />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="percent" value={0.75} />
|
<WaFormatNumber type="percent" value={0.75} />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="percent" value={1} />
|
<WaFormatNumber type="percent" value={1} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -89,21 +89,21 @@ const App = () => (
|
|||||||
Use the `lang` attribute to set the number formatting locale.
|
Use the `lang` attribute to set the number formatting locale.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
English: <sl-format-number value="2000" lang="en" minimum-fraction-digits="2"></sl-format-number><br />
|
English: <wa-format-number value="2000" lang="en" minimum-fraction-digits="2"></wa-format-number><br />
|
||||||
German: <sl-format-number value="2000" lang="de" minimum-fraction-digits="2"></sl-format-number><br />
|
German: <wa-format-number value="2000" lang="de" minimum-fraction-digits="2"></wa-format-number><br />
|
||||||
Russian: <sl-format-number value="2000" lang="ru" minimum-fraction-digits="2"></sl-format-number>
|
Russian: <wa-format-number value="2000" lang="ru" minimum-fraction-digits="2"></wa-format-number>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatNumber from '@shoelace-style/shoelace/dist/react/sl-format-number';
|
import WaFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
English: <SlFormatNumber value="2000" lang="en" minimum-fraction-digits="2" />
|
English: <WaFormatNumber value="2000" lang="en" minimum-fraction-digits="2" />
|
||||||
<br />
|
<br />
|
||||||
German: <SlFormatNumber value="2000" lang="de" minimum-fraction-digits="2" />
|
German: <WaFormatNumber value="2000" lang="de" minimum-fraction-digits="2" />
|
||||||
<br />
|
<br />
|
||||||
Russian: <SlFormatNumber value="2000" lang="ru" minimum-fraction-digits="2" />
|
Russian: <WaFormatNumber value="2000" lang="ru" minimum-fraction-digits="2" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -113,27 +113,27 @@ const App = () => (
|
|||||||
To format a number as a monetary value, set the `type` attribute to `currency` and set the `currency` attribute to the desired ISO 4217 currency code. You should also specify `lang` to ensure the the number is formatted correctly for the target locale.
|
To format a number as a monetary value, set the `type` attribute to `currency` and set the `currency` attribute to the desired ISO 4217 currency code. You should also specify `lang` to ensure the the number is formatted correctly for the target locale.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-format-number type="currency" currency="USD" value="2000" lang="en-US"></sl-format-number><br />
|
<wa-format-number type="currency" currency="USD" value="2000" lang="en-US"></wa-format-number><br />
|
||||||
<sl-format-number type="currency" currency="GBP" value="2000" lang="en-GB"></sl-format-number><br />
|
<wa-format-number type="currency" currency="GBP" value="2000" lang="en-GB"></wa-format-number><br />
|
||||||
<sl-format-number type="currency" currency="EUR" value="2000" lang="de"></sl-format-number><br />
|
<wa-format-number type="currency" currency="EUR" value="2000" lang="de"></wa-format-number><br />
|
||||||
<sl-format-number type="currency" currency="RUB" value="2000" lang="ru"></sl-format-number><br />
|
<wa-format-number type="currency" currency="RUB" value="2000" lang="ru"></wa-format-number><br />
|
||||||
<sl-format-number type="currency" currency="CNY" value="2000" lang="zh-cn"></sl-format-number>
|
<wa-format-number type="currency" currency="CNY" value="2000" lang="zh-cn"></wa-format-number>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlFormatNumber from '@shoelace-style/shoelace/dist/react/sl-format-number';
|
import WaFormatNumber from '@shoelace-style/shoelace/dist/react/format-number';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlFormatNumber type="currency" currency="USD" value="2000" lang="en-US" />
|
<WaFormatNumber type="currency" currency="USD" value="2000" lang="en-US" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="currency" currency="GBP" value="2000" lang="en-GB" />
|
<WaFormatNumber type="currency" currency="GBP" value="2000" lang="en-GB" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="currency" currency="EUR" value="2000" lang="de" />
|
<WaFormatNumber type="currency" currency="EUR" value="2000" lang="de" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="currency" currency="RUB" value="2000" lang="ru" />
|
<WaFormatNumber type="currency" currency="RUB" value="2000" lang="ru" />
|
||||||
<br />
|
<br />
|
||||||
<SlFormatNumber type="currency" currency="CNY" value="2000" lang="zh-cn" />
|
<WaFormatNumber type="currency" currency="CNY" value="2000" lang="zh-cn" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ meta:
|
|||||||
layout: component
|
layout: component
|
||||||
---
|
---
|
||||||
|
|
||||||
For a full list of icons that come bundled with Shoelace, refer to the [icon component](/components/icon).
|
For a full list of icons that come bundled with Web Awesome, refer to the [icon component](/components/icon).
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon-button name="gear" label="Settings"></sl-icon-button>
|
<wa-icon-button name="gear" label="Settings"></wa-icon-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => <SlIconButton name="gear" label="Settings" />;
|
const App = () => <WaIconButton name="gear" label="Settings" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -24,21 +24,21 @@ const App = () => <SlIconButton name="gear" label="Settings" />;
|
|||||||
Icon buttons inherit their parent element's `font-size`.
|
Icon buttons inherit their parent element's `font-size`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon-button name="pencil" label="Edit" style="font-size: 1.5rem;"></sl-icon-button>
|
<wa-icon-button name="pen-to-square" variant="solid" label="Edit" style="font-size: 1.5rem;"></wa-icon-button>
|
||||||
<sl-icon-button name="pencil" label="Edit" style="font-size: 2rem;"></sl-icon-button>
|
<wa-icon-button name="pen-to-square" variant="solid" label="Edit" style="font-size: 2rem;"></wa-icon-button>
|
||||||
<sl-icon-button name="pencil" label="Edit" style="font-size: 2.5rem;"></sl-icon-button>
|
<wa-icon-button name="pen-to-square" variant="solid" label="Edit" style="font-size: 2.5rem;"></wa-icon-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlIconButton name="pencil" label="Edit" style={{ fontSize: '1.5rem' }} />
|
<WaIconButton name="pen-to-square" variant="solid" label="Edit" style={{ fontSize: '1.5rem' }} />
|
||||||
<SlIconButton name="pencil" label="Edit" style={{ fontSize: '2rem' }} />
|
<WaIconButton name="pen-to-square" variant="solid" label="Edit" style={{ fontSize: '2rem' }} />
|
||||||
<SlIconButton name="pencil" label="Edit" style={{ fontSize: '2.5rem' }} />
|
<WaIconButton name="pen-to-square" variant="solid" label="Edit" style={{ fontSize: '2.5rem' }} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -51,41 +51,41 @@ Icon buttons are designed to have a uniform appearance, so their color is not in
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="icon-button-color">
|
<div class="icon-button-color">
|
||||||
<sl-icon-button name="type-bold" label="Bold"></sl-icon-button>
|
<wa-icon-button name="bold" variant="solid" label="Bold"></wa-icon-button>
|
||||||
<sl-icon-button name="type-italic" label="Italic"></sl-icon-button>
|
<wa-icon-button name="italic" variant="solid" label="Italic"></wa-icon-button>
|
||||||
<sl-icon-button name="type-underline" label="Underline"></sl-icon-button>
|
<wa-icon-button name="underline" variant="solid" label="Underline"></wa-icon-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.icon-button-color sl-icon-button::part(base) {
|
.icon-button-color wa-icon-button::part(base) {
|
||||||
color: #b00091;
|
color: #b00091;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button-color sl-icon-button::part(base):hover,
|
.icon-button-color wa-icon-button::part(base):hover,
|
||||||
.icon-button-color sl-icon-button::part(base):focus {
|
.icon-button-color wa-icon-button::part(base):focus {
|
||||||
color: #c913aa;
|
color: #c913aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button-color sl-icon-button::part(base):active {
|
.icon-button-color wa-icon-button::part(base):active {
|
||||||
color: #960077;
|
color: #960077;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.icon-button-color sl-icon-button::part(base) {
|
.icon-button-color wa-icon-button::part(base) {
|
||||||
color: #b00091;
|
color: #b00091;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button-color sl-icon-button::part(base):hover,
|
.icon-button-color wa-icon-button::part(base):hover,
|
||||||
.icon-button-color sl-icon-button::part(base):focus {
|
.icon-button-color wa-icon-button::part(base):focus {
|
||||||
color: #c913aa;
|
color: #c913aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button-color sl-icon-button::part(base):active {
|
.icon-button-color wa-icon-button::part(base):active {
|
||||||
color: #960077;
|
color: #960077;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -93,9 +93,9 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="icon-button-color">
|
<div className="icon-button-color">
|
||||||
<SlIconButton name="type-bold" label="Bold" />
|
<WaIconButton name="type-bold" variant="solid" label="Bold" />
|
||||||
<SlIconButton name="type-italic" label="Italic" />
|
<WaIconButton name="type-italic" variant="solid" label="Italic" />
|
||||||
<SlIconButton name="type-underline" label="Underline" />
|
<WaIconButton name="type-underline" variant="solid" label="Underline" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -108,13 +108,13 @@ const App = () => (
|
|||||||
Use the `href` attribute to convert the button to a link.
|
Use the `href` attribute to convert the button to a link.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon-button name="gear" label="Settings" href="https://example.com" target="_blank"></sl-icon-button>
|
<wa-icon-button name="gear" variant="solid" label="Settings" href="https://example.com" target="_blank"></wa-icon-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => <SlIconButton name="gear" label="Settings" href="https://example.com" target="_blank" />;
|
const App = () => <WaIconButton name="gear" variant="solid" label="Settings" href="https://example.com" target="_blank" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Icon Button with Tooltip
|
### Icon Button with Tooltip
|
||||||
@@ -122,19 +122,19 @@ const App = () => <SlIconButton name="gear" label="Settings" href="https://examp
|
|||||||
Wrap a tooltip around an icon button to provide contextual information to the user.
|
Wrap a tooltip around an icon button to provide contextual information to the user.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip content="Settings">
|
<wa-tooltip content="Settings">
|
||||||
<sl-icon-button name="gear" label="Settings"></sl-icon-button>
|
<wa-icon-button name="gear" variant="solid" label="Settings"></wa-icon-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTooltip content="Settings">
|
<WaTooltip content="Settings">
|
||||||
<SlIconButton name="gear" label="Settings" />
|
<WaIconButton name="gear" variant="solid" label="Settings" />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable the icon button.
|
Use the `disabled` attribute to disable the icon button.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon-button name="gear" label="Settings" disabled></sl-icon-button>
|
<wa-icon-button name="gear" variant="solid" label="Settings" disabled></wa-icon-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIconButton from '@shoelace-style/shoelace/dist/react/sl-icon-button';
|
import WaIconButton from '@shoelace-style/shoelace/dist/react/icon-button';
|
||||||
|
|
||||||
const App = () => <SlIconButton name="gear" label="Settings" disabled />;
|
const App = () => <WaIconButton name="gear" variant="solid" label="Settings" disabled />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ meta:
|
|||||||
layout: component
|
layout: component
|
||||||
---
|
---
|
||||||
|
|
||||||
Shoelace comes bundled with over 1,500 icons courtesy of the [Bootstrap Icons](https://icons.getbootstrap.com/) project. These icons are part of the `default` icon library. If you prefer, you can register [custom icon libraries](#icon-libraries) as well.
|
Web Awesome comes bundled with over 1,500 icons courtesy of the [Bootstrap Icons](https://icons.getbootstrap.com/) project. These icons are part of the `default` icon library. If you prefer, you can register [custom icon libraries](#icon-libraries) as well.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Depending on how you're loading Shoelace, you may need to copy icon assets and/or [set the base path](/getting-started/installation/#setting-the-base-path) so Shoelace knows where to load them from. Otherwise, icons may not appear and you'll see 404 Not Found errors in the dev console.
|
Depending on how you're loading Web Awesome, you may need to copy icon assets and/or [set the base path](/getting-started/installation/#setting-the-base-path) so Web Awesome knows where to load them from. Otherwise, icons may not appear and you'll see 404 Not Found errors in the dev console.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Default Icons
|
## Default Icons
|
||||||
@@ -16,87 +16,75 @@ Depending on how you're loading Shoelace, you may need to copy icon assets and/o
|
|||||||
All available icons in the `default` icon library are shown below. Click or tap on any icon to copy its name, then you can use it in your HTML like this.
|
All available icons in the `default` icon library are shown below. Click or tap on any icon to copy its name, then you can use it in your HTML like this.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-icon name="icon-name-here"></sl-icon>
|
<wa-icon name="icon-name-here"></wa-icon>
|
||||||
```
|
```
|
||||||
|
|
||||||
<div class="icon-search">
|
|
||||||
<div class="icon-search-controls">
|
|
||||||
<sl-input placeholder="Search Icons" clearable>
|
|
||||||
<sl-icon slot="prefix" name="search"></sl-icon>
|
|
||||||
</sl-input>
|
|
||||||
<sl-select value="outline">
|
|
||||||
<sl-option value="outline">Outlined</sl-option>
|
|
||||||
<sl-option value="fill">Filled</sl-option>
|
|
||||||
<sl-option value="all">All icons</sl-option>
|
|
||||||
</sl-select>
|
|
||||||
</div>
|
|
||||||
<div class="icon-list"></div>
|
|
||||||
<input type="text" class="icon-copy-input" aria-hidden="true" tabindex="-1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
TODO - show how to use `family` and `variant` attributes.
|
||||||
|
TODO - show how to use FA pro via `data-webawesome-kit="..."`
|
||||||
|
|
||||||
### Colors
|
### Colors
|
||||||
|
|
||||||
Icons inherit their color from the current text color. Thus, you can set the `color` property on the `<sl-icon>` element or an ancestor to change the color.
|
Icons inherit their color from the current text color. Thus, you can set the `color` property on the `<wa-icon>` element or an ancestor to change the color.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div style="color: #4a90e2;">
|
<div style="color: #4a90e2;">
|
||||||
<sl-icon name="exclamation-triangle"></sl-icon>
|
<wa-icon name="exclamation-triangle"></wa-icon>
|
||||||
<sl-icon name="archive"></sl-icon>
|
<wa-icon name="archive"></wa-icon>
|
||||||
<sl-icon name="battery-charging"></sl-icon>
|
<wa-icon name="battery-three-quarters"></wa-icon>
|
||||||
<sl-icon name="bell"></sl-icon>
|
<wa-icon name="bell"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #9013fe;">
|
<div style="color: #9013fe;">
|
||||||
<sl-icon name="clock"></sl-icon>
|
<wa-icon name="clock"></wa-icon>
|
||||||
<sl-icon name="cloud"></sl-icon>
|
<wa-icon name="cloud"></wa-icon>
|
||||||
<sl-icon name="download"></sl-icon>
|
<wa-icon name="download"></wa-icon>
|
||||||
<sl-icon name="file-earmark"></sl-icon>
|
<wa-icon name="file"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #417505;">
|
<div style="color: #417505;">
|
||||||
<sl-icon name="flag"></sl-icon>
|
<wa-icon name="flag"></wa-icon>
|
||||||
<sl-icon name="heart"></sl-icon>
|
<wa-icon name="heart"></wa-icon>
|
||||||
<sl-icon name="image"></sl-icon>
|
<wa-icon name="image"></wa-icon>
|
||||||
<sl-icon name="lightning"></sl-icon>
|
<wa-icon name="bolt-lightning"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #f5a623;">
|
<div style="color: #f5a623;">
|
||||||
<sl-icon name="mic"></sl-icon>
|
<wa-icon name="microphone"></wa-icon>
|
||||||
<sl-icon name="search"></sl-icon>
|
<wa-icon name="search"></wa-icon>
|
||||||
<sl-icon name="star"></sl-icon>
|
<wa-icon name="star"></wa-icon>
|
||||||
<sl-icon name="trash"></sl-icon>
|
<wa-icon name="trash"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div style={{ color: '#4a90e2' }}>
|
<div style={{ color: '#4a90e2' }}>
|
||||||
<SlIcon name="exclamation-triangle"></SlIcon>
|
<WaIcon name="exclamation-triangle"></WaIcon>
|
||||||
<SlIcon name="archive"></SlIcon>
|
<WaIcon name="archive"></WaIcon>
|
||||||
<SlIcon name="battery-charging"></SlIcon>
|
<WaIcon name="battery-three-quarters"></WaIcon>
|
||||||
<SlIcon name="bell"></SlIcon>
|
<WaIcon name="bell"></WaIcon>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ color: '#9013fe' }}>
|
<div style={{ color: '#9013fe' }}>
|
||||||
<SlIcon name="clock"></SlIcon>
|
<WaIcon name="clock"></WaIcon>
|
||||||
<SlIcon name="cloud"></SlIcon>
|
<WaIcon name="cloud"></WaIcon>
|
||||||
<SlIcon name="download"></SlIcon>
|
<WaIcon name="download"></WaIcon>
|
||||||
<SlIcon name="file-earmark"></SlIcon>
|
<WaIcon name="file"></WaIcon>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ color: '#417505' }}>
|
<div style={{ color: '#417505' }}>
|
||||||
<SlIcon name="flag"></SlIcon>
|
<WaIcon name="flag"></WaIcon>
|
||||||
<SlIcon name="heart"></SlIcon>
|
<WaIcon name="heart"></WaIcon>
|
||||||
<SlIcon name="image"></SlIcon>
|
<WaIcon name="image"></WaIcon>
|
||||||
<SlIcon name="lightning"></SlIcon>
|
<WaIcon name="bolt-lightning"></WaIcon>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ color: '#f5a623' }}>
|
<div style={{ color: '#f5a623' }}>
|
||||||
<SlIcon name="mic"></SlIcon>
|
<WaIcon name="microphone"></WaIcon>
|
||||||
<SlIcon name="search"></SlIcon>
|
<WaIcon name="search"></WaIcon>
|
||||||
<SlIcon name="star"></SlIcon>
|
<WaIcon name="star"></WaIcon>
|
||||||
<SlIcon name="trash"></SlIcon>
|
<WaIcon name="trash"></WaIcon>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -110,48 +98,48 @@ Icons are sized relative to the current font size. To change their size, set the
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div style="font-size: 32px;">
|
<div style="font-size: 32px;">
|
||||||
<sl-icon name="exclamation-triangle"></sl-icon>
|
<wa-icon name="exclamation-triangle"></wa-icon>
|
||||||
<sl-icon name="archive"></sl-icon>
|
<wa-icon name="archive"></wa-icon>
|
||||||
<sl-icon name="battery-charging"></sl-icon>
|
<wa-icon name="battery-three-quarters"></wa-icon>
|
||||||
<sl-icon name="bell"></sl-icon>
|
<wa-icon name="bell"></wa-icon>
|
||||||
<sl-icon name="clock"></sl-icon>
|
<wa-icon name="clock"></wa-icon>
|
||||||
<sl-icon name="cloud"></sl-icon>
|
<wa-icon name="cloud"></wa-icon>
|
||||||
<sl-icon name="download"></sl-icon>
|
<wa-icon name="download"></wa-icon>
|
||||||
<sl-icon name="file-earmark"></sl-icon>
|
<wa-icon name="file"></wa-icon>
|
||||||
<sl-icon name="flag"></sl-icon>
|
<wa-icon name="flag"></wa-icon>
|
||||||
<sl-icon name="heart"></sl-icon>
|
<wa-icon name="heart"></wa-icon>
|
||||||
<sl-icon name="image"></sl-icon>
|
<wa-icon name="image"></wa-icon>
|
||||||
<sl-icon name="lightning"></sl-icon>
|
<wa-icon name="bolt-lightning"></wa-icon>
|
||||||
<sl-icon name="mic"></sl-icon>
|
<wa-icon name="microphone"></wa-icon>
|
||||||
<sl-icon name="search"></sl-icon>
|
<wa-icon name="search"></wa-icon>
|
||||||
<sl-icon name="star"></sl-icon>
|
<wa-icon name="star"></wa-icon>
|
||||||
<sl-icon name="trash"></sl-icon>
|
<wa-icon name="trash"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<div style={{ fontSize: '32px' }}>
|
<div style={{ fontSize: '32px' }}>
|
||||||
<SlIcon name="exclamation-triangle" />
|
<WaIcon name="exclamation-triangle" />
|
||||||
<SlIcon name="archive" />
|
<WaIcon name="archive" />
|
||||||
<SlIcon name="battery-charging" />
|
<WaIcon name="battery-three-quarters" />
|
||||||
<SlIcon name="bell" />
|
<WaIcon name="bell" />
|
||||||
<SlIcon name="clock" />
|
<WaIcon name="clock" />
|
||||||
<SlIcon name="cloud" />
|
<WaIcon name="cloud" />
|
||||||
<SlIcon name="download" />
|
<WaIcon name="download" />
|
||||||
<SlIcon name="file-earmark" />
|
<WaIcon name="file" />
|
||||||
<SlIcon name="flag" />
|
<WaIcon name="flag" />
|
||||||
<SlIcon name="heart" />
|
<WaIcon name="heart" />
|
||||||
<SlIcon name="image" />
|
<WaIcon name="image" />
|
||||||
<SlIcon name="lightning" />
|
<WaIcon name="bolt-lightning" />
|
||||||
<SlIcon name="mic" />
|
<WaIcon name="microphone" />
|
||||||
<SlIcon name="search" />
|
<WaIcon name="search" />
|
||||||
<SlIcon name="star" />
|
<WaIcon name="star" />
|
||||||
<SlIcon name="trash" />
|
<WaIcon name="trash" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -163,13 +151,13 @@ const App = () => (
|
|||||||
For non-decorative icons, use the `label` attribute to announce it to assistive devices.
|
For non-decorative icons, use the `label` attribute to announce it to assistive devices.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon name="star-fill" label="Add to favorites"></sl-icon>
|
<wa-icon name="star" label="Add to favorites"></wa-icon>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => <SlIcon name="star-fill" label="Add to favorites" />;
|
const App = () => <WaIcon name="star" label="Add to favorites" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Icons
|
### Custom Icons
|
||||||
@@ -177,24 +165,24 @@ const App = () => <SlIcon name="star-fill" label="Add to favorites" />;
|
|||||||
Custom icons can be loaded individually with the `src` attribute. Only SVGs on a local or CORS-enabled endpoint are supported. If you're using more than one custom icon, it might make sense to register a [custom icon library](#icon-libraries).
|
Custom icons can be loaded individually with the `src` attribute. Only SVGs on a local or CORS-enabled endpoint are supported. If you're using more than one custom icon, it might make sense to register a [custom icon library](#icon-libraries).
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-icon src="https://shoelace.style/assets/images/shoe.svg" style="font-size: 8rem;"></sl-icon>
|
<wa-icon src="https://shoelace.style/assets/images/shoe.svg" style="font-size: 8rem;"></wa-icon>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => <SlIcon src="https://shoelace.style/assets/images/shoe.svg" style={{ fontSize: '8rem' }}></SlIcon>;
|
const App = () => <WaIcon src="https://shoelace.style/assets/images/shoe.svg" style={{ fontSize: '8rem' }}></WaIcon>;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
## Icon Libraries
|
## Icon Libraries
|
||||||
|
|
||||||
You can register additional icons to use with the `<sl-icon>` component through icon libraries. Icon files can exist locally or on a CORS-enabled endpoint (e.g. a CDN). There is no limit to how many icon libraries you can register and there is no cost associated with registering them, as individual icons are only requested when they're used.
|
You can register additional icons to use with the `<wa-icon>` component through icon libraries. Icon files can exist locally or on a CORS-enabled endpoint (e.g. a CDN). There is no limit to how many icon libraries you can register and there is no cost associated with registering them, as individual icons are only requested when they're used.
|
||||||
|
|
||||||
Shoelace ships with two built-in icon libraries, `default` and `system`. The [default icon library](#customizing-the-default-library) contains all of the icons in the Bootstrap Icons project. The [system icon library](#customizing-the-system-library) contains only a small subset of icons that are used internally by Shoelace components.
|
Web Awesome ships with two built-in icon libraries, `default` and `system`. The [default icon library](#customizing-the-default-library) contains all of the icons in the Bootstrap Icons project. The [system icon library](#customizing-the-system-library) contains only a small subset of icons that are used internally by Web Awesome components.
|
||||||
|
|
||||||
To register an additional icon library, use the `registerIconLibrary()` function that's exported from `utilities/icon-library.js`. At a minimum, you must provide a name and a resolver function. The resolver function translates an icon name to a URL where the corresponding SVG file exists. Refer to the examples below to better understand how it works.
|
To register an additional icon library, use the `registerIconLibrary()` function that's exported from `utilities/icon-library.js`. At a minimum, you must provide a name and a resolver function. The resolver function translates an icon name to a URL where the corresponding SVG file exists. Refer to the examples below to better understand how it works.
|
||||||
|
|
||||||
@@ -213,11 +201,11 @@ Here's an example that registers an icon library located in the `/assets/icons`
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
To display an icon, set the `library` and `name` attributes of an `<sl-icon>` element.
|
To display an icon, set the `library` and `name` attributes of an `<wa-icon>` element.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- This will show the icon located at /assets/icons/smile.svg -->
|
<!-- This will show the icon located at /assets/icons/smile.svg -->
|
||||||
<sl-icon library="my-icons" name="smile"></sl-icon>
|
<wa-icon library="my-icons" name="smile"></wa-icon>
|
||||||
```
|
```
|
||||||
|
|
||||||
If an icon is used before registration occurs, it will be empty initially but shown when registered.
|
If an icon is used before registration occurs, it will be empty initially but shown when registered.
|
||||||
@@ -246,26 +234,26 @@ Icons in this library are licensed under the [Creative Commons 4.0 License](http
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="boxicons" name="bx-bot"></sl-icon>
|
<wa-icon library="boxicons" name="bx-bot"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bx-cookie"></sl-icon>
|
<wa-icon library="boxicons" name="bx-cookie"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bx-joystick"></sl-icon>
|
<wa-icon library="boxicons" name="bx-joystick"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bx-save"></sl-icon>
|
<wa-icon library="boxicons" name="bx-save"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bx-server"></sl-icon>
|
<wa-icon library="boxicons" name="bx-server"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bx-wine"></sl-icon>
|
<wa-icon library="boxicons" name="bx-wine"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="boxicons" name="bxs-bot"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-bot"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxs-cookie"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-cookie"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxs-joystick"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-joystick"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxs-save"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-save"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxs-server"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-server"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxs-wine"></sl-icon>
|
<wa-icon library="boxicons" name="bxs-wine"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="boxicons" name="bxl-apple"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-apple"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxl-chrome"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-chrome"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxl-edge"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-edge"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxl-firefox"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-firefox"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxl-opera"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-opera"></wa-icon>
|
||||||
<sl-icon library="boxicons" name="bxl-microsoft"></sl-icon>
|
<wa-icon library="boxicons" name="bxl-microsoft"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -277,12 +265,12 @@ Icons in this library are licensed under the [MIT License](https://github.com/lu
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="lucide" name="feather"></sl-icon>
|
<wa-icon library="lucide" name="feather"></wa-icon>
|
||||||
<sl-icon library="lucide" name="pie-chart"></sl-icon>
|
<wa-icon library="lucide" name="pie-chart"></wa-icon>
|
||||||
<sl-icon library="lucide" name="settings"></sl-icon>
|
<wa-icon library="lucide" name="settings"></wa-icon>
|
||||||
<sl-icon library="lucide" name="map-pin"></sl-icon>
|
<wa-icon library="lucide" name="map-pin"></wa-icon>
|
||||||
<sl-icon library="lucide" name="printer"></sl-icon>
|
<wa-icon library="lucide" name="printer"></wa-icon>
|
||||||
<sl-icon library="lucide" name="shopping-cart"></sl-icon>
|
<wa-icon library="lucide" name="shopping-cart"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -317,26 +305,26 @@ Icons in this library are licensed under the [Font Awesome Free License](https:/
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="fa" name="far-bell"></sl-icon>
|
<wa-icon library="fa" name="far-bell"></wa-icon>
|
||||||
<sl-icon library="fa" name="far-comment"></sl-icon>
|
<wa-icon library="fa" name="far-comment"></wa-icon>
|
||||||
<sl-icon library="fa" name="far-hand-point-right"></sl-icon>
|
<wa-icon library="fa" name="far-hand-point-right"></wa-icon>
|
||||||
<sl-icon library="fa" name="far-hdd"></sl-icon>
|
<wa-icon library="fa" name="far-hdd"></wa-icon>
|
||||||
<sl-icon library="fa" name="far-heart"></sl-icon>
|
<wa-icon library="fa" name="far-heart"></wa-icon>
|
||||||
<sl-icon library="fa" name="far-star"></sl-icon>
|
<wa-icon library="fa" name="far-star"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="fa" name="fas-archive"></sl-icon>
|
<wa-icon library="fa" name="fas-archive"></wa-icon>
|
||||||
<sl-icon library="fa" name="fas-book"></sl-icon>
|
<wa-icon library="fa" name="fas-book"></wa-icon>
|
||||||
<sl-icon library="fa" name="fas-chess-knight"></sl-icon>
|
<wa-icon library="fa" name="fas-chess-knight"></wa-icon>
|
||||||
<sl-icon library="fa" name="fas-dice"></sl-icon>
|
<wa-icon library="fa" name="fas-dice"></wa-icon>
|
||||||
<sl-icon library="fa" name="fas-pizza-slice"></sl-icon>
|
<wa-icon library="fa" name="fas-pizza-slice"></wa-icon>
|
||||||
<sl-icon library="fa" name="fas-scroll"></sl-icon>
|
<wa-icon library="fa" name="fas-scroll"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="fa" name="fab-apple"></sl-icon>
|
<wa-icon library="fa" name="fab-apple"></wa-icon>
|
||||||
<sl-icon library="fa" name="fab-chrome"></sl-icon>
|
<wa-icon library="fa" name="fab-chrome"></wa-icon>
|
||||||
<sl-icon library="fa" name="fab-edge"></sl-icon>
|
<wa-icon library="fa" name="fab-edge"></wa-icon>
|
||||||
<sl-icon library="fa" name="fab-firefox"></sl-icon>
|
<wa-icon library="fa" name="fab-firefox"></wa-icon>
|
||||||
<sl-icon library="fa" name="fab-opera"></sl-icon>
|
<wa-icon library="fa" name="fab-opera"></wa-icon>
|
||||||
<sl-icon library="fa" name="fab-microsoft"></sl-icon>
|
<wa-icon library="fa" name="fab-microsoft"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -356,12 +344,12 @@ Icons in this library are licensed under the [MIT License](https://github.com/ta
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="heroicons" name="chat-bubble-left"></sl-icon>
|
<wa-icon library="heroicons" name="chat-bubble-left"></wa-icon>
|
||||||
<sl-icon library="heroicons" name="cloud"></sl-icon>
|
<wa-icon library="heroicons" name="cloud"></wa-icon>
|
||||||
<sl-icon library="heroicons" name="cog"></sl-icon>
|
<wa-icon library="heroicons" name="cog"></wa-icon>
|
||||||
<sl-icon library="heroicons" name="document-text"></sl-icon>
|
<wa-icon library="heroicons" name="document-text"></wa-icon>
|
||||||
<sl-icon library="heroicons" name="gift"></sl-icon>
|
<wa-icon library="heroicons" name="gift"></wa-icon>
|
||||||
<sl-icon library="heroicons" name="speaker-wave"></sl-icon>
|
<wa-icon library="heroicons" name="speaker-wave"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -381,12 +369,12 @@ Icons in this library are licensed under the [MIT License](https://github.com/lu
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="iconoir" name="check-circled-outline"></sl-icon>
|
<wa-icon library="iconoir" name="check-circled-outline"></wa-icon>
|
||||||
<sl-icon library="iconoir" name="drawer"></sl-icon>
|
<wa-icon library="iconoir" name="drawer"></wa-icon>
|
||||||
<sl-icon library="iconoir" name="keyframes"></sl-icon>
|
<wa-icon library="iconoir" name="keyframes"></wa-icon>
|
||||||
<sl-icon library="iconoir" name="headset-help"></sl-icon>
|
<wa-icon library="iconoir" name="headset-help"></wa-icon>
|
||||||
<sl-icon library="iconoir" name="color-picker"></sl-icon>
|
<wa-icon library="iconoir" name="color-picker"></wa-icon>
|
||||||
<sl-icon library="iconoir" name="wifi"></sl-icon>
|
<wa-icon library="iconoir" name="wifi"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -412,26 +400,26 @@ Icons in this library are licensed under the [MIT License](https://github.com/io
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="ionicons" name="alarm"></sl-icon>
|
<wa-icon library="ionicons" name="alarm"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="american-football"></sl-icon>
|
<wa-icon library="ionicons" name="american-football"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="bug"></sl-icon>
|
<wa-icon library="ionicons" name="bug"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="chatbubble"></sl-icon>
|
<wa-icon library="ionicons" name="chatbubble"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="settings"></sl-icon>
|
<wa-icon library="ionicons" name="settings"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="warning"></sl-icon>
|
<wa-icon library="ionicons" name="warning"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="ionicons" name="alarm-outline"></sl-icon>
|
<wa-icon library="ionicons" name="alarm-outline"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="american-football-outline"></sl-icon>
|
<wa-icon library="ionicons" name="american-football-outline"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="bug-outline"></sl-icon>
|
<wa-icon library="ionicons" name="bug-outline"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="chatbubble-outline"></sl-icon>
|
<wa-icon library="ionicons" name="chatbubble-outline"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="settings-outline"></sl-icon>
|
<wa-icon library="ionicons" name="settings-outline"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="warning-outline"></sl-icon>
|
<wa-icon library="ionicons" name="warning-outline"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="ionicons" name="alarm-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="alarm-sharp"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="american-football-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="american-football-sharp"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="bug-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="bug-sharp"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="chatbubble-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="chatbubble-sharp"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="settings-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="settings-sharp"></wa-icon>
|
||||||
<sl-icon library="ionicons" name="warning-sharp"></sl-icon>
|
<wa-icon library="ionicons" name="warning-sharp"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -452,19 +440,19 @@ Icons in this library are licensed under the [MIT License](https://github.com/mi
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="jam" name="calendar"></sl-icon>
|
<wa-icon library="jam" name="calendar"></wa-icon>
|
||||||
<sl-icon library="jam" name="camera"></sl-icon>
|
<wa-icon library="jam" name="camera"></wa-icon>
|
||||||
<sl-icon library="jam" name="filter"></sl-icon>
|
<wa-icon library="jam" name="filter"></wa-icon>
|
||||||
<sl-icon library="jam" name="leaf"></sl-icon>
|
<wa-icon library="jam" name="leaf"></wa-icon>
|
||||||
<sl-icon library="jam" name="picture"></sl-icon>
|
<wa-icon library="jam" name="picture"></wa-icon>
|
||||||
<sl-icon library="jam" name="set-square"></sl-icon>
|
<wa-icon library="jam" name="set-square"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="jam" name="calendar-f"></sl-icon>
|
<wa-icon library="jam" name="calendar-f"></wa-icon>
|
||||||
<sl-icon library="jam" name="camera-f"></sl-icon>
|
<wa-icon library="jam" name="camera-f"></wa-icon>
|
||||||
<sl-icon library="jam" name="filter-f"></sl-icon>
|
<wa-icon library="jam" name="filter-f"></wa-icon>
|
||||||
<sl-icon library="jam" name="leaf-f"></sl-icon>
|
<wa-icon library="jam" name="leaf-f"></wa-icon>
|
||||||
<sl-icon library="jam" name="picture-f"></sl-icon>
|
<wa-icon library="jam" name="picture-f"></wa-icon>
|
||||||
<sl-icon library="jam" name="set-square-f"></sl-icon>
|
<wa-icon library="jam" name="set-square-f"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -488,26 +476,26 @@ Icons in this library are licensed under the [Apache 2.0 License](https://github
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="material" name="notifications"></sl-icon>
|
<wa-icon library="material" name="notifications"></wa-icon>
|
||||||
<sl-icon library="material" name="email"></sl-icon>
|
<wa-icon library="material" name="email"></wa-icon>
|
||||||
<sl-icon library="material" name="delete"></sl-icon>
|
<wa-icon library="material" name="delete"></wa-icon>
|
||||||
<sl-icon library="material" name="volume_up"></sl-icon>
|
<wa-icon library="material" name="volume_up"></wa-icon>
|
||||||
<sl-icon library="material" name="settings"></sl-icon>
|
<wa-icon library="material" name="settings"></wa-icon>
|
||||||
<sl-icon library="material" name="shopping_basket"></sl-icon>
|
<wa-icon library="material" name="shopping_basket"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="material" name="notifications_round"></sl-icon>
|
<wa-icon library="material" name="notifications_round"></wa-icon>
|
||||||
<sl-icon library="material" name="email_round"></sl-icon>
|
<wa-icon library="material" name="email_round"></wa-icon>
|
||||||
<sl-icon library="material" name="delete_round"></sl-icon>
|
<wa-icon library="material" name="delete_round"></wa-icon>
|
||||||
<sl-icon library="material" name="volume_up_round"></sl-icon>
|
<wa-icon library="material" name="volume_up_round"></wa-icon>
|
||||||
<sl-icon library="material" name="settings_round"></sl-icon>
|
<wa-icon library="material" name="settings_round"></wa-icon>
|
||||||
<sl-icon library="material" name="shopping_basket_round"></sl-icon>
|
<wa-icon library="material" name="shopping_basket_round"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="material" name="notifications_sharp"></sl-icon>
|
<wa-icon library="material" name="notifications_sharp"></wa-icon>
|
||||||
<sl-icon library="material" name="email_sharp"></sl-icon>
|
<wa-icon library="material" name="email_sharp"></wa-icon>
|
||||||
<sl-icon library="material" name="delete_sharp"></sl-icon>
|
<wa-icon library="material" name="delete_sharp"></wa-icon>
|
||||||
<sl-icon library="material" name="volume_up_sharp"></sl-icon>
|
<wa-icon library="material" name="volume_up_sharp"></wa-icon>
|
||||||
<sl-icon library="material" name="settings_sharp"></sl-icon>
|
<wa-icon library="material" name="settings_sharp"></wa-icon>
|
||||||
<sl-icon library="material" name="shopping_basket_sharp"></sl-icon>
|
<wa-icon library="material" name="shopping_basket_sharp"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -532,19 +520,19 @@ Icons in this library are licensed under the [Apache 2.0 License](https://github
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="remixicon" name="business/cloud-line"></sl-icon>
|
<wa-icon library="remixicon" name="business/cloud-line"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="design/brush-line"></sl-icon>
|
<wa-icon library="remixicon" name="design/brush-line"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="business/pie-chart-line"></sl-icon>
|
<wa-icon library="remixicon" name="business/pie-chart-line"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="development/bug-line"></sl-icon>
|
<wa-icon library="remixicon" name="development/bug-line"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="media/image-line"></sl-icon>
|
<wa-icon library="remixicon" name="media/image-line"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="system/alert-line"></sl-icon>
|
<wa-icon library="remixicon" name="system/alert-line"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="remixicon" name="business/cloud-fill"></sl-icon>
|
<wa-icon library="remixicon" name="business/cloud-fill"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="design/brush-fill"></sl-icon>
|
<wa-icon library="remixicon" name="design/brush-fill"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="business/pie-chart-fill"></sl-icon>
|
<wa-icon library="remixicon" name="business/pie-chart-fill"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="development/bug-fill"></sl-icon>
|
<wa-icon library="remixicon" name="development/bug-fill"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="media/image-fill"></sl-icon>
|
<wa-icon library="remixicon" name="media/image-fill"></wa-icon>
|
||||||
<sl-icon library="remixicon" name="system/alert-fill"></sl-icon>
|
<wa-icon library="remixicon" name="system/alert-fill"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -564,19 +552,19 @@ Icons in this library are licensed under the [MIT License](https://github.com/ta
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="tabler" name="alert-triangle"></sl-icon>
|
<wa-icon library="tabler" name="alert-triangle"></wa-icon>
|
||||||
<sl-icon library="tabler" name="arrow-back"></sl-icon>
|
<wa-icon library="tabler" name="arrow-back"></wa-icon>
|
||||||
<sl-icon library="tabler" name="at"></sl-icon>
|
<wa-icon library="tabler" name="at"></wa-icon>
|
||||||
<sl-icon library="tabler" name="ball-baseball"></sl-icon>
|
<wa-icon library="tabler" name="ball-baseball"></wa-icon>
|
||||||
<sl-icon library="tabler" name="cake"></sl-icon>
|
<wa-icon library="tabler" name="cake"></wa-icon>
|
||||||
<sl-icon library="tabler" name="files"></sl-icon>
|
<wa-icon library="tabler" name="files"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="tabler" name="keyboard"></sl-icon>
|
<wa-icon library="tabler" name="keyboard"></wa-icon>
|
||||||
<sl-icon library="tabler" name="moon"></sl-icon>
|
<wa-icon library="tabler" name="moon"></wa-icon>
|
||||||
<sl-icon library="tabler" name="pig"></sl-icon>
|
<wa-icon library="tabler" name="pig"></wa-icon>
|
||||||
<sl-icon library="tabler" name="printer"></sl-icon>
|
<wa-icon library="tabler" name="printer"></wa-icon>
|
||||||
<sl-icon library="tabler" name="ship"></sl-icon>
|
<wa-icon library="tabler" name="ship"></wa-icon>
|
||||||
<sl-icon library="tabler" name="toilet-paper"></sl-icon>
|
<wa-icon library="tabler" name="toilet-paper"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -602,25 +590,25 @@ Icons in this library are licensed under the [Apache 2.0 License](https://github
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="unicons" name="clock"></sl-icon>
|
<wa-icon library="unicons" name="clock"></wa-icon>
|
||||||
<sl-icon library="unicons" name="graph-bar"></sl-icon>
|
<wa-icon library="unicons" name="graph-bar"></wa-icon>
|
||||||
<sl-icon library="unicons" name="padlock"></sl-icon>
|
<wa-icon library="unicons" name="padlock"></wa-icon>
|
||||||
<sl-icon library="unicons" name="polygon"></sl-icon>
|
<wa-icon library="unicons" name="polygon"></wa-icon>
|
||||||
<sl-icon library="unicons" name="rocket"></sl-icon>
|
<wa-icon library="unicons" name="rocket"></wa-icon>
|
||||||
<sl-icon library="unicons" name="star"></sl-icon>
|
<wa-icon library="unicons" name="star"></wa-icon>
|
||||||
<br />
|
<br />
|
||||||
<sl-icon library="unicons" name="clock-s"></sl-icon>
|
<wa-icon library="unicons" name="clock-s"></wa-icon>
|
||||||
<sl-icon library="unicons" name="graph-bar-s"></sl-icon>
|
<wa-icon library="unicons" name="graph-bar-s"></wa-icon>
|
||||||
<sl-icon library="unicons" name="padlock-s"></sl-icon>
|
<wa-icon library="unicons" name="padlock-s"></wa-icon>
|
||||||
<sl-icon library="unicons" name="polygon-s"></sl-icon>
|
<wa-icon library="unicons" name="polygon-s"></wa-icon>
|
||||||
<sl-icon library="unicons" name="rocket-s"></sl-icon>
|
<wa-icon library="unicons" name="rocket-s"></wa-icon>
|
||||||
<sl-icon library="unicons" name="star-s"></sl-icon>
|
<wa-icon library="unicons" name="star-s"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Customizing the Default Library
|
### Customizing the Default Library
|
||||||
|
|
||||||
The default icon library contains over 1,300 icons courtesy of the [Bootstrap Icons](https://icons.getbootstrap.com/) project. These are the icons that display when you use `<sl-icon>` without the `library` attribute. If you prefer to have these icons resolve elsewhere or to a different icon library, register an icon library using the `default` name and a custom resolver.
|
The default icon library contains over 1,300 icons courtesy of the [Bootstrap Icons](https://icons.getbootstrap.com/) project. These are the icons that display when you use `<wa-icon>` without the `library` attribute. If you prefer to have these icons resolve elsewhere or to a different icon library, register an icon library using the `default` name and a custom resolver.
|
||||||
|
|
||||||
This example will load the same set of icons from the jsDelivr CDN instead of your local assets folder.
|
This example will load the same set of icons from the jsDelivr CDN instead of your local assets folder.
|
||||||
|
|
||||||
@@ -641,11 +629,11 @@ To improve performance you can use a SVG sprites to avoid multiple trips for eac
|
|||||||
As always, make sure to benchmark these changes. When using HTTP/2, it may in fact be more bandwidth-friendly to use multiple small requests instead of 1 large sprite sheet.
|
As always, make sure to benchmark these changes. When using HTTP/2, it may in fact be more bandwidth-friendly to use multiple small requests instead of 1 large sprite sheet.
|
||||||
|
|
||||||
:::danger
|
:::danger
|
||||||
When using sprite sheets, the `sl-load` and `sl-error` events will not fire.
|
When using sprite sheets, the `wa-load` and `wa-error` events will not fire.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
:::danger
|
:::danger
|
||||||
For security reasons, browsers may apply the same-origin policy on `<use>` elements located in the `<sl-icon>` shadow DOM and may refuse to load a cross-origin URL. There is currently no defined way to set a cross-origin policy for `<use>` elements. For this reason, sprite sheets should only be used if you're self-hosting them.
|
For security reasons, browsers may apply the same-origin policy on `<use>` elements located in the `<wa-icon>` shadow DOM and may refuse to load a cross-origin URL. There is currently no defined way to set a cross-origin policy for `<use>` elements. For this reason, sprite sheets should only be used if you're self-hosting them.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
@@ -660,16 +648,16 @@ For security reasons, browsers may apply the same-origin policy on `<use>` eleme
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="font-size: 24px;">
|
<div style="font-size: 24px;">
|
||||||
<sl-icon library="sprite" name="clock"></sl-icon>
|
<wa-icon library="sprite" name="clock"></wa-icon>
|
||||||
<sl-icon library="sprite" name="speedometer"></sl-icon>
|
<wa-icon library="sprite" name="speedometer"></wa-icon>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Customizing the System Library
|
### Customizing the System Library
|
||||||
|
|
||||||
The system library contains only the icons used internally by Shoelace components. Unlike the default icon library, the system library does not rely on physical assets. Instead, its icons are hard-coded as data URIs into the resolver to ensure their availability.
|
The system library contains only the icons used internally by Web Awesome components. Unlike the default icon library, the system library does not rely on physical assets. Instead, its icons are hard-coded as data URIs into the resolver to ensure their availability.
|
||||||
|
|
||||||
If you want to change the icons Shoelace uses internally, you can register an icon library using the `system` name and a custom resolver. If you choose to do this, it's your responsibility to provide all of the icons that are required by components. You can reference `src/components/library.system.ts` for a complete list of system icons used by Shoelace.
|
If you want to change the icons Web Awesome uses internally, you can register an icon library using the `system` name and a custom resolver. If you choose to do this, it's your responsibility to provide all of the icons that are required by components. You can reference `src/components/library.system.ts` for a complete list of system icons used by Web Awesome.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -680,190 +668,3 @@ If you want to change the icons Shoelace uses internally, you can register an ic
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- Supporting scripts and styles for the search utility -->
|
|
||||||
<script>
|
|
||||||
function wrapWithTooltip(item) {
|
|
||||||
const tooltip = document.createElement('sl-tooltip');
|
|
||||||
tooltip.content = item.getAttribute('data-name');
|
|
||||||
|
|
||||||
// Close open tooltips
|
|
||||||
document.querySelectorAll('.icon-list sl-tooltip[open]').forEach(tooltip => tooltip.hide());
|
|
||||||
|
|
||||||
// Wrap it with a tooltip and trick it into showing up
|
|
||||||
item.parentNode.insertBefore(tooltip, item);
|
|
||||||
tooltip.appendChild(item);
|
|
||||||
requestAnimationFrame(() => tooltip.dispatchEvent(new MouseEvent('mouseover')));
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch('/dist/assets/icons/icons.json')
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(icons => {
|
|
||||||
const container = document.querySelector('.icon-search');
|
|
||||||
const input = container.querySelector('sl-input');
|
|
||||||
const select = container.querySelector('sl-select');
|
|
||||||
const copyInput = container.querySelector('.icon-copy-input');
|
|
||||||
const loader = container.querySelector('.icon-loader');
|
|
||||||
const list = container.querySelector('.icon-list');
|
|
||||||
const queue = [];
|
|
||||||
let inputTimeout;
|
|
||||||
|
|
||||||
// Generate icons
|
|
||||||
icons.map(i => {
|
|
||||||
const item = document.createElement('div');
|
|
||||||
item.classList.add('icon-list-item');
|
|
||||||
item.setAttribute('data-name', i.name);
|
|
||||||
item.setAttribute('data-terms', [i.name, i.title, ...(i.tags || []), ...(i.categories || [])].join(' '));
|
|
||||||
item.innerHTML = `
|
|
||||||
<svg width="1em" height="1em" fill="currentColor">
|
|
||||||
<use href="/assets/images/sprite.svg#${i.name}"></use>
|
|
||||||
</svg>
|
|
||||||
`;
|
|
||||||
list.appendChild(item);
|
|
||||||
|
|
||||||
// Wrap it with a tooltip the first time the mouse lands on it. We do this instead of baking them into the DOM
|
|
||||||
// to improve this page's performance. See: https://github.com/shoelace-style/shoelace/issues/1122
|
|
||||||
item.addEventListener('mouseover', () => wrapWithTooltip(item), { once: true });
|
|
||||||
|
|
||||||
// Copy on click
|
|
||||||
item.addEventListener('click', () => {
|
|
||||||
const tooltip = item.closest('sl-tooltip');
|
|
||||||
copyInput.value = i.name;
|
|
||||||
copyInput.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
|
|
||||||
if (tooltip) {
|
|
||||||
tooltip.content = 'Copied!';
|
|
||||||
setTimeout(() => tooltip.content = i.name, 1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Filter as the user types
|
|
||||||
input.addEventListener('sl-input', () => {
|
|
||||||
clearTimeout(inputTimeout);
|
|
||||||
inputTimeout = setTimeout(() => {
|
|
||||||
[...list.querySelectorAll('.icon-list-item')].map(item => {
|
|
||||||
const filter = input.value.toLowerCase();
|
|
||||||
if (filter === '') {
|
|
||||||
item.hidden = false;
|
|
||||||
} else {
|
|
||||||
const terms = item.getAttribute('data-terms').toLowerCase();
|
|
||||||
item.hidden = terms.indexOf(filter) < 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 250);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Sort by type and remember preference
|
|
||||||
const iconType = sessionStorage.getItem('sl-icon:type') || 'outline';
|
|
||||||
select.value = iconType;
|
|
||||||
list.setAttribute('data-type', select.value);
|
|
||||||
select.addEventListener('sl-change', () => {
|
|
||||||
list.setAttribute('data-type', select.value);
|
|
||||||
sessionStorage.setItem('sl-icon:type', select.value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.icon-search {
|
|
||||||
border: solid 1px var(--sl-panel-border-color);
|
|
||||||
border-radius: var(--sl-border-radius-medium);
|
|
||||||
padding: var(--sl-spacing-medium);
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search [hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search-controls {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search-controls sl-input {
|
|
||||||
flex: 1 1 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search-controls sl-select {
|
|
||||||
width: 10rem;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
margin-left: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-loader {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 30vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(12, 1fr);
|
|
||||||
position: relative;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-loader[hidden],
|
|
||||||
.icon-list[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list-item {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: var(--sl-border-radius-medium);
|
|
||||||
font-size: 24px;
|
|
||||||
width: 2em;
|
|
||||||
height: 2em;
|
|
||||||
margin: 0 auto;
|
|
||||||
cursor: copy;
|
|
||||||
transition: var(--sl-transition-medium) all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list-item:hover {
|
|
||||||
background-color: var(--sl-color-primary-50);
|
|
||||||
color: var(--sl-color-primary-600);
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list[data-type="outline"] .icon-list-item[data-name$="-fill"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list[data-type="fill"] .icon-list-item:not([data-name$="-fill"]) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-copy-input {
|
|
||||||
position: absolute;
|
|
||||||
opacity: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 1000px) {
|
|
||||||
.icon-list {
|
|
||||||
grid-template-columns: repeat(8, 1fr);
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-list-item {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search-controls {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-search-controls sl-select {
|
|
||||||
width: auto;
|
|
||||||
margin: 1rem 0 0 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 500px) {
|
|
||||||
.icon-list {
|
|
||||||
grid-template-columns: repeat(4, 1fr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ layout: component
|
|||||||
For best results, use images that share the same dimensions. The slider can be controlled by dragging or pressing the left and right arrow keys. (Tip: press shift + arrows to move the slider in larger intervals, or home + end to jump to the beginning or end.)
|
For best results, use images that share the same dimensions. The slider can be controlled by dragging or pressing the left and right arrow keys. (Tip: press shift + arrows to move the slider in larger intervals, or home + end to jump to the beginning or end.)
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-image-comparer>
|
<wa-image-comparer>
|
||||||
<img
|
<img
|
||||||
slot="before"
|
slot="before"
|
||||||
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80&sat=-100&bri=-5"
|
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80&sat=-100&bri=-5"
|
||||||
@@ -19,14 +19,14 @@ For best results, use images that share the same dimensions. The slider can be c
|
|||||||
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80"
|
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80"
|
||||||
alt="Color version of kittens in a basket looking around."
|
alt="Color version of kittens in a basket looking around."
|
||||||
/>
|
/>
|
||||||
</sl-image-comparer>
|
</wa-image-comparer>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlImageComparer from '@shoelace-style/shoelace/dist/react/sl-image-comparer';
|
import WaImageComparer from '@shoelace-style/shoelace/dist/react/image-comparer';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlImageComparer>
|
<WaImageComparer>
|
||||||
<img
|
<img
|
||||||
slot="before"
|
slot="before"
|
||||||
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80&sat=-100&bri=-5"
|
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80&sat=-100&bri=-5"
|
||||||
@@ -37,7 +37,7 @@ const App = () => (
|
|||||||
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80"
|
src="https://images.unsplash.com/photo-1517331156700-3c241d2b4d83?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80"
|
||||||
alt="Color version of kittens in a basket looking around."
|
alt="Color version of kittens in a basket looking around."
|
||||||
/>
|
/>
|
||||||
</SlImageComparer>
|
</WaImageComparer>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ const App = () => (
|
|||||||
Use the `position` attribute to set the initial position of the slider. This is a percentage from `0` to `100`.
|
Use the `position` attribute to set the initial position of the slider. This is a percentage from `0` to `100`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-image-comparer position="25">
|
<wa-image-comparer position="25">
|
||||||
<img
|
<img
|
||||||
slot="before"
|
slot="before"
|
||||||
src="https://images.unsplash.com/photo-1520903074185-8eca362b3dce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80"
|
src="https://images.unsplash.com/photo-1520903074185-8eca362b3dce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80"
|
||||||
@@ -59,14 +59,14 @@ Use the `position` attribute to set the initial position of the slider. This is
|
|||||||
src="https://images.unsplash.com/photo-1520640023173-50a135e35804?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80"
|
src="https://images.unsplash.com/photo-1520640023173-50a135e35804?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80"
|
||||||
alt="A person sitting on a yellow curb tying shoelaces on a boot."
|
alt="A person sitting on a yellow curb tying shoelaces on a boot."
|
||||||
/>
|
/>
|
||||||
</sl-image-comparer>
|
</wa-image-comparer>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlImageComparer from '@shoelace-style/shoelace/dist/react/sl-image-comparer';
|
import WaImageComparer from '@shoelace-style/shoelace/dist/react/image-comparer';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlImageComparer position={25}>
|
<WaImageComparer position={25}>
|
||||||
<img
|
<img
|
||||||
slot="before"
|
slot="before"
|
||||||
src="https://images.unsplash.com/photo-1520903074185-8eca362b3dce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80"
|
src="https://images.unsplash.com/photo-1520903074185-8eca362b3dce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&q=80"
|
||||||
@@ -77,6 +77,6 @@ const App = () => (
|
|||||||
src="https://images.unsplash.com/photo-1520640023173-50a135e35804?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80"
|
src="https://images.unsplash.com/photo-1520640023173-50a135e35804?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80"
|
||||||
alt="A person sitting on a yellow curb tying shoelaces on a boot."
|
alt="A person sitting on a yellow curb tying shoelaces on a boot."
|
||||||
/>
|
/>
|
||||||
</SlImageComparer>
|
</WaImageComparer>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -7,39 +7,39 @@ layout: component
|
|||||||
|
|
||||||
Included files are asynchronously requested using `window.fetch()`. Requests are cached, so the same file can be included multiple times, but only one request will be made.
|
Included files are asynchronously requested using `window.fetch()`. Requests are cached, so the same file can be included multiple times, but only one request will be made.
|
||||||
|
|
||||||
The included content will be inserted into the `<sl-include>` element's default slot so it can be easily accessed and styled through the light DOM.
|
The included content will be inserted into the `<wa-include>` element's default slot so it can be easily accessed and styled through the light DOM.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-include src="https://shoelace.style/assets/examples/include.html"></sl-include>
|
<wa-include src="https://shoelace.style/assets/examples/include.html"></wa-include>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInclude from '@shoelace-style/shoelace/dist/react/sl-include';
|
import WaInclude from '@shoelace-style/shoelace/dist/react/include';
|
||||||
|
|
||||||
const App = () => <SlInclude src="https://shoelace.style/assets/examples/include.html" />;
|
const App = () => <WaInclude src="https://shoelace.style/assets/examples/include.html" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Listening for Events
|
### Listening for Events
|
||||||
|
|
||||||
When an include file loads successfully, the `sl-load` event will be emitted. You can listen for this event to add custom loading logic to your includes.
|
When an include file loads successfully, the `wa-load` event will be emitted. You can listen for this event to add custom loading logic to your includes.
|
||||||
|
|
||||||
If the request fails, the `sl-error` event will be emitted. In this case, `event.detail.status` will contain the resulting HTTP status code of the request, e.g. 404 (not found).
|
If the request fails, the `wa-error` event will be emitted. In this case, `event.detail.status` will contain the resulting HTTP status code of the request, e.g. 404 (not found).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-include src="https://shoelace.style/assets/examples/include.html"></sl-include>
|
<wa-include src="https://shoelace.style/assets/examples/include.html"></wa-include>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const include = document.querySelector('sl-include');
|
const include = document.querySelector('wa-include');
|
||||||
|
|
||||||
include.addEventListener('sl-load', event => {
|
include.addEventListener('wa-load', event => {
|
||||||
if (event.eventPhase === Event.AT_TARGET) {
|
if (event.eventPhase === Event.AT_TARGET) {
|
||||||
console.log('Success');
|
console.log('Success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
include.addEventListener('sl-error', event => {
|
include.addEventListener('wa-error', event => {
|
||||||
if (event.eventPhase === Event.AT_TARGET) {
|
if (event.eventPhase === Event.AT_TARGET) {
|
||||||
console.log('Error', event.detail.status);
|
console.log('Error', event.detail.status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input></sl-input>
|
<wa-input></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput />;
|
const App = () => <WaInput />;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,14 +26,14 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `label` attribute to give the input an accessible label. For labels that contain HTML, use the `label` slot instead.
|
Use the `label` attribute to give the input an accessible label. For labels that contain HTML, use the `label` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input label="What is your name?"></sl-input>
|
<wa-input label="What is your name?"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput label="What is your name?" />;
|
const App = () => <WaInput label="What is your name?" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Help Text
|
### Help Text
|
||||||
@@ -41,14 +41,14 @@ const App = () => <SlInput label="What is your name?" />;
|
|||||||
Add descriptive help text to an input with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
Add descriptive help text to an input with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input label="Nickname" help-text="What would you like people to call you?"></sl-input>
|
<wa-input label="Nickname" help-text="What would you like people to call you?"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput label="Nickname" help-text="What would you like people to call you?" />;
|
const App = () => <WaInput label="Nickname" help-text="What would you like people to call you?" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Placeholders
|
### Placeholders
|
||||||
@@ -56,13 +56,13 @@ const App = () => <SlInput label="Nickname" help-text="What would you like peopl
|
|||||||
Use the `placeholder` attribute to add a placeholder.
|
Use the `placeholder` attribute to add a placeholder.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Type something"></sl-input>
|
<wa-input placeholder="Type something"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput placeholder="Type something" />;
|
const App = () => <WaInput placeholder="Type something" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clearable
|
### Clearable
|
||||||
@@ -70,13 +70,13 @@ const App = () => <SlInput placeholder="Type something" />;
|
|||||||
Add the `clearable` attribute to add a clear button when the input has content.
|
Add the `clearable` attribute to add a clear button when the input has content.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Clearable" clearable></sl-input>
|
<wa-input placeholder="Clearable" clearable></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput placeholder="Clearable" clearable />;
|
const App = () => <WaInput placeholder="Clearable" clearable />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Toggle Password
|
### Toggle Password
|
||||||
@@ -84,13 +84,13 @@ const App = () => <SlInput placeholder="Clearable" clearable />;
|
|||||||
Add the `password-toggle` attribute to add a toggle button that will show the password when activated.
|
Add the `password-toggle` attribute to add a toggle button that will show the password when activated.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input type="password" placeholder="Password Toggle" password-toggle></sl-input>
|
<wa-input type="password" placeholder="Password Toggle" password-toggle></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput type="password" placeholder="Password Toggle" size="medium" password-toggle />;
|
const App = () => <WaInput type="password" placeholder="Password Toggle" size="medium" password-toggle />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Filled Inputs
|
### Filled Inputs
|
||||||
@@ -98,13 +98,13 @@ const App = () => <SlInput type="password" placeholder="Password Toggle" size="m
|
|||||||
Add the `filled` attribute to draw a filled input.
|
Add the `filled` attribute to draw a filled input.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Type something" filled></sl-input>
|
<wa-input placeholder="Type something" filled></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput placeholder="Type something" filled />;
|
const App = () => <WaInput placeholder="Type something" filled />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -112,13 +112,13 @@ const App = () => <SlInput placeholder="Type something" filled />;
|
|||||||
Use the `disabled` attribute to disable an input.
|
Use the `disabled` attribute to disable an input.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Disabled" disabled></sl-input>
|
<wa-input placeholder="Disabled" disabled></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => <SlInput placeholder="Disabled" disabled />;
|
const App = () => <WaInput placeholder="Disabled" disabled />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sizes
|
### Sizes
|
||||||
@@ -126,23 +126,23 @@ const App = () => <SlInput placeholder="Disabled" disabled />;
|
|||||||
Use the `size` attribute to change an input's size.
|
Use the `size` attribute to change an input's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Small" size="small"></sl-input>
|
<wa-input placeholder="Small" size="small"></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Medium" size="medium"></sl-input>
|
<wa-input placeholder="Medium" size="medium"></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Large" size="large"></sl-input>
|
<wa-input placeholder="Large" size="large"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlInput placeholder="Small" size="small" />
|
<WaInput placeholder="Small" size="small" />
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Medium" size="medium" />
|
<WaInput placeholder="Medium" size="medium" />
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Large" size="large" />
|
<WaInput placeholder="Large" size="large" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -152,23 +152,23 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give inputs rounded edges.
|
Use the `pill` attribute to give inputs rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Small" size="small" pill></sl-input>
|
<wa-input placeholder="Small" size="small" pill></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Medium" size="medium" pill></sl-input>
|
<wa-input placeholder="Medium" size="medium" pill></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Large" size="large" pill></sl-input>
|
<wa-input placeholder="Large" size="large" pill></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlInput placeholder="Small" size="small" pill />
|
<WaInput placeholder="Small" size="small" pill />
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Medium" size="medium" pill />
|
<WaInput placeholder="Medium" size="medium" pill />
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Large" size="large" pill />
|
<WaInput placeholder="Large" size="large" pill />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -178,23 +178,23 @@ const App = () => (
|
|||||||
The `type` attribute controls the type of input the browser renders.
|
The `type` attribute controls the type of input the browser renders.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input type="email" placeholder="Email"></sl-input>
|
<wa-input type="email" placeholder="Email"></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input type="number" placeholder="Number"></sl-input>
|
<wa-input type="number" placeholder="Number"></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input type="date" placeholder="Date"></sl-input>
|
<wa-input type="date" placeholder="Date"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlInput type="email" placeholder="Email" />
|
<WaInput type="email" placeholder="Email" />
|
||||||
<br />
|
<br />
|
||||||
<SlInput type="number" placeholder="Number" />
|
<WaInput type="number" placeholder="Number" />
|
||||||
<br />
|
<br />
|
||||||
<SlInput type="date" placeholder="Date" />
|
<WaInput type="date" placeholder="Date" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -204,42 +204,42 @@ const App = () => (
|
|||||||
Use the `prefix` and `suffix` slots to add icons.
|
Use the `prefix` and `suffix` slots to add icons.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input placeholder="Small" size="small">
|
<wa-input placeholder="Small" size="small">
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon name="house" variant="solid" slot="prefix"></wa-icon>
|
||||||
<sl-icon name="chat" slot="suffix"></sl-icon>
|
<wa-icon name="comment" variant="solid" slot="suffix"></wa-icon>
|
||||||
</sl-input>
|
</wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Medium" size="medium">
|
<wa-input placeholder="Medium" size="medium">
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon name="house" variant="solid" slot="prefix"></wa-icon>
|
||||||
<sl-icon name="chat" slot="suffix"></sl-icon>
|
<wa-icon name="comment" variant="solid" slot="suffix"></wa-icon>
|
||||||
</sl-input>
|
</wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input placeholder="Large" size="large">
|
<wa-input placeholder="Large" size="large">
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon name="house" variant="solid" slot="prefix"></wa-icon>
|
||||||
<sl-icon name="chat" slot="suffix"></sl-icon>
|
<wa-icon name="comment" variant="solid" slot="suffix"></wa-icon>
|
||||||
</sl-input>
|
</wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlInput placeholder="Small" size="small">
|
<WaInput placeholder="Small" size="small">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon name="house" variant="solid" slot="prefix"></WaIcon>
|
||||||
<SlIcon name="chat" slot="suffix"></SlIcon>
|
<WaIcon name="comment" variant="solid" slot="suffix"></WaIcon>
|
||||||
</SlInput>
|
</WaInput>
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Medium" size="medium">
|
<WaInput placeholder="Medium" size="medium">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon name="house" variant="solid" slot="prefix"></WaIcon>
|
||||||
<SlIcon name="chat" slot="suffix"></SlIcon>
|
<WaIcon name="comment" variant="solid" slot="suffix"></WaIcon>
|
||||||
</SlInput>
|
</WaInput>
|
||||||
<br />
|
<br />
|
||||||
<SlInput placeholder="Large" size="large">
|
<WaInput placeholder="Large" size="large">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon name="house" variant="solid" slot="prefix"></WaIcon>
|
||||||
<SlIcon name="chat" slot="suffix"></SlIcon>
|
<WaIcon name="comment" variant="solid" slot="suffix"></WaIcon>
|
||||||
</SlInput>
|
</WaInput>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -249,9 +249,9 @@ const App = () => (
|
|||||||
Use [CSS parts](#css-parts) to customize the way form controls are drawn. This example uses CSS grid to position the label to the left of the control, but the possible orientations are nearly endless. The same technique works for inputs, textareas, radio groups, and similar form controls.
|
Use [CSS parts](#css-parts) to customize the way form controls are drawn. This example uses CSS grid to position the label to the left of the control, but the possible orientations are nearly endless. The same technique works for inputs, textareas, radio groups, and similar form controls.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-input class="label-on-left" label="Name" help-text="Enter your name"></sl-input>
|
<wa-input class="label-on-left" label="Name" help-text="Enter your name"></wa-input>
|
||||||
<sl-input class="label-on-left" label="Email" type="email" help-text="Enter your email"></sl-input>
|
<wa-input class="label-on-left" label="Email" type="email" help-text="Enter your email"></wa-input>
|
||||||
<sl-textarea class="label-on-left" label="Bio" help-text="Tell us something about yourself"></sl-textarea>
|
<wa-textarea class="label-on-left" label="Bio" help-text="Tell us something about yourself"></wa-textarea>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.label-on-left {
|
.label-on-left {
|
||||||
@@ -260,13 +260,13 @@ Use [CSS parts](#css-parts) to customize the way form controls are drawn. This e
|
|||||||
}
|
}
|
||||||
|
|
||||||
.label-on-left + .label-on-left {
|
.label-on-left + .label-on-left {
|
||||||
margin-top: var(--sl-spacing-medium);
|
margin-top: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
.label-on-left::part(form-control) {
|
.label-on-left::part(form-control) {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid: auto / var(--label-width) 1fr;
|
grid: auto / var(--label-width) 1fr;
|
||||||
gap: var(--sl-spacing-3x-small) var(--gap-width);
|
gap: var(--wa-space-3xs) var(--gap-width);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,53 +6,53 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item>Option 1</sl-menu-item>
|
<wa-menu-item>Option 1</wa-menu-item>
|
||||||
<sl-menu-item>Option 2</sl-menu-item>
|
<wa-menu-item>Option 2</wa-menu-item>
|
||||||
<sl-menu-item>Option 3</sl-menu-item>
|
<wa-menu-item>Option 3</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item type="checkbox" checked>Checkbox</sl-menu-item>
|
<wa-menu-item type="checkbox" checked>Checkbox</wa-menu-item>
|
||||||
<sl-menu-item disabled>Disabled</sl-menu-item>
|
<wa-menu-item disabled>Disabled</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
Prefix Icon
|
Prefix Icon
|
||||||
<sl-icon slot="prefix" name="gift"></sl-icon>
|
<wa-icon slot="prefix" name="gift" variant="solid"></wa-icon>
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
Suffix Icon
|
Suffix Icon
|
||||||
<sl-icon slot="suffix" name="heart"></sl-icon>
|
<wa-icon slot="suffix" name="heart" variant="solid"></wa-icon>
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem>Option 1</SlMenuItem>
|
<WaMenuItem>Option 1</WaMenuItem>
|
||||||
<SlMenuItem>Option 2</SlMenuItem>
|
<WaMenuItem>Option 2</WaMenuItem>
|
||||||
<SlMenuItem>Option 3</SlMenuItem>
|
<WaMenuItem>Option 3</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem type="checkbox" checked>
|
<WaMenuItem type="checkbox" checked>
|
||||||
Checkbox
|
Checkbox
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem disabled>Disabled</SlMenuItem>
|
<WaMenuItem disabled>Disabled</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Prefix Icon
|
Prefix Icon
|
||||||
<SlIcon slot="prefix" name="gift" />
|
<WaIcon slot="prefix" name="gift" variant="solid" />
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
Suffix Icon
|
Suffix Icon
|
||||||
<SlIcon slot="suffix" name="heart" />
|
<WaIcon slot="suffix" name="heart" variant="solid" />
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,25 +65,25 @@ const App = () => (
|
|||||||
Add the `disabled` attribute to disable the menu item so it cannot be selected.
|
Add the `disabled` attribute to disable the menu item so it cannot be selected.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item>Option 1</sl-menu-item>
|
<wa-menu-item>Option 1</wa-menu-item>
|
||||||
<sl-menu-item disabled>Option 2</sl-menu-item>
|
<wa-menu-item disabled>Option 2</wa-menu-item>
|
||||||
<sl-menu-item>Option 3</sl-menu-item>
|
<wa-menu-item>Option 3</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem>Option 1</SlMenuItem>
|
<WaMenuItem>Option 1</WaMenuItem>
|
||||||
<SlMenuItem disabled>Option 2</SlMenuItem>
|
<WaMenuItem disabled>Option 2</WaMenuItem>
|
||||||
<SlMenuItem>Option 3</SlMenuItem>
|
<WaMenuItem>Option 3</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -94,58 +94,58 @@ const App = () => (
|
|||||||
Add content to the start and end of menu items using the `prefix` and `suffix` slots.
|
Add content to the start and end of menu items using the `prefix` and `suffix` slots.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
<sl-icon slot="prefix" name="house"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
Home
|
Home
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
|
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
<sl-icon slot="prefix" name="envelope"></sl-icon>
|
<wa-icon slot="prefix" name="envelope" variant="solid"></wa-icon>
|
||||||
Messages
|
Messages
|
||||||
<sl-badge slot="suffix" variant="primary" pill>12</sl-badge>
|
<wa-badge slot="suffix" variant="brand" pill>12</wa-badge>
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
|
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
|
|
||||||
<sl-menu-item>
|
<wa-menu-item>
|
||||||
<sl-icon slot="prefix" name="gear"></sl-icon>
|
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
|
||||||
Settings
|
Settings
|
||||||
</sl-menu-item>
|
</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlBadge from '@shoelace-style/shoelace/dist/react/sl-badge';
|
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
<SlIcon slot="prefix" name="house" />
|
<WaIcon slot="prefix" name="house" variant="solid" />
|
||||||
Home
|
Home
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
|
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
<SlIcon slot="prefix" name="envelope" />
|
<WaIcon slot="prefix" name="envelope" variant="solid" />
|
||||||
Messages
|
Messages
|
||||||
<SlBadge slot="suffix" variant="primary" pill>
|
<WaBadge slot="suffix" variant="brand" pill>
|
||||||
12
|
12
|
||||||
</SlBadge>
|
</WaBadge>
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
|
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
|
|
||||||
<SlMenuItem>
|
<WaMenuItem>
|
||||||
<SlIcon slot="prefix" name="gear" />
|
<WaIcon slot="prefix" name="gear" variant="solid" />
|
||||||
Settings
|
Settings
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -158,27 +158,27 @@ Set the `type` attribute to `checkbox` to create a menu item that will toggle on
|
|||||||
Checkbox menu items are visually indistinguishable from regular menu items. Their ability to be toggled is primarily inferred from context, much like you'd find in the menu of a native app.
|
Checkbox menu items are visually indistinguishable from regular menu items. Their ability to be toggled is primarily inferred from context, much like you'd find in the menu of a native app.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item type="checkbox">Autosave</sl-menu-item>
|
<wa-menu-item type="checkbox">Autosave</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox" checked>Check Spelling</sl-menu-item>
|
<wa-menu-item type="checkbox" checked>Check Spelling</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox">Word Wrap</sl-menu-item>
|
<wa-menu-item type="checkbox">Word Wrap</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem type="checkbox">Autosave</SlMenuItem>
|
<WaMenuItem type="checkbox">Autosave</WaMenuItem>
|
||||||
<SlMenuItem type="checkbox" checked>
|
<WaMenuItem type="checkbox" checked>
|
||||||
Check Spelling
|
Check Spelling
|
||||||
</SlMenuItem>
|
</WaMenuItem>
|
||||||
<SlMenuItem type="checkbox">Word Wrap</SlMenuItem>
|
<WaMenuItem type="checkbox">Word Wrap</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -186,23 +186,23 @@ const App = () => (
|
|||||||
|
|
||||||
### Value & Selection
|
### Value & Selection
|
||||||
|
|
||||||
The `value` attribute can be used to assign a hidden value, such as a unique identifier, to a menu item. When an item is selected, the `sl-select` event will be emitted and a reference to the item will be available at `event.detail.item`. You can use this reference to access the selected item's value, its checked state, and more.
|
The `value` attribute can be used to assign a hidden value, such as a unique identifier, to a menu item. When an item is selected, the `wa-select` event will be emitted and a reference to the item will be available at `event.detail.item`. You can use this reference to access the selected item's value, its checked state, and more.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu class="menu-value" style="max-width: 200px;">
|
<wa-menu class="menu-value" style="max-width: 200px;">
|
||||||
<sl-menu-item value="opt-1">Option 1</sl-menu-item>
|
<wa-menu-item value="opt-1">Option 1</wa-menu-item>
|
||||||
<sl-menu-item value="opt-2">Option 2</sl-menu-item>
|
<wa-menu-item value="opt-2">Option 2</wa-menu-item>
|
||||||
<sl-menu-item value="opt-3">Option 3</sl-menu-item>
|
<wa-menu-item value="opt-3">Option 3</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item type="checkbox" value="opt-4">Checkbox 4</sl-menu-item>
|
<wa-menu-item type="checkbox" value="opt-4">Checkbox 4</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox" value="opt-5">Checkbox 5</sl-menu-item>
|
<wa-menu-item type="checkbox" value="opt-5">Checkbox 5</wa-menu-item>
|
||||||
<sl-menu-item type="checkbox" value="opt-6">Checkbox 6</sl-menu-item>
|
<wa-menu-item type="checkbox" value="opt-6">Checkbox 6</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const menu = document.querySelector('.menu-value');
|
const menu = document.querySelector('.menu-value');
|
||||||
|
|
||||||
menu.addEventListener('sl-select', event => {
|
menu.addEventListener('wa-select', event => {
|
||||||
const item = event.detail.item;
|
const item = event.detail.item;
|
||||||
|
|
||||||
// Log value
|
// Log value
|
||||||
@@ -218,8 +218,8 @@ The `value` attribute can be used to assign a hidden value, such as a unique ide
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSelect(event) {
|
function handleSelect(event) {
|
||||||
@@ -233,11 +233,11 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlMenu style={{ maxWidth: '200px' }} onSlSelect={handleSelect}>
|
<WaMenu style={{ maxWidth: '200px' }} onWaSelect={handleSelect}>
|
||||||
<SlMenuItem value="opt-1">Option 1</SlMenuItem>
|
<WaMenuItem value="opt-1">Option 1</WaMenuItem>
|
||||||
<SlMenuItem value="opt-2">Option 2</SlMenuItem>
|
<WaMenuItem value="opt-2">Option 2</WaMenuItem>
|
||||||
<SlMenuItem value="opt-3">Option 3</SlMenuItem>
|
<WaMenuItem value="opt-3">Option 3</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,39 +6,39 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-label>Fruits</sl-menu-label>
|
<wa-menu-label>Fruits</wa-menu-label>
|
||||||
<sl-menu-item value="apple">Apple</sl-menu-item>
|
<wa-menu-item value="apple">Apple</wa-menu-item>
|
||||||
<sl-menu-item value="banana">Banana</sl-menu-item>
|
<wa-menu-item value="banana">Banana</wa-menu-item>
|
||||||
<sl-menu-item value="orange">Orange</sl-menu-item>
|
<wa-menu-item value="orange">Orange</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-label>Vegetables</sl-menu-label>
|
<wa-menu-label>Vegetables</wa-menu-label>
|
||||||
<sl-menu-item value="broccoli">Broccoli</sl-menu-item>
|
<wa-menu-item value="broccoli">Broccoli</wa-menu-item>
|
||||||
<sl-menu-item value="carrot">Carrot</sl-menu-item>
|
<wa-menu-item value="carrot">Carrot</wa-menu-item>
|
||||||
<sl-menu-item value="zucchini">Zucchini</sl-menu-item>
|
<wa-menu-item value="zucchini">Zucchini</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuLabel from '@shoelace-style/shoelace/dist/react/sl-menu-label';
|
import WaMenuLabel from '@shoelace-style/shoelace/dist/react/menu-label';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuLabel>Fruits</SlMenuLabel>
|
<WaMenuLabel>Fruits</WaMenuLabel>
|
||||||
<SlMenuItem value="apple">Apple</SlMenuItem>
|
<WaMenuItem value="apple">Apple</WaMenuItem>
|
||||||
<SlMenuItem value="banana">Banana</SlMenuItem>
|
<WaMenuItem value="banana">Banana</WaMenuItem>
|
||||||
<SlMenuItem value="orange">Orange</SlMenuItem>
|
<WaMenuItem value="orange">Orange</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuLabel>Vegetables</SlMenuLabel>
|
<WaMenuLabel>Vegetables</WaMenuLabel>
|
||||||
<SlMenuItem value="broccoli">Broccoli</SlMenuItem>
|
<WaMenuItem value="broccoli">Broccoli</WaMenuItem>
|
||||||
<SlMenuItem value="carrot">Carrot</SlMenuItem>
|
<WaMenuItem value="carrot">Carrot</WaMenuItem>
|
||||||
<SlMenuItem value="zucchini">Zucchini</SlMenuItem>
|
<WaMenuItem value="zucchini">Zucchini</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -8,34 +8,34 @@ layout: component
|
|||||||
You can use [menu items](/components/menu-item), [menu labels](/components/menu-label), and [dividers](/components/divider) to compose a menu. Menus support keyboard interactions, including type-to-select an option.
|
You can use [menu items](/components/menu-item), [menu labels](/components/menu-label), and [dividers](/components/divider) to compose a menu. Menus support keyboard interactions, including type-to-select an option.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-menu style="max-width: 200px;">
|
<wa-menu style="max-width: 200px;">
|
||||||
<sl-menu-item value="undo">Undo</sl-menu-item>
|
<wa-menu-item value="undo">Undo</wa-menu-item>
|
||||||
<sl-menu-item value="redo">Redo</sl-menu-item>
|
<wa-menu-item value="redo">Redo</wa-menu-item>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<sl-menu-item value="cut">Cut</sl-menu-item>
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
<sl-menu-item value="copy">Copy</sl-menu-item>
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
<sl-menu-item value="paste">Paste</sl-menu-item>
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
<sl-menu-item value="delete">Delete</sl-menu-item>
|
<wa-menu-item value="delete">Delete</wa-menu-item>
|
||||||
</sl-menu>
|
</wa-menu>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlMenu from '@shoelace-style/shoelace/dist/react/sl-menu';
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlMenu style={{ maxWidth: '200px' }}>
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
<SlMenuItem value="undo">Undo</SlMenuItem>
|
<WaMenuItem value="undo">Undo</WaMenuItem>
|
||||||
<SlMenuItem value="redo">Redo</SlMenuItem>
|
<WaMenuItem value="redo">Redo</WaMenuItem>
|
||||||
<SlDivider />
|
<WaDivider />
|
||||||
<SlMenuItem value="cut">Cut</SlMenuItem>
|
<WaMenuItem value="cut">Cut</WaMenuItem>
|
||||||
<SlMenuItem value="copy">Copy</SlMenuItem>
|
<WaMenuItem value="copy">Copy</WaMenuItem>
|
||||||
<SlMenuItem value="paste">Paste</SlMenuItem>
|
<WaMenuItem value="paste">Paste</WaMenuItem>
|
||||||
<SlMenuItem value="delete">Delete</SlMenuItem>
|
<WaMenuItem value="delete">Delete</WaMenuItem>
|
||||||
</SlMenu>
|
</WaMenu>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -44,3 +44,112 @@ const App = () => (
|
|||||||
:::tip
|
:::tip
|
||||||
Menus are intended for system menus (dropdown menus, select menus, context menus, etc.). They should not be mistaken for navigation menus which serve a different purpose and have a different semantic meaning. If you're building navigation, use `<nav>` and `<a>` elements instead.
|
Menus are intended for system menus (dropdown menus, select menus, context menus, etc.). They should not be mistaken for navigation menus which serve a different purpose and have a different semantic meaning. If you're building navigation, use `<nav>` and `<a>` elements instead.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### In Dropdowns
|
||||||
|
|
||||||
|
Menus work really well when used inside [dropdowns](/components/dropdown).
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-dropdown>
|
||||||
|
<wa-button slot="trigger" caret>Edit</wa-button>
|
||||||
|
<wa-menu>
|
||||||
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-dropdown>
|
||||||
|
```
|
||||||
|
|
||||||
|
```jsx:react
|
||||||
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
|
import WaDropdown from '@shoelace-style/shoelace/dist/react/dropdown';
|
||||||
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
|
const App = () => (
|
||||||
|
<WaDropdown>
|
||||||
|
<WaButton slot="trigger" caret>Edit</WaButton>
|
||||||
|
<WaMenu>
|
||||||
|
<WaMenuItem value="cut">Cut</WaMenuItem>
|
||||||
|
<WaMenuItem value="copy">Copy</WaMenuItem>
|
||||||
|
<WaMenuItem value="paste">Paste</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaDropdown>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Submenus
|
||||||
|
|
||||||
|
To create a submenu, nest an `<wa-menu slot="submenu">` in any [menu item](/components/menu-item).
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-menu style="max-width: 200px;">
|
||||||
|
<wa-menu-item value="undo">Undo</wa-menu-item>
|
||||||
|
<wa-menu-item value="redo">Redo</wa-menu-item>
|
||||||
|
<wa-divider></wa-divider>
|
||||||
|
<wa-menu-item value="cut">Cut</wa-menu-item>
|
||||||
|
<wa-menu-item value="copy">Copy</wa-menu-item>
|
||||||
|
<wa-menu-item value="paste">Paste</wa-menu-item>
|
||||||
|
<wa-divider></wa-divider>
|
||||||
|
<wa-menu-item>
|
||||||
|
Find
|
||||||
|
<wa-menu slot="submenu">
|
||||||
|
<wa-menu-item value="find">Find…</wa-menu-item>
|
||||||
|
<wa-menu-item value="find-previous">Find Next</wa-menu-item>
|
||||||
|
<wa-menu-item value="find-next">Find Previous</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-menu-item>
|
||||||
|
<wa-menu-item>
|
||||||
|
Transformations
|
||||||
|
<wa-menu slot="submenu">
|
||||||
|
<wa-menu-item value="uppercase">Make uppercase</wa-menu-item>
|
||||||
|
<wa-menu-item value="lowercase">Make lowercase</wa-menu-item>
|
||||||
|
<wa-menu-item value="capitalize">Capitalize</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
</wa-menu-item>
|
||||||
|
</wa-menu>
|
||||||
|
```
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```jsx:react
|
||||||
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
|
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
|
||||||
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
|
const App = () => (
|
||||||
|
<WaMenu style={{ maxWidth: '200px' }}>
|
||||||
|
<WaMenuItem value="undo">Undo</WaMenuItem>
|
||||||
|
<WaMenuItem value="redo">Redo</WaMenuItem>
|
||||||
|
<WaDivider />
|
||||||
|
<WaMenuItem value="cut">Cut</WaMenuItem>
|
||||||
|
<WaMenuItem value="copy">Copy</WaMenuItem>
|
||||||
|
<WaMenuItem value="paste">Paste</WaMenuItem>
|
||||||
|
<WaDivider />
|
||||||
|
<WaMenuItem>
|
||||||
|
Find
|
||||||
|
<WaMenu slot="submenu">
|
||||||
|
<WaMenuItem value="find">Find…</WaMenuItem>
|
||||||
|
<WaMenuItem value="find-previous">Find Next</WaMenuItem>
|
||||||
|
<WaMenuItem value="find-next">Find Previous</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaMenuItem>
|
||||||
|
<WaMenuItem>
|
||||||
|
Transformations
|
||||||
|
<WaMenu slot="submenu">
|
||||||
|
<WaMenuItem value="uppercase">Make uppercase</WaMenuItem>
|
||||||
|
<WaMenuItem value="lowercase">Make lowercase</WaMenuItem>
|
||||||
|
<WaMenuItem value="capitalize">Capitalize</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
</WaMenuItem>
|
||||||
|
</WaMenu>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
As a UX best practice, avoid using more than one level of submenus when possible.
|
||||||
|
:::
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|||||||
@@ -5,22 +5,22 @@ meta:
|
|||||||
layout: component
|
layout: component
|
||||||
---
|
---
|
||||||
|
|
||||||
The mutation observer will report changes to the content it wraps through the `sl-mutation` event. When emitted, a collection of [MutationRecord](https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord) objects will be attached to `event.detail` that contains information about how it changed.
|
The mutation observer will report changes to the content it wraps through the `wa-mutation` event. When emitted, a collection of [MutationRecord](https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord) objects will be attached to `event.detail` that contains information about how it changed.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="mutation-overview">
|
<div class="mutation-overview">
|
||||||
<sl-mutation-observer attr="variant">
|
<wa-mutation-observer attr="variant">
|
||||||
<sl-button variant="primary">Click to mutate</sl-button>
|
<wa-button variant="brand">Click to mutate</wa-button>
|
||||||
</sl-mutation-observer>
|
</wa-mutation-observer>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
👆 Click the button and watch the console
|
👆 Click the button and watch the console
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.mutation-overview');
|
const container = document.querySelector('.mutation-overview');
|
||||||
const mutationObserver = container.querySelector('sl-mutation-observer');
|
const mutationObserver = container.querySelector('wa-mutation-observer');
|
||||||
const button = container.querySelector('sl-button');
|
const button = container.querySelector('wa-button');
|
||||||
const variants = ['primary', 'success', 'neutral', 'warning', 'danger'];
|
const variants = ['brand', 'success', 'neutral', 'warning', 'danger'];
|
||||||
let clicks = 0;
|
let clicks = 0;
|
||||||
|
|
||||||
// Change the button's variant attribute
|
// Change the button's variant attribute
|
||||||
@@ -30,13 +30,13 @@ The mutation observer will report changes to the content it wraps through the `s
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Log mutations
|
// Log mutations
|
||||||
mutationObserver.addEventListener('sl-mutation', event => {
|
mutationObserver.addEventListener('wa-mutation', event => {
|
||||||
console.log(event.detail);
|
console.log(event.detail);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.mutation-overview sl-button {
|
.mutation-overview wa-button {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -45,25 +45,20 @@ The mutation observer will report changes to the content it wraps through the `s
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlMutationObserver from '@shoelace-style/shoelace/dist/react/sl-mutation-observer';
|
import WaMutationObserver from '@shoelace-style/shoelace/dist/react/mutation-observer';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.resize-observer-overview div {
|
.mutation-overview wa-button {
|
||||||
display: flex;
|
margin-bottom: 1rem;
|
||||||
border: solid 2px var(--sl-input-border-color);
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
text-align: center;
|
|
||||||
padding: 4rem 2rem;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const variants = ['primary', 'success', 'neutral', 'warning', 'danger'];
|
const variants = ['brand', 'success', 'neutral', 'warning', 'danger'];
|
||||||
let clicks = 0;
|
let clicks = 0;
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [variant, setVariant] = useState('primary');
|
const [variant, setVariant] = useState('brand');
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
clicks++;
|
clicks++;
|
||||||
@@ -72,11 +67,14 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlMutationObserver attr="*" onSlMutation={event => console.log(event.detail)}>
|
<WaMutationObserver attr="*" onWaMutation={event => console.log(event.detail)}>
|
||||||
<SlButton variant={variant} onClick={handleClick}>
|
<WaButton variant={variant} onClick={handleClick}>
|
||||||
Click to mutate
|
Click to mutate
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</SlMutationObserver>
|
</WaMutationObserver>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
👆 Click the button and watch the console
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
</>
|
</>
|
||||||
@@ -96,31 +94,31 @@ Use the `child-list` attribute to watch for new child elements that are added or
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="mutation-child-list">
|
<div class="mutation-child-list">
|
||||||
<sl-mutation-observer child-list>
|
<wa-mutation-observer child-list>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<sl-button variant="primary">Add button</sl-button>
|
<wa-button variant="brand">Add button</wa-button>
|
||||||
</div>
|
</div>
|
||||||
</sl-mutation-observer>
|
</wa-mutation-observer>
|
||||||
|
|
||||||
👆 Add and remove buttons and watch the console
|
👆 Add and remove buttons and watch the console
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.mutation-child-list');
|
const container = document.querySelector('.mutation-child-list');
|
||||||
const mutationObserver = container.querySelector('sl-mutation-observer');
|
const mutationObserver = container.querySelector('wa-mutation-observer');
|
||||||
const buttons = container.querySelector('.buttons');
|
const buttons = container.querySelector('.buttons');
|
||||||
const button = container.querySelector('sl-button[variant="primary"]');
|
const button = container.querySelector('wa-button[variant="brand"]');
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
// Add a button
|
// Add a button
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const button = document.createElement('sl-button');
|
const button = document.createElement('wa-button');
|
||||||
button.textContent = ++i;
|
button.textContent = ++i;
|
||||||
buttons.append(button);
|
buttons.append(button);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove a button
|
// Remove a button
|
||||||
buttons.addEventListener('click', event => {
|
buttons.addEventListener('click', event => {
|
||||||
const target = event.target.closest('sl-button:not([variant="primary"])');
|
const target = event.target.closest('wa-button:not([variant="brand"])');
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
@@ -129,7 +127,7 @@ Use the `child-list` attribute to watch for new child elements that are added or
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Log mutations
|
// Log mutations
|
||||||
mutationObserver.addEventListener('sl-mutation', event => {
|
mutationObserver.addEventListener('wa-mutation', event => {
|
||||||
console.log(event.detail);
|
console.log(event.detail);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -147,8 +145,8 @@ Use the `child-list` attribute to watch for new child elements that are added or
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlMutationObserver from '@shoelace-style/shoelace/dist/react/sl-mutation-observer';
|
import WaMutationObserver from '@shoelace-style/shoelace/dist/react/mutation-observer';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.mutation-child-list .buttons {
|
.mutation-child-list .buttons {
|
||||||
@@ -175,18 +173,18 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mutation-child-list">
|
<div className="mutation-child-list">
|
||||||
<SlMutationObserver child-list onSlMutation={event => console.log(event.detail)}>
|
<WaMutationObserver child-list onWaMutation={event => console.log(event.detail)}>
|
||||||
<div className="buttons">
|
<div className="buttons">
|
||||||
<SlButton variant="primary" onClick={addButton}>
|
<WaButton variant="brand" onClick={addButton}>
|
||||||
Add button
|
Add button
|
||||||
</SlButton>
|
</WaButton>
|
||||||
{buttonIds.map(id => (
|
{buttonIds.map(id => (
|
||||||
<SlButton key={id} variant="default" onClick={() => removeButton(id)}>
|
<WaButton key={id} variant="default" onClick={() => removeButton(id)}>
|
||||||
{id}
|
{id}
|
||||||
</SlButton>
|
</WaButton>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</SlMutationObserver>
|
</WaMutationObserver>
|
||||||
</div>
|
</div>
|
||||||
👆 Add and remove buttons and watch the console
|
👆 Add and remove buttons and watch the console
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Select one">
|
<wa-select label="Select one">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect>
|
<WaSelect>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -33,25 +33,25 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable an option and prevent it from being selected.
|
Use the `disabled` attribute to disable an option and prevent it from being selected.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Select one">
|
<wa-select label="Select one">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2" disabled>Option 2</sl-option>
|
<wa-option value="option-2" disabled>Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect>
|
<WaSelect>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2" disabled>
|
<WaOption value="option-2" disabled>
|
||||||
Option 2
|
Option 2
|
||||||
</SlOption>
|
</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -60,23 +60,23 @@ const App = () => (
|
|||||||
Add icons to the start and end of menu items using the `prefix` and `suffix` slots.
|
Add icons to the start and end of menu items using the `prefix` and `suffix` slots.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Select one">
|
<wa-select label="Select one">
|
||||||
<sl-option value="option-1">
|
<wa-option value="option-1">
|
||||||
<sl-icon slot="prefix" name="envelope"></sl-icon>
|
<wa-icon slot="prefix" name="envelope" variant="solid"></wa-icon>
|
||||||
Email
|
Email
|
||||||
<sl-icon slot="suffix" name="patch-check"></sl-icon>
|
<wa-icon slot="suffix" name="circle-check" variant="solid"></wa-icon>
|
||||||
</sl-option>
|
</wa-option>
|
||||||
|
|
||||||
<sl-option value="option-2">
|
<wa-option value="option-2">
|
||||||
<sl-icon slot="prefix" name="telephone"></sl-icon>
|
<wa-icon slot="prefix" name="phone" variant="solid"></wa-icon>
|
||||||
Phone
|
Phone
|
||||||
<sl-icon slot="suffix" name="patch-check"></sl-icon>
|
<wa-icon slot="suffix" name="circle-check" variant="solid"></wa-icon>
|
||||||
</sl-option>
|
</wa-option>
|
||||||
|
|
||||||
<sl-option value="option-3">
|
<wa-option value="option-3">
|
||||||
<sl-icon slot="prefix" name="chat-dots"></sl-icon>
|
<wa-icon slot="prefix" name="comment" variant="solid"></wa-icon>
|
||||||
Chat
|
Chat
|
||||||
<sl-icon slot="suffix" name="patch-check"></sl-icon>
|
<wa-icon slot="suffix" name="circle-check" variant="solid"></wa-icon>
|
||||||
</sl-option>
|
</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-bar value="50"></sl-progress-bar>
|
<wa-progress-bar value="50"></wa-progress-bar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressBar from '@shoelace-style/shoelace/dist/react/sl-progress-bar';
|
import WaProgressBar from '@shoelace-style/shoelace/dist/react/progress-bar';
|
||||||
|
|
||||||
const App = () => <SlProgressBar value={50} />;
|
const App = () => <WaProgressBar value={50} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,13 +22,13 @@ const App = () => <SlProgressBar value={50} />;
|
|||||||
Use the `label` attribute to label the progress bar and tell assistive devices how to announce it.
|
Use the `label` attribute to label the progress bar and tell assistive devices how to announce it.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-bar value="50" label="Upload progress"></sl-progress-bar>
|
<wa-progress-bar value="50" label="Upload progress"></wa-progress-bar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressBar from '@shoelace-style/shoelace/dist/react/sl-progress-bar';
|
import WaProgressBar from '@shoelace-style/shoelace/dist/react/progress-bar';
|
||||||
|
|
||||||
const App = () => <SlProgressBar value="50" label="Upload progress" />;
|
const App = () => <WaProgressBar value="50" label="Upload progress" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Height
|
### Custom Height
|
||||||
@@ -36,15 +36,15 @@ const App = () => <SlProgressBar value="50" label="Upload progress" />;
|
|||||||
Use the `--height` custom property to set the progress bar's height.
|
Use the `--height` custom property to set the progress bar's height.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-bar value="50" style="--height: 6px;"></sl-progress-bar>
|
<wa-progress-bar value="50" style="--height: 6px;"></wa-progress-bar>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressBar from '@shoelace-style/shoelace/dist/react/sl-progress-bar';
|
import WaProgressBar from '@shoelace-style/shoelace/dist/react/progress-bar';
|
||||||
|
|
||||||
const App = () => <SlProgressBar value={50} style={{ '--height': '6px' }} />;
|
const App = () => <WaProgressBar value={50} style={{ '--height': '6px' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -54,12 +54,12 @@ const App = () => <SlProgressBar value={50} style={{ '--height': '6px' }} />;
|
|||||||
Use the default slot to show a value.
|
Use the default slot to show a value.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-bar value="50" class="progress-bar-values">50%</sl-progress-bar>
|
<wa-progress-bar value="50" class="progress-bar-values">50%</wa-progress-bar>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-button circle><sl-icon name="dash" label="Decrease"></sl-icon></sl-button>
|
<wa-button circle><wa-icon name="minus" variant="solid" label="Decrease"></wa-icon></wa-button>
|
||||||
<sl-button circle><sl-icon name="plus" label="Increase"></sl-icon></sl-button>
|
<wa-button circle><wa-icon name="plus" variant="solid" label="Increase"></wa-icon></wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const progressBar = document.querySelector('.progress-bar-values');
|
const progressBar = document.querySelector('.progress-bar-values');
|
||||||
@@ -82,9 +82,9 @@ Use the default slot to show a value.
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlProgressBar from '@shoelace-style/shoelace/dist/react/sl-progress-bar';
|
import WaProgressBar from '@shoelace-style/shoelace/dist/react/progress-bar';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [value, setValue] = useState(50);
|
const [value, setValue] = useState(50);
|
||||||
@@ -98,17 +98,17 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlProgressBar value={value}>{value}%</SlProgressBar>
|
<WaProgressBar value={value}>{value}%</WaProgressBar>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButton circle onClick={() => adjustValue(-10)}>
|
<WaButton circle onClick={() => adjustValue(-10)}>
|
||||||
<SlIcon name="dash" label="Decrease" />
|
<WaIcon name="minus" variant="solid" label="Decrease" />
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton circle onClick={() => adjustValue(10)}>
|
<WaButton circle onClick={() => adjustValue(10)}>
|
||||||
<SlIcon name="plus" label="Increase" />
|
<WaIcon name="plus" variant="solid" label="Increase" />
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -119,11 +119,11 @@ const App = () => {
|
|||||||
The `indeterminate` attribute can be used to inform the user that the operation is pending, but its status cannot currently be determined. In this state, `value` is ignored and the label, if present, will not be shown.
|
The `indeterminate` attribute can be used to inform the user that the operation is pending, but its status cannot currently be determined. In this state, `value` is ignored and the label, if present, will not be shown.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-bar indeterminate></sl-progress-bar>
|
<wa-progress-bar indeterminate></wa-progress-bar>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressBar from '@shoelace-style/shoelace/dist/react/sl-progress-bar';
|
import WaProgressBar from '@shoelace-style/shoelace/dist/react/progress-bar';
|
||||||
|
|
||||||
const App = () => <SlProgressBar indeterminate />;
|
const App = () => <WaProgressBar indeterminate />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring value="25"></sl-progress-ring>
|
<wa-progress-ring value="25"></wa-progress-ring>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => <SlProgressRing value="25" />;
|
const App = () => <WaProgressRing value="25" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,15 +22,15 @@ const App = () => <SlProgressRing value="25" />;
|
|||||||
Use the `--size` custom property to set the diameter of the progress ring.
|
Use the `--size` custom property to set the diameter of the progress ring.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring value="50" style="--size: 200px;"></sl-progress-ring>
|
<wa-progress-ring value="50" style="--size: 200px;"></wa-progress-ring>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => <SlProgressRing value="50" style={{ '--size': '200px' }} />;
|
const App = () => <WaProgressRing value="50" style={{ '--size': '200px' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -40,15 +40,15 @@ const App = () => <SlProgressRing value="50" style={{ '--size': '200px' }} />;
|
|||||||
Use the `--track-width` and `--indicator-width` custom properties to set the width of the progress ring's track and indicator.
|
Use the `--track-width` and `--indicator-width` custom properties to set the width of the progress ring's track and indicator.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring value="50" style="--track-width: 6px; --indicator-width: 12px;"></sl-progress-ring>
|
<wa-progress-ring value="50" style="--track-width: 6px; --indicator-width: 12px;"></wa-progress-ring>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => <SlProgressRing value="50" style={{ '--track-width': '6px', '--indicator-width': '12px' }} />;
|
const App = () => <WaProgressRing value="50" style={{ '--track-width': '6px', '--indicator-width': '12px' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -58,22 +58,22 @@ const App = () => <SlProgressRing value="50" style={{ '--track-width': '6px', '-
|
|||||||
To change the color, use the `--track-color` and `--indicator-color` custom properties.
|
To change the color, use the `--track-color` and `--indicator-color` custom properties.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring
|
<wa-progress-ring
|
||||||
value="50"
|
value="50"
|
||||||
style="
|
style="
|
||||||
--track-color: pink;
|
--track-color: pink;
|
||||||
--indicator-color: deeppink;
|
--indicator-color: deeppink;
|
||||||
"
|
"
|
||||||
></sl-progress-ring>
|
></wa-progress-ring>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlProgressRing
|
<WaProgressRing
|
||||||
value="50"
|
value="50"
|
||||||
style={{
|
style={{
|
||||||
'--track-color': 'pink',
|
'--track-color': 'pink',
|
||||||
@@ -90,13 +90,13 @@ const App = () => (
|
|||||||
Use the `label` attribute to label the progress ring and tell assistive devices how to announce it.
|
Use the `label` attribute to label the progress ring and tell assistive devices how to announce it.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring value="50" label="Upload progress"></sl-progress-ring>
|
<wa-progress-ring value="50" label="Upload progress"></wa-progress-ring>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => <SlProgressRing value="50" label="Upload progress" />;
|
const App = () => <WaProgressRing value="50" label="Upload progress" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Showing Values
|
### Showing Values
|
||||||
@@ -104,12 +104,12 @@ const App = () => <SlProgressRing value="50" label="Upload progress" />;
|
|||||||
Use the default slot to show a label inside the progress ring.
|
Use the default slot to show a label inside the progress ring.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-progress-ring value="50" class="progress-ring-values" style="margin-bottom: .5rem;">50%</sl-progress-ring>
|
<wa-progress-ring value="50" class="progress-ring-values" style="margin-bottom: .5rem;">50%</wa-progress-ring>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-button circle><sl-icon name="dash" label="Decrease"></sl-icon></sl-button>
|
<wa-button circle><wa-icon name="minus" variant="solid" label="Decrease"></wa-icon></wa-button>
|
||||||
<sl-button circle><sl-icon name="plus" label="Increase"></sl-icon></sl-button>
|
<wa-button circle><wa-icon name="plus" variant="solid" label="Increase"></wa-icon></wa-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const progressRing = document.querySelector('.progress-ring-values');
|
const progressRing = document.querySelector('.progress-ring-values');
|
||||||
@@ -134,9 +134,9 @@ Use the default slot to show a label inside the progress ring.
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlProgressRing from '@shoelace-style/shoelace/dist/react/sl-progress-ring';
|
import WaProgressRing from '@shoelace-style/shoelace/dist/react/progress-ring';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [value, setValue] = useState(50);
|
const [value, setValue] = useState(50);
|
||||||
@@ -150,19 +150,19 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlProgressRing value={value} style={{ marginBottom: '.5rem' }}>
|
<WaProgressRing value={value} style={{ marginBottom: '.5rem' }}>
|
||||||
{value}%
|
{value}%
|
||||||
</SlProgressRing>
|
</WaProgressRing>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlButton circle onClick={() => adjustValue(-10)}>
|
<WaButton circle onClick={() => adjustValue(-10)}>
|
||||||
<SlIcon name="dash" label="Decrease" />
|
<WaIcon name="minus" variant="solid" label="Decrease" />
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlButton circle onClick={() => adjustValue(10)}>
|
<WaButton circle onClick={() => adjustValue(10)}>
|
||||||
<SlIcon name="plus" label="Increase" />
|
<WaIcon name="plus" variant="solid" label="Increase" />
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ QR codes are useful for providing small pieces of information to users who can q
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="qr-overview">
|
<div class="qr-overview">
|
||||||
<sl-qr-code value="https://shoelace.style/" label="Scan this code to visit Shoelace on the web!"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" label="Scan this code to visit Web Awesome on the web!"></wa-qr-code>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-input maxlength="255" clearable label="Value"></sl-input>
|
<wa-input maxlength="255" clearable label="Value"></wa-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.qr-overview');
|
const container = document.querySelector('.qr-overview');
|
||||||
const qrCode = container.querySelector('sl-qr-code');
|
const qrCode = container.querySelector('wa-qr-code');
|
||||||
const input = container.querySelector('sl-input');
|
const input = container.querySelector('wa-input');
|
||||||
|
|
||||||
customElements.whenDefined('sl-qr-code').then(() => {
|
customElements.whenDefined('wa-qr-code').then(() => {
|
||||||
input.value = qrCode.value;
|
input.value = qrCode.value;
|
||||||
input.addEventListener('sl-input', () => (qrCode.value = input.value));
|
input.addEventListener('wa-input', () => (qrCode.value = input.value));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ QR codes are useful for providing small pieces of information to users who can q
|
|||||||
max-width: 256px;
|
max-width: 256px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr-overview sl-input {
|
.qr-overview wa-input {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -39,15 +39,15 @@ QR codes are useful for providing small pieces of information to users who can q
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlQrCode from '@shoelace-style/shoelace/dist/react/sl-qr-code';
|
import WaQrCode from '@shoelace-style/shoelace/dist/react/qr-code';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.qr-overview {
|
.qr-overview {
|
||||||
max-width: 256px;
|
max-width: 256px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr-overview sl-input {
|
.qr-overview wa-input {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -58,10 +58,10 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="qr-overview">
|
<div className="qr-overview">
|
||||||
<SlQrCode value={value} label="Scan this code to visit Shoelace on the web!" />
|
<WaQrCode value={value} label="Scan this code to visit Web Awesome on the web!" />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlInput maxlength="255" clearable onInput={event => setValue(event.target.value)} />
|
<WaInput maxlength="255" clearable onInput={event => setValue(event.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -77,13 +77,13 @@ const App = () => {
|
|||||||
Use the `fill` and `background` attributes to modify the QR code's colors. You should always ensure good contrast for optimal compatibility with QR code scanners.
|
Use the `fill` and `background` attributes to modify the QR code's colors. You should always ensure good contrast for optimal compatibility with QR code scanners.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-qr-code value="https://shoelace.style/" fill="deeppink" background="white"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" fill="deeppink" background="white"></wa-qr-code>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlQrCode from '@shoelace-style/shoelace/dist/react/sl-qr-code';
|
import WaQrCode from '@shoelace-style/shoelace/dist/react/qr-code';
|
||||||
|
|
||||||
const App = () => <SlQrCode value="https://shoelace.style/" fill="deeppink" background="white" />;
|
const App = () => <WaQrCode value="https://shoelace.style/" fill="deeppink" background="white" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Size
|
### Size
|
||||||
@@ -91,13 +91,13 @@ const App = () => <SlQrCode value="https://shoelace.style/" fill="deeppink" back
|
|||||||
Use the `size` attribute to change the size of the QR code.
|
Use the `size` attribute to change the size of the QR code.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-qr-code value="https://shoelace.style/" size="64"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" size="64"></wa-qr-code>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlQrCode from '@shoelace-style/shoelace/dist/react/sl-qr-code';
|
import WaQrCode from '@shoelace-style/shoelace/dist/react/qr-code';
|
||||||
|
|
||||||
const App = () => <SlQrCode value="https://shoelace.style/" size="64" />;
|
const App = () => <WaQrCode value="https://shoelace.style/" size="64" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Radius
|
### Radius
|
||||||
@@ -105,13 +105,13 @@ const App = () => <SlQrCode value="https://shoelace.style/" size="64" />;
|
|||||||
Create a rounded effect with the `radius` attribute.
|
Create a rounded effect with the `radius` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-qr-code value="https://shoelace.style/" radius="0.5"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" radius="0.5"></wa-qr-code>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlQrCode from '@shoelace-style/shoelace/dist/react/sl-qr-code';
|
import WaQrCode from '@shoelace-style/shoelace/dist/react/qr-code';
|
||||||
|
|
||||||
const App = () => <SlQrCode value="https://shoelace.style/" radius="0.5" />;
|
const App = () => <WaQrCode value="https://shoelace.style/" radius="0.5" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Error Correction
|
### Error Correction
|
||||||
@@ -120,10 +120,10 @@ QR codes can be rendered with various levels of [error correction](https://www.q
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="qr-error-correction">
|
<div class="qr-error-correction">
|
||||||
<sl-qr-code value="https://shoelace.style/" error-correction="L"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" error-correction="L"></wa-qr-code>
|
||||||
<sl-qr-code value="https://shoelace.style/" error-correction="M"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" error-correction="M"></wa-qr-code>
|
||||||
<sl-qr-code value="https://shoelace.style/" error-correction="Q"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" error-correction="Q"></wa-qr-code>
|
||||||
<sl-qr-code value="https://shoelace.style/" error-correction="H"></sl-qr-code>
|
<wa-qr-code value="https://shoelace.style/" error-correction="H"></wa-qr-code>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -136,7 +136,7 @@ QR codes can be rendered with various levels of [error correction](https://www.q
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlQrCode from '@shoelace-style/shoelace/dist/react/sl-qr-code';
|
import WaQrCode from '@shoelace-style/shoelace/dist/react/qr-code';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.qr-error-correction {
|
.qr-error-correction {
|
||||||
@@ -150,10 +150,10 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="qr-error-correction">
|
<div className="qr-error-correction">
|
||||||
<SlQrCode value="https://shoelace.style/" error-correction="L" />
|
<WaQrCode value="https://shoelace.style/" error-correction="L" />
|
||||||
<SlQrCode value="https://shoelace.style/" error-correction="M" />
|
<WaQrCode value="https://shoelace.style/" error-correction="M" />
|
||||||
<SlQrCode value="https://shoelace.style/" error-correction="Q" />
|
<WaQrCode value="https://shoelace.style/" error-correction="Q" />
|
||||||
<SlQrCode value="https://shoelace.style/" error-correction="H" />
|
<WaQrCode value="https://shoelace.style/" error-correction="H" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -8,23 +8,23 @@ layout: component
|
|||||||
Radio buttons are designed to be used with [radio groups](/components/radio-group). When a radio button has focus, the arrow keys can be used to change the selected option just like standard radio controls.
|
Radio buttons are designed to be used with [radio groups](/components/radio-group). When a radio button has focus, the arrow keys can be used to change the selected option just like standard radio controls.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -35,23 +35,23 @@ const App = () => (
|
|||||||
To set the initial value and checked state, use the `value` attribute on the containing radio group.
|
To set the initial value and checked state, use the `value` attribute on the containing radio group.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -60,25 +60,25 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable a radio button.
|
Use the `disabled` attribute to disable a radio button.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button value="2" disabled>Option 2</sl-radio-button>
|
<wa-radio-button value="2" disabled>Option 2</wa-radio-button>
|
||||||
<sl-radio-button value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton value="2" disabled>
|
<WaRadioButton value="2" disabled>
|
||||||
Option 2
|
Option 2
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
<SlRadioButton value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -87,55 +87,55 @@ const App = () => (
|
|||||||
Use the `size` attribute to change a radio button's size.
|
Use the `size` attribute to change a radio button's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="small" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button size="small" value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button size="small" value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button size="small" value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="medium" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button size="medium" value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button size="medium" value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button size="medium" value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="large" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button size="large" value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button size="large" value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button size="large" value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="small" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton size="small" value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton size="small" value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton size="small" value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="medium" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton size="medium" value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton size="medium" value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton size="medium" value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="large" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton size="large" value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton size="large" value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton size="large" value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -144,55 +144,55 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give radio buttons rounded edges.
|
Use the `pill` attribute to give radio buttons rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="small" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button pill size="small" value="1">Option 1</sl-radio-button>
|
<wa-radio-button pill value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button pill size="small" value="2">Option 2</sl-radio-button>
|
<wa-radio-button pill value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button pill size="small" value="3">Option 3</sl-radio-button>
|
<wa-radio-button pill value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="medium" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button pill size="medium" value="1">Option 1</sl-radio-button>
|
<wa-radio-button pill value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button pill size="medium" value="2">Option 2</sl-radio-button>
|
<wa-radio-button pill value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button pill size="medium" value="3">Option 3</sl-radio-button>
|
<wa-radio-button pill value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group size="large" label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button pill size="large" value="1">Option 1</sl-radio-button>
|
<wa-radio-button pill value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button pill size="large" value="2">Option 2</sl-radio-button>
|
<wa-radio-button pill value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button pill size="large" value="3">Option 3</sl-radio-button>
|
<wa-radio-button pill value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="small" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton pill size="small" value="1">Option 1</SlRadioButton>
|
<WaRadioButton pill value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton pill size="small" value="2">Option 2</SlRadioButton>
|
<WaRadioButton pill value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton pill size="small" value="3">Option 3</SlRadioButton>
|
<WaRadioButton pill value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="medium" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton pill size="medium" value="1">Option 1</SlRadioButton>
|
<WaRadioButton pill value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton pill size="medium" value="2">Option 2</SlRadioButton>
|
<WaRadioButton pill value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton pill size="medium" value="3">Option 3</SlRadioButton>
|
<WaRadioButton pill value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup size="large" label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton pill size="large" value="1">Option 1</SlRadioButton>
|
<WaRadioButton pill value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton pill size="large" value="2">Option 2</SlRadioButton>
|
<WaRadioButton pill value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton pill size="large" value="3">Option 3</SlRadioButton>
|
<WaRadioButton pill value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -201,48 +201,48 @@ const App = () => (
|
|||||||
Use the `prefix` and `suffix` slots to add icons.
|
Use the `prefix` and `suffix` slots to add icons.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio-button value="1">
|
<wa-radio-button value="1">
|
||||||
<sl-icon slot="prefix" name="archive"></sl-icon>
|
<wa-icon slot="prefix" name="archive" variant="solid"></wa-icon>
|
||||||
Option 1
|
Option 1
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="2">
|
<wa-radio-button value="2">
|
||||||
<sl-icon slot="suffix" name="bag"></sl-icon>
|
<wa-icon slot="suffix" name="bag-shopping" variant="solid"></wa-icon>
|
||||||
Option 2
|
Option 2
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="3">
|
<wa-radio-button value="3">
|
||||||
<sl-icon slot="prefix" name="gift"></sl-icon>
|
<wa-icon slot="prefix" name="gift" variant="solid"></wa-icon>
|
||||||
<sl-icon slot="suffix" name="cart"></sl-icon>
|
<wa-icon slot="suffix" name="shopping-cart" variant="solid"></wa-icon>
|
||||||
Option 3
|
Option 3
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton value="1">
|
<WaRadioButton value="1">
|
||||||
<SlIcon slot="prefix" name="archive" />
|
<WaIcon slot="prefix" name="archive" variant="solid" />
|
||||||
Option 1
|
Option 1
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="2">
|
<WaRadioButton value="2">
|
||||||
<SlIcon slot="suffix" name="bag" />
|
<WaIcon slot="suffix" name="bag" variant="solid" />
|
||||||
Option 2
|
Option 2
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="3">
|
<WaRadioButton value="3">
|
||||||
<SlIcon slot="prefix" name="gift" />
|
<WaIcon slot="prefix" name="gift" variant="solid" />
|
||||||
<SlIcon slot="suffix" name="cart" />
|
<WaIcon slot="suffix" name="cart" variant="solid" />
|
||||||
Option 3
|
Option 3
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -251,55 +251,55 @@ const App = () => (
|
|||||||
You can omit button labels and use icons instead. Make sure to set a `label` attribute on each icon so screen readers will announce each option correctly.
|
You can omit button labels and use icons instead. Make sure to set a `label` attribute on each icon so screen readers will announce each option correctly.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="neutral">
|
<wa-radio-group label="Select an option" name="a" value="neutral">
|
||||||
<sl-radio-button value="angry">
|
<wa-radio-button value="angry">
|
||||||
<sl-icon name="emoji-angry" label="Angry"></sl-icon>
|
<wa-icon name="face-angry" variant="solid" label="Angry"></wa-icon>
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="sad">
|
<wa-radio-button value="sad">
|
||||||
<sl-icon name="emoji-frown" label="Sad"></sl-icon>
|
<wa-icon name="face-frown" variant="solid" label="Sad"></wa-icon>
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="neutral">
|
<wa-radio-button value="neutral">
|
||||||
<sl-icon name="emoji-neutral" label="Neutral"></sl-icon>
|
<wa-icon name="face-meh" variant="solid" label="Neutral"></wa-icon>
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="happy">
|
<wa-radio-button value="happy">
|
||||||
<sl-icon name="emoji-smile" label="Happy"></sl-icon>
|
<wa-icon name="face-smile" variant="solid" label="Happy"></wa-icon>
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
|
|
||||||
<sl-radio-button value="laughing">
|
<wa-radio-button value="laughing">
|
||||||
<sl-icon name="emoji-laughing" label="Laughing"></sl-icon>
|
<wa-icon name="face-laugh" variant="solid" label="Laughing"></wa-icon>
|
||||||
</sl-radio-button>
|
</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="neutral">
|
<WaRadioGroup label="Select an option" name="a" value="neutral">
|
||||||
<SlRadioButton value="angry">
|
<WaRadioButton value="angry">
|
||||||
<SlIcon name="emoji-angry" label="Angry" />
|
<WaIcon name="face-angry" label="Angry" />
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="sad">
|
<WaRadioButton value="sad">
|
||||||
<SlIcon name="emoji-frown" label="Sad" />
|
<WaIcon name="face-frown" label="Sad" />
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="neutral">
|
<WaRadioButton value="neutral">
|
||||||
<SlIcon name="emoji-neutral" label="Neutral" />
|
<WaIcon name="face-neutral" label="Neutral" />
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="happy">
|
<WaRadioButton value="happy">
|
||||||
<SlIcon name="emoji-smile" label="Happy" />
|
<WaIcon name="face-smile" label="Happy" />
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
|
|
||||||
<SlRadioButton value="laughing">
|
<WaRadioButton value="laughing">
|
||||||
<SlIcon name="emoji-laughing" label="Laughing" />
|
<WaIcon name="face-laughing" label="Laughing" />
|
||||||
</SlRadioButton>
|
</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2">Option 2</sl-radio>
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2">Option 2</SlRadio>
|
<WaRadio value="2">Option 2</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -33,23 +33,23 @@ const App = () => (
|
|||||||
Add descriptive help text to a radio group with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
Add descriptive help text to a radio group with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" help-text="Choose the most appropriate option." name="a" value="1">
|
<wa-radio-group label="Select an option" help-text="Choose the most appropriate option." name="a" value="1">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2">Option 2</sl-radio>
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" help-text="Choose the most appropriate option." name="a" value="1">
|
<WaRadioGroup label="Select an option" help-text="Choose the most appropriate option." name="a" value="1">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2">Option 2</SlRadio>
|
<WaRadio value="2">Option 2</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -58,23 +58,23 @@ const App = () => (
|
|||||||
[Radio buttons](/components/radio-button) offer an alternate way to display radio controls. In this case, an internal [button group](/components/button-group) is used to group the buttons into a single, cohesive control.
|
[Radio buttons](/components/radio-button) offer an alternate way to display radio controls. In this case, an internal [button group](/components/button-group) is used to group the buttons into a single, cohesive control.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" help-text="Select an option that makes you proud." name="a" value="1">
|
<wa-radio-group label="Select an option" help-text="Select an option that makes you proud." name="a" value="1">
|
||||||
<sl-radio-button value="1">Option 1</sl-radio-button>
|
<wa-radio-button value="1">Option 1</wa-radio-button>
|
||||||
<sl-radio-button value="2">Option 2</sl-radio-button>
|
<wa-radio-button value="2">Option 2</wa-radio-button>
|
||||||
<sl-radio-button value="3">Option 3</sl-radio-button>
|
<wa-radio-button value="3">Option 3</wa-radio-button>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadioButton from '@shoelace-style/shoelace/dist/react/sl-radio-button';
|
import WaRadioButton from '@shoelace-style/shoelace/dist/react/radio-button';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadioButton value="1">Option 1</SlRadioButton>
|
<WaRadioButton value="1">Option 1</WaRadioButton>
|
||||||
<SlRadioButton value="2">Option 2</SlRadioButton>
|
<WaRadioButton value="2">Option 2</WaRadioButton>
|
||||||
<SlRadioButton value="3">Option 3</SlRadioButton>
|
<WaRadioButton value="3">Option 3</WaRadioButton>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -83,25 +83,25 @@ const App = () => (
|
|||||||
Radios and radio buttons can be disabled by adding the `disabled` attribute to the respective options inside the radio group.
|
Radios and radio buttons can be disabled by adding the `disabled` attribute to the respective options inside the radio group.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2" disabled>Option 2</sl-radio>
|
<wa-radio value="2" disabled>Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2" disabled>
|
<WaRadio value="2" disabled>
|
||||||
Option 2
|
Option 2
|
||||||
</SlRadio>
|
</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -110,16 +110,16 @@ const App = () => (
|
|||||||
The size of [Radios](/components/radio) and [Radio Buttons](/components/radio-buttons) will be determined by the Radio Group's `size` attribute.
|
The size of [Radios](/components/radio) and [Radio Buttons](/components/radio-buttons) will be determined by the Radio Group's `size` attribute.
|
||||||
|
|
||||||
```html preview
|
```html preview
|
||||||
<sl-radio-group label="Select an option" size="medium" value="medium" class="radio-group-size">
|
<wa-radio-group label="Select an option" size="medium" value="medium" class="radio-group-size">
|
||||||
<sl-radio value="small">Small</sl-radio>
|
<wa-radio value="small">Small</wa-radio>
|
||||||
<sl-radio value="medium">Medium</sl-radio>
|
<wa-radio value="medium">Medium</wa-radio>
|
||||||
<sl-radio value="large">Large</sl-radio>
|
<wa-radio value="large">Large</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const radioGroup = document.querySelector('.radio-group-size');
|
const radioGroup = document.querySelector('.radio-group-size');
|
||||||
|
|
||||||
radioGroup.addEventListener('sl-change', () => {
|
radioGroup.addEventListener('wa-change', () => {
|
||||||
radioGroup.size = radioGroup.value;
|
radioGroup.size = radioGroup.value;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -127,25 +127,25 @@ The size of [Radios](/components/radio) and [Radio Buttons](/components/radio-bu
|
|||||||
|
|
||||||
```jsx react
|
```jsx react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [size, setSize] = useState('medium');
|
const [size, setSize] = useState('medium');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlRadioGroup
|
<WaRadioGroup
|
||||||
label="Select an option"
|
label="Select an option"
|
||||||
size={size}
|
size={size}
|
||||||
value={size}
|
value={size}
|
||||||
class="radio-group-size"
|
class="radio-group-size"
|
||||||
onSlChange={event => setSize(event.target.value)}
|
onWaChange={event => setSize(event.target.value)}
|
||||||
>
|
>
|
||||||
<SlRadio value="small">Small</SlRadio>
|
<WaRadio value="small">Small</WaRadio>
|
||||||
<SlRadio value="medium">Medium</SlRadio>
|
<WaRadio value="medium">Medium</WaRadio>
|
||||||
<SlRadio value="large">Large</SlRadio>
|
<WaRadio value="large">Large</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -161,13 +161,13 @@ Setting the `required` attribute to make selecting an option mandatory. If a val
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="validation">
|
<form class="validation">
|
||||||
<sl-radio-group label="Select an option" name="a" required>
|
<wa-radio-group label="Select an option" name="a" required>
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2">Option 2</sl-radio>
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -182,10 +182,10 @@ Setting the `required` attribute to make selecting an option mandatory. If a val
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSubmit(event) {
|
function handleSubmit(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -194,21 +194,21 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form class="custom-validity" onSubmit={handleSubmit}>
|
<form class="custom-validity" onSubmit={handleSubmit}>
|
||||||
<SlRadioGroup label="Select an option" name="a" required onSlChange={handleChange}>
|
<WaRadioGroup label="Select an option" name="a" required onWaChange={handleChange}>
|
||||||
<SlRadio value="1">
|
<WaRadio value="1">
|
||||||
Option 1
|
Option 1
|
||||||
</SlRadio>
|
</WaRadio>
|
||||||
<SlRadiovalue="2">
|
<WaRadiovalue="2">
|
||||||
Option 2
|
Option 2
|
||||||
</SlRadio>
|
</WaRadio>
|
||||||
<SlRadio value="3">
|
<WaRadio value="3">
|
||||||
Option 3
|
Option 3
|
||||||
</SlRadio>
|
</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -220,27 +220,27 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="custom-validity">
|
<form class="custom-validity">
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio value="1">Not me</sl-radio>
|
<wa-radio value="1">Not me</wa-radio>
|
||||||
<sl-radio value="2">Me neither</sl-radio>
|
<wa-radio value="2">Me neither</wa-radio>
|
||||||
<sl-radio value="3">Choose me</sl-radio>
|
<wa-radio value="3">Choose me</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const form = document.querySelector('.custom-validity');
|
const form = document.querySelector('.custom-validity');
|
||||||
const radioGroup = form.querySelector('sl-radio-group');
|
const radioGroup = form.querySelector('wa-radio-group');
|
||||||
const errorMessage = 'You must choose the last option';
|
const errorMessage = 'You must choose the last option';
|
||||||
|
|
||||||
// Set initial validity as soon as the element is defined
|
// Set initial validity as soon as the element is defined
|
||||||
customElements.whenDefined('sl-radio').then(() => {
|
customElements.whenDefined('wa-radio').then(() => {
|
||||||
radioGroup.setCustomValidity(errorMessage);
|
radioGroup.setCustomValidity(errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update validity when a selection is made
|
// Update validity when a selection is made
|
||||||
form.addEventListener('sl-change', () => {
|
form.addEventListener('wa-change', () => {
|
||||||
const isValid = radioGroup.value === '3';
|
const isValid = radioGroup.value === '3';
|
||||||
radioGroup.setCustomValidity(isValid ? '' : errorMessage);
|
radioGroup.setCustomValidity(isValid ? '' : errorMessage);
|
||||||
});
|
});
|
||||||
@@ -255,10 +255,10 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const radioGroup = useRef(null);
|
const radioGroup = useRef(null);
|
||||||
const errorMessage = 'You must choose this option';
|
const errorMessage = 'You must choose this option';
|
||||||
@@ -278,15 +278,15 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form class="custom-validity" onSubmit={handleSubmit}>
|
<form class="custom-validity" onSubmit={handleSubmit}>
|
||||||
<SlRadioGroup ref={radioGroup} label="Select an option" name="a" value="1" onSlChange={handleChange}>
|
<WaRadioGroup ref={radioGroup} label="Select an option" name="a" value="1" onWaChange={handleChange}>
|
||||||
<SlRadio value="1">Not me</SlRadio>
|
<WaRadio value="1">Not me</WaRadio>
|
||||||
<SlRadio value="2">Me neither</SlRadio>
|
<WaRadio value="2">Me neither</WaRadio>
|
||||||
<SlRadio value="3">Choose me</SlRadio>
|
<WaRadio value="3">Choose me</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,23 +8,23 @@ layout: component
|
|||||||
Radios are designed to be used with [radio groups](/components/radio-group).
|
Radios are designed to be used with [radio groups](/components/radio-group).
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2">Option 2</sl-radio>
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2">Option 2</SlRadio>
|
<WaRadio value="2">Option 2</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -39,23 +39,23 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
To set the initial value and checked state, use the `value` attribute on the containing radio group.
|
To set the initial value and checked state, use the `value` attribute on the containing radio group.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="3">
|
<wa-radio-group label="Select an option" name="a" value="3">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2">Option 2</sl-radio>
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="3">
|
<WaRadioGroup label="Select an option" name="a" value="3">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2">Option 2</SlRadio>
|
<WaRadio value="2">Option 2</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -64,25 +64,25 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable a radio.
|
Use the `disabled` attribute to disable a radio.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-radio-group label="Select an option" name="a" value="1">
|
<wa-radio-group label="Select an option" name="a" value="1">
|
||||||
<sl-radio value="1">Option 1</sl-radio>
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
<sl-radio value="2" disabled>Option 2</sl-radio>
|
<wa-radio value="2" disabled>Option 2</wa-radio>
|
||||||
<sl-radio value="3">Option 3</sl-radio>
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
import SlRadioGroup from '@shoelace-style/shoelace/dist/react/sl-radio-group';
|
import WaRadioGroup from '@shoelace-style/shoelace/dist/react/radio-group';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRadioGroup label="Select an option" name="a" value="1">
|
<WaRadioGroup label="Select an option" name="a" value="1">
|
||||||
<SlRadio value="1">Option 1</SlRadio>
|
<WaRadio value="1">Option 1</WaRadio>
|
||||||
<SlRadio value="2" disabled>
|
<WaRadio value="2" disabled>
|
||||||
Option 2
|
Option 2
|
||||||
</SlRadio>
|
</WaRadio>
|
||||||
<SlRadio value="3">Option 3</SlRadio>
|
<WaRadio value="3">Option 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -91,55 +91,55 @@ const App = () => (
|
|||||||
Add the `size` attribute to the [Radio Group](/components/radio-group) to change the radios' size.
|
Add the `size` attribute to the [Radio Group](/components/radio-group) to change the radios' size.
|
||||||
|
|
||||||
```html preview
|
```html preview
|
||||||
<sl-radio-group size="small" value="1">
|
<wa-radio-group size="small" value="1">
|
||||||
<sl-radio value="1">Small 1</sl-radio>
|
<wa-radio value="1">Small 1</wa-radio>
|
||||||
<sl-radio value="2">Small 2</sl-radio>
|
<wa-radio value="2">Small 2</wa-radio>
|
||||||
<sl-radio value="3">Small 3</sl-radio>
|
<wa-radio value="3">Small 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group size="medium" value="1">
|
<wa-radio-group size="medium" value="1">
|
||||||
<sl-radio value="1">Medium 1</sl-radio>
|
<wa-radio value="1">Medium 1</wa-radio>
|
||||||
<sl-radio value="2">Medium 2</sl-radio>
|
<wa-radio value="2">Medium 2</wa-radio>
|
||||||
<sl-radio value="3">Medium 3</sl-radio>
|
<wa-radio value="3">Medium 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-radio-group size="large" value="1">
|
<wa-radio-group size="large" value="1">
|
||||||
<sl-radio value="1">Large 1</sl-radio>
|
<wa-radio value="1">Large 1</wa-radio>
|
||||||
<sl-radio value="2">Large 2</sl-radio>
|
<wa-radio value="2">Large 2</wa-radio>
|
||||||
<sl-radio value="3">Large 3</sl-radio>
|
<wa-radio value="3">Large 3</wa-radio>
|
||||||
</sl-radio-group>
|
</wa-radio-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx react
|
```jsx react
|
||||||
import SlRadio from '@shoelace-style/shoelace/dist/react/sl-radio';
|
import WaRadio from '@shoelace-style/shoelace/dist/react/radio';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlRadioGroup size="small" value="1">
|
<WaRadioGroup size="small" value="1">
|
||||||
<SlRadio value="1">Small 1</SlRadio>
|
<WaRadio value="1">Small 1</WaRadio>
|
||||||
<SlRadio value="2">Small 2</SlRadio>
|
<WaRadio value="2">Small 2</WaRadio>
|
||||||
<SlRadio value="3">Small 3</SlRadio>
|
<WaRadio value="3">Small 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup size="medium" value="1">
|
<WaRadioGroup size="medium" value="1">
|
||||||
<SlRadio value="1">Medium 1</SlRadio>
|
<WaRadio value="1">Medium 1</WaRadio>
|
||||||
<SlRadio value="2">Medium 2</SlRadio>
|
<WaRadio value="2">Medium 2</WaRadio>
|
||||||
<SlRadio value="3">Medium 3</SlRadio>
|
<WaRadio value="3">Medium 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlRadioGroup size="large" value="1">
|
<WaRadioGroup size="large" value="1">
|
||||||
<SlRadio value="1">Large 1</SlRadio>
|
<WaRadio value="1">Large 1</WaRadio>
|
||||||
<SlRadio value="2">Large 2</SlRadio>
|
<WaRadio value="2">Large 2</WaRadio>
|
||||||
<SlRadio value="3">Large 3</SlRadio>
|
<WaRadio value="3">Large 3</WaRadio>
|
||||||
</SlRadioGroup>
|
</WaRadioGroup>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range></sl-range>
|
<wa-range></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange />;
|
const App = () => <WaRange />;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,13 +26,13 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `label` attribute to give the range an accessible label. For labels that contain HTML, use the `label` slot instead.
|
Use the `label` attribute to give the range an accessible label. For labels that contain HTML, use the `label` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range label="Volume" min="0" max="100"></sl-range>
|
<wa-range label="Volume" min="0" max="100"></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange label="Volume" min={0} max={100} />;
|
const App = () => <WaRange label="Volume" min={0} max={100} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Help Text
|
### Help Text
|
||||||
@@ -40,13 +40,13 @@ const App = () => <SlRange label="Volume" min={0} max={100} />;
|
|||||||
Add descriptive help text to a range with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
Add descriptive help text to a range with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range label="Volume" help-text="Controls the volume of the current song." min="0" max="100"></sl-range>
|
<wa-range label="Volume" help-text="Controls the volume of the current song." min="0" max="100"></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange label="Volume" help-text="Controls the volume of the current song." min={0} max={100} />;
|
const App = () => <WaRange label="Volume" help-text="Controls the volume of the current song." min={0} max={100} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Min, Max, and Step
|
### Min, Max, and Step
|
||||||
@@ -54,13 +54,13 @@ const App = () => <SlRange label="Volume" help-text="Controls the volume of the
|
|||||||
Use the `min` and `max` attributes to set the range's minimum and maximum values, respectively. The `step` attribute determines the value's interval when increasing and decreasing.
|
Use the `min` and `max` attributes to set the range's minimum and maximum values, respectively. The `step` attribute determines the value's interval when increasing and decreasing.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range min="0" max="10" step="1"></sl-range>
|
<wa-range min="0" max="10" step="1"></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange min={0} max={10} step={1} />;
|
const App = () => <WaRange min={0} max={10} step={1} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -68,13 +68,13 @@ const App = () => <SlRange min={0} max={10} step={1} />;
|
|||||||
Use the `disabled` attribute to disable a slider.
|
Use the `disabled` attribute to disable a slider.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range disabled></sl-range>
|
<wa-range disabled></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange disabled />;
|
const App = () => <WaRange disabled />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tooltip Placement
|
### Tooltip Placement
|
||||||
@@ -82,13 +82,13 @@ const App = () => <SlRange disabled />;
|
|||||||
By default, the tooltip is shown on top. Set `tooltip` to `bottom` to show it below the slider.
|
By default, the tooltip is shown on top. Set `tooltip` to `bottom` to show it below the slider.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range tooltip="bottom"></sl-range>
|
<wa-range tooltip="bottom"></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange tooltip="bottom" />;
|
const App = () => <WaRange tooltip="bottom" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disable the Tooltip
|
### Disable the Tooltip
|
||||||
@@ -96,13 +96,13 @@ const App = () => <SlRange tooltip="bottom" />;
|
|||||||
To disable the tooltip, set `tooltip` to `none`.
|
To disable the tooltip, set `tooltip` to `none`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range tooltip="none"></sl-range>
|
<wa-range tooltip="none"></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange tooltip="none" />;
|
const App = () => <WaRange tooltip="none" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Custom Track Colors
|
### Custom Track Colors
|
||||||
@@ -110,24 +110,24 @@ const App = () => <SlRange tooltip="none" />;
|
|||||||
You can customize the active and inactive portions of the track using the `--track-color-active` and `--track-color-inactive` custom properties.
|
You can customize the active and inactive portions of the track using the `--track-color-active` and `--track-color-inactive` custom properties.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range
|
<wa-range
|
||||||
style="
|
style="
|
||||||
--track-color-active: var(--sl-color-primary-600);
|
--track-color-active: var(--wa-color-brand-spot);
|
||||||
--track-color-inactive: var(--sl-color-primary-100);
|
--track-color-inactive: var(--wa-color-brand-fill-highlight);
|
||||||
"
|
"
|
||||||
></sl-range>
|
></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRange
|
<WaRange
|
||||||
style={{
|
style={{
|
||||||
'--track-color-active': 'var(--sl-color-primary-600)',
|
'--track-color-active': 'var(--wa-color-brand-spot)',
|
||||||
'--track-color-inactive': 'var(--sl-color-primary-200)'
|
'--track-color-inactive': 'var(--wa-color-brand-fill-highlight)'
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -140,29 +140,29 @@ const App = () => (
|
|||||||
You can customize the initial offset of the active track using the `--track-active-offset` custom property.
|
You can customize the initial offset of the active track using the `--track-active-offset` custom property.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range
|
<wa-range
|
||||||
min="-100"
|
min="-100"
|
||||||
max="100"
|
max="100"
|
||||||
style="
|
style="
|
||||||
--track-color-active: var(--sl-color-primary-600);
|
--track-color-active: var(--wa-color-brand-spot);
|
||||||
--track-color-inactive: var(--sl-color-primary-100);
|
--track-color-inactive: var(--wa-color-brand-fill-highlight);
|
||||||
--track-active-offset: 50%;
|
--track-active-offset: 50%;
|
||||||
"
|
"
|
||||||
></sl-range>
|
></wa-range>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRange
|
<WaRange
|
||||||
min={-100}
|
min={-100}
|
||||||
max={100}
|
max={100}
|
||||||
style={{
|
style={{
|
||||||
'--track-color-active': 'var(--sl-color-primary-600)',
|
'--track-color-active': 'var(--wa-color-brand-spot)',
|
||||||
'--track-color-inactive': 'var(--sl-color-primary-200)',
|
'--track-color-inactive': 'var(--wa-color-brand-fill-highlight)',
|
||||||
'--track-active-offset': '50%'
|
'--track-active-offset': '50%'
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -176,7 +176,7 @@ const App = () => (
|
|||||||
You can change the tooltip's content by setting the `tooltipFormatter` property to a function that accepts the range's value as an argument.
|
You can change the tooltip's content by setting the `tooltipFormatter` property to a function that accepts the range's value as an argument.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-range min="0" max="100" step="1" class="range-with-custom-formatter"></sl-range>
|
<wa-range min="0" max="100" step="1" class="range-with-custom-formatter"></wa-range>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const range = document.querySelector('.range-with-custom-formatter');
|
const range = document.querySelector('.range-with-custom-formatter');
|
||||||
@@ -185,7 +185,7 @@ You can change the tooltip's content by setting the `tooltipFormatter` property
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRange from '@shoelace-style/shoelace/dist/react/sl-range';
|
import WaRange from '@shoelace-style/shoelace/dist/react/range';
|
||||||
|
|
||||||
const App = () => <SlRange min={0} max={100} step={1} tooltipFormatter={value => `Total - ${value}%`} />;
|
const App = () => <WaRange min={0} max={100} step={1} tooltipFormatter={value => `Total - ${value}%`} />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating"></sl-rating>
|
<wa-rating label="Rating"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" />;
|
const App = () => <WaRating label="Rating" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,13 +22,13 @@ const App = () => <SlRating label="Rating" />;
|
|||||||
Ratings are commonly identified contextually, so labels aren't displayed. However, you should always provide one for assistive devices using the `label` attribute.
|
Ratings are commonly identified contextually, so labels aren't displayed. However, you should always provide one for assistive devices using the `label` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rate this component"></sl-rating>
|
<wa-rating label="Rate this component"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rate this component" />;
|
const App = () => <WaRating label="Rate this component" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Maximum Value
|
### Maximum Value
|
||||||
@@ -36,13 +36,13 @@ const App = () => <SlRating label="Rate this component" />;
|
|||||||
Ratings are 0-5 by default. To change the maximum possible value, use the `max` attribute.
|
Ratings are 0-5 by default. To change the maximum possible value, use the `max` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" max="3"></sl-rating>
|
<wa-rating label="Rating" max="3"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" max={3} />;
|
const App = () => <WaRating label="Rating" max={3} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Precision
|
### Precision
|
||||||
@@ -50,13 +50,13 @@ const App = () => <SlRating label="Rating" max={3} />;
|
|||||||
Use the `precision` attribute to let users select fractional ratings.
|
Use the `precision` attribute to let users select fractional ratings.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" precision="0.5" value="2.5"></sl-rating>
|
<wa-rating label="Rating" precision="0.5" value="2.5"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" precision={0.5} value={2.5} />;
|
const App = () => <WaRating label="Rating" precision={0.5} value={2.5} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Symbol Sizes
|
### Symbol Sizes
|
||||||
@@ -64,15 +64,15 @@ const App = () => <SlRating label="Rating" precision={0.5} value={2.5} />;
|
|||||||
Set the `--symbol-size` custom property to adjust the size.
|
Set the `--symbol-size` custom property to adjust the size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" style="--symbol-size: 2rem;"></sl-rating>
|
<wa-rating label="Rating" style="--symbol-size: 2rem;"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" style={{ '--symbol-size': '2rem' }} />;
|
const App = () => <WaRating label="Rating" style={{ '--symbol-size': '2rem' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -82,13 +82,13 @@ const App = () => <SlRating label="Rating" style={{ '--symbol-size': '2rem' }} /
|
|||||||
Use the `readonly` attribute to display a rating that users can't change.
|
Use the `readonly` attribute to display a rating that users can't change.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" readonly value="3"></sl-rating>
|
<wa-rating label="Rating" readonly value="3"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" readonly value={3} />;
|
const App = () => <WaRating label="Rating" readonly value={3} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -96,33 +96,33 @@ const App = () => <SlRating label="Rating" readonly value={3} />;
|
|||||||
Use the `disable` attribute to disable the rating.
|
Use the `disable` attribute to disable the rating.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" disabled value="3"></sl-rating>
|
<wa-rating label="Rating" disabled value="3"></wa-rating>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" disabled value={3} />;
|
const App = () => <WaRating label="Rating" disabled value={3} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Detecting Hover
|
### Detecting Hover
|
||||||
|
|
||||||
Use the `sl-hover` event to detect when the user hovers over (or touch and drag) the rating. This lets you hook into values as the user interacts with the rating, but before they select a value.
|
Use the `wa-hover` event to detect when the user hovers over (or touch and drag) the rating. This lets you hook into values as the user interacts with the rating, but before they select a value.
|
||||||
|
|
||||||
The event has a payload with `phase` and `value` properties. The `phase` property tells when hovering starts, moves to a new value, and ends. The `value` property tells what the rating's value would be if the user were to commit to the hovered value.
|
The event has a payload with `phase` and `value` properties. The `phase` property tells when hovering starts, moves to a new value, and ends. The `value` property tells what the rating's value would be if the user were to commit to the hovered value.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="detect-hover">
|
<div class="detect-hover">
|
||||||
<sl-rating label="Rating"></sl-rating>
|
<wa-rating label="Rating"></wa-rating>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const rating = document.querySelector('.detect-hover > sl-rating');
|
const rating = document.querySelector('.detect-hover > wa-rating');
|
||||||
const span = rating.nextElementSibling;
|
const span = rating.nextElementSibling;
|
||||||
const terms = ['No rating', 'Terrible', 'Bad', 'OK', 'Good', 'Excellent'];
|
const terms = ['No rating', 'Terrible', 'Bad', 'OK', 'Good', 'Excellent'];
|
||||||
|
|
||||||
rating.addEventListener('sl-hover', event => {
|
rating.addEventListener('wa-hover', event => {
|
||||||
span.textContent = terms[event.detail.value];
|
span.textContent = terms[event.detail.value];
|
||||||
|
|
||||||
// Clear feedback when hovering stops
|
// Clear feedback when hovering stops
|
||||||
@@ -137,9 +137,9 @@ The event has a payload with `phase` and `value` properties. The `phase` propert
|
|||||||
position: relative;
|
position: relative;
|
||||||
top: -4px;
|
top: -4px;
|
||||||
left: 8px;
|
left: 8px;
|
||||||
border-radius: var(--sl-border-radius-small);
|
border-radius: var(--wa-corners-s);
|
||||||
background: var(--sl-color-neutral-900);
|
background: var(--wa-color-neutral-spot);
|
||||||
color: var(--sl-color-neutral-0);
|
color: var(--wa-color-neutral-text-on-spot);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ The event has a payload with `phase` and `value` properties. The `phase` propert
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const terms = ['No rating', 'Terrible', 'Bad', 'OK', 'Good', 'Excellent'];
|
const terms = ['No rating', 'Terrible', 'Bad', 'OK', 'Good', 'Excellent'];
|
||||||
const css = `
|
const css = `
|
||||||
@@ -160,9 +160,9 @@ const css = `
|
|||||||
position: relative;
|
position: relative;
|
||||||
top: -4px;
|
top: -4px;
|
||||||
left: 8px;
|
left: 8px;
|
||||||
border-radius: var(--sl-border-radius-small);
|
border-radius: var(--wa-corners-s);
|
||||||
background: var(--sl-color-neutral-900);
|
background: var(--wa-color-neutral-spot);
|
||||||
color: var(--sl-color-neutral-0);
|
color: var(--wa-color-neutral-text-on-spot);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4px 6px;
|
padding: 4px 6px;
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ const css = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function handleHover(event) {
|
function handleHover(event) {
|
||||||
rating.addEventListener('sl-hover', event => {
|
rating.addEventListener('wa-hover', event => {
|
||||||
setFeedback(terms[event.detail.value]);
|
setFeedback(terms[event.detail.value]);
|
||||||
|
|
||||||
// Clear feedback when hovering stops
|
// Clear feedback when hovering stops
|
||||||
@@ -189,7 +189,7 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class="detect-hover">
|
<div class="detect-hover">
|
||||||
<SlRating label="Rating" onSlHover={handleHover} />
|
<WaRating label="Rating" onWaHover={handleHover} />
|
||||||
<span>{feedback}</span>
|
<span>{feedback}</span>
|
||||||
</div>
|
</div>
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -203,23 +203,23 @@ const App = () => {
|
|||||||
You can provide custom icons by passing a function to the `getSymbol` property.
|
You can provide custom icons by passing a function to the `getSymbol` property.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" class="rating-hearts" style="--symbol-color-active: #ff4136;"></sl-rating>
|
<wa-rating label="Rating" class="rating-hearts" style="--symbol-color-active: #ff4136;"></wa-rating>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const rating = document.querySelector('.rating-hearts');
|
const rating = document.querySelector('.rating-hearts');
|
||||||
rating.getSymbol = () => '<sl-icon name="heart-fill"></sl-icon>';
|
rating.getSymbol = () => '<wa-icon name="heart" variant="solid"></wa-icon>';
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlRating
|
<WaRating
|
||||||
label="Rating"
|
label="Rating"
|
||||||
getSymbol={() => '<sl-icon name="heart-fill"></sl-icon>'}
|
getSymbol={() => '<wa-icon name="heart" variant="solid"></wa-icon>'}
|
||||||
style={{ '--symbol-color-active': '#ff4136' }}
|
style={{ '--symbol-color-active': '#ff4136' }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -232,25 +232,25 @@ const App = () => (
|
|||||||
You can also use the `getSymbol` property to render different icons based on value.
|
You can also use the `getSymbol` property to render different icons based on value.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-rating label="Rating" class="rating-emojis"></sl-rating>
|
<wa-rating label="Rating" class="rating-emojis"></wa-rating>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const rating = document.querySelector('.rating-emojis');
|
const rating = document.querySelector('.rating-emojis');
|
||||||
|
|
||||||
rating.getSymbol = value => {
|
rating.getSymbol = value => {
|
||||||
const icons = ['emoji-angry', 'emoji-frown', 'emoji-expressionless', 'emoji-smile', 'emoji-laughing'];
|
const icons = ['face-angry', 'face-frown', 'face-meh', 'face-smile', 'face-laugh'];
|
||||||
return `<sl-icon name="${icons[value - 1]}"></sl-icon>`;
|
return `<wa-icon name="${icons[value - 1]}"></wa-icon>`;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRating from '@shoelace-style/shoelace/dist/react/sl-rating';
|
import WaRating from '@shoelace-style/shoelace/dist/react/rating';
|
||||||
|
|
||||||
function getSymbol(value) {
|
function getSymbol(value) {
|
||||||
const icons = ['emoji-angry', 'emoji-frown', 'emoji-expressionless', 'emoji-smile', 'emoji-laughing'];
|
const icons = ['face-angry', 'face-frown', 'face-meh', 'face-smile', 'face-laugh'];
|
||||||
return `<sl-icon name="${icons[value - 1]}"></sl-icon>`;
|
return `<wa-icon name="${icons[value - 1]}"></wa-icon>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const App = () => <SlRating label="Rating" getSymbol={getSymbol} />;
|
const App = () => <WaRating label="Rating" getSymbol={getSymbol} />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ layout: component
|
|||||||
Localization is handled by the browser's [`Intl.RelativeTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat). No language packs are required.
|
Localization is handled by the browser's [`Intl.RelativeTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat). No language packs are required.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<!-- Shoelace 2 release date 🎉 -->
|
<!-- Web Awesome 2 release date 🎉 -->
|
||||||
<sl-relative-time date="2020-07-15T09:17:00-04:00"></sl-relative-time>
|
<wa-relative-time date="2020-07-15T09:17:00-04:00"></wa-relative-time>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRelativeTime from '@shoelace-style/shoelace/dist/react/sl-relative-time';
|
import WaRelativeTime from '@shoelace-style/shoelace/dist/react/relative-time';
|
||||||
|
|
||||||
const App = () => <SlRelativeTime date="2020-07-15T09:17:00-04:00" />;
|
const App = () => <WaRelativeTime date="2020-07-15T09:17:00-04:00" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
The `date` attribute determines when the date/time is calculated from. It must be a string that [`Date.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) can interpret or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object set via JavaScript.
|
The `date` attribute determines when the date/time is calculated from. It must be a string that [`Date.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) can interpret or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object set via JavaScript.
|
||||||
@@ -32,23 +32,23 @@ Use the `sync` attribute to update the displayed value automatically as time pas
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="relative-time-sync">
|
<div class="relative-time-sync">
|
||||||
<sl-relative-time sync></sl-relative-time>
|
<wa-relative-time sync></wa-relative-time>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.relative-time-sync');
|
const container = document.querySelector('.relative-time-sync');
|
||||||
const relativeTime = container.querySelector('sl-relative-time');
|
const relativeTime = container.querySelector('wa-relative-time');
|
||||||
|
|
||||||
relativeTime.date = new Date(new Date().getTime() - 60000);
|
relativeTime.date = new Date(new Date().getTime() - 60000);
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRelativeTime from '@shoelace-style/shoelace/dist/react/sl-relative-time';
|
import WaRelativeTime from '@shoelace-style/shoelace/dist/react/relative-time';
|
||||||
|
|
||||||
const date = new Date(new Date().getTime() - 60000);
|
const date = new Date(new Date().getTime() - 60000);
|
||||||
|
|
||||||
const App = () => <SlRelativeTime date={date} sync />;
|
const App = () => <WaRelativeTime date={date} sync />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Formatting Styles
|
### Formatting Styles
|
||||||
@@ -56,21 +56,21 @@ const App = () => <SlRelativeTime date={date} sync />;
|
|||||||
You can change how the time is displayed using the `format` attribute. Note that some locales may display the same values for `narrow` and `short` formats.
|
You can change how the time is displayed using the `format` attribute. Note that some locales may display the same values for `narrow` and `short` formats.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-relative-time date="2020-07-15T09:17:00-04:00" format="narrow"></sl-relative-time><br />
|
<wa-relative-time date="2020-07-15T09:17:00-04:00" format="narrow"></wa-relative-time><br />
|
||||||
<sl-relative-time date="2020-07-15T09:17:00-04:00" format="short"></sl-relative-time><br />
|
<wa-relative-time date="2020-07-15T09:17:00-04:00" format="short"></wa-relative-time><br />
|
||||||
<sl-relative-time date="2020-07-15T09:17:00-04:00" format="long"></sl-relative-time>
|
<wa-relative-time date="2020-07-15T09:17:00-04:00" format="long"></wa-relative-time>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRelativeTime from '@shoelace-style/shoelace/dist/react/sl-relative-time';
|
import WaRelativeTime from '@shoelace-style/shoelace/dist/react/relative-time';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlRelativeTime date="2020-07-15T09:17:00-04:00" format="narrow" />
|
<WaRelativeTime date="2020-07-15T09:17:00-04:00" format="narrow" />
|
||||||
<br />
|
<br />
|
||||||
<SlRelativeTime date="2020-07-15T09:17:00-04:00" format="short" />
|
<WaRelativeTime date="2020-07-15T09:17:00-04:00" format="short" />
|
||||||
<br />
|
<br />
|
||||||
<SlRelativeTime date="2020-07-15T09:17:00-04:00" format="long" />
|
<WaRelativeTime date="2020-07-15T09:17:00-04:00" format="long" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -80,27 +80,27 @@ const App = () => (
|
|||||||
Use the `lang` attribute to set the desired locale.
|
Use the `lang` attribute to set the desired locale.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
English: <sl-relative-time date="2020-07-15T09:17:00-04:00" lang="en-US"></sl-relative-time><br />
|
English: <wa-relative-time date="2020-07-15T09:17:00-04:00" lang="en-US"></wa-relative-time><br />
|
||||||
Chinese: <sl-relative-time date="2020-07-15T09:17:00-04:00" lang="zh-CN"></sl-relative-time><br />
|
Chinese: <wa-relative-time date="2020-07-15T09:17:00-04:00" lang="zh-CN"></wa-relative-time><br />
|
||||||
German: <sl-relative-time date="2020-07-15T09:17:00-04:00" lang="de"></sl-relative-time><br />
|
German: <wa-relative-time date="2020-07-15T09:17:00-04:00" lang="de"></wa-relative-time><br />
|
||||||
Greek: <sl-relative-time date="2020-07-15T09:17:00-04:00" lang="el"></sl-relative-time><br />
|
Greek: <wa-relative-time date="2020-07-15T09:17:00-04:00" lang="el"></wa-relative-time><br />
|
||||||
Russian: <sl-relative-time date="2020-07-15T09:17:00-04:00" lang="ru"></sl-relative-time>
|
Russian: <wa-relative-time date="2020-07-15T09:17:00-04:00" lang="ru"></wa-relative-time>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlRelativeTime from '@shoelace-style/shoelace/dist/react/sl-relative-time';
|
import WaRelativeTime from '@shoelace-style/shoelace/dist/react/relative-time';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
English: <SlRelativeTime date="2020-07-15T09:17:00-04:00" lang="en-US" />
|
English: <WaRelativeTime date="2020-07-15T09:17:00-04:00" lang="en-US" />
|
||||||
<br />
|
<br />
|
||||||
Chinese: <SlRelativeTime date="2020-07-15T09:17:00-04:00" lang="zh-CN" />
|
Chinese: <WaRelativeTime date="2020-07-15T09:17:00-04:00" lang="zh-CN" />
|
||||||
<br />
|
<br />
|
||||||
German: <SlRelativeTime date="2020-07-15T09:17:00-04:00" lang="de" />
|
German: <WaRelativeTime date="2020-07-15T09:17:00-04:00" lang="de" />
|
||||||
<br />
|
<br />
|
||||||
Greek: <SlRelativeTime date="2020-07-15T09:17:00-04:00" lang="el" />
|
Greek: <WaRelativeTime date="2020-07-15T09:17:00-04:00" lang="el" />
|
||||||
<br />
|
<br />
|
||||||
Russian: <SlRelativeTime date="2020-07-15T09:17:00-04:00" lang="ru" />
|
Russian: <WaRelativeTime date="2020-07-15T09:17:00-04:00" lang="ru" />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ meta:
|
|||||||
layout: component
|
layout: component
|
||||||
---
|
---
|
||||||
|
|
||||||
The resize observer will report changes to the dimensions of the elements it wraps through the `sl-resize` event. When emitted, a collection of [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) objects will be attached to `event.detail` that contains the target element and information about its dimensions.
|
The resize observer will report changes to the dimensions of the elements it wraps through the `wa-resize` event. When emitted, a collection of [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) objects will be attached to `event.detail` that contains the target element and information about its dimensions.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="resize-observer-overview">
|
<div class="resize-observer-overview">
|
||||||
<sl-resize-observer>
|
<wa-resize-observer>
|
||||||
<div>Resize this box and watch the console 👉</div>
|
<div>Resize this box and watch the console 👉</div>
|
||||||
</sl-resize-observer>
|
</wa-resize-observer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.resize-observer-overview');
|
const container = document.querySelector('.resize-observer-overview');
|
||||||
const resizeObserver = container.querySelector('sl-resize-observer');
|
const resizeObserver = container.querySelector('wa-resize-observer');
|
||||||
|
|
||||||
resizeObserver.addEventListener('sl-resize', event => {
|
resizeObserver.addEventListener('wa-resize', event => {
|
||||||
console.log(event.detail);
|
console.log(event.detail);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -26,7 +26,7 @@ The resize observer will report changes to the dimensions of the elements it wra
|
|||||||
<style>
|
<style>
|
||||||
.resize-observer-overview div {
|
.resize-observer-overview div {
|
||||||
display: flex;
|
display: flex;
|
||||||
border: solid 2px var(--sl-input-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -36,12 +36,12 @@ The resize observer will report changes to the dimensions of the elements it wra
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlResizeObserver from '@shoelace-style/shoelace/dist/react/sl-resize-observer';
|
import WaResizeObserver from '@shoelace-style/shoelace/dist/react/resize-observer';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.resize-observer-overview div {
|
.resize-observer-overview div {
|
||||||
display: flex;
|
display: flex;
|
||||||
border: solid 2px var(--sl-input-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -52,9 +52,9 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="resize-observer-overview">
|
<div className="resize-observer-overview">
|
||||||
<SlResizeObserver onSlResize={event => console.log(event.detail)}>
|
<WaResizeObserver onWaResize={event => console.log(event.detail)}>
|
||||||
<div>Resize this box and watch the console 👉</div>
|
<div>Resize this box and watch the console 👉</div>
|
||||||
</SlResizeObserver>
|
</WaResizeObserver>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,29 +6,29 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select>
|
<wa-select>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
<sl-option value="option-4">Option 4</sl-option>
|
<wa-option value="option-4">Option 4</wa-option>
|
||||||
<sl-option value="option-5">Option 5</sl-option>
|
<wa-option value="option-5">Option 5</wa-option>
|
||||||
<sl-option value="option-6">Option 6</sl-option>
|
<wa-option value="option-6">Option 6</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect>
|
<WaSelect>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
<SlOption value="option-4">Option 4</SlOption>
|
<WaOption value="option-4">Option 4</WaOption>
|
||||||
<SlOption value="option-5">Option 5</SlOption>
|
<WaOption value="option-5">Option 5</WaOption>
|
||||||
<SlOption value="option-6">Option 6</SlOption>
|
<WaOption value="option-6">Option 6</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -43,23 +43,23 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `label` attribute to give the select an accessible label. For labels that contain HTML, use the `label` slot instead.
|
Use the `label` attribute to give the select an accessible label. For labels that contain HTML, use the `label` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Select one">
|
<wa-select label="Select one">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect label="Select one">
|
<WaSelect label="Select one">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -68,23 +68,23 @@ const App = () => (
|
|||||||
Add descriptive help text to a select with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
Add descriptive help text to a select with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Experience" help-text="Please tell us your skill level.">
|
<wa-select label="Experience" help-text="Please tell us your skill level.">
|
||||||
<sl-option value="1">Novice</sl-option>
|
<wa-option value="1">Novice</wa-option>
|
||||||
<sl-option value="2">Intermediate</sl-option>
|
<wa-option value="2">Intermediate</wa-option>
|
||||||
<sl-option value="3">Advanced</sl-option>
|
<wa-option value="3">Advanced</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect label="Experience" help-text="Please tell us your skill level.">
|
<WaSelect label="Experience" help-text="Please tell us your skill level.">
|
||||||
<SlOption value="1">Novice</SlOption>
|
<WaOption value="1">Novice</WaOption>
|
||||||
<SlOption value="2">Intermediate</SlOption>
|
<WaOption value="2">Intermediate</WaOption>
|
||||||
<SlOption value="3">Advanced</SlOption>
|
<WaOption value="3">Advanced</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -93,23 +93,23 @@ const App = () => (
|
|||||||
Use the `placeholder` attribute to add a placeholder.
|
Use the `placeholder` attribute to add a placeholder.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select placeholder="Select one">
|
<wa-select placeholder="Select one">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect placeholder="Select one">
|
<WaSelect placeholder="Select one">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -118,23 +118,23 @@ const App = () => (
|
|||||||
Use the `clearable` attribute to make the control clearable. The clear button only appears when an option is selected.
|
Use the `clearable` attribute to make the control clearable. The clear button only appears when an option is selected.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select clearable value="option-1">
|
<wa-select clearable value="option-1">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect placeholder="Clearable" clearable>
|
<WaSelect placeholder="Clearable" clearable>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -143,23 +143,23 @@ const App = () => (
|
|||||||
Add the `filled` attribute to draw a filled select.
|
Add the `filled` attribute to draw a filled select.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select filled>
|
<wa-select filled>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect filled>
|
<WaSelect filled>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -168,23 +168,23 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give selects rounded edges.
|
Use the `pill` attribute to give selects rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select pill>
|
<wa-select pill>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect pill>
|
<WaSelect pill>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -193,23 +193,23 @@ const App = () => (
|
|||||||
Use the `disabled` attribute to disable a select.
|
Use the `disabled` attribute to disable a select.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select placeholder="Disabled" disabled>
|
<wa-select placeholder="Disabled" disabled>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect placeholder="Disabled" disabled>
|
<WaSelect placeholder="Disabled" disabled>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -218,29 +218,29 @@ const App = () => (
|
|||||||
To allow multiple options to be selected, use the `multiple` attribute. It's a good practice to use `clearable` when this option is enabled. To set multiple values at once, set `value` to a space-delimited list of values.
|
To allow multiple options to be selected, use the `multiple` attribute. It's a good practice to use `clearable` when this option is enabled. To set multiple values at once, set `value` to a space-delimited list of values.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select label="Select a Few" value="option-1 option-2 option-3" multiple clearable>
|
<wa-select label="Select a Few" value="option-1 option-2 option-3" multiple clearable>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
<sl-option value="option-4">Option 4</sl-option>
|
<wa-option value="option-4">Option 4</wa-option>
|
||||||
<sl-option value="option-5">Option 5</sl-option>
|
<wa-option value="option-5">Option 5</wa-option>
|
||||||
<sl-option value="option-6">Option 6</sl-option>
|
<wa-option value="option-6">Option 6</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect label="Select a Few" value="option-1 option-2 option-3" multiple clearable>
|
<WaSelect label="Select a Few" value="option-1 option-2 option-3" multiple clearable>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
<SlOption value="option-4">Option 4</SlOption>
|
<WaOption value="option-4">Option 4</WaOption>
|
||||||
<SlOption value="option-5">Option 5</SlOption>
|
<WaOption value="option-5">Option 5</WaOption>
|
||||||
<SlOption value="option-6">Option 6</SlOption>
|
<WaOption value="option-6">Option 6</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -250,62 +250,64 @@ Note that multi-select options may wrap, causing the control to expand verticall
|
|||||||
|
|
||||||
### Setting Initial Values
|
### Setting Initial Values
|
||||||
|
|
||||||
Use the `value` attribute to set the initial selection. When using `multiple`, use space-delimited values to select more than one option.
|
Use the `value` attribute to set the initial selection.
|
||||||
|
|
||||||
|
When using `multiple`, the `value` _attribute_ uses space-delimited values to select more than one option. Because of this, `<wa-option>` values cannot contain spaces. If you're accessing the `value` _property_ through Javascript, it will be an array.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select value="option-1 option-2" multiple clearable>
|
<wa-select value="option-1 option-2" multiple clearable>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
<sl-option value="option-4">Option 4</sl-option>
|
<wa-option value="option-4">Option 4</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlDivider from '@shoelace-style/shoelace/dist/react/sl-divider';
|
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect value="option-1 option-2" multiple clearable>
|
<WaSelect value="option-1 option-2" multiple clearable>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Grouping Options
|
### Grouping Options
|
||||||
|
|
||||||
Use `<sl-divider>` to group listbox items visually. You can also use `<small>` to provide labels, but they won't be announced by most assistive devices.
|
Use `<wa-divider>` to group listbox items visually. You can also use `<small>` to provide labels, but they won't be announced by most assistive devices.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select>
|
<wa-select>
|
||||||
<small>Section 1</small>
|
<small>Section 1</small>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
<sl-divider></sl-divider>
|
<wa-divider></wa-divider>
|
||||||
<small>Section 2</small>
|
<small>Section 2</small>
|
||||||
<sl-option value="option-4">Option 4</sl-option>
|
<wa-option value="option-4">Option 4</wa-option>
|
||||||
<sl-option value="option-5">Option 5</sl-option>
|
<wa-option value="option-5">Option 5</wa-option>
|
||||||
<sl-option value="option-6">Option 6</sl-option>
|
<wa-option value="option-6">Option 6</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect>
|
<WaSelect>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
<SlOption value="option-4">Option 4</SlOption>
|
<WaOption value="option-4">Option 4</WaOption>
|
||||||
<SlOption value="option-5">Option 5</SlOption>
|
<WaOption value="option-5">Option 5</WaOption>
|
||||||
<SlOption value="option-6">Option 6</SlOption>
|
<WaOption value="option-6">Option 6</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -314,56 +316,56 @@ const App = () => (
|
|||||||
Use the `size` attribute to change a select's size. Note that size does not apply to listbox options.
|
Use the `size` attribute to change a select's size. Note that size does not apply to listbox options.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select placeholder="Small" size="small">
|
<wa-select placeholder="Small" size="small">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-select placeholder="Medium" size="medium">
|
<wa-select placeholder="Medium" size="medium">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-select placeholder="Large" size="large">
|
<wa-select placeholder="Large" size="large">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlSelect placeholder="Small" size="small">
|
<WaSelect placeholder="Small" size="small">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlSelect placeholder="Medium" size="medium">
|
<WaSelect placeholder="Medium" size="medium">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlSelect placeholder="Large" size="large">
|
<WaSelect placeholder="Large" size="large">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -373,25 +375,23 @@ const App = () => (
|
|||||||
The preferred placement of the select's listbox can be set with the `placement` attribute. Note that the actual position may vary to ensure the panel remains in the viewport. Valid placements are `top` and `bottom`.
|
The preferred placement of the select's listbox can be set with the `placement` attribute. Note that the actual position may vary to ensure the panel remains in the viewport. Valid placements are `top` and `bottom`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select placement="top">
|
<wa-select placement="top">
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import {
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
SlOption,
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
SlSelect
|
|
||||||
} from '@shoelace-style/shoelace/dist/react';
|
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSelect placement="top">
|
<WaSelect placement="top">
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlDropdown>
|
</WaDropdown>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -400,55 +400,105 @@ const App = () => (
|
|||||||
Use the `prefix` slot to prepend an icon to the control.
|
Use the `prefix` slot to prepend an icon to the control.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select placeholder="Small" size="small" clearable>
|
<wa-select placeholder="Small" size="small" clearable>
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
<br />
|
<br />
|
||||||
<sl-select placeholder="Medium" size="medium" clearable>
|
<wa-select placeholder="Medium" size="medium" clearable>
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
<br />
|
<br />
|
||||||
<sl-select placeholder="Large" size="large" clearable>
|
<wa-select placeholder="Large" size="large" clearable>
|
||||||
<sl-icon name="house" slot="prefix"></sl-icon>
|
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
|
||||||
<sl-option value="option-1">Option 1</sl-option>
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
<sl-option value="option-2">Option 2</sl-option>
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
<sl-option value="option-3">Option 3</sl-option>
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlOption from '@shoelace-style/shoelace/dist/react/sl-option';
|
import WaOption from '@shoelace-style/shoelace/dist/react/option';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlSelect placeholder="Small" size="small">
|
<WaSelect placeholder="Small" size="small">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon slot="prefix" name="house" variant="solid"></WaIcon>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
<br />
|
<br />
|
||||||
<SlSelect placeholder="Medium" size="medium">
|
<WaSelect placeholder="Medium" size="medium">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon slot="prefix" name="house" variant="solid"></WaIcon>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
<br />
|
<br />
|
||||||
<SlSelect placeholder="Large" size="large">
|
<WaSelect placeholder="Large" size="large">
|
||||||
<SlIcon name="house" slot="prefix"></SlIcon>
|
<WaIcon slot="prefix" name="house" variant="solid"></WaIcon>
|
||||||
<SlOption value="option-1">Option 1</SlOption>
|
<WaOption value="option-1">Option 1</WaOption>
|
||||||
<SlOption value="option-2">Option 2</SlOption>
|
<WaOption value="option-2">Option 2</WaOption>
|
||||||
<SlOption value="option-3">Option 3</SlOption>
|
<WaOption value="option-3">Option 3</WaOption>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Custom Tags
|
||||||
|
|
||||||
|
When multiple options can be selected, you can provide custom tags by passing a function to the `getTag` property. Your function can return a string of HTML, a <a href="https://lit.dev/docs/templates/overview/">Lit Template</a>, or an [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement). The `getTag()` function will be called for each option. The first argument is an `<wa-option>` element and the second argument is the tag's index (its position in the tag list).
|
||||||
|
|
||||||
|
Remember that custom tags are rendered in a shadow root. To style them, you can use the `style` attribute in your template or you can add your own [parts](/getting-started/customizing/#css-parts) and target them with the [`::part()`](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) selector.
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-select
|
||||||
|
placeholder="Select one"
|
||||||
|
value="email phone"
|
||||||
|
multiple
|
||||||
|
clearable
|
||||||
|
class="custom-tag"
|
||||||
|
>
|
||||||
|
<wa-option value="email">
|
||||||
|
<wa-icon slot="prefix" name="envelope" variant="solid"></wa-icon>
|
||||||
|
Email
|
||||||
|
</wa-option>
|
||||||
|
<wa-option value="phone">
|
||||||
|
<wa-icon slot="prefix" name="phone" variant="solid"></wa-icon>
|
||||||
|
Phone
|
||||||
|
</wa-option>
|
||||||
|
<wa-option value="chat">
|
||||||
|
<wa-icon slot="prefix" name="comment" variant="solid"></wa-icon>
|
||||||
|
Chat
|
||||||
|
</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
const select = document.querySelector('.custom-tag');
|
||||||
|
|
||||||
|
select.getTag = (option, index) => {
|
||||||
|
// Use the same icon used in the <wa-option>
|
||||||
|
const name = option.querySelector('wa-icon[slot="prefix"]').name;
|
||||||
|
|
||||||
|
// You can return a string, a Lit Template, or an HTMLElement here
|
||||||
|
return `
|
||||||
|
<wa-tag removable>
|
||||||
|
<wa-icon name="${name}" style="padding-inline-end: .5rem;"></wa-icon>
|
||||||
|
${option.getTextLabel()}
|
||||||
|
</wa-tag>
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
:::warning
|
||||||
|
Be sure you trust the content you are outputting! Passing unsanitized user input to `getTag()` can result in XSS vulnerabilities.
|
||||||
|
:::
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ Skeletons try not to be opinionated, as there are endless possibilities for desi
|
|||||||
```html:preview
|
```html:preview
|
||||||
<div class="skeleton-overview">
|
<div class="skeleton-overview">
|
||||||
<header>
|
<header>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -28,16 +28,16 @@ Skeletons try not to be opinionated, as there are endless possibilities for desi
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview header sl-skeleton:last-child {
|
.skeleton-overview header wa-skeleton:last-child {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: 30%;
|
width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton {
|
.skeleton-overview wa-skeleton {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(1) {
|
.skeleton-overview wa-skeleton:nth-child(1) {
|
||||||
float: left;
|
float: left;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
@@ -45,18 +45,18 @@ Skeletons try not to be opinionated, as there are endless possibilities for desi
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(3) {
|
.skeleton-overview wa-skeleton:nth-child(3) {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(4) {
|
.skeleton-overview wa-skeleton:nth-child(4) {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-overview header {
|
.skeleton-overview header {
|
||||||
@@ -65,16 +65,16 @@ const css = `
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview header sl-skeleton:last-child {
|
.skeleton-overview header wa-skeleton:last-child {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: 30%;
|
width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton {
|
.skeleton-overview wa-skeleton {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(1) {
|
.skeleton-overview wa-skeleton:nth-child(1) {
|
||||||
float: left;
|
float: left;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
@@ -82,11 +82,11 @@ const css = `
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(3) {
|
.skeleton-overview wa-skeleton:nth-child(3) {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-overview sl-skeleton:nth-child(4) {
|
.skeleton-overview wa-skeleton:nth-child(4) {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -95,13 +95,13 @@ const App = () => (
|
|||||||
<>
|
<>
|
||||||
<div className="skeleton-overview">
|
<div className="skeleton-overview">
|
||||||
<header>
|
<header>
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -117,36 +117,36 @@ There are two built-in effects, `sheen` and `pulse`. Effects are intentionally s
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="skeleton-effects">
|
<div class="skeleton-effects">
|
||||||
<sl-skeleton effect="none"></sl-skeleton>
|
<wa-skeleton effect="none"></wa-skeleton>
|
||||||
None
|
None
|
||||||
|
|
||||||
<sl-skeleton effect="sheen"></sl-skeleton>
|
<wa-skeleton effect="sheen"></wa-skeleton>
|
||||||
Sheen
|
Sheen
|
||||||
|
|
||||||
<sl-skeleton effect="pulse"></sl-skeleton>
|
<wa-skeleton effect="pulse"></wa-skeleton>
|
||||||
Pulse
|
Pulse
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.skeleton-effects {
|
.skeleton-effects {
|
||||||
font-size: var(--sl-font-size-small);
|
font-size: var(--wa-font-size-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-effects sl-skeleton:not(:first-child) {
|
.skeleton-effects wa-skeleton:not(:first-child) {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-effects {
|
.skeleton-effects {
|
||||||
font-size: var(--sl-font-size-small);
|
font-size: var(--wa-font-size-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-effects sl-skeleton:not(:first-child) {
|
.skeleton-effects wa-skeleton:not(:first-child) {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -154,11 +154,11 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="skeleton-effects">
|
<div className="skeleton-effects">
|
||||||
<SlSkeleton effect="none" />
|
<WaSkeleton effect="none" />
|
||||||
None
|
None
|
||||||
<SlSkeleton effect="sheen" />
|
<WaSkeleton effect="sheen" />
|
||||||
Sheen
|
Sheen
|
||||||
<SlSkeleton effect="pulse" />
|
<WaSkeleton effect="pulse" />
|
||||||
Pulse
|
Pulse
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -173,49 +173,49 @@ Use multiple skeletons and some clever styles to simulate paragraphs.
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="skeleton-paragraphs">
|
<div class="skeleton-paragraphs">
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.skeleton-paragraphs sl-skeleton {
|
.skeleton-paragraphs wa-skeleton {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:nth-child(2) {
|
.skeleton-paragraphs wa-skeleton:nth-child(2) {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:nth-child(4) {
|
.skeleton-paragraphs wa-skeleton:nth-child(4) {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:last-child {
|
.skeleton-paragraphs wa-skeleton:last-child {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-paragraphs sl-skeleton {
|
.skeleton-paragraphs wa-skeleton {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:nth-child(2) {
|
.skeleton-paragraphs wa-skeleton:nth-child(2) {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:nth-child(4) {
|
.skeleton-paragraphs wa-skeleton:nth-child(4) {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-paragraphs sl-skeleton:last-child {
|
.skeleton-paragraphs wa-skeleton:last-child {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -223,11 +223,11 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="skeleton-paragraphs">
|
<div className="skeleton-paragraphs">
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -241,55 +241,55 @@ Set a matching width and height to make a circle, square, or rounded avatar skel
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="skeleton-avatars">
|
<div class="skeleton-avatars">
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
<sl-skeleton></sl-skeleton>
|
<wa-skeleton></wa-skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.skeleton-avatars sl-skeleton {
|
.skeleton-avatars wa-skeleton {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(1) {
|
.skeleton-avatars wa-skeleton:nth-child(1) {
|
||||||
--border-radius: 0;
|
--border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(2) {
|
.skeleton-avatars wa-skeleton:nth-child(2) {
|
||||||
--border-radius: var(--sl-border-radius-medium);
|
--border-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-avatars sl-skeleton {
|
.skeleton-avatars wa-skeleton {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
margin-right: .5rem;
|
margin-right: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(1) {
|
.skeleton-avatars wa-skeleton:nth-child(1) {
|
||||||
--border-radius: 0;
|
--border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(2) {
|
.skeleton-avatars wa-skeleton:nth-child(2) {
|
||||||
--border-radius: var(--sl-border-radius-medium);
|
--border-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="skeleton-avatars">
|
<div className="skeleton-avatars">
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
<SlSkeleton />
|
<WaSkeleton />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -303,26 +303,26 @@ Use the `--border-radius` custom property to make circles, squares, and rectangl
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="skeleton-shapes">
|
<div class="skeleton-shapes">
|
||||||
<sl-skeleton class="square"></sl-skeleton>
|
<wa-skeleton class="square"></wa-skeleton>
|
||||||
<sl-skeleton class="circle"></sl-skeleton>
|
<wa-skeleton class="circle"></wa-skeleton>
|
||||||
<sl-skeleton class="triangle"></sl-skeleton>
|
<wa-skeleton class="triangle"></wa-skeleton>
|
||||||
<sl-skeleton class="cross"></sl-skeleton>
|
<wa-skeleton class="cross"></wa-skeleton>
|
||||||
<sl-skeleton class="comment"></sl-skeleton>
|
<wa-skeleton class="comment"></wa-skeleton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.skeleton-shapes sl-skeleton {
|
.skeleton-shapes wa-skeleton {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .square::part(indicator) {
|
.skeleton-shapes .square::part(indicator) {
|
||||||
--border-radius: var(--sl-border-radius-medium);
|
--border-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .circle::part(indicator) {
|
.skeleton-shapes .circle::part(indicator) {
|
||||||
--border-radius: var(--sl-border-radius-circle);
|
--border-radius: var(--wa-corners-circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .triangle::part(indicator) {
|
.skeleton-shapes .triangle::part(indicator) {
|
||||||
@@ -353,28 +353,28 @@ Use the `--border-radius` custom property to make circles, squares, and rectangl
|
|||||||
clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
|
clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes sl-skeleton:not(:last-child) {
|
.skeleton-shapes wa-skeleton:not(:last-child) {
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-shapes sl-skeleton {
|
.skeleton-shapes wa-skeleton {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .square::part(indicator) {
|
.skeleton-shapes .square::part(indicator) {
|
||||||
--border-radius: var(--sl-border-radius-medium);
|
--border-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .circle::part(indicator) {
|
.skeleton-shapes .circle::part(indicator) {
|
||||||
--border-radius: var(--sl-border-radius-circle);
|
--border-radius: var(--wa-corners-circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes .triangle::part(indicator) {
|
.skeleton-shapes .triangle::part(indicator) {
|
||||||
@@ -392,7 +392,7 @@ const css = `
|
|||||||
clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
|
clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-shapes sl-skeleton:not(:last-child) {
|
.skeleton-shapes wa-skeleton:not(:last-child) {
|
||||||
margin-right: .5rem;
|
margin-right: .5rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -400,11 +400,11 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="skeleton-shapes">
|
<div className="skeleton-shapes">
|
||||||
<SlSkeleton className="square" />
|
<WaSkeleton className="square" />
|
||||||
<SlSkeleton className="circle" />
|
<WaSkeleton className="circle" />
|
||||||
<SlSkeleton className="triangle" />
|
<WaSkeleton className="triangle" />
|
||||||
<SlSkeleton className="cross" />
|
<WaSkeleton className="cross" />
|
||||||
<SlSkeleton className="comment" />
|
<WaSkeleton className="comment" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
@@ -417,32 +417,32 @@ const App = () => (
|
|||||||
Set the `--color` and `--sheen-color` custom properties to adjust the skeleton's color.
|
Set the `--color` and `--sheen-color` custom properties to adjust the skeleton's color.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-skeleton effect="sheen" style="--color: tomato; --sheen-color: #ffb094;"></sl-skeleton>
|
<wa-skeleton effect="sheen" style="--color: tomato; --sheen-color: #ffb094;"></wa-skeleton>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSkeleton from '@shoelace-style/shoelace/dist/react/sl-skeleton';
|
import WaSkeleton from '@shoelace-style/shoelace/dist/react/skeleton';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.skeleton-avatars sl-skeleton {
|
.skeleton-avatars wa-skeleton {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
margin-right: .5rem;
|
margin-right: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(1) {
|
.skeleton-avatars wa-skeleton:nth-child(1) {
|
||||||
--border-radius: 0;
|
--border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton-avatars sl-skeleton:nth-child(2) {
|
.skeleton-avatars wa-skeleton:nth-child(2) {
|
||||||
--border-radius: var(--sl-border-radius-medium);
|
--border-radius: var(--wa-corners-s);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => <SlSkeleton effect="sheen" style={{ '--color': 'tomato', '--sheen-color': '#ffb094' }} />;
|
const App = () => <WaSkeleton effect="sheen" style={{ '--color': 'tomato', '--sheen-color': '#ffb094' }} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-spinner></sl-spinner>
|
<wa-spinner></wa-spinner>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSpinner from '@shoelace-style/shoelace/dist/react/sl-spinner';
|
import WaSpinner from '@shoelace-style/shoelace/dist/react/spinner';
|
||||||
|
|
||||||
const App = () => <SlSpinner />;
|
const App = () => <WaSpinner />;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@@ -22,21 +22,21 @@ const App = () => <SlSpinner />;
|
|||||||
Spinners are sized based on the current font size. To change their size, set the `font-size` property on the spinner itself or on a parent element as shown below.
|
Spinners are sized based on the current font size. To change their size, set the `font-size` property on the spinner itself or on a parent element as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-spinner></sl-spinner>
|
<wa-spinner></wa-spinner>
|
||||||
<sl-spinner style="font-size: 2rem;"></sl-spinner>
|
<wa-spinner style="font-size: 2rem;"></wa-spinner>
|
||||||
<sl-spinner style="font-size: 3rem;"></sl-spinner>
|
<wa-spinner style="font-size: 3rem;"></wa-spinner>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSpinner from '@shoelace-style/shoelace/dist/react/sl-spinner';
|
import WaSpinner from '@shoelace-style/shoelace/dist/react/spinner';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlSpinner />
|
<WaSpinner />
|
||||||
<SlSpinner style={{ fontSize: '2rem' }} />
|
<WaSpinner style={{ fontSize: '2rem' }} />
|
||||||
<SlSpinner style={{ fontSize: '3rem' }} />
|
<WaSpinner style={{ fontSize: '3rem' }} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -48,16 +48,16 @@ const App = () => (
|
|||||||
The width of the spinner's track can be changed by setting the `--track-width` custom property.
|
The width of the spinner's track can be changed by setting the `--track-width` custom property.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-spinner style="font-size: 50px; --track-width: 10px;"></sl-spinner>
|
<wa-spinner style="font-size: 50px; --track-width: 10px;"></wa-spinner>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSpinner from '@shoelace-style/shoelace/dist/react/sl-spinner';
|
import WaSpinner from '@shoelace-style/shoelace/dist/react/spinner';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSpinner
|
<WaSpinner
|
||||||
style={{
|
style={{
|
||||||
fontSize: '3rem',
|
fontSize: '3rem',
|
||||||
'--track-width': '6px'
|
'--track-width': '6px'
|
||||||
@@ -73,16 +73,16 @@ const App = () => (
|
|||||||
The spinner's colors can be changed by setting the `--indicator-color` and `--track-color` custom properties.
|
The spinner's colors can be changed by setting the `--indicator-color` and `--track-color` custom properties.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-spinner style="font-size: 3rem; --indicator-color: deeppink; --track-color: pink;"></sl-spinner>
|
<wa-spinner style="font-size: 3rem; --indicator-color: deeppink; --track-color: pink;"></wa-spinner>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSpinner from '@shoelace-style/shoelace/dist/react/sl-spinner';
|
import WaSpinner from '@shoelace-style/shoelace/dist/react/spinner';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSpinner
|
<WaSpinner
|
||||||
style={{
|
style={{
|
||||||
fontSize: '3rem',
|
fontSize: '3rem',
|
||||||
'--indicator-color': 'deeppink',
|
'--indicator-color': 'deeppink',
|
||||||
|
|||||||
@@ -6,34 +6,34 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel>
|
<wa-split-panel>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel>
|
<WaSplitPanel>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -45,7 +45,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -53,7 +53,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -66,20 +66,34 @@ const App = () => (
|
|||||||
To set the initial position, use the `position` attribute. If no position is provided, it will default to 50% of the available space.
|
To set the initial position, use the `position` attribute. If no position is provided, it will default to 50% of the available space.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel position="75">
|
<wa-split-panel position="75">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Initial Position in Pixels
|
### Initial Position in Pixels
|
||||||
@@ -87,34 +101,34 @@ To set the initial position, use the `position` attribute. If no position is pro
|
|||||||
To set the initial position in pixels instead of a percentage, use the `position-in-pixels` attribute.
|
To set the initial position in pixels instead of a percentage, use the `position-in-pixels` attribute.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel position-in-pixels="150">
|
<wa-split-panel position-in-pixels="150">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel position="200">
|
<WaSplitPanel position="200">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -126,7 +140,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -134,7 +148,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -145,34 +159,34 @@ const App = () => (
|
|||||||
Add the `vertical` attribute to render the split panel in a vertical orientation where the start and end panels are stacked. You also need to set a height when using the vertical orientation.
|
Add the `vertical` attribute to render the split panel in a vertical orientation where the start and end panels are stacked. You also need to set a height when using the vertical orientation.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel vertical style="height: 400px;">
|
<wa-split-panel vertical style="height: 400px;">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 100%; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 100%; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 100%; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 100%; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel vertical style={{ height: '400px' }}>
|
<WaSplitPanel vertical style={{ height: '400px' }}>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -184,7 +198,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -192,7 +206,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -204,20 +218,20 @@ To snap panels at specific positions while dragging, add the `snap` attribute wi
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="split-panel-snapping">
|
<div class="split-panel-snapping">
|
||||||
<sl-split-panel snap="100px 50%">
|
<wa-split-panel snap="100px 50%">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
|
|
||||||
<div class="split-panel-snapping-dots"></div>
|
<div class="split-panel-snapping-dots"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -235,7 +249,7 @@ To snap panels at specific positions while dragging, add the `snap` attribute wi
|
|||||||
width: 6px;
|
width: 6px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--sl-color-neutral-400);
|
background: var(--wa-color-neutral-spot);
|
||||||
transform: translateX(-3px);
|
transform: translateX(-3px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +266,7 @@ To snap panels at specific positions while dragging, add the `snap` attribute wi
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.split-panel-snapping {
|
.split-panel-snapping {
|
||||||
@@ -267,7 +281,7 @@ const css = `
|
|||||||
width: 6px;
|
width: 6px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--sl-color-neutral-400);
|
background: var(--wa-color-neutral-spot);
|
||||||
transform: translateX(-3px);
|
transform: translateX(-3px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,12 +297,12 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="split-panel-snapping">
|
<div className="split-panel-snapping">
|
||||||
<SlSplitPanel snap="100px 50%">
|
<WaSplitPanel snap="100px 50%">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -300,7 +314,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -308,7 +322,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
|
|
||||||
<div className="split-panel-snapping-dots" />
|
<div className="split-panel-snapping-dots" />
|
||||||
</div>
|
</div>
|
||||||
@@ -325,34 +339,34 @@ const App = () => (
|
|||||||
Add the `disabled` attribute to prevent the divider from being repositioned.
|
Add the `disabled` attribute to prevent the divider from being repositioned.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel disabled>
|
<wa-split-panel disabled>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel disabled>
|
<WaSplitPanel disabled>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -364,7 +378,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -372,7 +386,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -386,34 +400,34 @@ Try resizing the example below with each option and notice how the panels respon
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="split-panel-primary">
|
<div class="split-panel-primary">
|
||||||
<sl-split-panel>
|
<wa-split-panel>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
|
|
||||||
<sl-select label="Primary Panel" value="" style="max-width: 200px; margin-top: 1rem;">
|
<wa-select label="Primary Panel" value="" style="max-width: 200px; margin-top: 1rem;">
|
||||||
<sl-option value="">None</sl-option>
|
<wa-option value="">None</wa-option>
|
||||||
<sl-option value="start">Start</sl-option>
|
<wa-option value="start">Start</wa-option>
|
||||||
<sl-option value="end">End</sl-option>
|
<wa-option value="end">End</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const container = document.querySelector('.split-panel-primary');
|
const container = document.querySelector('.split-panel-primary');
|
||||||
const splitPanel = container.querySelector('sl-split-panel');
|
const splitPanel = container.querySelector('wa-split-panel');
|
||||||
const select = container.querySelector('sl-select');
|
const select = container.querySelector('wa-select');
|
||||||
|
|
||||||
select.addEventListener('sl-change', () => (splitPanel.primary = select.value));
|
select.addEventListener('wa-change', () => (splitPanel.primary = select.value));
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -421,21 +435,21 @@ Try resizing the example below with each option and notice how the panels respon
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [primary, setPrimary] = useState('');
|
const [primary, setPrimary] = useState('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlSplitPanel primary={primary}>
|
<WaSplitPanel primary={primary}>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -447,7 +461,7 @@ const App = () => {
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -455,18 +469,18 @@ const App = () => {
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
|
|
||||||
<SlSelect
|
<WaSelect
|
||||||
label="Primary Panel"
|
label="Primary Panel"
|
||||||
value={primary}
|
value={primary}
|
||||||
style={{ maxWidth: '200px', marginTop: '1rem' }}
|
style={{ maxWidth: '200px', marginTop: '1rem' }}
|
||||||
onSlChange={event => setPrimary(event.target.value)}
|
onWaChange={event => setPrimary(event.target.value)}
|
||||||
>
|
>
|
||||||
<SlMenuItem value="">None</SlMenuItem>
|
<WaMenuItem value="">None</WaMenuItem>
|
||||||
<SlMenuItem value="start">Start</SlMenuItem>
|
<WaMenuItem value="start">Start</WaMenuItem>
|
||||||
<SlMenuItem value="end">End</SlMenuItem>
|
<WaMenuItem value="end">End</WaMenuItem>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -481,34 +495,34 @@ To set a minimum or maximum size of the primary panel, use the `--min` and `--ma
|
|||||||
This examples demonstrates how you can ensure both panels are at least 150px using `--min`, `--max`, and the `calc()` function.
|
This examples demonstrates how you can ensure both panels are at least 150px using `--min`, `--max`, and the `calc()` function.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel style="--min: 150px; --max: calc(100% - 150px);">
|
<wa-split-panel style="--min: 150px; --max: calc(100% - 150px);">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="height: 200px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel style={{ '--min': '150px', '--max': 'calc(100% - 150px)' }}>
|
<WaSplitPanel style={{ '--min': '150px', '--max': 'calc(100% - 150px)' }}>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -520,7 +534,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -528,7 +542,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -539,44 +553,44 @@ const App = () => (
|
|||||||
Create complex layouts that can be repositioned independently by nesting split panels.
|
Create complex layouts that can be repositioned independently by nesting split panels.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel>
|
<wa-split-panel>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 400px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
style="height: 400px; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div slot="end">
|
<div slot="end">
|
||||||
<sl-split-panel vertical style="height: 400px;">
|
<wa-split-panel vertical style="height: 400px;">
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 100%; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
style="height: 100%; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
||||||
>
|
>
|
||||||
Top
|
Top
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 100%; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
style="height: 100%; background: var(--wa-color-surface-lowered); display: flex; align-items: center; justify-content: center; overflow: hidden"
|
||||||
>
|
>
|
||||||
Bottom
|
Bottom
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel>
|
<WaSplitPanel>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '400px',
|
height: '400px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -585,12 +599,12 @@ const App = () => (
|
|||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div slot="end">
|
<div slot="end">
|
||||||
<SlSplitPanel vertical style={{ height: '400px' }}>
|
<WaSplitPanel vertical style={{ height: '400px' }}>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -602,7 +616,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -610,9 +624,9 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -623,37 +637,51 @@ const App = () => (
|
|||||||
You can target the `divider` part to apply CSS properties to the divider. To add a custom handle, slot an icon into the `divider` slot. When customizing the divider, make sure to think about focus styles for keyboard users.
|
You can target the `divider` part to apply CSS properties to the divider. To add a custom handle, slot an icon into the `divider` slot. When customizing the divider, make sure to think about focus styles for keyboard users.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-split-panel style="--divider-width: 20px;">
|
<wa-split-panel style="--divider-width: 20px;">
|
||||||
<sl-icon slot="divider" name="grip-vertical"></sl-icon>
|
<wa-icon slot="divider" name="grip-vertical" variant="solid"></wa-icon>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSplitPanel style={{ '--divider-width': '20px' }}>
|
<WaSplitPanel style={{ '--divider-width': '20px' }}>
|
||||||
<SlIcon slot="divider" name="grip-vertical" />
|
<WaIcon slot="divider" name="grip-vertical" variant="solid" />
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -665,7 +693,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -673,7 +701,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -683,47 +711,61 @@ Here's a more elaborate example that changes the divider's color and width and a
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="split-panel-divider">
|
<div class="split-panel-divider">
|
||||||
<sl-split-panel>
|
<wa-split-panel>
|
||||||
<sl-icon slot="divider" name="grip-vertical"></sl-icon>
|
<wa-icon slot="divider" name="grip-vertical" variant="solid"></wa-icon>
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
slot="end"
|
slot="end"
|
||||||
style="height: 200px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
|
style="
|
||||||
|
height: 200px;
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</sl-split-panel>
|
</wa-split-panel>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.split-panel-divider sl-split-panel {
|
.split-panel-divider wa-split-panel {
|
||||||
--divider-width: 2px;
|
--divider-width: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel::part(divider) {
|
.split-panel-divider wa-split-panel::part(divider) {
|
||||||
background-color: var(--sl-color-pink-600);
|
background-color: var(--wa-color-red-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-icon {
|
.split-panel-divider wa-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border-radius: var(--sl-border-radius-small);
|
border-radius: var(--wa-corners-l);
|
||||||
background: var(--sl-color-pink-600);
|
background: var(--wa-color-red-50);
|
||||||
color: var(--sl-color-neutral-0);
|
color: white;
|
||||||
padding: 0.5rem 0.125rem;
|
padding: 0.5rem 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel::part(divider):focus-visible {
|
.split-panel-divider wa-split-panel::part(divider):focus-visible {
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-blue-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel:focus-within sl-icon {
|
.split-panel-divider wa-split-panel:focus-within wa-icon {
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-blue-50);
|
||||||
color: var(--sl-color-neutral-0);
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
@@ -731,46 +773,46 @@ Here's a more elaborate example that changes the divider's color and width and a
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSplitPanel from '@shoelace-style/shoelace/dist/react/sl-split-panel';
|
import WaSplitPanel from '@shoelace-style/shoelace/dist/react/split-panel';
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.split-panel-divider sl-split-panel {
|
.split-panel-divider wa-split-panel {
|
||||||
--divider-width: 2px;
|
--divider-width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.split-panel-divider wa-split-panel::part(divider) {
|
||||||
|
background-color: var(--wa-color-red-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel::part(divider) {
|
.split-panel-divider wa-icon {
|
||||||
background-color: var(--sl-color-pink-600);
|
|
||||||
}
|
|
||||||
|
|
||||||
.split-panel-divider sl-icon {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border-radius: var(--sl-border-radius-small);
|
border-radius: var(--wa-corners-xs);
|
||||||
background: var(--sl-color-pink-600);
|
background: var(--wa-color-red-50);
|
||||||
color: var(--sl-color-neutral-0);
|
color: white;
|
||||||
padding: .5rem .125rem;
|
padding: .5rem .25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel::part(divider):focus-visible {
|
.split-panel-divider wa-split-panel::part(divider):focus-visible {
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-blue-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.split-panel-divider sl-split-panel:focus-within sl-icon {
|
.split-panel-divider wa-split-panel:focus-within wa-icon {
|
||||||
background-color: var(--sl-color-primary-600);
|
background-color: var(--wa-color-blue-50);
|
||||||
color: var(--sl-color-neutral-0);
|
color: white;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div className="split-panel-divider">
|
<div className="split-panel-divider">
|
||||||
<SlSplitPanel>
|
<WaSplitPanel>
|
||||||
<SlIcon slot="divider" name="grip-vertical" />
|
<WaIcon slot="divider" name="grip-vertical" variant="solid" />
|
||||||
<div
|
<div
|
||||||
slot="start"
|
slot="start"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -782,7 +824,7 @@ const App = () => (
|
|||||||
slot="end"
|
slot="end"
|
||||||
style={{
|
style={{
|
||||||
height: '200px',
|
height: '200px',
|
||||||
background: 'var(--sl-color-neutral-50)',
|
background: 'var(--wa-color-surface-lowered)',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
@@ -790,7 +832,7 @@ const App = () => (
|
|||||||
>
|
>
|
||||||
End
|
End
|
||||||
</div>
|
</div>
|
||||||
</SlSplitPanel>
|
</WaSplitPanel>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-switch>Switch</sl-switch>
|
<wa-switch>Switch</wa-switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSwitch from '@shoelace-style/shoelace/dist/react/sl-switch';
|
import WaSwitch from '@shoelace-style/shoelace/dist/react/switch';
|
||||||
|
|
||||||
const App = () => <SlSwitch>Switch</SlSwitch>;
|
const App = () => <WaSwitch>Switch</WaSwitch>;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,13 +26,13 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `checked` attribute to activate the switch.
|
Use the `checked` attribute to activate the switch.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-switch checked>Checked</sl-switch>
|
<wa-switch checked>Checked</wa-switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSwitch from '@shoelace-style/shoelace/dist/react/sl-switch';
|
import WaSwitch from '@shoelace-style/shoelace/dist/react/switch';
|
||||||
|
|
||||||
const App = () => <SlSwitch checked>Checked</SlSwitch>;
|
const App = () => <WaSwitch checked>Checked</WaSwitch>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -40,13 +40,13 @@ const App = () => <SlSwitch checked>Checked</SlSwitch>;
|
|||||||
Use the `disabled` attribute to disable the switch.
|
Use the `disabled` attribute to disable the switch.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-switch disabled>Disabled</sl-switch>
|
<wa-switch disabled>Disabled</wa-switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSwitch from '@shoelace-style/shoelace/dist/react/sl-switch';
|
import WaSwitch from '@shoelace-style/shoelace/dist/react/switch';
|
||||||
|
|
||||||
const App = () => <SlSwitch disabled>Disabled</SlSwitch>;
|
const App = () => <WaSwitch disabled>Disabled</WaSwitch>;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sizes
|
### Sizes
|
||||||
@@ -54,23 +54,23 @@ const App = () => <SlSwitch disabled>Disabled</SlSwitch>;
|
|||||||
Use the `size` attribute to change a switch's size.
|
Use the `size` attribute to change a switch's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-switch size="small">Small</sl-switch>
|
<wa-switch size="small">Small</wa-switch>
|
||||||
<br />
|
<br />
|
||||||
<sl-switch size="medium">Medium</sl-switch>
|
<wa-switch size="medium">Medium</wa-switch>
|
||||||
<br />
|
<br />
|
||||||
<sl-switch size="large">Large</sl-switch>
|
<wa-switch size="large">Large</wa-switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSwitch from '@shoelace-style/shoelace/dist/react/sl-switch';
|
import WaSwitch from '@shoelace-style/shoelace/dist/react/switch';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlSwitch size="small">Small</SlSwitch>
|
<WaSwitch size="small">Small</WaSwitch>
|
||||||
<br />
|
<br />
|
||||||
<SlSwitch size="medium">Medium</SlSwitch>
|
<WaSwitch size="medium">Medium</WaSwitch>
|
||||||
<br />
|
<br />
|
||||||
<SlSwitch size="large">Large</SlSwitch>
|
<WaSwitch size="large">Large</WaSwitch>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -80,16 +80,16 @@ const App = () => (
|
|||||||
Use the available custom properties to change how the switch is styled.
|
Use the available custom properties to change how the switch is styled.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-switch style="--width: 80px; --height: 40px; --thumb-size: 36px;">Really big</sl-switch>
|
<wa-switch style="--width: 80px; --height: 40px; --thumb-size: 36px;">Really big</wa-switch>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlSwitch from '@shoelace-style/shoelace/dist/react/sl-switch';
|
import WaSwitch from '@shoelace-style/shoelace/dist/react/switch';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlSwitch
|
<WaSwitch
|
||||||
style={{
|
style={{
|
||||||
'--width': '80px',
|
'--width': '80px',
|
||||||
'--height': '32px',
|
'--height': '32px',
|
||||||
|
|||||||
@@ -8,44 +8,44 @@ layout: component
|
|||||||
Tab groups make use of [tabs](/components/tab) and [tab panels](/components/tab-panel). Each tab must be slotted into the `nav` slot and its `panel` must refer to a tab panel of the same name.
|
Tab groups make use of [tabs](/components/tab) and [tab panels](/components/tab-panel). Each tab must be slotted into the `nav` slot and its `panel` must refer to a tab panel of the same name.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group>
|
<wa-tab-group>
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup>
|
<WaTabGroup>
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -56,44 +56,44 @@ const App = () => (
|
|||||||
Tabs can be shown on the bottom by setting `placement` to `bottom`.
|
Tabs can be shown on the bottom by setting `placement` to `bottom`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group placement="bottom">
|
<wa-tab-group placement="bottom">
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup placement="bottom">
|
<WaTabGroup placement="bottom">
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -102,44 +102,44 @@ const App = () => (
|
|||||||
Tabs can be shown on the starting side by setting `placement` to `start`.
|
Tabs can be shown on the starting side by setting `placement` to `start`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group placement="start">
|
<wa-tab-group placement="start">
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup placement="start">
|
<WaTabGroup placement="start">
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -148,44 +148,44 @@ const App = () => (
|
|||||||
Tabs can be shown on the ending side by setting `placement` to `end`.
|
Tabs can be shown on the ending side by setting `placement` to `end`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group placement="end">
|
<wa-tab-group placement="end">
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup placement="end">
|
<WaTabGroup placement="end">
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -194,24 +194,24 @@ const App = () => (
|
|||||||
Add the `closable` attribute to a tab to show a close button. This example shows how you can dynamically remove tabs from the DOM when the close button is activated.
|
Add the `closable` attribute to a tab to show a close button. This example shows how you can dynamically remove tabs from the DOM when the close button is activated.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group class="tabs-closable">
|
<wa-tab-group class="tabs-closable">
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="closable-1" closable>Closable 1</sl-tab>
|
<wa-tab slot="nav" panel="closable-1" closable>Closable 1</wa-tab>
|
||||||
<sl-tab slot="nav" panel="closable-2" closable>Closable 2</sl-tab>
|
<wa-tab slot="nav" panel="closable-2" closable>Closable 2</wa-tab>
|
||||||
<sl-tab slot="nav" panel="closable-3" closable>Closable 3</sl-tab>
|
<wa-tab slot="nav" panel="closable-3" closable>Closable 3</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="closable-1">This is the first closable tab panel.</sl-tab-panel>
|
<wa-tab-panel name="closable-1">This is the first closable tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="closable-2">This is the second closable tab panel.</sl-tab-panel>
|
<wa-tab-panel name="closable-2">This is the second closable tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="closable-3">This is the third closable tab panel.</sl-tab-panel>
|
<wa-tab-panel name="closable-3">This is the third closable tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const tabGroup = document.querySelector('.tabs-closable');
|
const tabGroup = document.querySelector('.tabs-closable');
|
||||||
|
|
||||||
tabGroup.addEventListener('sl-close', async event => {
|
tabGroup.addEventListener('wa-close', async event => {
|
||||||
const tab = event.target;
|
const tab = event.target;
|
||||||
const panel = tabGroup.querySelector(`sl-tab-panel[name="${tab.panel}"]`);
|
const panel = tabGroup.querySelector(`wa-tab-panel[name="${tab.panel}"]`);
|
||||||
|
|
||||||
// Show the previous tab if the tab is currently active
|
// Show the previous tab if the tab is currently active
|
||||||
if (tab.active) {
|
if (tab.active) {
|
||||||
@@ -226,9 +226,9 @@ Add the `closable` attribute to a tab to show a close button. This example shows
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleClose(event) {
|
function handleClose(event) {
|
||||||
@@ -238,7 +238,7 @@ const App = () => {
|
|||||||
// would significantly complicate the example.
|
// would significantly complicate the example.
|
||||||
//
|
//
|
||||||
const tab = event.target;
|
const tab = event.target;
|
||||||
const tabGroup = tab.closest('sl-tab-group');
|
const tabGroup = tab.closest('wa-tab-group');
|
||||||
const tabPanel = tabGroup.querySelector(`[aria-labelledby="${tab.id}"]`);
|
const tabPanel = tabGroup.querySelector(`[aria-labelledby="${tab.id}"]`);
|
||||||
|
|
||||||
tab.remove();
|
tab.remove();
|
||||||
@@ -246,25 +246,25 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlTabGroup className="tabs-closable" onSlClose={handleClose}>
|
<WaTabGroup className="tabs-closable" onWaClose={handleClose}>
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="closable-1" closable onSlClose={handleClose}>
|
<WaTab slot="nav" panel="closable-1" closable onWaClose={handleClose}>
|
||||||
Closable 1
|
Closable 1
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="closable-2" closable onSlClose={handleClose}>
|
<WaTab slot="nav" panel="closable-2" closable onWaClose={handleClose}>
|
||||||
Closable 2
|
Closable 2
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="closable-3" closable onSlClose={handleClose}>
|
<WaTab slot="nav" panel="closable-3" closable onWaClose={handleClose}>
|
||||||
Closable 3
|
Closable 3
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="closable-1">This is the first closable tab panel.</SlTabPanel>
|
<WaTabPanel name="closable-1">This is the first closable tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="closable-2">This is the second closable tab panel.</SlTabPanel>
|
<WaTabPanel name="closable-2">This is the second closable tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="closable-3">This is the third closable tab panel.</SlTabPanel>
|
<WaTabPanel name="closable-3">This is the third closable tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -274,140 +274,140 @@ const App = () => {
|
|||||||
When there are more tabs than horizontal space allows, the nav will be scrollable.
|
When there are more tabs than horizontal space allows, the nav will be scrollable.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group>
|
<wa-tab-group>
|
||||||
<sl-tab slot="nav" panel="tab-1">Tab 1</sl-tab>
|
<wa-tab slot="nav" panel="tab-1">Tab 1</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-2">Tab 2</sl-tab>
|
<wa-tab slot="nav" panel="tab-2">Tab 2</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-3">Tab 3</sl-tab>
|
<wa-tab slot="nav" panel="tab-3">Tab 3</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-4">Tab 4</sl-tab>
|
<wa-tab slot="nav" panel="tab-4">Tab 4</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-5">Tab 5</sl-tab>
|
<wa-tab slot="nav" panel="tab-5">Tab 5</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-6">Tab 6</sl-tab>
|
<wa-tab slot="nav" panel="tab-6">Tab 6</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-7">Tab 7</sl-tab>
|
<wa-tab slot="nav" panel="tab-7">Tab 7</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-8">Tab 8</sl-tab>
|
<wa-tab slot="nav" panel="tab-8">Tab 8</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-9">Tab 9</sl-tab>
|
<wa-tab slot="nav" panel="tab-9">Tab 9</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-10">Tab 10</sl-tab>
|
<wa-tab slot="nav" panel="tab-10">Tab 10</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-11">Tab 11</sl-tab>
|
<wa-tab slot="nav" panel="tab-11">Tab 11</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-12">Tab 12</sl-tab>
|
<wa-tab slot="nav" panel="tab-12">Tab 12</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-13">Tab 13</sl-tab>
|
<wa-tab slot="nav" panel="tab-13">Tab 13</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-14">Tab 14</sl-tab>
|
<wa-tab slot="nav" panel="tab-14">Tab 14</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-15">Tab 15</sl-tab>
|
<wa-tab slot="nav" panel="tab-15">Tab 15</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-16">Tab 16</sl-tab>
|
<wa-tab slot="nav" panel="tab-16">Tab 16</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-17">Tab 17</sl-tab>
|
<wa-tab slot="nav" panel="tab-17">Tab 17</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-18">Tab 18</sl-tab>
|
<wa-tab slot="nav" panel="tab-18">Tab 18</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-19">Tab 19</sl-tab>
|
<wa-tab slot="nav" panel="tab-19">Tab 19</wa-tab>
|
||||||
<sl-tab slot="nav" panel="tab-20">Tab 20</sl-tab>
|
<wa-tab slot="nav" panel="tab-20">Tab 20</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="tab-1">Tab panel 1</sl-tab-panel>
|
<wa-tab-panel name="tab-1">Tab panel 1</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-2">Tab panel 2</sl-tab-panel>
|
<wa-tab-panel name="tab-2">Tab panel 2</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-3">Tab panel 3</sl-tab-panel>
|
<wa-tab-panel name="tab-3">Tab panel 3</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-4">Tab panel 4</sl-tab-panel>
|
<wa-tab-panel name="tab-4">Tab panel 4</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-5">Tab panel 5</sl-tab-panel>
|
<wa-tab-panel name="tab-5">Tab panel 5</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-6">Tab panel 6</sl-tab-panel>
|
<wa-tab-panel name="tab-6">Tab panel 6</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-7">Tab panel 7</sl-tab-panel>
|
<wa-tab-panel name="tab-7">Tab panel 7</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-8">Tab panel 8</sl-tab-panel>
|
<wa-tab-panel name="tab-8">Tab panel 8</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-9">Tab panel 9</sl-tab-panel>
|
<wa-tab-panel name="tab-9">Tab panel 9</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-10">Tab panel 10</sl-tab-panel>
|
<wa-tab-panel name="tab-10">Tab panel 10</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-11">Tab panel 11</sl-tab-panel>
|
<wa-tab-panel name="tab-11">Tab panel 11</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-12">Tab panel 12</sl-tab-panel>
|
<wa-tab-panel name="tab-12">Tab panel 12</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-13">Tab panel 13</sl-tab-panel>
|
<wa-tab-panel name="tab-13">Tab panel 13</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-14">Tab panel 14</sl-tab-panel>
|
<wa-tab-panel name="tab-14">Tab panel 14</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-15">Tab panel 15</sl-tab-panel>
|
<wa-tab-panel name="tab-15">Tab panel 15</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-16">Tab panel 16</sl-tab-panel>
|
<wa-tab-panel name="tab-16">Tab panel 16</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-17">Tab panel 17</sl-tab-panel>
|
<wa-tab-panel name="tab-17">Tab panel 17</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-18">Tab panel 18</sl-tab-panel>
|
<wa-tab-panel name="tab-18">Tab panel 18</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-19">Tab panel 19</sl-tab-panel>
|
<wa-tab-panel name="tab-19">Tab panel 19</wa-tab-panel>
|
||||||
<sl-tab-panel name="tab-20">Tab panel 20</sl-tab-panel>
|
<wa-tab-panel name="tab-20">Tab panel 20</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup>
|
<WaTabGroup>
|
||||||
<SlTab slot="nav" panel="tab-1">
|
<WaTab slot="nav" panel="tab-1">
|
||||||
Tab 1
|
Tab 1
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-2">
|
<WaTab slot="nav" panel="tab-2">
|
||||||
Tab 2
|
Tab 2
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-3">
|
<WaTab slot="nav" panel="tab-3">
|
||||||
Tab 3
|
Tab 3
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-4">
|
<WaTab slot="nav" panel="tab-4">
|
||||||
Tab 4
|
Tab 4
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-5">
|
<WaTab slot="nav" panel="tab-5">
|
||||||
Tab 5
|
Tab 5
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-6">
|
<WaTab slot="nav" panel="tab-6">
|
||||||
Tab 6
|
Tab 6
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-7">
|
<WaTab slot="nav" panel="tab-7">
|
||||||
Tab 7
|
Tab 7
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-8">
|
<WaTab slot="nav" panel="tab-8">
|
||||||
Tab 8
|
Tab 8
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-9">
|
<WaTab slot="nav" panel="tab-9">
|
||||||
Tab 9
|
Tab 9
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-10">
|
<WaTab slot="nav" panel="tab-10">
|
||||||
Tab 10
|
Tab 10
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-11">
|
<WaTab slot="nav" panel="tab-11">
|
||||||
Tab 11
|
Tab 11
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-12">
|
<WaTab slot="nav" panel="tab-12">
|
||||||
Tab 12
|
Tab 12
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-13">
|
<WaTab slot="nav" panel="tab-13">
|
||||||
Tab 13
|
Tab 13
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-14">
|
<WaTab slot="nav" panel="tab-14">
|
||||||
Tab 14
|
Tab 14
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-15">
|
<WaTab slot="nav" panel="tab-15">
|
||||||
Tab 15
|
Tab 15
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-16">
|
<WaTab slot="nav" panel="tab-16">
|
||||||
Tab 16
|
Tab 16
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-17">
|
<WaTab slot="nav" panel="tab-17">
|
||||||
Tab 17
|
Tab 17
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-18">
|
<WaTab slot="nav" panel="tab-18">
|
||||||
Tab 18
|
Tab 18
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-19">
|
<WaTab slot="nav" panel="tab-19">
|
||||||
Tab 19
|
Tab 19
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="tab-20">
|
<WaTab slot="nav" panel="tab-20">
|
||||||
Tab 20
|
Tab 20
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="tab-1">Tab panel 1</SlTabPanel>
|
<WaTabPanel name="tab-1">Tab panel 1</WaTabPanel>
|
||||||
<SlTabPanel name="tab-2">Tab panel 2</SlTabPanel>
|
<WaTabPanel name="tab-2">Tab panel 2</WaTabPanel>
|
||||||
<SlTabPanel name="tab-3">Tab panel 3</SlTabPanel>
|
<WaTabPanel name="tab-3">Tab panel 3</WaTabPanel>
|
||||||
<SlTabPanel name="tab-4">Tab panel 4</SlTabPanel>
|
<WaTabPanel name="tab-4">Tab panel 4</WaTabPanel>
|
||||||
<SlTabPanel name="tab-5">Tab panel 5</SlTabPanel>
|
<WaTabPanel name="tab-5">Tab panel 5</WaTabPanel>
|
||||||
<SlTabPanel name="tab-6">Tab panel 6</SlTabPanel>
|
<WaTabPanel name="tab-6">Tab panel 6</WaTabPanel>
|
||||||
<SlTabPanel name="tab-7">Tab panel 7</SlTabPanel>
|
<WaTabPanel name="tab-7">Tab panel 7</WaTabPanel>
|
||||||
<SlTabPanel name="tab-8">Tab panel 8</SlTabPanel>
|
<WaTabPanel name="tab-8">Tab panel 8</WaTabPanel>
|
||||||
<SlTabPanel name="tab-9">Tab panel 9</SlTabPanel>
|
<WaTabPanel name="tab-9">Tab panel 9</WaTabPanel>
|
||||||
<SlTabPanel name="tab-10">Tab panel 10</SlTabPanel>
|
<WaTabPanel name="tab-10">Tab panel 10</WaTabPanel>
|
||||||
<SlTabPanel name="tab-11">Tab panel 11</SlTabPanel>
|
<WaTabPanel name="tab-11">Tab panel 11</WaTabPanel>
|
||||||
<SlTabPanel name="tab-12">Tab panel 12</SlTabPanel>
|
<WaTabPanel name="tab-12">Tab panel 12</WaTabPanel>
|
||||||
<SlTabPanel name="tab-13">Tab panel 13</SlTabPanel>
|
<WaTabPanel name="tab-13">Tab panel 13</WaTabPanel>
|
||||||
<SlTabPanel name="tab-14">Tab panel 14</SlTabPanel>
|
<WaTabPanel name="tab-14">Tab panel 14</WaTabPanel>
|
||||||
<SlTabPanel name="tab-15">Tab panel 15</SlTabPanel>
|
<WaTabPanel name="tab-15">Tab panel 15</WaTabPanel>
|
||||||
<SlTabPanel name="tab-16">Tab panel 16</SlTabPanel>
|
<WaTabPanel name="tab-16">Tab panel 16</WaTabPanel>
|
||||||
<SlTabPanel name="tab-17">Tab panel 17</SlTabPanel>
|
<WaTabPanel name="tab-17">Tab panel 17</WaTabPanel>
|
||||||
<SlTabPanel name="tab-18">Tab panel 18</SlTabPanel>
|
<WaTabPanel name="tab-18">Tab panel 18</WaTabPanel>
|
||||||
<SlTabPanel name="tab-19">Tab panel 19</SlTabPanel>
|
<WaTabPanel name="tab-19">Tab panel 19</WaTabPanel>
|
||||||
<SlTabPanel name="tab-20">Tab panel 20</SlTabPanel>
|
<WaTabPanel name="tab-20">Tab panel 20</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -416,43 +416,43 @@ const App = () => (
|
|||||||
When focused, keyboard users can press [[Left]] or [[Right]] to select the desired tab. By default, the corresponding tab panel will be shown immediately (automatic activation). You can change this behavior by setting `activation="manual"` which will require the user to press [[Space]] or [[Enter]] before showing the tab panel (manual activation).
|
When focused, keyboard users can press [[Left]] or [[Right]] to select the desired tab. By default, the corresponding tab panel will be shown immediately (automatic activation). You can change this behavior by setting `activation="manual"` which will require the user to press [[Space]] or [[Enter]] before showing the tab panel (manual activation).
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group activation="manual">
|
<wa-tab-group activation="manual">
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup activation="manual">
|
<WaTabGroup activation="manual">
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,44 +6,44 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab-group>
|
<wa-tab-group>
|
||||||
<sl-tab slot="nav" panel="general">General</sl-tab>
|
<wa-tab slot="nav" panel="general">General</wa-tab>
|
||||||
<sl-tab slot="nav" panel="custom">Custom</sl-tab>
|
<wa-tab slot="nav" panel="custom">Custom</wa-tab>
|
||||||
<sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
|
<wa-tab slot="nav" panel="advanced">Advanced</wa-tab>
|
||||||
<sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
|
<wa-tab slot="nav" panel="disabled" disabled>Disabled</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
|
<wa-tab-panel name="general">This is the general tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
|
<wa-tab-panel name="custom">This is the custom tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
|
<wa-tab-panel name="advanced">This is the advanced tab panel.</wa-tab-panel>
|
||||||
<sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
|
<wa-tab-panel name="disabled">This is a disabled tab panel.</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
import SlTabGroup from '@shoelace-style/shoelace/dist/react/sl-tab-group';
|
import WaTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
|
||||||
import SlTabPanel from '@shoelace-style/shoelace/dist/react/sl-tab-panel';
|
import WaTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTabGroup>
|
<WaTabGroup>
|
||||||
<SlTab slot="nav" panel="general">
|
<WaTab slot="nav" panel="general">
|
||||||
General
|
General
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="custom">
|
<WaTab slot="nav" panel="custom">
|
||||||
Custom
|
Custom
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="advanced">
|
<WaTab slot="nav" panel="advanced">
|
||||||
Advanced
|
Advanced
|
||||||
</SlTab>
|
</WaTab>
|
||||||
<SlTab slot="nav" panel="disabled" disabled>
|
<WaTab slot="nav" panel="disabled" disabled>
|
||||||
Disabled
|
Disabled
|
||||||
</SlTab>
|
</WaTab>
|
||||||
|
|
||||||
<SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
|
<WaTabPanel name="general">This is the general tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
|
<WaTabPanel name="custom">This is the custom tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
|
<WaTabPanel name="advanced">This is the advanced tab panel.</WaTabPanel>
|
||||||
<SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
|
<WaTabPanel name="disabled">This is a disabled tab panel.</WaTabPanel>
|
||||||
</SlTabGroup>
|
</WaTabGroup>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -6,21 +6,21 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tab>Tab</sl-tab>
|
<wa-tab>Tab</wa-tab>
|
||||||
<sl-tab active>Active</sl-tab>
|
<wa-tab active>Active</wa-tab>
|
||||||
<sl-tab closable>Closable</sl-tab>
|
<wa-tab closable>Closable</wa-tab>
|
||||||
<sl-tab disabled>Disabled</sl-tab>
|
<wa-tab disabled>Disabled</wa-tab>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTab from '@shoelace-style/shoelace/dist/react/sl-tab';
|
import WaTab from '@shoelace-style/shoelace/dist/react/tab';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlTab>Tab</SlTab>
|
<WaTab>Tab</WaTab>
|
||||||
<SlTab active>Active</SlTab>
|
<WaTab active>Active</WaTab>
|
||||||
<SlTab closable>Closable</SlTab>
|
<WaTab closable>Closable</WaTab>
|
||||||
<SlTab disabled>Disabled</SlTab>
|
<WaTab disabled>Disabled</WaTab>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tag variant="primary">Primary</sl-tag>
|
<wa-tag variant="brand">Brand</wa-tag>
|
||||||
<sl-tag variant="success">Success</sl-tag>
|
<wa-tag variant="success">Success</wa-tag>
|
||||||
<sl-tag variant="neutral">Neutral</sl-tag>
|
<wa-tag variant="neutral">Neutral</wa-tag>
|
||||||
<sl-tag variant="warning">Warning</sl-tag>
|
<wa-tag variant="warning">Warning</wa-tag>
|
||||||
<sl-tag variant="danger">Danger</sl-tag>
|
<wa-tag variant="danger">Danger</wa-tag>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTag from '@shoelace-style/shoelace/dist/react/sl-tag';
|
import WaTag from '@shoelace-style/shoelace/dist/react/tag';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlTag variant="primary">Primary</SlTag>
|
<WaTag variant="brand">Brand</WaTag>
|
||||||
<SlTag variant="success">Success</SlTag>
|
<WaTag variant="success">Success</WaTag>
|
||||||
<SlTag variant="neutral">Neutral</SlTag>
|
<WaTag variant="neutral">Neutral</WaTag>
|
||||||
<SlTag variant="warning">Warning</SlTag>
|
<WaTag variant="warning">Warning</WaTag>
|
||||||
<SlTag variant="danger">Danger</SlTag>
|
<WaTag variant="danger">Danger</WaTag>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -34,19 +34,19 @@ const App = () => (
|
|||||||
Use the `size` attribute to change a tab's size.
|
Use the `size` attribute to change a tab's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tag size="small">Small</sl-tag>
|
<wa-tag size="small">Small</wa-tag>
|
||||||
<sl-tag size="medium">Medium</sl-tag>
|
<wa-tag size="medium">Medium</wa-tag>
|
||||||
<sl-tag size="large">Large</sl-tag>
|
<wa-tag size="large">Large</wa-tag>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTag from '@shoelace-style/shoelace/dist/react/sl-tag';
|
import WaTag from '@shoelace-style/shoelace/dist/react/tag';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlTag size="small">Small</SlTag>
|
<WaTag size="small">Small</WaTag>
|
||||||
<SlTag size="medium">Medium</SlTag>
|
<WaTag size="medium">Medium</WaTag>
|
||||||
<SlTag size="large">Large</SlTag>
|
<WaTag size="large">Large</WaTag>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -56,25 +56,25 @@ const App = () => (
|
|||||||
Use the `pill` attribute to give tabs rounded edges.
|
Use the `pill` attribute to give tabs rounded edges.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tag size="small" pill>Small</sl-tag>
|
<wa-tag size="small" pill>Small</wa-tag>
|
||||||
<sl-tag size="medium" pill>Medium</sl-tag>
|
<wa-tag size="medium" pill>Medium</wa-tag>
|
||||||
<sl-tag size="large" pill>Large</sl-tag>
|
<wa-tag size="large" pill>Large</wa-tag>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTag from '@shoelace-style/shoelace/dist/react/sl-tag';
|
import WaTag from '@shoelace-style/shoelace/dist/react/tag';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlTag size="small" pill>
|
<WaTag size="small" pill>
|
||||||
Small
|
Small
|
||||||
</SlTag>
|
</WaTag>
|
||||||
<SlTag size="medium" pill>
|
<WaTag size="medium" pill>
|
||||||
Medium
|
Medium
|
||||||
</SlTag>
|
</WaTag>
|
||||||
<SlTag size="large" pill>
|
<WaTag size="large" pill>
|
||||||
Large
|
Large
|
||||||
</SlTag>
|
</WaTag>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -85,15 +85,15 @@ Use the `removable` attribute to add a remove button to the tag.
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="tags-removable">
|
<div class="tags-removable">
|
||||||
<sl-tag size="small" removable>Small</sl-tag>
|
<wa-tag size="small" removable>Small</wa-tag>
|
||||||
<sl-tag size="medium" removable>Medium</sl-tag>
|
<wa-tag size="medium" removable>Medium</wa-tag>
|
||||||
<sl-tag size="large" removable>Large</sl-tag>
|
<wa-tag size="large" removable>Large</wa-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const div = document.querySelector('.tags-removable');
|
const div = document.querySelector('.tags-removable');
|
||||||
|
|
||||||
div.addEventListener('sl-remove', event => {
|
div.addEventListener('wa-remove', event => {
|
||||||
const tag = event.target;
|
const tag = event.target;
|
||||||
tag.style.opacity = '0';
|
tag.style.opacity = '0';
|
||||||
setTimeout(() => (tag.style.opacity = '1'), 2000);
|
setTimeout(() => (tag.style.opacity = '1'), 2000);
|
||||||
@@ -101,18 +101,18 @@ Use the `removable` attribute to add a remove button to the tag.
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tags-removable sl-tag {
|
.tags-removable wa-tag {
|
||||||
transition: var(--sl-transition-medium) opacity;
|
transition: var(--wa-transition-fast) opacity;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTag from '@shoelace-style/shoelace/dist/react/sl-tag';
|
import WaTag from '@shoelace-style/shoelace/dist/react/tag';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.tags-removable sl-tag {
|
.tags-removable wa-tag {
|
||||||
transition: var(--sl-transition-medium) opacity;
|
transition: var(--wa-transition-fast) opacity;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -126,17 +126,17 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="tags-removable">
|
<div className="tags-removable">
|
||||||
<SlTag size="small" removable onSlRemove={handleRemove}>
|
<WaTag size="small" removable onWaRemove={handleRemove}>
|
||||||
Small
|
Small
|
||||||
</SlTag>
|
</WaTag>
|
||||||
|
|
||||||
<SlTag size="medium" removable onSlRemove={handleRemove}>
|
<WaTag size="medium" removable onWaRemove={handleRemove}>
|
||||||
Medium
|
Medium
|
||||||
</SlTag>
|
</WaTag>
|
||||||
|
|
||||||
<SlTag size="large" removable onSlRemove={handleRemove}>
|
<WaTag size="large" removable onWaRemove={handleRemove}>
|
||||||
Large
|
Large
|
||||||
</SlTag>
|
</WaTag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea></sl-textarea>
|
<wa-textarea></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea />;
|
const App = () => <WaTextarea />;
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -26,13 +26,13 @@ This component works with standard `<form>` elements. Please refer to the sectio
|
|||||||
Use the `label` attribute to give the textarea an accessible label. For labels that contain HTML, use the `label` slot instead.
|
Use the `label` attribute to give the textarea an accessible label. For labels that contain HTML, use the `label` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea label="Comments"></sl-textarea>
|
<wa-textarea label="Comments"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea label="Comments" />;
|
const App = () => <WaTextarea label="Comments" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Help Text
|
### Help Text
|
||||||
@@ -40,13 +40,13 @@ const App = () => <SlTextarea label="Comments" />;
|
|||||||
Add descriptive help text to a textarea with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
Add descriptive help text to a textarea with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea label="Feedback" help-text="Please tell us what you think."> </sl-textarea>
|
<wa-textarea label="Feedback" help-text="Please tell us what you think."> </wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea label="Feedback" help-text="Please tell us what you think." />;
|
const App = () => <WaTextarea label="Feedback" help-text="Please tell us what you think." />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rows
|
### Rows
|
||||||
@@ -54,13 +54,13 @@ const App = () => <SlTextarea label="Feedback" help-text="Please tell us what yo
|
|||||||
Use the `rows` attribute to change the number of text rows that get shown.
|
Use the `rows` attribute to change the number of text rows that get shown.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea rows="2"></sl-textarea>
|
<wa-textarea rows="2"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea rows={2} />;
|
const App = () => <WaTextarea rows={2} />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Placeholders
|
### Placeholders
|
||||||
@@ -68,13 +68,13 @@ const App = () => <SlTextarea rows={2} />;
|
|||||||
Use the `placeholder` attribute to add a placeholder.
|
Use the `placeholder` attribute to add a placeholder.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea placeholder="Type something"></sl-textarea>
|
<wa-textarea placeholder="Type something"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea placeholder="Type something" />;
|
const App = () => <WaTextarea placeholder="Type something" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Filled Textareas
|
### Filled Textareas
|
||||||
@@ -82,13 +82,13 @@ const App = () => <SlTextarea placeholder="Type something" />;
|
|||||||
Add the `filled` attribute to draw a filled textarea.
|
Add the `filled` attribute to draw a filled textarea.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea placeholder="Type something" filled></sl-textarea>
|
<wa-textarea placeholder="Type something" filled></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea placeholder="Type something" filled />;
|
const App = () => <WaTextarea placeholder="Type something" filled />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disabled
|
### Disabled
|
||||||
@@ -96,13 +96,13 @@ const App = () => <SlTextarea placeholder="Type something" filled />;
|
|||||||
Use the `disabled` attribute to disable a textarea.
|
Use the `disabled` attribute to disable a textarea.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea placeholder="Textarea" disabled></sl-textarea>
|
<wa-textarea placeholder="Textarea" disabled></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea placeholder="Textarea" disabled />;
|
const App = () => <WaTextarea placeholder="Textarea" disabled />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sizes
|
### Sizes
|
||||||
@@ -110,23 +110,23 @@ const App = () => <SlTextarea placeholder="Textarea" disabled />;
|
|||||||
Use the `size` attribute to change a textarea's size.
|
Use the `size` attribute to change a textarea's size.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea placeholder="Small" size="small"></sl-textarea>
|
<wa-textarea placeholder="Small" size="small"></wa-textarea>
|
||||||
<br />
|
<br />
|
||||||
<sl-textarea placeholder="Medium" size="medium"></sl-textarea>
|
<wa-textarea placeholder="Medium" size="medium"></wa-textarea>
|
||||||
<br />
|
<br />
|
||||||
<sl-textarea placeholder="Large" size="large"></sl-textarea>
|
<wa-textarea placeholder="Large" size="large"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<SlTextarea placeholder="Small" size="small"></SlTextarea>
|
<WaTextarea placeholder="Small" size="small"></WaTextarea>
|
||||||
<br />
|
<br />
|
||||||
<SlTextarea placeholder="Medium" size="medium"></SlTextarea>
|
<WaTextarea placeholder="Medium" size="medium"></WaTextarea>
|
||||||
<br />
|
<br />
|
||||||
<SlTextarea placeholder="Large" size="large"></SlTextarea>
|
<WaTextarea placeholder="Large" size="large"></WaTextarea>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -136,13 +136,13 @@ const App = () => (
|
|||||||
By default, textareas can be resized vertically by the user. To prevent resizing, set the `resize` attribute to `none`.
|
By default, textareas can be resized vertically by the user. To prevent resizing, set the `resize` attribute to `none`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea resize="none"></sl-textarea>
|
<wa-textarea resize="none"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea resize="none" />;
|
const App = () => <WaTextarea resize="none" />;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Expand with Content
|
### Expand with Content
|
||||||
@@ -150,11 +150,11 @@ const App = () => <SlTextarea resize="none" />;
|
|||||||
Textareas will automatically resize to expand to fit their content when `resize` is set to `auto`.
|
Textareas will automatically resize to expand to fit their content when `resize` is set to `auto`.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-textarea resize="auto"></sl-textarea>
|
<wa-textarea resize="auto"></wa-textarea>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => <SlTextarea resize="auto" />;
|
const App = () => <WaTextarea resize="auto" />;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ A tooltip's target is its _first child element_, so you should only wrap one ele
|
|||||||
Tooltips use `display: contents` so they won't interfere with how elements are positioned in a flex or grid layout.
|
Tooltips use `display: contents` so they won't interfere with how elements are positioned in a flex or grid layout.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip content="This is a tooltip">
|
<wa-tooltip content="This is a tooltip">
|
||||||
<sl-button>Hover Me</sl-button>
|
<wa-button>Hover Me</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTooltip content="This is a tooltip">
|
<WaTooltip content="This is a tooltip">
|
||||||
<SlButton>Hover Me</SlButton>
|
<WaButton>Hover Me</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -35,61 +35,61 @@ Use the `placement` attribute to set the preferred placement of the tooltip.
|
|||||||
```html:preview
|
```html:preview
|
||||||
<div class="tooltip-placement-example">
|
<div class="tooltip-placement-example">
|
||||||
<div class="tooltip-placement-example-row">
|
<div class="tooltip-placement-example-row">
|
||||||
<sl-tooltip content="top-start" placement="top-start">
|
<wa-tooltip content="top-start" placement="top-start">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="top" placement="top">
|
<wa-tooltip content="top" placement="top">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="top-end" placement="top-end">
|
<wa-tooltip content="top-end" placement="top-end">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tooltip-placement-example-row">
|
<div class="tooltip-placement-example-row">
|
||||||
<sl-tooltip content="left-start" placement="left-start">
|
<wa-tooltip content="left-start" placement="left-start">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="right-start" placement="right-start">
|
<wa-tooltip content="right-start" placement="right-start">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tooltip-placement-example-row">
|
<div class="tooltip-placement-example-row">
|
||||||
<sl-tooltip content="left" placement="left">
|
<wa-tooltip content="left" placement="left">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="right" placement="right">
|
<wa-tooltip content="right" placement="right">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tooltip-placement-example-row">
|
<div class="tooltip-placement-example-row">
|
||||||
<sl-tooltip content="left-end" placement="left-end">
|
<wa-tooltip content="left-end" placement="left-end">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="right-end" placement="right-end">
|
<wa-tooltip content="right-end" placement="right-end">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tooltip-placement-example-row">
|
<div class="tooltip-placement-example-row">
|
||||||
<sl-tooltip content="bottom-start" placement="bottom-start">
|
<wa-tooltip content="bottom-start" placement="bottom-start">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="bottom" placement="bottom">
|
<wa-tooltip content="bottom" placement="bottom">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="bottom-end" placement="bottom-end">
|
<wa-tooltip content="bottom-end" placement="bottom-end">
|
||||||
<sl-button></sl-button>
|
<wa-button></wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -105,29 +105,29 @@ Use the `placement` attribute to set the preferred placement of the tooltip.
|
|||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example sl-button {
|
.tooltip-placement-example wa-button {
|
||||||
float: left;
|
float: left;
|
||||||
width: 2.5rem;
|
width: 2.5rem;
|
||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example-row:nth-child(1) sl-tooltip:first-child sl-button,
|
.tooltip-placement-example-row:nth-child(1) wa-tooltip:first-child wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(5) sl-tooltip:first-child sl-button {
|
.tooltip-placement-example-row:nth-child(5) wa-tooltip:first-child wa-button {
|
||||||
margin-left: calc(40px + 0.25rem);
|
margin-left: calc(40px + 0.25rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example-row:nth-child(2) sl-tooltip:nth-child(2) sl-button,
|
.tooltip-placement-example-row:nth-child(2) wa-tooltip:nth-child(2) wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(3) sl-tooltip:nth-child(2) sl-button,
|
.tooltip-placement-example-row:nth-child(3) wa-tooltip:nth-child(2) wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(4) sl-tooltip:nth-child(2) sl-button {
|
.tooltip-placement-example-row:nth-child(4) wa-tooltip:nth-child(2) wa-button {
|
||||||
margin-left: calc((40px * 3) + (0.25rem * 3));
|
margin-left: calc((40px * 3) + (0.25rem * 3));
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.tooltip-placement-example {
|
.tooltip-placement-example {
|
||||||
@@ -140,21 +140,21 @@ const css = `
|
|||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example sl-button {
|
.tooltip-placement-example wa-button {
|
||||||
float: left;
|
float: left;
|
||||||
width: 2.5rem;
|
width: 2.5rem;
|
||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example-row:nth-child(1) sl-tooltip:first-child sl-button,
|
.tooltip-placement-example-row:nth-child(1) wa-tooltip:first-child wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(5) sl-tooltip:first-child sl-button {
|
.tooltip-placement-example-row:nth-child(5) wa-tooltip:first-child wa-button {
|
||||||
margin-left: calc(40px + 0.25rem);
|
margin-left: calc(40px + 0.25rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-placement-example-row:nth-child(2) sl-tooltip:nth-child(2) sl-button,
|
.tooltip-placement-example-row:nth-child(2) wa-tooltip:nth-child(2) wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(3) sl-tooltip:nth-child(2) sl-button,
|
.tooltip-placement-example-row:nth-child(3) wa-tooltip:nth-child(2) wa-button,
|
||||||
.tooltip-placement-example-row:nth-child(4) sl-tooltip:nth-child(2) sl-button {
|
.tooltip-placement-example-row:nth-child(4) wa-tooltip:nth-child(2) wa-button {
|
||||||
margin-left: calc((40px * 3) + (0.25rem * 3));
|
margin-left: calc((40px * 3) + (0.25rem * 3));
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -163,61 +163,61 @@ const App = () => (
|
|||||||
<>
|
<>
|
||||||
<div className="tooltip-placement-example">
|
<div className="tooltip-placement-example">
|
||||||
<div className="tooltip-placement-example-row">
|
<div className="tooltip-placement-example-row">
|
||||||
<SlTooltip content="top-start" placement="top-start">
|
<WaTooltip content="top-start" placement="top-start">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="top" placement="top">
|
<WaTooltip content="top" placement="top">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="top-end" placement="top-end">
|
<WaTooltip content="top-end" placement="top-end">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tooltip-placement-example-row">
|
<div className="tooltip-placement-example-row">
|
||||||
<SlTooltip content="left-start" placement="left-start">
|
<WaTooltip content="left-start" placement="left-start">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="right-start" placement="right-start">
|
<WaTooltip content="right-start" placement="right-start">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tooltip-placement-example-row">
|
<div className="tooltip-placement-example-row">
|
||||||
<SlTooltip content="left" placement="left">
|
<WaTooltip content="left" placement="left">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="right" placement="right">
|
<WaTooltip content="right" placement="right">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tooltip-placement-example-row">
|
<div className="tooltip-placement-example-row">
|
||||||
<SlTooltip content="left-end" placement="left-end">
|
<WaTooltip content="left-end" placement="left-end">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="right-end" placement="right-end">
|
<WaTooltip content="right-end" placement="right-end">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="tooltip-placement-example-row">
|
<div className="tooltip-placement-example-row">
|
||||||
<SlTooltip content="bottom-start" placement="bottom-start">
|
<WaTooltip content="bottom-start" placement="bottom-start">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="bottom" placement="bottom">
|
<WaTooltip content="bottom" placement="bottom">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="bottom-end" placement="bottom-end">
|
<WaTooltip content="bottom-end" placement="bottom-end">
|
||||||
<SlButton />
|
<WaButton />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -231,19 +231,19 @@ const App = () => (
|
|||||||
Set the `trigger` attribute to `click` to toggle the tooltip on click instead of hover.
|
Set the `trigger` attribute to `click` to toggle the tooltip on click instead of hover.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip content="Click again to dismiss" trigger="click">
|
<wa-tooltip content="Click again to dismiss" trigger="click">
|
||||||
<sl-button>Click to Toggle</sl-button>
|
<wa-button>Click to Toggle</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTooltip content="Click again to dismiss" trigger="click">
|
<WaTooltip content="Click again to dismiss" trigger="click">
|
||||||
<SlButton>Click to Toggle</SlButton>
|
<WaButton>Click to Toggle</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -252,11 +252,11 @@ const App = () => (
|
|||||||
Tooltips can be controller programmatically by setting the `trigger` attribute to `manual`. Use the `open` attribute to control when the tooltip is shown.
|
Tooltips can be controller programmatically by setting the `trigger` attribute to `manual`. Use the `open` attribute to control when the tooltip is shown.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button style="margin-right: 4rem;">Toggle Manually</sl-button>
|
<wa-button style="margin-right: 4rem;">Toggle Manually</wa-button>
|
||||||
|
|
||||||
<sl-tooltip content="This is an avatar" trigger="manual" class="manual-tooltip">
|
<wa-tooltip content="This is an avatar" trigger="manual" class="manual-tooltip">
|
||||||
<sl-avatar label="User"></sl-avatar>
|
<wa-avatar label="User"></wa-avatar>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const tooltip = document.querySelector('.manual-tooltip');
|
const tooltip = document.querySelector('.manual-tooltip');
|
||||||
@@ -270,22 +270,22 @@ Tooltips can be controller programmatically by setting the `trigger` attribute t
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlAvatar from '@shoelace-style/shoelace/dist/react/sl-avatar';
|
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlButton style={{ marginRight: '4rem' }} onClick={() => setOpen(!open)}>
|
<WaButton style={{ marginRight: '4rem' }} onClick={() => setOpen(!open)}>
|
||||||
Toggle Manually
|
Toggle Manually
|
||||||
</SlButton>
|
</WaButton>
|
||||||
|
|
||||||
<SlTooltip open={open} content="This is an avatar" trigger="manual">
|
<WaTooltip open={open} content="This is an avatar" trigger="manual">
|
||||||
<SlAvatar />
|
<WaAvatar />
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -295,40 +295,40 @@ const App = () => {
|
|||||||
|
|
||||||
### Removing Arrows
|
### Removing Arrows
|
||||||
|
|
||||||
You can control the size of tooltip arrows by overriding the `--sl-tooltip-arrow-size` design token. To remove them, set the value to `0` as shown below.
|
You can control the size of tooltip arrows by overriding the `--wa-tooltip-arrow-size` design token. To remove them, set the value to `0` as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip content="This is a tooltip" style="--sl-tooltip-arrow-size: 0;">
|
<wa-tooltip content="This is a tooltip" style="--wa-tooltip-arrow-size: 0;">
|
||||||
<sl-button>No Arrow</sl-button>
|
<wa-button>No Arrow</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<div style={{ '--sl-tooltip-arrow-size': '0' }}>
|
<div style={{ '--wa-tooltip-arrow-size': '0' }}>
|
||||||
<SlTooltip content="This is a tooltip">
|
<WaTooltip content="This is a tooltip">
|
||||||
<SlButton>Above</SlButton>
|
<WaButton>Above</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="This is a tooltip" placement="bottom">
|
<WaTooltip content="This is a tooltip" placement="bottom">
|
||||||
<SlButton>Below</SlButton>
|
<WaButton>Below</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
To override it globally, set it in a root block in your stylesheet after the Shoelace stylesheet is loaded.
|
To override it globally, set it in a root block in your stylesheet after the Web Awesome stylesheet is loaded.
|
||||||
|
|
||||||
```css
|
```css
|
||||||
:root {
|
:root {
|
||||||
--sl-tooltip-arrow-size: 0;
|
--wa-tooltip-arrow-size: 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -337,25 +337,25 @@ To override it globally, set it in a root block in your stylesheet after the Sho
|
|||||||
Use the `content` slot to create tooltips with HTML content. Tooltips are designed only for text and presentational elements. Avoid placing interactive content, such as buttons, links, and form controls, in a tooltip.
|
Use the `content` slot to create tooltips with HTML content. Tooltips are designed only for text and presentational elements. Avoid placing interactive content, such as buttons, links, and form controls, in a tooltip.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip>
|
<wa-tooltip>
|
||||||
<div slot="content">I'm not <strong>just</strong> a tooltip, I'm a <em>tooltip</em> with HTML!</div>
|
<div slot="content">I'm not <strong>just</strong> a tooltip, I'm a <em>tooltip</em> with HTML!</div>
|
||||||
|
|
||||||
<sl-button>Hover me</sl-button>
|
<wa-button>Hover me</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTooltip>
|
<WaTooltip>
|
||||||
<div slot="content">
|
<div slot="content">
|
||||||
I'm not <strong>just</strong> a tooltip, I'm a <em>tooltip</em> with HTML!
|
I'm not <strong>just</strong> a tooltip, I'm a <em>tooltip</em> with HTML!
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SlButton>Hover Me</SlButton>
|
<WaButton>Hover Me</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -364,21 +364,21 @@ const App = () => (
|
|||||||
Use the `--max-width` custom property to change the width the tooltip can grow to before wrapping occurs.
|
Use the `--max-width` custom property to change the width the tooltip can grow to before wrapping occurs.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tooltip style="--max-width: 80px;" content="This tooltip will wrap after only 80 pixels.">
|
<wa-tooltip style="--max-width: 80px;" content="This tooltip will wrap after only 80 pixels.">
|
||||||
<sl-button>Hover me</sl-button>
|
<wa-button>Hover me</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
```
|
```
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTooltip style={{ '--max-width': '80px' }} content="This tooltip will wrap after only 80 pixels.">
|
<WaTooltip style={{ '--max-width': '80px' }} content="This tooltip will wrap after only 80 pixels.">
|
||||||
<SlButton>Hover Me</SlButton>
|
<WaButton>Hover Me</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -390,34 +390,34 @@ Tooltips will be clipped if they're inside a container that has `overflow: auto|
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div class="tooltip-hoist">
|
<div class="tooltip-hoist">
|
||||||
<sl-tooltip content="This is a tooltip">
|
<wa-tooltip content="This is a tooltip">
|
||||||
<sl-button>No Hoist</sl-button>
|
<wa-button>No Hoist</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
|
|
||||||
<sl-tooltip content="This is a tooltip" hoist>
|
<wa-tooltip content="This is a tooltip" hoist>
|
||||||
<sl-button>Hoist</sl-button>
|
<wa-button>Hoist</wa-button>
|
||||||
</sl-tooltip>
|
</wa-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tooltip-hoist {
|
.tooltip-hoist {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: solid 2px var(--sl-panel-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: var(--sl-spacing-medium);
|
padding: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlTooltip from '@shoelace-style/shoelace/dist/react/sl-tooltip';
|
import WaTooltip from '@shoelace-style/shoelace/dist/react/tooltip';
|
||||||
|
|
||||||
const css = `
|
const css = `
|
||||||
.tooltip-hoist {
|
.tooltip-hoist {
|
||||||
border: solid 2px var(--sl-panel-border-color);
|
border: solid 2px var(--wa-color-surface-border);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: var(--sl-spacing-medium);
|
padding: var(--wa-space-m);
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -425,13 +425,13 @@ const css = `
|
|||||||
const App = () => (
|
const App = () => (
|
||||||
<>
|
<>
|
||||||
<div class="tooltip-hoist">
|
<div class="tooltip-hoist">
|
||||||
<SlTooltip content="This is a tooltip">
|
<WaTooltip content="This is a tooltip">
|
||||||
<SlButton>No Hoist</SlButton>
|
<WaButton>No Hoist</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
|
|
||||||
<SlTooltip content="This is a tooltip" hoist>
|
<WaTooltip content="This is a tooltip" hoist>
|
||||||
<SlButton>Hoist</SlButton>
|
<WaButton>Hoist</WaButton>
|
||||||
</SlTooltip>
|
</WaTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>{css}</style>
|
<style>{css}</style>
|
||||||
|
|||||||
@@ -6,34 +6,34 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Item 1
|
Item 1
|
||||||
<sl-tree-item>Item A</sl-tree-item>
|
<wa-tree-item>Item A</wa-tree-item>
|
||||||
<sl-tree-item>Item B</sl-tree-item>
|
<wa-tree-item>Item B</wa-tree-item>
|
||||||
<sl-tree-item>Item C</sl-tree-item>
|
<wa-tree-item>Item C</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item 2</sl-tree-item>
|
<wa-tree-item>Item 2</wa-tree-item>
|
||||||
<sl-tree-item>Item 3</sl-tree-item>
|
<wa-tree-item>Item 3</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Item 1
|
Item 1
|
||||||
<SlTreeItem>Item A</SlTreeItem>
|
<WaTreeItem>Item A</WaTreeItem>
|
||||||
<SlTreeItem>Item B</SlTreeItem>
|
<WaTreeItem>Item B</WaTreeItem>
|
||||||
<SlTreeItem>Item C</SlTreeItem>
|
<WaTreeItem>Item C</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item 2</SlTreeItem>
|
<WaTreeItem>Item 2</WaTreeItem>
|
||||||
<SlTreeItem>Item 3</SlTreeItem>
|
<WaTreeItem>Item 3</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -44,44 +44,44 @@ const App = () => (
|
|||||||
A tree item can contain other tree items. This allows the node to be expanded or collapsed by the user.
|
A tree item can contain other tree items. This allows the node to be expanded or collapsed by the user.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Item 1
|
Item 1
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Item A
|
Item A
|
||||||
<sl-tree-item>Item Z</sl-tree-item>
|
<wa-tree-item>Item Z</wa-tree-item>
|
||||||
<sl-tree-item>Item Y</sl-tree-item>
|
<wa-tree-item>Item Y</wa-tree-item>
|
||||||
<sl-tree-item>Item X</sl-tree-item>
|
<wa-tree-item>Item X</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item B</sl-tree-item>
|
<wa-tree-item>Item B</wa-tree-item>
|
||||||
<sl-tree-item>Item C</sl-tree-item>
|
<wa-tree-item>Item C</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item 2</sl-tree-item>
|
<wa-tree-item>Item 2</wa-tree-item>
|
||||||
<sl-tree-item>Item 3</sl-tree-item>
|
<wa-tree-item>Item 3</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Item 1
|
Item 1
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Item A
|
Item A
|
||||||
<SlTreeItem>Item Z</SlTreeItem>
|
<WaTreeItem>Item Z</WaTreeItem>
|
||||||
<SlTreeItem>Item Y</SlTreeItem>
|
<WaTreeItem>Item Y</WaTreeItem>
|
||||||
<SlTreeItem>Item X</SlTreeItem>
|
<WaTreeItem>Item X</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item B</SlTreeItem>
|
<WaTreeItem>Item B</WaTreeItem>
|
||||||
<SlTreeItem>Item C</SlTreeItem>
|
<WaTreeItem>Item C</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item 2</SlTreeItem>
|
<WaTreeItem>Item 2</WaTreeItem>
|
||||||
<SlTreeItem>Item 3</SlTreeItem>
|
<WaTreeItem>Item 3</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -90,34 +90,34 @@ const App = () => (
|
|||||||
Use the `selected` attribute to select a tree item initially.
|
Use the `selected` attribute to select a tree item initially.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item selected>
|
<wa-tree-item selected>
|
||||||
Item 1
|
Item 1
|
||||||
<sl-tree-item>Item A</sl-tree-item>
|
<wa-tree-item>Item A</wa-tree-item>
|
||||||
<sl-tree-item>Item B</sl-tree-item>
|
<wa-tree-item>Item B</wa-tree-item>
|
||||||
<sl-tree-item>Item C</sl-tree-item>
|
<wa-tree-item>Item C</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item 2</sl-tree-item>
|
<wa-tree-item>Item 2</wa-tree-item>
|
||||||
<sl-tree-item>Item 3</sl-tree-item>
|
<wa-tree-item>Item 3</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem selected>
|
<WaTreeItem selected>
|
||||||
Item 1
|
Item 1
|
||||||
<SlTreeItem>Item A</SlTreeItem>
|
<WaTreeItem>Item A</WaTreeItem>
|
||||||
<SlTreeItem>Item B</SlTreeItem>
|
<WaTreeItem>Item B</WaTreeItem>
|
||||||
<SlTreeItem>Item C</SlTreeItem>
|
<WaTreeItem>Item C</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item 2</SlTreeItem>
|
<WaTreeItem>Item 2</WaTreeItem>
|
||||||
<SlTreeItem>Item 3</SlTreeItem>
|
<WaTreeItem>Item 3</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -126,43 +126,43 @@ const App = () => (
|
|||||||
Use the `expanded` attribute to expand a tree item initially.
|
Use the `expanded` attribute to expand a tree item initially.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item expanded>
|
<wa-tree-item expanded>
|
||||||
Item 1
|
Item 1
|
||||||
<sl-tree-item expanded>
|
<wa-tree-item expanded>
|
||||||
Item A
|
Item A
|
||||||
<sl-tree-item>Item Z</sl-tree-item>
|
<wa-tree-item>Item Z</wa-tree-item>
|
||||||
<sl-tree-item>Item Y</sl-tree-item>
|
<wa-tree-item>Item Y</wa-tree-item>
|
||||||
<sl-tree-item>Item X</sl-tree-item>
|
<wa-tree-item>Item X</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item B</sl-tree-item>
|
<wa-tree-item>Item B</wa-tree-item>
|
||||||
<sl-tree-item>Item C</sl-tree-item>
|
<wa-tree-item>Item C</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item 2</sl-tree-item>
|
<wa-tree-item>Item 2</wa-tree-item>
|
||||||
<sl-tree-item>Item 3</sl-tree-item>
|
<wa-tree-item>Item 3</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem expanded>
|
<WaTreeItem expanded>
|
||||||
Item 1
|
Item 1
|
||||||
<SlTreeItem expanded>
|
<WaTreeItem expanded>
|
||||||
Item A
|
Item A
|
||||||
<SlTreeItem>Item Z</SlTreeItem>
|
<WaTreeItem>Item Z</WaTreeItem>
|
||||||
<SlTreeItem>Item Y</SlTreeItem>
|
<WaTreeItem>Item Y</WaTreeItem>
|
||||||
<SlTreeItem>Item X</SlTreeItem>
|
<WaTreeItem>Item X</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item B</SlTreeItem>
|
<WaTreeItem>Item B</WaTreeItem>
|
||||||
<SlTreeItem>Item C</SlTreeItem>
|
<WaTreeItem>Item C</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item 2</SlTreeItem>
|
<WaTreeItem>Item 2</WaTreeItem>
|
||||||
<SlTreeItem>Item 3</SlTreeItem>
|
<WaTreeItem>Item 3</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,68 +6,68 @@ layout: component
|
|||||||
---
|
---
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Deciduous
|
Deciduous
|
||||||
<sl-tree-item>Birch</sl-tree-item>
|
<wa-tree-item>Birch</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Maple
|
Maple
|
||||||
<sl-tree-item>Field maple</sl-tree-item>
|
<wa-tree-item>Field maple</wa-tree-item>
|
||||||
<sl-tree-item>Red maple</sl-tree-item>
|
<wa-tree-item>Red maple</wa-tree-item>
|
||||||
<sl-tree-item>Sugar maple</sl-tree-item>
|
<wa-tree-item>Sugar maple</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Oak</sl-tree-item>
|
<wa-tree-item>Oak</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Coniferous
|
Coniferous
|
||||||
<sl-tree-item>Cedar</sl-tree-item>
|
<wa-tree-item>Cedar</wa-tree-item>
|
||||||
<sl-tree-item>Pine</sl-tree-item>
|
<wa-tree-item>Pine</wa-tree-item>
|
||||||
<sl-tree-item>Spruce</sl-tree-item>
|
<wa-tree-item>Spruce</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Non-trees
|
Non-trees
|
||||||
<sl-tree-item>Bamboo</sl-tree-item>
|
<wa-tree-item>Bamboo</wa-tree-item>
|
||||||
<sl-tree-item>Cactus</sl-tree-item>
|
<wa-tree-item>Cactus</wa-tree-item>
|
||||||
<sl-tree-item>Fern</sl-tree-item>
|
<wa-tree-item>Fern</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Deciduous
|
Deciduous
|
||||||
<SlTreeItem>Birch</SlTreeItem>
|
<WaTreeItem>Birch</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Maple
|
Maple
|
||||||
<SlTreeItem>Field maple</SlTreeItem>
|
<WaTreeItem>Field maple</WaTreeItem>
|
||||||
<SlTreeItem>Red maple</SlTreeItem>
|
<WaTreeItem>Red maple</WaTreeItem>
|
||||||
<SlTreeItem>Sugar maple</SlTreeItem>
|
<WaTreeItem>Sugar maple</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Oak</SlTreeItem>
|
<WaTreeItem>Oak</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Coniferous
|
Coniferous
|
||||||
<SlTreeItem>Cedar</SlTreeItem>
|
<WaTreeItem>Cedar</WaTreeItem>
|
||||||
<SlTreeItem>Pine</SlTreeItem>
|
<WaTreeItem>Pine</WaTreeItem>
|
||||||
<SlTreeItem>Spruce</SlTreeItem>
|
<WaTreeItem>Spruce</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Non-trees
|
Non-trees
|
||||||
<SlTreeItem>Bamboo</SlTreeItem>
|
<WaTreeItem>Bamboo</WaTreeItem>
|
||||||
<SlTreeItem>Cactus</SlTreeItem>
|
<WaTreeItem>Cactus</WaTreeItem>
|
||||||
<SlTreeItem>Fern</SlTreeItem>
|
<WaTreeItem>Fern</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -82,36 +82,36 @@ The `selection` attribute lets you change the selection behavior of the tree.
|
|||||||
- Use `leaf` to only allow leaf nodes to be selected.
|
- Use `leaf` to only allow leaf nodes to be selected.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-select id="selection-mode" value="single" label="Selection">
|
<wa-select id="selection-mode" value="single" label="Selection">
|
||||||
<sl-option value="single">Single</sl-option>
|
<wa-option value="single">Single</wa-option>
|
||||||
<sl-option value="multiple">Multiple</sl-option>
|
<wa-option value="multiple">Multiple</wa-option>
|
||||||
<sl-option value="leaf">Leaf</sl-option>
|
<wa-option value="leaf">Leaf</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<sl-tree class="tree-selectable">
|
<wa-tree class="tree-selectable">
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Item 1
|
Item 1
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Item A
|
Item A
|
||||||
<sl-tree-item>Item Z</sl-tree-item>
|
<wa-tree-item>Item Z</wa-tree-item>
|
||||||
<sl-tree-item>Item Y</sl-tree-item>
|
<wa-tree-item>Item Y</wa-tree-item>
|
||||||
<sl-tree-item>Item X</sl-tree-item>
|
<wa-tree-item>Item X</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item B</sl-tree-item>
|
<wa-tree-item>Item B</wa-tree-item>
|
||||||
<sl-tree-item>Item C</sl-tree-item>
|
<wa-tree-item>Item C</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Item 2</sl-tree-item>
|
<wa-tree-item>Item 2</wa-tree-item>
|
||||||
<sl-tree-item>Item 3</sl-tree-item>
|
<wa-tree-item>Item 3</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const selectionMode = document.querySelector('#selection-mode');
|
const selectionMode = document.querySelector('#selection-mode');
|
||||||
const tree = document.querySelector('.tree-selectable');
|
const tree = document.querySelector('.tree-selectable');
|
||||||
|
|
||||||
selectionMode.addEventListener('sl-change', () => {
|
selectionMode.addEventListener('wa-change', () => {
|
||||||
tree.querySelectorAll('sl-tree-item').forEach(item => (item.selected = false));
|
tree.querySelectorAll('wa-tree-item').forEach(item => (item.selected = false));
|
||||||
tree.selection = selectionMode.value;
|
tree.selection = selectionMode.value;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -119,37 +119,37 @@ The `selection` attribute lets you change the selection behavior of the tree.
|
|||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [selection, setSelection] = useState('single');
|
const [selection, setSelection] = useState('single');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SlSelect label="Selection" value={selection} onSlChange={event => setSelection(event.target.value)}>
|
<WaSelect label="Selection" value={selection} onWaChange={event => setSelection(event.target.value)}>
|
||||||
<SlMenuItem value="single">single</SlMenuItem>
|
<WaMenuItem value="single">single</WaMenuItem>
|
||||||
<SlMenuItem value="multiple">multiple</SlMenuItem>
|
<WaMenuItem value="multiple">multiple</WaMenuItem>
|
||||||
<SlMenuItem value="leaf">leaf</SlMenuItem>
|
<WaMenuItem value="leaf">leaf</WaMenuItem>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<SlTree selection={selection}>
|
<WaTree selection={selection}>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Item 1
|
Item 1
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Item A
|
Item A
|
||||||
<SlTreeItem>Item Z</SlTreeItem>
|
<WaTreeItem>Item Z</WaTreeItem>
|
||||||
<SlTreeItem>Item Y</SlTreeItem>
|
<WaTreeItem>Item Y</WaTreeItem>
|
||||||
<SlTreeItem>Item X</SlTreeItem>
|
<WaTreeItem>Item X</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item B</SlTreeItem>
|
<WaTreeItem>Item B</WaTreeItem>
|
||||||
<SlTreeItem>Item C</SlTreeItem>
|
<WaTreeItem>Item C</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Item 2</SlTreeItem>
|
<WaTreeItem>Item 2</WaTreeItem>
|
||||||
<SlTreeItem>Item 3</SlTreeItem>
|
<WaTreeItem>Item 3</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -160,33 +160,33 @@ const App = () => {
|
|||||||
Indent guides can be drawn by setting `--indent-guide-width`. You can also change the color, offset, and style, using `--indent-guide-color`, `--indent-guide-style`, and `--indent-guide-offset`, respectively.
|
Indent guides can be drawn by setting `--indent-guide-width`. You can also change the color, offset, and style, using `--indent-guide-color`, `--indent-guide-style`, and `--indent-guide-offset`, respectively.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree class="tree-with-lines">
|
<wa-tree class="tree-with-lines">
|
||||||
<sl-tree-item expanded>
|
<wa-tree-item expanded>
|
||||||
Deciduous
|
Deciduous
|
||||||
<sl-tree-item>Birch</sl-tree-item>
|
<wa-tree-item>Birch</wa-tree-item>
|
||||||
<sl-tree-item expanded>
|
<wa-tree-item expanded>
|
||||||
Maple
|
Maple
|
||||||
<sl-tree-item>Field maple</sl-tree-item>
|
<wa-tree-item>Field maple</wa-tree-item>
|
||||||
<sl-tree-item>Red maple</sl-tree-item>
|
<wa-tree-item>Red maple</wa-tree-item>
|
||||||
<sl-tree-item>Sugar maple</sl-tree-item>
|
<wa-tree-item>Sugar maple</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Oak</sl-tree-item>
|
<wa-tree-item>Oak</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Coniferous
|
Coniferous
|
||||||
<sl-tree-item>Cedar</sl-tree-item>
|
<wa-tree-item>Cedar</wa-tree-item>
|
||||||
<sl-tree-item>Pine</sl-tree-item>
|
<wa-tree-item>Pine</wa-tree-item>
|
||||||
<sl-tree-item>Spruce</sl-tree-item>
|
<wa-tree-item>Spruce</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Non-trees
|
Non-trees
|
||||||
<sl-tree-item>Bamboo</sl-tree-item>
|
<wa-tree-item>Bamboo</wa-tree-item>
|
||||||
<sl-tree-item>Cactus</sl-tree-item>
|
<wa-tree-item>Cactus</wa-tree-item>
|
||||||
<sl-tree-item>Fern</sl-tree-item>
|
<wa-tree-item>Fern</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tree-with-lines {
|
.tree-with-lines {
|
||||||
@@ -199,37 +199,37 @@ Indent guides can be drawn by setting `--indent-guide-width`. You can also chang
|
|||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree class="tree-with-lines" style={{ '--indent-guide-width': '1px' }}>
|
<WaTree class="tree-with-lines" style={{ '--indent-guide-width': '1px' }}>
|
||||||
<SlTreeItem expanded>
|
<WaTreeItem expanded>
|
||||||
Deciduous
|
Deciduous
|
||||||
<SlTreeItem>Birch</SlTreeItem>
|
<WaTreeItem>Birch</WaTreeItem>
|
||||||
<SlTreeItem expanded>
|
<WaTreeItem expanded>
|
||||||
Maple
|
Maple
|
||||||
<SlTreeItem>Field maple</SlTreeItem>
|
<WaTreeItem>Field maple</WaTreeItem>
|
||||||
<SlTreeItem>Red maple</SlTreeItem>
|
<WaTreeItem>Red maple</WaTreeItem>
|
||||||
<SlTreeItem>Sugar maple</SlTreeItem>
|
<WaTreeItem>Sugar maple</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Oak</SlTreeItem>
|
<WaTreeItem>Oak</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Coniferous
|
Coniferous
|
||||||
<SlTreeItem>Cedar</SlTreeItem>
|
<WaTreeItem>Cedar</WaTreeItem>
|
||||||
<SlTreeItem>Pine</SlTreeItem>
|
<WaTreeItem>Pine</WaTreeItem>
|
||||||
<SlTreeItem>Spruce</SlTreeItem>
|
<WaTreeItem>Spruce</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Non-trees
|
Non-trees
|
||||||
<SlTreeItem>Bamboo</SlTreeItem>
|
<WaTreeItem>Bamboo</WaTreeItem>
|
||||||
<SlTreeItem>Cactus</SlTreeItem>
|
<WaTreeItem>Cactus</WaTreeItem>
|
||||||
<SlTreeItem>Fern</SlTreeItem>
|
<WaTreeItem>Fern</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -237,25 +237,25 @@ const App = () => (
|
|||||||
|
|
||||||
### Lazy Loading
|
### Lazy Loading
|
||||||
|
|
||||||
Use the `lazy` attribute on a tree item to indicate that the content is not yet present and will be loaded later. When the user tries to expand the node, the `loading` state is set to `true` and the `sl-lazy-load` event will be emitted to allow you to load data asynchronously. The item will remain in a loading state until its content is changed.
|
Use the `lazy` attribute on a tree item to indicate that the content is not yet present and will be loaded later. When the user tries to expand the node, the `loading` state is set to `true` and the `wa-lazy-load` event will be emitted to allow you to load data asynchronously. The item will remain in a loading state until its content is changed.
|
||||||
|
|
||||||
If you want to disable this behavior after the first load, simply remove the `lazy` attribute and, on the next expand, the existing content will be shown instead.
|
If you want to disable this behavior after the first load, simply remove the `lazy` attribute and, on the next expand, the existing content will be shown instead.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree>
|
<wa-tree>
|
||||||
<sl-tree-item lazy>Available Trees</sl-tree-item>
|
<wa-tree-item lazy>Available Trees</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const lazyItem = document.querySelector('sl-tree-item[lazy]');
|
const lazyItem = document.querySelector('wa-tree-item[lazy]');
|
||||||
|
|
||||||
lazyItem.addEventListener('sl-lazy-load', () => {
|
lazyItem.addEventListener('wa-lazy-load', () => {
|
||||||
// Simulate asynchronous loading
|
// Simulate asynchronous loading
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const subItems = ['Birch', 'Cedar', 'Maple', 'Pine'];
|
const subItems = ['Birch', 'Cedar', 'Maple', 'Pine'];
|
||||||
|
|
||||||
for (const item of subItems) {
|
for (const item of subItems) {
|
||||||
const treeItem = document.createElement('sl-tree-item');
|
const treeItem = document.createElement('wa-tree-item');
|
||||||
treeItem.innerText = item;
|
treeItem.innerText = item;
|
||||||
lazyItem.append(treeItem);
|
lazyItem.append(treeItem);
|
||||||
}
|
}
|
||||||
@@ -268,8 +268,8 @@ If you want to disable this behavior after the first load, simply remove the `la
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [childItems, setChildItems] = useState([]);
|
const [childItems, setChildItems] = useState([]);
|
||||||
@@ -286,14 +286,14 @@ const App = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlTreeItem lazy={lazy} onSlLazyLoad={handleLazyLoad}>
|
<WaTreeItem lazy={lazy} onWaLazyLoad={handleLazyLoad}>
|
||||||
Available Trees
|
Available Trees
|
||||||
{childItems.map(item => (
|
{childItems.map(item => (
|
||||||
<SlTreeItem>{item}</SlTreeItem>
|
<WaTreeItem>{item}</WaTreeItem>
|
||||||
))}
|
))}
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -303,39 +303,39 @@ const App = () => {
|
|||||||
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `expand-button` part as shown below.
|
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `expand-button` part as shown below.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree class="custom-icons">
|
<wa-tree class="custom-icons">
|
||||||
<sl-icon name="plus-square" slot="expand-icon"></sl-icon>
|
<wa-icon name="square-plus" variant="solid" slot="expand-icon"></wa-icon>
|
||||||
<sl-icon name="dash-square" slot="collapse-icon"></sl-icon>
|
<wa-icon name="square-minus" variant="solid" slot="collapse-icon"></wa-icon>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Deciduous
|
Deciduous
|
||||||
<sl-tree-item>Birch</sl-tree-item>
|
<wa-tree-item>Birch</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Maple
|
Maple
|
||||||
<sl-tree-item>Field maple</sl-tree-item>
|
<wa-tree-item>Field maple</wa-tree-item>
|
||||||
<sl-tree-item>Red maple</sl-tree-item>
|
<wa-tree-item>Red maple</wa-tree-item>
|
||||||
<sl-tree-item>Sugar maple</sl-tree-item>
|
<wa-tree-item>Sugar maple</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>Oak</sl-tree-item>
|
<wa-tree-item>Oak</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Coniferous
|
Coniferous
|
||||||
<sl-tree-item>Cedar</sl-tree-item>
|
<wa-tree-item>Cedar</wa-tree-item>
|
||||||
<sl-tree-item>Pine</sl-tree-item>
|
<wa-tree-item>Pine</wa-tree-item>
|
||||||
<sl-tree-item>Spruce</sl-tree-item>
|
<wa-tree-item>Spruce</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
Non-trees
|
Non-trees
|
||||||
<sl-tree-item>Bamboo</sl-tree-item>
|
<wa-tree-item>Bamboo</wa-tree-item>
|
||||||
<sl-tree-item>Cactus</sl-tree-item>
|
<wa-tree-item>Cactus</wa-tree-item>
|
||||||
<sl-tree-item>Fern</sl-tree-item>
|
<wa-tree-item>Fern</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.custom-icons sl-tree-item::part(expand-button) {
|
.custom-icons wa-tree-item::part(expand-button) {
|
||||||
/* Disable the expand/collapse animation */
|
/* Disable the expand/collapse animation */
|
||||||
rotate: none;
|
rotate: none;
|
||||||
}
|
}
|
||||||
@@ -344,40 +344,40 @@ Use the `expand-icon` and `collapse-icon` slots to change the expand and collaps
|
|||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<SlTree>
|
<WaTree>
|
||||||
<SlIcon name="plus-square" slot="expand-icon"></SlIcon>
|
<WaIcon name="square-plus" variant="solid" slot="expand-icon"></WaIcon>
|
||||||
<SlIcon name="dash-square" slot="collapse-icon"></SlIcon>
|
<WaIcon name="square-minus" variant="solid" slot="collapse-icon"></WaIcon>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Deciduous
|
Deciduous
|
||||||
<SlTreeItem>Birch</SlTreeItem>
|
<WaTreeItem>Birch</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Maple
|
Maple
|
||||||
<SlTreeItem>Field maple</SlTreeItem>
|
<WaTreeItem>Field maple</WaTreeItem>
|
||||||
<SlTreeItem>Red maple</SlTreeItem>
|
<WaTreeItem>Red maple</WaTreeItem>
|
||||||
<SlTreeItem>Sugar maple</SlTreeItem>
|
<WaTreeItem>Sugar maple</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>Oak</SlTreeItem>
|
<WaTreeItem>Oak</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Coniferous
|
Coniferous
|
||||||
<SlTreeItem>Cedar</SlTreeItem>
|
<WaTreeItem>Cedar</WaTreeItem>
|
||||||
<SlTreeItem>Pine</SlTreeItem>
|
<WaTreeItem>Pine</WaTreeItem>
|
||||||
<SlTreeItem>Spruce</SlTreeItem>
|
<WaTreeItem>Spruce</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
|
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
Non-trees
|
Non-trees
|
||||||
<SlTreeItem>Bamboo</SlTreeItem>
|
<WaTreeItem>Bamboo</WaTreeItem>
|
||||||
<SlTreeItem>Cactus</SlTreeItem>
|
<WaTreeItem>Cactus</WaTreeItem>
|
||||||
<SlTreeItem>Fern</SlTreeItem>
|
<WaTreeItem>Fern</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -386,91 +386,91 @@ const App = () => (
|
|||||||
Decorative icons can be used before labels to provide hints for each node.
|
Decorative icons can be used before labels to provide hints for each node.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-tree class="tree-with-icons">
|
<wa-tree class="tree-with-icons">
|
||||||
<sl-tree-item expanded>
|
<wa-tree-item expanded>
|
||||||
<sl-icon name="folder"></sl-icon>
|
<wa-icon name="folder" variant="regular"></wa-icon>
|
||||||
Documents
|
Documents
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="folder"> </sl-icon>
|
<wa-icon name="folder" variant="regular"> </wa-icon>
|
||||||
Photos
|
Photos
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="image"></sl-icon>
|
<wa-icon name="image" variant="regular"></wa-icon>
|
||||||
birds.jpg
|
birds.jpg
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="image"></sl-icon>
|
<wa-icon name="image" variant="regular"></wa-icon>
|
||||||
kitten.jpg
|
kitten.jpg
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="image"></sl-icon>
|
<wa-icon name="image" variant="regular"></wa-icon>
|
||||||
puppy.jpg
|
puppy.jpg
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
|
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="folder"></sl-icon>
|
<wa-icon name="folder" variant="regular"></wa-icon>
|
||||||
Writing
|
Writing
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="file"></sl-icon>
|
<wa-icon name="file" variant="regular"></wa-icon>
|
||||||
draft.txt
|
draft.txt
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="file-pdf"></sl-icon>
|
<wa-icon name="file-pdf" variant="regular"></wa-icon>
|
||||||
final.pdf
|
final.pdf
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
<sl-tree-item>
|
<wa-tree-item>
|
||||||
<sl-icon name="file-bar-graph"></sl-icon>
|
<wa-icon name="file-lines" variant="regular"></wa-icon>
|
||||||
sales.xls
|
sales.xls
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree-item>
|
</wa-tree-item>
|
||||||
</sl-tree>
|
</wa-tree>
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlIcon from '@shoelace-style/shoelace/dist/react/sl-icon';
|
import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
|
||||||
import SlTree from '@shoelace-style/shoelace/dist/react/sl-tree';
|
import WaTree from '@shoelace-style/shoelace/dist/react/tree';
|
||||||
import SlTreeItem from '@shoelace-style/shoelace/dist/react/sl-tree-item';
|
import WaTreeItem from '@shoelace-style/shoelace/dist/react/tree-item';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return (
|
return (
|
||||||
<SlTree class="tree-with-icons">
|
<WaTree class="tree-with-icons">
|
||||||
<SlTreeItem expanded>
|
<WaTreeItem expanded>
|
||||||
<SlIcon name="folder" />
|
<WaIcon name="folder" />
|
||||||
Root
|
Root
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
<SlIcon name="folder" />
|
<WaIcon name="folder" />
|
||||||
Folder 1<SlTreeItem>
|
Folder 1<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 1 - 1
|
File 1 - 1
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem disabled>
|
<WaTreeItem disabled>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 1 - 2
|
File 1 - 2
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 1 - 3
|
File 1 - 3
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
Folder 2<SlTreeItem>
|
Folder 2<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 2 - 1
|
File 2 - 1
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 2 - 2
|
File 2 - 2
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
<SlTreeItem>
|
<WaTreeItem>
|
||||||
<SlIcon name="files" />
|
<WaIcon name="files" />
|
||||||
File 1
|
File 1
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTreeItem>
|
</WaTreeItem>
|
||||||
</SlTree>
|
</WaTree>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ Since visually hidden content can receive focus when tabbing, the element will b
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<div style="min-height: 1.875rem;">
|
<div style="min-height: 1.875rem;">
|
||||||
<sl-visually-hidden>
|
<wa-visually-hidden>
|
||||||
<a href="#">Skip to main content</a>
|
<a href="#">Skip to main content</a>
|
||||||
</sl-visually-hidden>
|
</wa-visually-hidden>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ In this example, the link will open a new window. Screen readers will announce "
|
|||||||
```html:preview
|
```html:preview
|
||||||
<a href="https://example.com/" target="_blank">
|
<a href="https://example.com/" target="_blank">
|
||||||
Visit External Page
|
Visit External Page
|
||||||
<sl-icon name="box-arrow-up-right"></sl-icon>
|
<wa-icon name="arrow-up-right-from-square" variant="regular"></wa-icon>
|
||||||
<sl-visually-hidden>opens in a new window</sl-visually-hidden>
|
<wa-visually-hidden>opens in a new window</wa-visually-hidden>
|
||||||
</a>
|
</a>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -36,11 +36,11 @@ In this example, the link will open a new window. Screen readers will announce "
|
|||||||
Adding a label may seem redundant at times, but they're very helpful for unsighted users. Rather than omit them, you can provide context to unsighted users with visually hidden content that will be announced by assistive devices such as screen readers.
|
Adding a label may seem redundant at times, but they're very helpful for unsighted users. Rather than omit them, you can provide context to unsighted users with visually hidden content that will be announced by assistive devices such as screen readers.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-card style="width: 100%; max-width: 360px;">
|
<wa-card style="width: 100%; max-width: 360px;">
|
||||||
<header>
|
<header>
|
||||||
<sl-visually-hidden>Personal Info</sl-visually-hidden>
|
<wa-visually-hidden>Personal Info</wa-visually-hidden>
|
||||||
</header>
|
</header>
|
||||||
<sl-input label="Name" style="margin-bottom: .5rem;"></sl-input>
|
<wa-input label="Name" style="margin-bottom: .5rem;"></wa-input>
|
||||||
<sl-input label="Email" type="email"></sl-input>
|
<wa-input label="Email" type="email"></wa-input>
|
||||||
</sl-card>
|
</wa-card>
|
||||||
```
|
```
|
||||||
|
|||||||
52
docs/pages/experimental/form-validation.md
Normal file
52
docs/pages/experimental/form-validation.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
meta:
|
||||||
|
title: Form Control Validation
|
||||||
|
description: TODO
|
||||||
|
---
|
||||||
|
|
||||||
|
# Form Control Validation
|
||||||
|
|
||||||
|
Adding the `wa-valid` or `wa-invalid` class to a form control will change its appearance. This is useful for applying validation styles to server-rendered form controls.
|
||||||
|
|
||||||
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;">
|
||||||
|
<div>
|
||||||
|
<h3>Valid</h3>
|
||||||
|
<wa-input class="wa-valid" label="Name" help-text="Just a first name is fine" placeholder="Enter your name"></wa-input><br>
|
||||||
|
<wa-select class="wa-valid" label="Choose one" help-text="Make a choice already">
|
||||||
|
<wa-option>There can be only one!</wa-option>
|
||||||
|
<wa-option>Well, maybe two is OK</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-textarea class="wa-valid" label="Bio" help-text="Tell us about yourself" placeholder="Enter a bio"></wa-textarea><br>
|
||||||
|
<wa-range class="wa-valid" value="50" label="Volume" help-text="Crank it up"></wa-range><br>
|
||||||
|
<wa-checkbox class="wa-valid" checked>I am awesome</wa-checkbox><br>
|
||||||
|
<wa-checkbox class="wa-valid">So am I</wa-checkbox><br><br>
|
||||||
|
<wa-switch class="wa-valid" checked>Still awesome</wa-switch><br>
|
||||||
|
<wa-switch class="wa-valid">More awesome</wa-switch><br><br>
|
||||||
|
<wa-radio-group class="wa-valid" label="Select an option" name="a" value="1">
|
||||||
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
|
</wa-radio-group><br>
|
||||||
|
<wa-button variant="brand">Submit Form</wa-button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Invalid</h3>
|
||||||
|
<wa-input class="wa-invalid" label="Name" help-text="Just a first name is fine" placeholder="Enter your name"></wa-input><br>
|
||||||
|
<wa-select class="wa-invalid" label="Choose one" help-text="Make a choice already">
|
||||||
|
<wa-option>There can be only one!</wa-option>
|
||||||
|
<wa-option>Well, maybe two is OK</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-textarea class="wa-invalid" label="Bio" help-text="Tell us about yourself" placeholder="Enter a bio"></wa-textarea><br>
|
||||||
|
<wa-range class="wa-invalid" value="50" label="Volume" help-text="Crank it up"></wa-range><br>
|
||||||
|
<wa-checkbox class="wa-invalid" checked>I am awesome</wa-checkbox><br>
|
||||||
|
<wa-checkbox class="wa-invalid">So am I</wa-checkbox><br><br>
|
||||||
|
<wa-switch class="wa-invalid" checked>Still awesome</wa-switch><br>
|
||||||
|
<wa-switch class="wa-invalid">More awesome</wa-switch><br><br>
|
||||||
|
<wa-radio-group class="wa-invalid" label="Select an option" name="a" value="1">
|
||||||
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
|
</wa-radio-group><br>
|
||||||
|
<wa-button variant="brand">Submit Form</wa-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
168
docs/pages/experimental/sandbox.md
Normal file
168
docs/pages/experimental/sandbox.md
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
---
|
||||||
|
meta:
|
||||||
|
title: Theming Sandbox
|
||||||
|
description: TODO
|
||||||
|
---
|
||||||
|
|
||||||
|
# Theming Sandbox
|
||||||
|
|
||||||
|
#### Card
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-card class="card-overview">
|
||||||
|
<img
|
||||||
|
slot="image"
|
||||||
|
src="https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80"
|
||||||
|
alt="A kitten sits patiently between a terracotta pot and decorative grasses."
|
||||||
|
/>
|
||||||
|
|
||||||
|
<strong>Mittens</strong><br />
|
||||||
|
This kitten is as cute as he is playful. Bring him home today!<br />
|
||||||
|
<small>6 weeks old</small>
|
||||||
|
|
||||||
|
<div slot="footer">
|
||||||
|
<wa-button variant="brand" pill>More Info</wa-button>
|
||||||
|
<wa-rating></wa-rating>
|
||||||
|
</div>
|
||||||
|
</wa-card>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.card-overview {
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-overview small {
|
||||||
|
color: var(--wa-color-text-quiet);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-overview [slot='footer'] {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Alerts
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-alert variant="brand" open>
|
||||||
|
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
|
||||||
|
<strong>This is super informative</strong><br />
|
||||||
|
You can tell by how pretty the alert is.
|
||||||
|
</wa-alert>
|
||||||
|
<br />
|
||||||
|
<wa-alert variant="success" open>
|
||||||
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
|
<strong>Your changes have been saved</strong><br />
|
||||||
|
You can safely exit the app now.
|
||||||
|
</wa-alert>
|
||||||
|
<br />
|
||||||
|
<wa-alert variant="neutral" open>
|
||||||
|
<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>
|
||||||
|
<strong>Your settings have been updated</strong><br />
|
||||||
|
Settings will take affect on next login.
|
||||||
|
</wa-alert>
|
||||||
|
<br />
|
||||||
|
<wa-alert variant="warning" open>
|
||||||
|
<wa-icon slot="icon" name="circle-exclamation" variant="solid"></wa-icon>
|
||||||
|
<strong>Your session has ended</strong><br />
|
||||||
|
Please login again to continue.
|
||||||
|
</wa-alert>
|
||||||
|
<br />
|
||||||
|
<wa-alert variant="danger" open>
|
||||||
|
<wa-icon slot="icon" name="triangle-exclamation" variant="solid"></wa-icon>
|
||||||
|
<strong>Your account has been deleted</strong><br />
|
||||||
|
We're very sorry to see you go!
|
||||||
|
</wa-alert>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Badges and Tags
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-badge variant="brand">Brand</wa-badge>
|
||||||
|
<wa-badge variant="success">Success</wa-badge>
|
||||||
|
<wa-badge variant="neutral">Neutral</wa-badge>
|
||||||
|
<wa-badge variant="warning">Warning</wa-badge>
|
||||||
|
<wa-badge variant="danger">Danger</wa-badge>
|
||||||
|
<br />
|
||||||
|
<wa-tag variant="brand">Brand</wa-tag>
|
||||||
|
<wa-tag variant="success">Success</wa-tag>
|
||||||
|
<wa-tag variant="neutral">Neutral</wa-tag>
|
||||||
|
<wa-tag variant="warning">Warning</wa-tag>
|
||||||
|
<wa-tag variant="danger">Danger</wa-tag>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Buttons
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-button variant="brand">Brand</wa-button>
|
||||||
|
<wa-button variant="success">Success</wa-button>
|
||||||
|
<wa-button variant="neutral">Neutral</wa-button>
|
||||||
|
<wa-button variant="warning">Warning</wa-button>
|
||||||
|
<wa-button variant="danger">Danger</wa-button>
|
||||||
|
<br /><br />
|
||||||
|
<wa-button variant="brand" outline>Brand</wa-button>
|
||||||
|
<wa-button variant="success" outline>Success</wa-button>
|
||||||
|
<wa-button variant="neutral" outline>Neutral</wa-button>
|
||||||
|
<wa-button variant="warning" outline>Warning</wa-button>
|
||||||
|
<wa-button variant="danger" outline>Danger</wa-button>
|
||||||
|
<br /><br />
|
||||||
|
<wa-button variant="text">Brand</wa-button>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Form controls
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-checkbox>Unchecked</wa-checkbox>
|
||||||
|
<br />
|
||||||
|
<wa-checkbox checked>Checked</wa-checkbox>
|
||||||
|
<br /><br />
|
||||||
|
<wa-radio-group label="Radio" name="a" value="1">
|
||||||
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
|
</wa-radio-group>
|
||||||
|
<br />
|
||||||
|
<wa-switch>Switch off</wa-switch>
|
||||||
|
<br />
|
||||||
|
<wa-switch checked>Switch on</wa-switch>
|
||||||
|
<br /><br />
|
||||||
|
<wa-input label="Label" help-text="Super helpful and/or contextual content" placeholder="Placeholder"></wa-input>
|
||||||
|
<br />
|
||||||
|
<wa-select label="Select">
|
||||||
|
<wa-option value="option-1">Option 1</wa-option>
|
||||||
|
<wa-option value="option-2">Option 2</wa-option>
|
||||||
|
<wa-option value="option-3">Option 3</wa-option>
|
||||||
|
<wa-option value="option-4">Option 4</wa-option>
|
||||||
|
<wa-option value="option-5">Option 5</wa-option>
|
||||||
|
<wa-option value="option-6">Option 6</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Progress
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<wa-progress-ring value="25" style="--indicator-width: 4px;"></wa-progress-ring>
|
||||||
|
<wa-progress-bar value="60"></wa-progress-bar>
|
||||||
|
<wa-spinner></wa-spinner>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Shadows
|
||||||
|
|
||||||
|
```html:preview
|
||||||
|
<style>
|
||||||
|
div.shadow {
|
||||||
|
border: 1px solid var(--wa-color-surface-border);
|
||||||
|
border-radius: var(--wa-corners-s);
|
||||||
|
display: inline-block;
|
||||||
|
height: 4rem;
|
||||||
|
margin-right: 2rem;
|
||||||
|
width: 4rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="shadow" style="box-shadow: var(--wa-shadow-inset);"></div>
|
||||||
|
<div class="shadow" style="box-shadow: var(--wa-shadow-level-1);"></div>
|
||||||
|
<div class="shadow" style="box-shadow: var(--wa-shadow-level-2);"></div>
|
||||||
|
<div class="shadow" style="box-shadow: var(--wa-shadow-level-3);"></div>
|
||||||
|
```
|
||||||
162
docs/pages/experimental/style-guide.md
Normal file
162
docs/pages/experimental/style-guide.md
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
---
|
||||||
|
meta:
|
||||||
|
title: Style Guide
|
||||||
|
description: TODO
|
||||||
|
---
|
||||||
|
|
||||||
|
# Style Guide
|
||||||
|
|
||||||
|
The styles shown below can be all yours by adding Web Awesome's applied stylesheet to your project.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Typography
|
||||||
|
|
||||||
|
Vel risus commodo viverra maecenas accumsan lacus vel facilisis volutpat. Amet mauris commodo quis imperdiet. Bibendum ut tristique et egestas quis ipsum suspendisse. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat.
|
||||||
|
|
||||||
|
Cras pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci. Scelerisque eleifend donec pretium vulputate sapien nec. Donec et odio pellentesque diam volutpat commodo sed egestas egestas. Mauris rhoncus aenean vel elit scelerisque mauris pellentesque.
|
||||||
|
|
||||||
|
> What is a Web year now, about three months? And when people can browse around, discover new things, and download them fast, when we all have agents - then Web years could slip by before human beings can notice.
|
||||||
|
>
|
||||||
|
> — Tim Berners-Lee
|
||||||
|
|
||||||
|
## Inline Text
|
||||||
|
|
||||||
|
<div class="docs-grid">
|
||||||
|
<p><strong>Bold</strong></p>
|
||||||
|
<p><em>Italics</em></p>
|
||||||
|
<p><u>Underline</u></p>
|
||||||
|
<p><del>Deleted</del></p>
|
||||||
|
<p><ins>Inserted</ins></p>
|
||||||
|
<p><s>Strike-through</s></p>
|
||||||
|
<p><small>Small</small></p>
|
||||||
|
<p><span>Text <sub>Sub</sub></span></p>
|
||||||
|
<p><span>Text <sup>Sup</sup></span></p>
|
||||||
|
<p><abbr title="Abbreviation">Abbr.</abbr></p>
|
||||||
|
<p><kbd>Keyboard</kbd></p>
|
||||||
|
<p><mark>Highlighted</mark></p>
|
||||||
|
<p><a href="#">Link text</a></p>
|
||||||
|
<p><code>Inline code</code></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Lists
|
||||||
|
|
||||||
|
- List item 1
|
||||||
|
- List item 2
|
||||||
|
- List item 3
|
||||||
|
- Subitem a
|
||||||
|
- Subitem b
|
||||||
|
|
||||||
|
1. List item 1
|
||||||
|
2. List item 2
|
||||||
|
3. List item 3
|
||||||
|
- Subitem a
|
||||||
|
- Subitem b
|
||||||
|
|
||||||
|
## Headings
|
||||||
|
|
||||||
|
### Heading 3
|
||||||
|
|
||||||
|
Feugiat nisl pretium fusce id. Ipsum dolor sit amet consectetur adipiscing elit. Eget nunc lobortis mattis aliquam faucibus purus. Metus dictum at tempor commodo ullamcorper a lacus vestibulum. Urna condimentum mattis pellentesque id nibh tortor id.
|
||||||
|
|
||||||
|
#### Heading 4
|
||||||
|
|
||||||
|
Gravida arcu ac tortor dignissim convallis aenean. Pellentesque pulvinar pellentesque habitant morbi tristique senectus et. Ipsum nunc aliquet bibendum enim facilisis gravida neque. Donec adipiscing tristique risus nec feugiat in.
|
||||||
|
|
||||||
|
##### Heading 5
|
||||||
|
|
||||||
|
Enim diam vulputate ut pharetra sit. Enim facilisis gravida neque convallis a cras. Enim neque volutpat ac tincidunt vitae semper. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium.
|
||||||
|
|
||||||
|
###### Heading 6
|
||||||
|
|
||||||
|
Tincidunt ornare massa eget egestas purus viverra accumsan in nisl. Facilisis mauris sit amet massa vitae. Nunc faucibus a pellentesque sit amet porttitor. Adipiscing tristique risus nec feugiat in fermentum.
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
Individual details look like this.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Tincidunt nunc pulvinar</summary>
|
||||||
|
<p>Ut lectus arcu bibendum at varius. Convallis a cras semper auctor neque vitae. Odio pellentesque diam volutpat commodo sed egestas. Amet dictum sit amet justo donec enim diam vulputate ut.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
Grouping them provides accordion-style functionality.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Enim diam</summary>
|
||||||
|
<p>Nunc faucibus a pellentesque sit amet porttitor. Adipiscing tristique risus nec feugiat in fermentum. Leo duis ut diam quam nulla porttitor massa id. Mauris nunc congue nisi vitae.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Arcu non odio</summary>
|
||||||
|
<p>Sed libero enim sed faucibus turpis in eu mi bibendum. Nunc mi ipsum faucibus vitae aliquet nec. Ultricies tristique nulla aliquet enim tortor. Tellus at urna condimentum mattis pellentesque.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Ut porttitor</summary>
|
||||||
|
<p>Eu facilisis sed odio morbi quis commodo odio aenean sed. Sit amet purus gravida quis blandit turpis cursus. Eu consequat ac felis donec et odio pellentesque diam volutpat.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Code Blocks
|
||||||
|
|
||||||
|
```
|
||||||
|
// do a thing
|
||||||
|
export function thing() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Images
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Tables
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<caption>I'm just a table</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Column 1</th>
|
||||||
|
<th>Column 2</th>
|
||||||
|
<th>Column 3</th>
|
||||||
|
<th>Column 4</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
## Definition Lists
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Definition 1</dt>
|
||||||
|
<dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd>
|
||||||
|
<dt>Definition 2</dt>
|
||||||
|
<dd>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</dd>
|
||||||
|
<dt>Definition 3</dt>
|
||||||
|
<dd>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</dd>
|
||||||
|
</dl>
|
||||||
546
docs/pages/experimental/themer.md
Normal file
546
docs/pages/experimental/themer.md
Normal file
@@ -0,0 +1,546 @@
|
|||||||
|
---
|
||||||
|
meta:
|
||||||
|
title: Themer
|
||||||
|
description: TODO
|
||||||
|
toc: false
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- Knobs -->
|
||||||
|
<div id="knobs">
|
||||||
|
<div class="space-vertically">
|
||||||
|
<a href="/">{% include 'logo.njk' %}</a>
|
||||||
|
<wa-select name="theme" label="Theme" value="default">
|
||||||
|
<wa-option value="default">Default</wa-option>
|
||||||
|
<wa-option value="classic">Classic</wa-option>
|
||||||
|
<wa-option value="glassy">Glassy</wa-option>
|
||||||
|
<wa-option value="mellow">Mellow</wa-option>
|
||||||
|
<wa-option value="playful">Playful</wa-option>
|
||||||
|
<wa-option value="chic">Chic</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-select name="heading-text" label="Heading" value="">
|
||||||
|
<wa-option value="">Theme default</wa-option>
|
||||||
|
<wa-option value="serif">Serif</wa-option>
|
||||||
|
<wa-option value="sans-serif">Sans-serif</wa-option>
|
||||||
|
<wa-option value="monospace">Monospace</wa-option>
|
||||||
|
<wa-option value="cursive">Cursive</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-select name="body-text" label="Body" value="">
|
||||||
|
<wa-option value="">Theme default</wa-option>
|
||||||
|
<wa-option value="serif">Serif</wa-option>
|
||||||
|
<wa-option value="sans-serif">Sans-serif</wa-option>
|
||||||
|
<wa-option value="monospace">Monospace</wa-option>
|
||||||
|
<wa-option value="cursive">Cursive</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-select name="border-style" label="Border Style" value="solid">
|
||||||
|
<wa-option value="solid">Solid</wa-option>
|
||||||
|
<wa-option value="dashed">Dashed</wa-option>
|
||||||
|
<wa-option value="dotted">Dotted</wa-option>
|
||||||
|
<wa-option value="double">Double</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-range name="border-width" label="Border Width" min="1" max="5" value="1" step="1" tooltip="none"></wa-range>
|
||||||
|
<wa-range name="spacing" label="Spacing" min=".5" max="1.5" value="1" step="0.125" tooltip="none"></wa-range>
|
||||||
|
<wa-range name="corners" label="Corners" min="0" max="1.5" value=".25" step=".125" tooltip="none"></wa-range>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const container = document.getElementById('knobs');
|
||||||
|
const themeStylesheet = document.getElementById('theme-stylesheet');
|
||||||
|
|
||||||
|
// Theme
|
||||||
|
container.querySelector('[name="theme"]').addEventListener('wa-change', event => {
|
||||||
|
themeStylesheet.href = `/dist/themes/${event.target.value}.css`;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Heading text
|
||||||
|
container.querySelector('[name="heading-text"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-font-family-heading', event.target.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Body text
|
||||||
|
container.querySelector('[name="body-text"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-font-family-body', event.target.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Corners
|
||||||
|
container.querySelector('[name="corners"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-corners-base', `${event.target.value}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Border width
|
||||||
|
container.querySelector('[name="border-width"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-border-width-base', `${event.target.value / 16}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Border style
|
||||||
|
container.querySelector('[name="border-style"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-border-style', event.target.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spacing style
|
||||||
|
container.querySelector('[name="spacing"]').addEventListener('wa-input', event => {
|
||||||
|
document.documentElement.style.setProperty('--wa-space-base', `${event.target.value}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--knobs-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#knobs {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 10;
|
||||||
|
top: 2rem;
|
||||||
|
left: 2rem;
|
||||||
|
background: var(--wa-color-surface-default);
|
||||||
|
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-border);
|
||||||
|
border-radius: var(--wa-corners-m);
|
||||||
|
box-shadow: var(--wa-shadow-level-2);
|
||||||
|
width: var(--knobs-width);
|
||||||
|
padding: 2rem;
|
||||||
|
margin-inline: auto;
|
||||||
|
margin-block: 0 4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#knobs p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Preview -->
|
||||||
|
<div class="preview-container">
|
||||||
|
<section class="overlap">
|
||||||
|
<h1>Make it Awesome</h1>
|
||||||
|
<wa-card>
|
||||||
|
<div class="grid">
|
||||||
|
<svg class="image" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="linear-gradient" x1="100" y1="166.04" x2="100" y2="0" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" class="gradient-start" stop-color="#f78ca8"/>
|
||||||
|
<stop offset="1" class="gradient-stop" stop-color="#9556d9"/>
|
||||||
|
</linearGradient>
|
||||||
|
<style>
|
||||||
|
.cls-4{stroke-width:0;fill:#3c2358}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<g id="bespin">
|
||||||
|
<path id="sky" d="M171.75 15.52c1.99-.3 3.87 0 5.6 1.07.31.2.45.15.65-.16 2.11-3.3 5.04-5.48 8.91-6.23 4.78-.93 8.95.38 12.48 3.73.2.19.41.37.61.56 0-4.67 0-9.34.01-14.01-.01-.39-.1-.48-.49-.48C133.02.01 66.51 0 0 0v78.43c.31.03.46.29.66.46 6.02 5.38 9.65 12.05 10.81 20.05.12.82.19 1.65.24 2.48.7-.3 1.27-.82 1.93-1.2 2.12-1.21 4.37-1.99 6.82-2.23 4.52-.44 8.61.69 12.21 3.44 3.69 2.82 5.9 6.56 6.6 11.17.15.99.21 2 .2 3 0 .26.02.46.32.57 2.14.78 4 1.98 5.6 3.61.04.04.08.06.13.09.11.11.21.22.32.32.66.84 1.33 1.68 1.87 2.62 1.63 2.87 2.34 5.93 2.03 9.23-.09.92-.33 1.8-.46 2.71v.22c1.01-.42 2.01-.84 3.08-1.11 2.26-.59 4.54-.71 6.85-.37 2.95.43 5.62 1.53 7.96 3.35 3.66 2.85 5.9 6.57 6.59 11.18.15.99.21 2 .2 3 0 .26.02.46.32.57 2.14.78 4 1.98 5.59 3.61.04.04.08.06.13.09l.32.32c.66.84 1.33 1.68 1.87 2.62 1.3 2.27 2.03 4.7 2.09 7.32.01.56.01.57.48.29 3.5-2.11 7.27-3.5 11.3-4.15 1.49-.24 2.99-.38 4.5-.34.5.01.55-.14.39-.55-.73-1.9-1.02-3.88-.94-5.91.14-3.46 1.33-6.53 3.52-9.2 1.73-2.12 3.9-3.62 6.44-4.61.22-.09.36-.17.35-.43-.04-1.69.17-3.35.54-5-3.53-.63-7.06-1.27-10.59-1.89-4.64-.82-9.29-1.63-13.93-2.45-4.27-.75-8.53-1.51-12.8-2.26-.72-.13-.72-.12-.72-.85v-2.5c0-.26.07-.45.24-.65a52.26 52.26 0 0 1 15.31-11.92c.83-.43 1.69-.82 2.52-1.25.21-.11.42-.12.65-.12 1.35 0 2.71-.03 4.06.01.62.02 1.14-.16 1.65-.45 1.73-.99 3.47-1.96 5.26-2.83 3.11-1.52 6.4-2.45 9.83-2.87.32-.04.41-.17.4-.46v-2.71c0-.29.08-.4.38-.39 1.18.01 2.36.01 3.54 0 .29 0 .35.11.34.36-.01.75 0 1.49-.01 2.24 0 .32.05.45.42.44 1.06-.04.95.1.95-.96 0-1.42.01-2.85 0-4.27 0-.36.09-.48.46-.47.87.03 1.74.02 2.6 0 .36 0 .58.06.51.48-.06.36.09.5.46.47.33-.03.66.01.99 0 .32-.02.42.09.42.41-.02 1.21.01 2.43-.02 3.64 0 .4.12.54.5.48.1-.02.21-.01.31 0 .43.05.58-.12.57-.56-.02-1.96 0-3.92-.02-5.88 0-.43.11-.56.55-.55 1.08.03 2.15.03 3.23 0 .38 0 .5.09.49.48-.01 2.1 0 4.2 0 6.3.02.03.05.05.07.08q1.26.08 1.26-1.13c0-.69.02-1.39 0-2.08-.01-.35.11-.44.44-.43 1.68.02 3.37.02 5.05 0 .36 0 .48.09.47.46-.03.97 0 1.94-.01 2.91 0 .62.48.44.8.5.37.07.57-.06.56-.5-.02-1.65 0-3.3-.02-4.94 0-.37.07-.53.48-.5.55.04 1.11.03 1.66 0 .35-.02.44.1.44.44-.01 1.68 0 3.37-.02 5.05 0 .45.1.59.56.59.8 0 .8.03.8-.79v-1.56c0-.25.09-.34.33-.33.73 0 1.46.01 2.19 0 .32 0 .37.15.37.42v2.24c0 .29.06.43.4.44.41 0 .82.11 1.22.17.13-.28.41-.36.65-.49 2.41-1.34 4.98-2.17 7.73-2.42.61-.05 1.21-.08 1.82-.08.63 0 .7-.04.72-.72.04-1.01.18-2 .4-2.98.73-3.42 2.19-6.49 4.48-9.15 2.94-3.42 6.6-5.63 11.05-6.43 4.65-.83 9 .04 13.01 2.53 2.81 1.74 5.01 4.09 6.64 6.96.19.33.33.46.71.2 1.89-1.34 4.03-1.88 6.32-1.86V48.36H167.6a11.05 11.05 0 0 1-10.92-9.3c-.87-5.46 2.69-10.87 8.09-12.24.49-.12.63-.24.45-.78-1.54-4.7 1.62-9.76 6.52-10.5ZM61.4 62c-2.25 2.53-5.1 3.74-8.48 3.74-10.4 0-20.8-.01-31.19 0-3.73 0-6.89-1.3-9.42-4.03-1.78-1.92-2.83-4.2-3.15-6.83-.39-3.28.46-6.21 2.37-8.88.27-.38.67-.66.88-1.09l.53-.53c.97-.79 1.93-1.62 3.11-2.06.89-.33 1.35-.75 1.32-1.79-.03-1.58.32-3.14.95-4.6 2.02-4.69 5.5-7.65 10.57-8.42 5.92-.9 10.54 1.37 13.85 6.32.18.27.3.34.61.16 4.59-2.69 10.17-.74 12.06 4.23.66 1.75.66 3.53.06 5.29-.13.39-.06.52.34.63 4.51 1.28 7.33 4.21 8.18 8.82.62 3.38-.3 6.44-2.6 9.02Z" stroke-width="0" fill="url(#linear-gradient)"/>
|
||||||
|
<path id="city" class="cls-4" d="M179.31 119.35a51.77 51.77 0 0 0-11.3-7.13c-.48-.22-.93-.48-1.52-.47-1.44.04-2.88.01-4.32.02-.25 0-.47-.04-.7-.16-1.47-.81-2.95-1.61-4.42-2.41-3.32-1.8-6.85-2.99-10.59-3.5-.41-.06-.81-.16-1.22-.17-.34 0-.41-.14-.4-.44.01-.75 0-1.49 0-2.24 0-.27-.05-.42-.37-.42-.73.02-1.46.01-2.19 0-.25 0-.34.09-.33.33.01.52 0 1.04 0 1.56 0 .82 0 .79-.8.79-.47 0-.57-.15-.56-.59.03-1.68 0-3.37.02-5.05 0-.34-.09-.46-.44-.44-.55.03-1.11.03-1.66 0-.41-.03-.49.13-.48.5.02 1.65 0 3.3.02 4.94 0 .44-.19.57-.56.5-.32-.06-.81.12-.8-.5.01-.97-.01-1.94.01-2.91 0-.37-.11-.46-.47-.46-1.68.02-3.37.02-5.05 0-.33 0-.46.09-.44.43.03.69 0 1.39 0 2.08q0 1.22-1.26 1.13s-.05-.05-.07-.08c0-2.1-.02-4.2 0-6.3 0-.4-.11-.49-.49-.48-1.08.03-2.15.03-3.23 0-.43-.01-.55.11-.55.55.02 1.96 0 3.92.02 5.88 0 .44-.15.61-.57.56-.1-.01-.21-.02-.31 0-.38.06-.51-.08-.5-.48.03-1.21 0-2.43.02-3.64 0-.32-.1-.43-.42-.41-.33.02-.66-.02-.99 0-.37.03-.52-.11-.46-.47.07-.42-.15-.48-.51-.48-.87.02-1.74.02-2.6 0-.37-.01-.47.11-.46.47.02 1.42 0 2.85 0 4.27 0 1.06.11.92-.95.96-.37.01-.43-.12-.42-.44.02-.75 0-1.49.01-2.24 0-.26-.06-.37-.34-.36-1.18.01-2.36.01-3.54 0-.3 0-.38.1-.38.39.01.9 0 1.8 0 2.71 0 .29-.08.42-.4.46-3.43.42-6.72 1.35-9.83 2.87-1.79.87-3.53 1.84-5.26 2.83-.51.29-1.03.48-1.65.45-1.35-.05-2.71-.01-4.06-.01-.22 0-.44.01-.65.12-.84.43-1.69.82-2.52 1.25a52.39 52.39 0 0 0-15.31 11.92c-.18.2-.25.39-.24.65.01.83 0 1.67 0 2.5 0 .73 0 .72.72.85 4.27.75 8.53 1.51 12.8 2.26 4.64.82 9.29 1.63 13.93 2.45l10.59 1.89c.89.15 1.77.31 2.66.46.53.09 1.02.19 1.49.52 3.96 2.84 7.93 5.66 11.9 8.48.33.24.46.48.46.89-.01 6.16 0 12.32 0 18.49 1.19-.05 2.38.05 3.56.07 0-.66.02-1.32.02-1.98v-16.66c0-.36.09-.59.4-.81 3.96-2.8 7.92-5.61 11.86-8.45.68-.49 1.45-.52 2.21-.66 4.02-.72 8.05-1.42 12.08-2.13.12-.19.24-.38.35-.57 2.78-4.5 6.79-7.02 12.07-7.48 2.11-.18 4.13.21 6.1.91.39.14.5.09.58-.33.28-1.36.75-2.66 1.31-3.93.46-1.03 1.07-1.97 1.61-2.96-.07-.05-.15-.09-.22-.14Z"/>
|
||||||
|
<path id="forefront_clouds" data-name="forefront clouds" d="M0 78.44c.31.03.46.29.66.46 6.02 5.38 9.65 12.05 10.81 20.05.12.82.19 1.65.24 2.48.08 1.35.06 2.7-.02 4.05-.2 3.44-.96 6.75-2.23 9.96-.65 1.65-1.45 3.23-2.36 4.75-.28.47-.26.49.27.54.47.04.93.08 1.39.17 4.47.86 7.92 3.23 10.33 7.08 1.51 2.41 2.21 5.08 2.23 7.91 0 1.73-.35 3.41-.96 5.03-.13.36-.1.49.31.58 4.47 1.04 8.2 3.32 11.16 6.83 2.86 3.39 4.42 7.32 4.69 11.72.21 3.46-.46 6.77-1.99 9.89-.25.51-.18.77.24 1.12 2.2 1.82 4.02 3.97 5.46 6.43.23.39.38.36.7.14 3.29-2.16 6.92-2.9 10.74-2.16 6.1 1.18 10.12 4.82 12.04 10.74.18.55.17.55.65.19 1.39-1.07 2.85-2.04 4.4-2.87 5.52-2.95 11.39-4.27 17.65-3.87 2.72.17 5.37.67 7.95 1.5a31.63 31.63 0 0 1 8.88 4.5c.46.33.51.31.6-.16 1.16-6.42 4.3-11.66 9.42-15.69 3.29-2.59 7.03-4.22 11.16-4.95.97-.17 1.96-.22 2.93-.38 1.19-.05 2.38.05 3.56.07 5.54.48 10.39 2.61 14.66 6.27.13-1.32.2-2.53.43-3.73 1.46-7.48 5.45-13.2 11.93-17.2.39-.24.46-.36.19-.76-2.18-3.3-2.78-6.93-2.15-10.8.25-1.57.82-3.04 1.5-4.47.12-.19.24-.38.35-.57 2.78-4.5 6.79-7.02 12.07-7.48 2.11-.18 4.13.21 6.1.91.39.14.5.09.58-.33.28-1.36.75-2.66 1.31-3.93.46-1.03 1.07-1.97 1.61-2.96.08-.09.17-.17.24-.27 1.04-1.51 2.28-2.84 3.68-4.01 3.67-3.05 7.89-4.61 12.66-4.71 1.31-.03 2.59.17 3.88.32v88.68c0 .37-.05.49-.47.49-66.36-.01-132.71-.01-199.07 0-.42 0-.46-.13-.46-.5V78.43Z" fill="#f9b4d9" stroke-width="0"/>
|
||||||
|
<path id="upper_clouds" data-name="upper clouds" d="M199.99 48.34H167.6a11.05 11.05 0 0 1-10.92-9.3c-.87-5.46 2.69-10.87 8.09-12.24.49-.12.63-.24.45-.78-1.54-4.7 1.62-9.76 6.52-10.5 1.99-.3 3.87 0 5.6 1.07.31.2.45.15.65-.16 2.11-3.3 5.04-5.48 8.91-6.23 4.78-.93 8.95.38 12.48 3.73.2.19.41.37.61.56v33.85ZM12.41 44.92c-.21.43-.61.71-.88 1.09-1.91 2.66-2.76 5.59-2.37 8.88.31 2.63 1.37 4.91 3.15 6.83 2.53 2.73 5.68 4.04 9.42 4.03 10.4-.02 20.8 0 31.19 0 3.38 0 6.23-1.2 8.48-3.74 2.3-2.59 3.22-5.64 2.6-9.02-.85-4.61-3.68-7.53-8.18-8.82-.4-.11-.48-.24-.34-.63.6-1.77.6-3.55-.06-5.29-1.89-4.96-7.46-6.91-12.06-4.23-.31.18-.43.11-.61-.16-3.32-4.95-7.93-7.22-13.85-6.32-5.07.77-8.55 3.72-10.57 8.42-.63 1.47-.98 3.02-.95 4.6.02 1.05-.43 1.46-1.32 1.79-1.18.44-2.14 1.27-3.11 2.06l-.53.53Z" fill="#eeb6e5" stroke-width="0"/>
|
||||||
|
<path id="background_clouds" data-name="background clouds" d="M199.99 110.83c-1.29-.15-2.57-.34-3.88-.32-4.77.09-8.99 1.66-12.66 4.71-1.41 1.17-2.64 2.5-3.68 4.01-.07.1-.16.18-.24.27-.07-.05-.15-.09-.22-.14a51.77 51.77 0 0 0-11.3-7.13c-.48-.22-.93-.48-1.52-.47-1.44.04-2.88.01-4.32.02-.25 0-.47-.04-.7-.16-1.47-.81-2.95-1.61-4.42-2.41-3.32-1.8-6.85-2.99-10.59-3.5.13-.28.41-.36.65-.49 2.41-1.34 4.98-2.17 7.73-2.42.61-.05 1.21-.08 1.82-.08.63 0 .7-.04.72-.72.04-1.01.18-2 .4-2.98.73-3.42 2.19-6.49 4.48-9.15 2.94-3.42 6.6-5.63 11.05-6.43 4.65-.83 9 .04 13.01 2.53 2.81 1.74 5.01 4.09 6.64 6.96.19.33.33.46.71.2 1.89-1.34 4.03-1.88 6.32-1.86v19.58Zm-72.62 35.16c0-.41-.12-.65-.46-.89-3.98-2.81-7.95-5.63-11.9-8.48-.47-.34-.96-.44-1.49-.52-.89-.15-1.77-.3-2.66-.46-.37 1.65-.58 3.31-.54 5 0 .26-.13.35-.35.43-2.54.98-4.71 2.49-6.44 4.61-2.19 2.68-3.39 5.74-3.52 9.2-.08 2.03.2 4.01.94 5.91.16.42.11.56-.39.55-1.51-.04-3.01.1-4.5.34-4.03.65-7.8 2.04-11.3 4.15-.47.28-.46.28-.48-.29-.07-2.62-.79-5.05-2.09-7.32-.54-.94-1.21-1.78-1.87-2.62-.11-.11-.21-.22-.32-.32-.04-.03-.09-.05-.13-.09a14.968 14.968 0 0 0-5.59-3.61c-.3-.11-.32-.31-.32-.57.02-1.01-.05-2.01-.2-3-.7-4.61-2.93-8.33-6.59-11.18-2.35-1.83-5.02-2.92-7.96-3.35-2.31-.34-4.59-.21-6.85.37-1.06.28-2.07.69-3.08 1.11-.1-.07-.07-.15 0-.22.13-.91.37-1.79.46-2.71.31-3.31-.39-6.36-2.03-9.23-.53-.94-1.2-1.77-1.87-2.62-.11-.11-.21-.22-.32-.32-.04-.03-.09-.05-.13-.09a14.926 14.926 0 0 0-5.6-3.61c-.3-.11-.32-.31-.32-.57.02-1.01-.05-2.01-.2-3-.7-4.61-2.91-8.35-6.6-11.17-3.6-2.75-7.69-3.88-12.21-3.44-2.44.24-4.69 1.02-6.82 2.23-.66.38-1.23.89-1.93 1.2.08 1.35.06 2.7-.02 4.05-.2 3.44-.96 6.75-2.23 9.96-.65 1.65-1.45 3.23-2.36 4.75-.28.47-.26.49.27.54.47.04.93.08 1.39.17 4.47.86 7.92 3.23 10.33 7.08 1.51 2.41 2.21 5.08 2.23 7.91 0 1.73-.35 3.41-.96 5.03-.13.36-.1.49.31.58 4.47 1.04 8.2 3.32 11.16 6.83 2.86 3.39 4.42 7.32 4.69 11.72.21 3.46-.46 6.77-1.99 9.89-.25.51-.18.77.24 1.12 2.2 1.82 4.02 3.97 5.46 6.43.23.39.38.36.7.14 3.29-2.16 6.92-2.9 10.74-2.16 6.1 1.18 10.12 4.82 12.04 10.74.18.55.17.55.65.19 1.39-1.07 2.85-2.04 4.4-2.87 5.52-2.95 11.39-4.27 17.65-3.87 2.72.17 5.37.67 7.95 1.5a31.63 31.63 0 0 1 8.88 4.5c.46.33.51.31.6-.16 1.16-6.42 4.3-11.66 9.42-15.69 3.29-2.59 7.03-4.22 11.16-4.95.97-.17 1.96-.22 2.93-.38v-18.49Zm18.22 24.82c.13-1.32.2-2.53.43-3.73 1.46-7.48 5.45-13.2 11.93-17.2.39-.24.46-.36.19-.76-2.18-3.3-2.78-6.93-2.15-10.8.25-1.57.82-3.04 1.51-4.47-4.03.71-8.06 1.41-12.08 2.13-.75.14-1.52.17-2.21.66-3.94 2.84-7.9 5.65-11.86 8.45-.31.22-.4.45-.4.81.01 5.55 0 11.11 0 16.66 0 .66-.01 1.32-.02 1.98 5.54.48 10.39 2.61 14.66 6.27Z" fill="#fddce4" stroke-width="0"/>
|
||||||
|
<path id="fighters" d="m105.65 67.02-.66-2.46c-.59-2.23-1.19-4.46-1.78-6.68-.09-.35-.23-.66-.62-.77-.71-.19-1.18.32-1.01 1.11.16.73.38 1.44.57 2.16q.39 1.49-1.18 1.51c-.29 0-.53-.02-.74-.27-2.08-2.35-6.01-1.53-6.96 1.49-.21.67-.52 1.09-1.16 1.31-.15.05-.29.13-.42.21-.34.22-.47.08-.56-.27-.25-1.01-.54-2.01-.8-3.02-.17-.64-.59-.94-1.12-.79-.45.13-.65.6-.49 1.2.38 1.43.76 2.85 1.14 4.27.44 1.64.87 3.28 1.31 4.93.09.35.24.67.6.8.29.1.59.07.83-.15.25-.23.33-.51.24-.85-.29-1.05-.57-2.11-.84-3.17-.04-.15-.22-.39.08-.48.52-.17 1.07-.1 1.6-.11.31 0 .42.29.6.46 2.12 2.06 5.82 1.26 6.75-1.52.27-.8.68-1.27 1.42-1.53.08-.03.16-.07.23-.11.34-.23.49-.14.59.27.25 1.04.54 2.08.83 3.12.15.53.49.74.96.68.41-.06.67-.4.67-.94-.01-.07-.04-.22-.08-.37Zm-6.83-4.35c.3 0 .48.3.5.56.03.33-.34.19-.44.31-.28 0-.45-.09-.43-.32.02-.24.12-.54.37-.55Zm-1.4-.71c.2.07.55-.06.51.27-.03.23-.14.57-.5.56-.36 0-.35-.34-.39-.58-.06-.34.23-.19.37-.26Zm-2.73 2.19c.06-.17-.01-.49.31-.44.23.04.51.16.51.49 0 .37-.32.36-.56.38-.28.03-.26-.21-.26-.42Zm1.23 1.52c-.02.24-.13.46-.37.58-.29-.13-.51-.34-.51-.62 0-.3.32-.26.52-.29.23-.03.38.11.36.34Zm.07-2.47c-.25-.01-.51-.14-.62-.39-.05-.12.49-.58.64-.54.28.07.2.36.31.53.01.25-.13.41-.32.4Zm.98 3.77c-.13-.17-.6.09-.54-.33.03-.22.15-.58.51-.56.42.02.4.38.43.66.03.25-.19.24-.4.23Zm.2-1.74a.8.8 0 0 1-.81-.78c0-.43.4-.85.82-.85.43 0 .84.42.83.83-.02.47-.37.8-.85.79Zm1.22 1.38c-.32-.01-.3-.38-.32-.61-.02-.21.2-.34.39-.3.22.05.43.19.58.38-.18.27-.38.54-.65.53Zm1-1.43c-.25 0-.51-.16-.53-.48-.02-.37.31-.33.52-.38.29-.07.3.14.3.38-.05.17.02.49-.29.48Zm41.06 1.2c-.52-.13-.91.16-1.07.78-.28 1.04-.56 2.08-.83 3.12-.08.3-.2.37-.47.23-.35-.19-.71-.37-1.07-.54-.28-.13-.4-.32-.47-.63-.22-.96-.68-1.79-1.49-2.37-1.84-1.33-4.08-1.13-5.66.5-.14.14-.26.27-.48.26-.4-.02-.8-.01-1.2-.02-.4-.01-.54-.18-.41-.6.29-1 .55-2.01.82-3.01.15-.59-.04-1.03-.48-1.15-.55-.15-.95.09-1.12.71-.84 3.13-1.68 6.27-2.51 9.4-.15.56.09 1.01.55 1.12.5.11.91-.16 1.07-.74.21-.79.41-1.58.64-2.36.33-1.16.33-1.15 1.46-.63.36.17.62.36.73.79.47 1.94 2.06 3.16 4.08 3.17 1.22.07 2.21-.47 3.07-1.32.14-.14.26-.27.48-.26.43.02.86 0 1.3.07.4.05.42.21.33.55-.29 1.02-.56 2.04-.81 3.07-.14.58.08.98.51 1.1.52.13.94-.11 1.09-.69.84-3.11 1.67-6.23 2.5-9.35.16-.61-.07-1.06-.54-1.18Zm-8.08 1.37c.16-.04.32 0 .29.25-.11.23-.01.64-.45.63-.34-.01-.48-.37-.47-.59.01-.33.4-.22.63-.29Zm-2.02 1.31c.04-.27.22-.58.52-.57.25 0 .34.33.36.56.01.27-.19.34-.45.31-.15-.08-.47-.02-.43-.31Zm-.35 1.49c.01-.21-.02-.46.27-.4.22.04.56 0 .55.38 0 .32-.26.46-.51.48-.32.03-.26-.29-.31-.46Zm1.33 1.9c-.29 0-.59-.24-.63-.52-.03-.24.3-.36.53-.4.21-.04.39.1.42.37-.13.16.01.55-.32.55Zm1.34.36c-.22 0-.41-.03-.35-.28.07-.25.04-.61.42-.61.37 0 .51.37.51.61 0 .32-.4.19-.58.28Zm-.22-1.75c-.44-.02-.79-.37-.78-.8 0-.43.43-.84.85-.82.43.01.83.44.8.86-.03.47-.39.78-.87.77Zm.92-2.38c.03-.21 0-.58.31-.56.26.01.49.24.64.5-.1.25-.33.36-.56.41-.24.05-.43-.11-.39-.35Zm1.26 2.83c-.05.27-.25.59-.51.58-.24 0-.37-.36-.4-.6-.03-.24.21-.32.47-.32.15.1.51 0 .45.34Zm.06-1.09c-.22-.04-.52-.03-.52-.37 0-.34.27-.5.54-.5.29 0 .24.31.28.47 0 .25-.03.45-.3.4Z" fill="#78206a" stroke-width="0"/>
|
||||||
|
<path id="falcon" class="cls-4" d="M55.44 150.43c-2.18.04-3.97 1-5.51 2.46-.38.36-.74.65-1.3.54-.15-.03-.27.04-.39.11-.75.43-1.51.84-2.24 1.31-.58.37-1.07 1.2-.55 2.06.15.26.63.36.48.73-.12.29-.39.52-.6.78-.13.16-.26.33-.39.49-1.22 1.46-1.16 1.37-.19 3.01.29.5.51.56 1.02.27.92-.52 1.83-1.06 2.75-1.58q1.13-.65 1.76.47c.32.57.28.76-.29 1.09-1.06.62-2.13 1.24-3.2 1.84-.42.23-.52.52-.26.93.16.25.3.51.44.76.45.77.68.87 1.57.73l5.24-.81c1.51-.23 3.02-.41 4.43-1.05 2.93-1.33 4.49-3.58 4.63-6.25.01-4.64-3.31-7.94-7.39-7.87Zm1.74 2.26c.32 0 .45.22.48.51-.03.29-.17.51-.48.5-.31 0-.54-.17-.53-.51 0-.33.2-.51.53-.5Zm-1.59 7.62c-1.44 0-2.67-1.18-2.67-2.56 0-1.19 1.08-2.74 2.63-2.55 1.34-.25 2.62 1.11 2.62 2.47 0 1.46-1.14 2.64-2.58 2.64Zm3.51-4.96c.02-.28.19-.49.51-.47.33.02.51.19.5.53-.01.34-.27.44-.5.54-.34-.1-.53-.3-.51-.6Zm1.16 3.76c-.28-.02-.49-.18-.49-.5 0-.33.2-.49.51-.52.33.02.5.2.5.5 0 .32-.18.53-.51.51Zm-3.14-1.42c0 .88-.67 1.57-1.52 1.58-.88 0-1.64-.71-1.64-1.53 0-.84.75-1.58 1.6-1.59.86 0 1.56.68 1.56 1.54Z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<div class="content">
|
||||||
|
<h2>Here's a heading</h2>
|
||||||
|
<p>
|
||||||
|
This paragraph is a preview of your body text. We've put enough text
|
||||||
|
here to give you a sense of your theme's line length and line height.
|
||||||
|
Adjust your theme's spacing and size to get the fabulous reading
|
||||||
|
experience that you deserve. It's on us - cheers!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<wa-button variant="brand">Action</wa-button>
|
||||||
|
<wa-button variant="text">Low emphasis action →</wa-button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</wa-card>
|
||||||
|
<div class="cards">
|
||||||
|
<wa-card>
|
||||||
|
<div class="space-vertically">
|
||||||
|
<wa-alert variant="success" open>
|
||||||
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
|
This is the way.
|
||||||
|
</wa-alert>
|
||||||
|
<wa-select label="Signet" help-text="This identifies your clan. You can change this later.">
|
||||||
|
<wa-option>Mudhorn</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-checkbox checked>I swear on my name and the names of the ancestors</wa-checkbox>
|
||||||
|
<wa-button variant="success">Forge</wa-button>
|
||||||
|
</div>
|
||||||
|
</wa-card>
|
||||||
|
<wa-card>
|
||||||
|
<div class="space-vertically">
|
||||||
|
<wa-alert variant="warning" open>
|
||||||
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
|
It's a trap!
|
||||||
|
</wa-alert>
|
||||||
|
<wa-radio-group label="Faction" value="2">
|
||||||
|
<wa-radio value="1">Galactic Empire</wa-radio>
|
||||||
|
<wa-radio value="2">Rebel Alliance</wa-radio>
|
||||||
|
</wa-radio-group>
|
||||||
|
<wa-input label="Mission" value="Destroy the Death Star"></wa-input>
|
||||||
|
<wa-button variant="warning">Proceed</wa-button>
|
||||||
|
</div>
|
||||||
|
</wa-card>
|
||||||
|
<wa-card>
|
||||||
|
<div class="space-vertically">
|
||||||
|
<wa-alert variant="danger" open>
|
||||||
|
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
|
||||||
|
That's no moon.
|
||||||
|
</wa-alert>
|
||||||
|
<wa-input label="Destination" value="Alderaan"></wa-input>
|
||||||
|
<wa-switch checked>Jam fighter transmission</wa-switch>
|
||||||
|
<wa-switch disabled>Lock in artillery power</wa-switch>
|
||||||
|
<wa-button variant="danger">Turn around</wa-button>
|
||||||
|
</div>
|
||||||
|
</wa-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
background: white;
|
||||||
|
background-image: radial-gradient(rgb(0 0 0 / .1) 1.5px, transparent 0);
|
||||||
|
background-size: 28px 28px;
|
||||||
|
background-position: -19px -19px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu-toggle,
|
||||||
|
#sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
max-width: 1024px;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-container {
|
||||||
|
background: var(--wa-color-surface-lowered);
|
||||||
|
padding-inline: var(--wa-space-2xl);
|
||||||
|
padding-block-end: var(--wa-space-2xl);
|
||||||
|
translate: calc((var(--knobs-width) + 2rem) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap {
|
||||||
|
position: relative;
|
||||||
|
color: var(--wa-color-text-normal);
|
||||||
|
padding: 0 var(--wa-space-m);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: calc(-1 * var(--wa-space-2xl));
|
||||||
|
left: calc(-1 * var(--wa-space-2xl));
|
||||||
|
width: calc(100% + var(--wa-space-2xl) * 2);
|
||||||
|
height: 300px;
|
||||||
|
background: var(--wa-color-brand-spot);
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap h1 {
|
||||||
|
color: var(--wa-color-brand-text-on-spot);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 2fr 3fr;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--wa-space-xl);
|
||||||
|
padding: var(--wa-space-m);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
border-radius: var(--wa-corners-m);
|
||||||
|
align-self: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image #city,
|
||||||
|
.overlap .image #falcon {
|
||||||
|
fill: color-mix(in oklab, var(--wa-color-brand-spot), black 50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image #fighters {
|
||||||
|
fill: color-mix(in oklab, var(--wa-color-brand-spot), black 30%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image #upper_clouds {
|
||||||
|
fill: color-mix(in oklab, var(--wa-color-brand-spot), white 80%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image #background_clouds {
|
||||||
|
fill: color-mix(in oklab, var(--wa-color-brand-spot), white 90%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image #forefront_clouds {
|
||||||
|
fill: color-mix(in oklab, var(--wa-color-brand-spot), white 70%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image .gradient-start {
|
||||||
|
stop-color: color-mix(in oklab, var(--wa-color-brand-spot), white 80%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlap .image .gradient-stop {
|
||||||
|
stop-color: color-mix(in oklab, var(--wa-color-brand-spot), white 0%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cards {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
grid-auto-rows: 1fr;
|
||||||
|
gap: 1rem;
|
||||||
|
margin-block-start: var(--wa-space-m);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cards wa-card::part(base) {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.space-vertically {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
wa-select[label="Signet"]::part(form-control-help-text) {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 670px) {
|
||||||
|
.overlap .grid {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1040px) {
|
||||||
|
.cards {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1450px) {
|
||||||
|
.cards {
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Style Guide -->
|
||||||
|
<wa-card id="style-guide">
|
||||||
|
|
||||||
|
## Typography
|
||||||
|
|
||||||
|
Vel risus commodo viverra maecenas accumsan lacus vel facilisis volutpat. Amet mauris commodo quis imperdiet. Bibendum ut tristique et egestas quis ipsum suspendisse. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat.
|
||||||
|
|
||||||
|
Cras pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci. Scelerisque eleifend donec pretium vulputate sapien nec. Donec et odio pellentesque diam volutpat commodo sed egestas egestas. Mauris rhoncus aenean vel elit scelerisque mauris pellentesque.
|
||||||
|
|
||||||
|
> What is a Web year now, about three months? And when people can browse around, discover new things, and download them fast, when we all have agents - then Web years could slip by before human beings can notice.
|
||||||
|
>
|
||||||
|
> — Tim Berners-Lee
|
||||||
|
|
||||||
|
## Inline Text
|
||||||
|
|
||||||
|
<div class="docs-grid">
|
||||||
|
<p><strong>Bold</strong></p>
|
||||||
|
<p><em>Italics</em></p>
|
||||||
|
<p><u>Underline</u></p>
|
||||||
|
<p><del>Deleted</del></p>
|
||||||
|
<p><ins>Inserted</ins></p>
|
||||||
|
<p><s>Strike-through</s></p>
|
||||||
|
<p><small>Small</small></p>
|
||||||
|
<p><span>Text <sub>Sub</sub></span></p>
|
||||||
|
<p><span>Text <sup>Sup</sup></span></p>
|
||||||
|
<p><abbr title="Abbreviation">Abbr.</abbr></p>
|
||||||
|
<p><kbd>Keyboard</kbd></p>
|
||||||
|
<p><mark>Highlighted</mark></p>
|
||||||
|
<p><a href="#">Link text</a></p>
|
||||||
|
<p><code>Inline code</code></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Lists
|
||||||
|
|
||||||
|
- List item 1
|
||||||
|
- List item 2
|
||||||
|
- List item 3
|
||||||
|
- Subitem a
|
||||||
|
- Subitem b
|
||||||
|
|
||||||
|
1. List item 1
|
||||||
|
2. List item 2
|
||||||
|
3. List item 3
|
||||||
|
- Subitem a
|
||||||
|
- Subitem b
|
||||||
|
|
||||||
|
## Headings
|
||||||
|
|
||||||
|
### Heading 3
|
||||||
|
|
||||||
|
Feugiat nisl pretium fusce id. Ipsum dolor sit amet consectetur adipiscing elit. Eget nunc lobortis mattis aliquam faucibus purus. Metus dictum at tempor commodo ullamcorper a lacus vestibulum. Urna condimentum mattis pellentesque id nibh tortor id.
|
||||||
|
|
||||||
|
#### Heading 4
|
||||||
|
|
||||||
|
Gravida arcu ac tortor dignissim convallis aenean. Pellentesque pulvinar pellentesque habitant morbi tristique senectus et. Ipsum nunc aliquet bibendum enim facilisis gravida neque. Donec adipiscing tristique risus nec feugiat in.
|
||||||
|
|
||||||
|
##### Heading 5
|
||||||
|
|
||||||
|
Enim diam vulputate ut pharetra sit. Enim facilisis gravida neque convallis a cras. Enim neque volutpat ac tincidunt vitae semper. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium.
|
||||||
|
|
||||||
|
###### Heading 6
|
||||||
|
|
||||||
|
Tincidunt ornare massa eget egestas purus viverra accumsan in nisl. Facilisis mauris sit amet massa vitae. Nunc faucibus a pellentesque sit amet porttitor. Adipiscing tristique risus nec feugiat in fermentum.
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
Individual details look like this.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Tincidunt nunc pulvinar</summary>
|
||||||
|
<p>Ut lectus arcu bibendum at varius. Convallis a cras semper auctor neque vitae. Odio pellentesque diam volutpat commodo sed egestas. Amet dictum sit amet justo donec enim diam vulputate ut.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
Grouping them provides accordion-style functionality.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Enim diam</summary>
|
||||||
|
<p>Nunc faucibus a pellentesque sit amet porttitor. Adipiscing tristique risus nec feugiat in fermentum. Leo duis ut diam quam nulla porttitor massa id. Mauris nunc congue nisi vitae.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Arcu non odio</summary>
|
||||||
|
<p>Sed libero enim sed faucibus turpis in eu mi bibendum. Nunc mi ipsum faucibus vitae aliquet nec. Ultricies tristique nulla aliquet enim tortor. Tellus at urna condimentum mattis pellentesque.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Ut porttitor</summary>
|
||||||
|
<p>Eu facilisis sed odio morbi quis commodo odio aenean sed. Sit amet purus gravida quis blandit turpis cursus. Eu consequat ac felis donec et odio pellentesque diam volutpat.</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Code Blocks
|
||||||
|
|
||||||
|
```
|
||||||
|
// do a thing
|
||||||
|
export function thing() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Images
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Tables
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<caption>I'm just a table</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Column 1</th>
|
||||||
|
<th>Column 2</th>
|
||||||
|
<th>Column 3</th>
|
||||||
|
<th>Column 4</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
## Definition Lists
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Definition 1</dt>
|
||||||
|
<dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd>
|
||||||
|
<dt>Definition 2</dt>
|
||||||
|
<dd>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</dd>
|
||||||
|
<dt>Definition 3</dt>
|
||||||
|
<dd>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2>Form Control Validation</h2>
|
||||||
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;">
|
||||||
|
<div>
|
||||||
|
<h3>Valid</h3>
|
||||||
|
<wa-input class="wa-valid" label="Name" help-text="Just a first name is fine" placeholder="Enter your name"></wa-input><br>
|
||||||
|
<wa-select class="wa-valid" label="Choose one" help-text="Make a choice already">
|
||||||
|
<wa-option>There can be only one!</wa-option>
|
||||||
|
<wa-option>Well, maybe two is OK</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-textarea class="wa-valid" label="Bio" help-text="Tell us about yourself" placeholder="Enter a bio"></wa-textarea><br>
|
||||||
|
<wa-range class="wa-valid" value="50" label="Volume" help-text="Crank it up" tooltip="none"></wa-range><br>
|
||||||
|
<wa-checkbox class="wa-valid" checked>I am awesome</wa-checkbox><br>
|
||||||
|
<wa-checkbox class="wa-valid">So am I</wa-checkbox><br><br>
|
||||||
|
<wa-switch class="wa-valid" checked>Still awesome</wa-switch><br>
|
||||||
|
<wa-switch class="wa-valid">More awesome</wa-switch><br><br>
|
||||||
|
<wa-radio-group class="wa-valid" label="Select an option" name="a" value="1">
|
||||||
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
|
</wa-radio-group><br>
|
||||||
|
<wa-button variant="brand">Submit Form</wa-button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Invalid</h3>
|
||||||
|
<wa-input class="wa-invalid" label="Name" help-text="Just a first name is fine" placeholder="Enter your name"></wa-input><br>
|
||||||
|
<wa-select class="wa-invalid" label="Choose one" help-text="Make a choice already">
|
||||||
|
<wa-option>There can be only one!</wa-option>
|
||||||
|
<wa-option>Well, maybe two is OK</wa-option>
|
||||||
|
</wa-select>
|
||||||
|
<wa-textarea class="wa-invalid" label="Bio" help-text="Tell us about yourself" placeholder="Enter a bio"></wa-textarea><br>
|
||||||
|
<wa-range class="wa-invalid" value="50" label="Volume" help-text="Crank it up" tooltip="none"></wa-range><br>
|
||||||
|
<wa-checkbox class="wa-invalid" checked>I am awesome</wa-checkbox><br>
|
||||||
|
<wa-checkbox class="wa-invalid">So am I</wa-checkbox><br><br>
|
||||||
|
<wa-switch class="wa-invalid" checked>Still awesome</wa-switch><br>
|
||||||
|
<wa-switch class="wa-invalid">More awesome</wa-switch><br><br>
|
||||||
|
<wa-radio-group class="wa-invalid" label="Select an option" name="a" value="1">
|
||||||
|
<wa-radio value="1">Option 1</wa-radio>
|
||||||
|
<wa-radio value="2">Option 2</wa-radio>
|
||||||
|
<wa-radio value="3">Option 3</wa-radio>
|
||||||
|
</wa-radio-group><br>
|
||||||
|
<wa-button variant="brand">Submit Form</wa-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#style-guide {
|
||||||
|
margin-block-start: var(--wa-flow-spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#style-guide wa-card {
|
||||||
|
padding-block: var(--wa-space-xl);
|
||||||
|
padding-inline: var(--wa-space-2xl);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,25 +1,49 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Angular
|
title: Angular
|
||||||
description: Tips for using Shoelace in your Angular app.
|
description: Tips for using Web Awesome in your Angular app.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Angular
|
# Angular
|
||||||
|
|
||||||
Angular [plays nice](https://custom-elements-everywhere.com/#angular) with custom elements, so you can use Shoelace in your Angular apps with ease.
|
Angular [plays nice](https://custom-elements-everywhere.com/#angular) with custom elements, so you can use Web Awesome in your Angular apps with ease.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To add Shoelace to your Angular app, install the package from npm.
|
### Download the npm package
|
||||||
|
|
||||||
|
To add Web Awesome to your Angular app, install the package from npm.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path.
|
### Update the Angular Configuration
|
||||||
|
|
||||||
|
Next, [include a theme](/getting-started/themes). In this example, we'll import the light theme.
|
||||||
|
Its also important to load the components by using a `<script>` tag into the index.html file. However, the Angular way to do it is by adding a script configurations into your angular.json file as follows:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
...
|
||||||
|
"options": {
|
||||||
|
...
|
||||||
|
"styles": [
|
||||||
|
"src/styles.scss",
|
||||||
|
"@shoelace-style/shoelace/dist/themes/light.css"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
"@shoelace-style/shoelace/dist/shoelace.js"
|
||||||
|
]
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Setting up the base path
|
||||||
|
|
||||||
|
Next, set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets in the `main.ts`. In this example, we'll use the CDN as a base path.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/themes/light.css';
|
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
||||||
|
|
||||||
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
||||||
@@ -49,20 +73,20 @@ import { AppComponent } from './app.component';
|
|||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Reference Shoelace components in your Angular component code
|
## Reference Web Awesome components in your Angular component code
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { SlDrawer } from '@shoelace-style/shoelace';
|
import { WaDrawer } from '@shoelace-style/shoelace';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-drawer-example',
|
selector: 'app-drawer-example',
|
||||||
template: '<div id="page"><button (click)="showDrawer()">Show drawer</button><sl-drawer #drawer label="Drawer" class="drawer-focus" style="--size: 50vw"><p>Drawer content</p></sl-drawer></div>'
|
template: '<div id="page"><button (click)="showDrawer()">Show drawer</button><wa-drawer #drawer label="Drawer" class="drawer-focus" style="--size: 50vw"><p>Drawer content</p></wa-drawer></div>'
|
||||||
})
|
})
|
||||||
export class DrawerExampleComponent implements OnInit {
|
export class DrawerExampleComponent implements OnInit {
|
||||||
|
|
||||||
// use @ViewChild to get a reference to the #drawer element within component template
|
// use @ViewChild to get a reference to the #drawer element within component template
|
||||||
@ViewChild('drawer')
|
@ViewChild('drawer')
|
||||||
drawer?: ElementRef<SlDrawer>;
|
drawer?: ElementRef<WaDrawer>;
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
@@ -75,14 +99,14 @@ export class DrawerExampleComponent implements OnInit {
|
|||||||
...
|
...
|
||||||
|
|
||||||
showDrawer() {
|
showDrawer() {
|
||||||
// use nativeElement to access Shoelace components
|
// use nativeElement to access Web Awesome components
|
||||||
this.drawer?.nativeElement.show();
|
this.drawer?.nativeElement.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can start using Shoelace components in your app!
|
Now you can start using Web Awesome components in your app!
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Are you using Shoelace with Angular? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/angular.md)
|
Are you using Web Awesome with Angular? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/angular.md)
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: React
|
title: React
|
||||||
description: Tips for using Shoelace in your React app.
|
description: Tips for using Web Awesome in your React app.
|
||||||
---
|
---
|
||||||
|
|
||||||
# React
|
# React
|
||||||
|
|
||||||
Shoelace offers a React version of every component to provide an idiomatic experience for React users. You can easily toggle between HTML and React examples throughout the documentation.
|
Web Awesome offers a React version of every component to provide an idiomatic experience for React users. You can easily toggle between HTML and React examples throughout the documentation.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To add Shoelace to your React app, install the package from npm.
|
To add Web Awesome to your React app, install the package from npm.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
@@ -20,7 +20,7 @@ Next, [include a theme](/getting-started/themes) and set the [base path](/gettin
|
|||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
// App.jsx
|
// App.jsx
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/themes/light.css';
|
import '@shoelace-style/shoelace/%NPMDIR%/themes/default.css';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
||||||
|
|
||||||
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
||||||
@@ -32,16 +32,20 @@ If you'd rather not use the CDN for assets, you can create a [build task](https:
|
|||||||
|
|
||||||
Now you can start using components!
|
Now you can start using components!
|
||||||
|
|
||||||
|
### Preact
|
||||||
|
|
||||||
|
Preact users facing type errors using components may benefit from setting "paths" in their tsconfig.json so that react types will instead resolve to `preact/compat` as described in [Preact's typescript documentation](https://preactjs.com/guide/v10/typescript/#typescript-preactcompat-configuration).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Importing Components
|
### Importing Components
|
||||||
|
|
||||||
Every Shoelace component is available to import as a React component. Note that we're importing the `<SlButton>` _React component_ instead of the `<sl-button>` _custom element_ in the example below.
|
Every Web Awesome component is available to import as a React component. Note that we're importing the `<WaButton>` _React component_ instead of the `<wa-button>` _custom element_ in the example below.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import SlButton from '@shoelace-style/shoelace/%NPMDIR%/react/button';
|
import WaButton from '@shoelace-style/shoelace/%NPMDIR%/react/button';
|
||||||
|
|
||||||
const MyComponent = () => <SlButton variant="primary">Click me</SlButton>;
|
const MyComponent = () => <WaButton variant="brand">Click me</WaButton>;
|
||||||
|
|
||||||
export default MyComponent;
|
export default MyComponent;
|
||||||
```
|
```
|
||||||
@@ -51,32 +55,32 @@ export default MyComponent;
|
|||||||
Previously, it was recommended to import from a single entrypoint like so:
|
Previously, it was recommended to import from a single entrypoint like so:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import { SlButton } from '@shoelace-style/shoelace/%NPMDIR%/react';
|
import { WaButton } from '@shoelace-style/shoelace/%NPMDIR%/react';
|
||||||
```
|
```
|
||||||
|
|
||||||
However, tree-shaking extra Shoelace components proved to be a challenge. As a result, we now recommend cherry-picking components you want to use, rather than importing from a single entrypoint.
|
However, tree-shaking extra Web Awesome components proved to be a challenge. As a result, we now recommend cherry-picking components you want to use, rather than importing from a single entrypoint.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- import { SlButton } from '@shoelace-style/shoelace/%NPMDIR%/react';
|
- import { WaButton } from '@shoelace-style/shoelace/%NPMDIR%/react';
|
||||||
+ import SlButton from '@shoelace-style/shoelace/%NPMDIR%/react/button';
|
+ import WaButton from '@shoelace-style/shoelace/%NPMDIR%/react/button';
|
||||||
```
|
```
|
||||||
|
|
||||||
You can find a copy + paste import for each component in the "importing" section of its documentation.
|
You can find a copy + paste import for each component in the "importing" section of its documentation.
|
||||||
|
|
||||||
### Event Handling
|
### Event Handling
|
||||||
|
|
||||||
Many Shoelace components emit [custom events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). For example, the [input component](/components/input) emits the `sl-input` event when it receives input. In React, you can listen for the event using `onSlInput`.
|
Many Web Awesome components emit [custom events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). For example, the [input component](/components/input) emits the `wa-input` event when it receives input. In React, you can listen for the event using `onWaInput`.
|
||||||
|
|
||||||
Here's how you can bind the input's value to a state variable.
|
Here's how you can bind the input's value to a state variable.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlInput from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
import WaInput from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
||||||
|
|
||||||
function MyComponent() {
|
function MyComponent() {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
|
|
||||||
return <SlInput value={value} onSlInput={event => setValue(event.target.value)} />;
|
return <WaInput value={value} onWaInput={event => setValue(event.target.value)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MyComponent;
|
export default MyComponent;
|
||||||
@@ -86,13 +90,13 @@ If you're using TypeScript, it's important to note that `event.target` will be a
|
|||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import SlInput from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
import WaInput from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
||||||
import type SlInputElement from '@shoelace-style/shoelace/%NPMDIR%/components/input/input';
|
import type WaInputElement from '@shoelace-style/shoelace/%NPMDIR%/components/input/input';
|
||||||
|
|
||||||
function MyComponent() {
|
function MyComponent() {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
|
|
||||||
return <SlInput value={value} onSlInput={event => setValue((event.target as SlInputElement).value)} />;
|
return <WaInput value={value} onWaInput={event => setValue((event.target as WaInputElement).value)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MyComponent;
|
export default MyComponent;
|
||||||
@@ -102,16 +106,16 @@ You can also import the event type for use in your callbacks, shown below.
|
|||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import SlInput, { type SlInputEvent } from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
import WaInput, { type WaInputEvent } from '@shoelace-style/shoelace/%NPMDIR%/react/input';
|
||||||
import type SlInputElement from '@shoelace-style/shoelace/%NPMDIR%/components/input/input';
|
import type WaInputElement from '@shoelace-style/shoelace/%NPMDIR%/components/input/input';
|
||||||
|
|
||||||
function MyComponent() {
|
function MyComponent() {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
const onInput = useCallback((event: SlInputEvent) => {
|
const onInput = useCallback((event: WaInputEvent) => {
|
||||||
setValue(event.detail);
|
setValue(event.detail);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <SlInput value={value} onSlInput={event => setValue((event.target as SlInputElement).value)} />;
|
return <WaInput value={value} onWaInput={event => setValue((event.target as WaInputElement).value)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MyComponent;
|
export default MyComponent;
|
||||||
@@ -121,7 +125,7 @@ export default MyComponent;
|
|||||||
|
|
||||||
Testing with web components can be challenging if your test environment runs in a Node environment (i.e. it doesn't run in a real browser). Fortunately, [Jest](https://jestjs.io/) has made a number of strides to support web components and provide additional browser APIs. However, it's still not a complete replication of a browser environment.
|
Testing with web components can be challenging if your test environment runs in a Node environment (i.e. it doesn't run in a real browser). Fortunately, [Jest](https://jestjs.io/) has made a number of strides to support web components and provide additional browser APIs. However, it's still not a complete replication of a browser environment.
|
||||||
|
|
||||||
Here are some tips that will help smooth things over if you're having trouble with Jest + Shoelace.
|
Here are some tips that will help smooth things over if you're having trouble with Jest + Web Awesome.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
If you're looking for a fast, modern testing alternative, consider [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/).
|
If you're looking for a fast, modern testing alternative, consider [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/).
|
||||||
@@ -163,13 +167,13 @@ For more details, refer to Jest's [manual mocking](https://jestjs.io/docs/manual
|
|||||||
|
|
||||||
### Transform ES Modules
|
### Transform ES Modules
|
||||||
|
|
||||||
ES Modules are a [well-supported browser standard](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/). This is how Shoelace is distributed, but most React apps expect CommonJS. As a result, you'll probably run into the following error.
|
ES Modules are a [well-supported browser standard](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/). This is how Web Awesome is distributed, but most React apps expect CommonJS. As a result, you'll probably run into the following error.
|
||||||
|
|
||||||
```
|
```
|
||||||
Error: Unable to import outside of a module
|
Error: Unable to import outside of a module
|
||||||
```
|
```
|
||||||
|
|
||||||
To fix this, add the following to your `package.json` which tells the transpiler to process Shoelace modules.
|
To fix this, add the following to your `package.json` which tells the transpiler to process Web Awesome modules.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
@@ -184,5 +188,5 @@ These instructions are for apps created via Create React App. If you're using Je
|
|||||||
For more details, refer to Jest's [`transformIgnorePatterns` customization](https://jestjs.io/docs/tutorial-react-native#transformignorepatterns-customization) documentation.
|
For more details, refer to Jest's [`transformIgnorePatterns` customization](https://jestjs.io/docs/tutorial-react-native#transformignorepatterns-customization) documentation.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Are you using Shoelace with React? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/react.md)
|
Are you using Web Awesome with React? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/react.md)
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Vue (version 2)
|
title: Vue (version 2)
|
||||||
description: Tips for using Shoelace in your Vue 2 app.
|
description: Tips for using Web Awesome in your Vue 2 app.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Vue (version 2)
|
# Vue (version 2)
|
||||||
|
|
||||||
Vue [plays nice](https://custom-elements-everywhere.com/#vue) with custom elements, so you can use Shoelace in your Vue apps with ease.
|
Vue [plays nice](https://custom-elements-everywhere.com/#vue) with custom elements, so you can use Web Awesome in your Vue apps with ease.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
These instructions are for Vue 2. If you're using Vue 3 or above, please see the [Vue 3 instructions](/frameworks/vue).
|
These instructions are for Vue 2. If you're using Vue 3 or above, please see the [Vue 3 instructions](/frameworks/vue).
|
||||||
@@ -14,7 +14,7 @@ These instructions are for Vue 2. If you're using Vue 3 or above, please see the
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To add Shoelace to your Vue app, install the package from npm.
|
To add Web Awesome to your Vue app, install the package from npm.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
@@ -23,7 +23,7 @@ npm install @shoelace-style/shoelace
|
|||||||
Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path.
|
Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/themes/light.css';
|
import '@shoelace-style/shoelace/%NPMDIR%/themes/default.css';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path';
|
||||||
|
|
||||||
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
||||||
@@ -35,7 +35,7 @@ If you'd rather not use the CDN for assets, you can create a build task that cop
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
You'll need to tell Vue to ignore Shoelace components. This is pretty easy because they all start with `sl-`.
|
You'll need to tell Vue to ignore Web Awesome components. This is pretty easy because they all start with `sl-`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
@@ -50,7 +50,7 @@ const app = new Vue({
|
|||||||
app.$mount('#app');
|
app.$mount('#app');
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can start using Shoelace components in your app!
|
Now you can start using Web Awesome components in your app!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ Now you can start using Shoelace components in your app!
|
|||||||
When binding complex data such as objects and arrays, use the `.prop` modifier to make Vue bind them as a property instead of an attribute.
|
When binding complex data such as objects and arrays, use the `.prop` modifier to make Vue bind them as a property instead of an attribute.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-color-picker :swatches.prop="mySwatches" />
|
<wa-color-picker :swatches.prop="mySwatches" />
|
||||||
```
|
```
|
||||||
|
|
||||||
### Two-way Binding
|
### Two-way Binding
|
||||||
@@ -68,12 +68,12 @@ One caveat is there's currently [no support for v-model on custom elements](http
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- This doesn't work -->
|
<!-- This doesn't work -->
|
||||||
<sl-input v-model="name"></sl-input>
|
<wa-input v-model="name"></wa-input>
|
||||||
<!-- This works, but it's a bit longer -->
|
<!-- This works, but it's a bit longer -->
|
||||||
<sl-input :value="name" @input="name = $event.target.value"></sl-input>
|
<wa-input :value="name" @input="name = $event.target.value"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
If that's too verbose for your liking, you can use a custom directive instead. [This utility](https://www.npmjs.com/package/@shoelace-style/vue-sl-model) adds a custom directive that will work just like `v-model` but for Shoelace components. To install it, use this command.
|
If that's too verbose for your liking, you can use a custom directive instead. [This utility](https://www.npmjs.com/package/@shoelace-style/vue-sl-model) adds a custom directive that will work just like `v-model` but for Web Awesome components. To install it, use this command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/vue-sl-model@1
|
npm install @shoelace-style/vue-sl-model@1
|
||||||
@@ -83,10 +83,10 @@ Next, import the directive and enable it like this.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import ShoelaceModelDirective from '@shoelace-style/vue-sl-model';
|
import Web AwesomeModelDirective from '@shoelace-style/vue-sl-model';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
|
||||||
Vue.use(ShoelaceModelDirective);
|
Vue.use(Web AwesomeModelDirective);
|
||||||
Vue.config.ignoredElements = [/sl-/];
|
Vue.config.ignoredElements = [/sl-/];
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
@@ -99,9 +99,9 @@ app.$mount('#app');
|
|||||||
Now you can use the `v-sl-model` directive to keep your data in sync!
|
Now you can use the `v-sl-model` directive to keep your data in sync!
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-input v-sl-model="name"></sl-input>
|
<wa-input v-sl-model="name"></wa-input>
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Are you using Shoelace with Vue? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/vue-2.md)
|
Are you using Web Awesome with Vue? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/vue-2.md)
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Vue
|
title: Vue
|
||||||
description: Tips for using Shoelace in your Vue 3 app.
|
description: Tips for using Web Awesome in your Vue 3 app.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Vue
|
# Vue
|
||||||
|
|
||||||
Vue [plays nice](https://custom-elements-everywhere.com/#vue) with custom elements, so you can use Shoelace in your Vue apps with ease.
|
Vue [plays nice](https://custom-elements-everywhere.com/#vue) with custom elements, so you can use Web Awesome in your Vue apps with ease.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
These instructions are for Vue 3 and above. If you're using Vue 2, please see the [Vue 2 instructions](/frameworks/vue-2).
|
These instructions are for Vue 3 and above. If you're using Vue 2, please see the [Vue 2 instructions](/frameworks/vue-2).
|
||||||
@@ -14,7 +14,7 @@ These instructions are for Vue 3 and above. If you're using Vue 2, please see th
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To add Shoelace to your Vue app, install the package from npm.
|
To add Web Awesome to your Vue app, install the package from npm.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
@@ -23,7 +23,7 @@ npm install @shoelace-style/shoelace
|
|||||||
Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path.
|
Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import '@shoelace-style/shoelace/dist/themes/light.css';
|
import '@shoelace-style/shoelace/dist/themes/default.css';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path';
|
import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path';
|
||||||
|
|
||||||
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/');
|
||||||
@@ -35,7 +35,7 @@ If you'd rather not use the CDN for assets, you can create a build task that cop
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
You'll need to tell Vue to ignore Shoelace components. This is pretty easy because they all start with `sl-`.
|
You'll need to tell Vue to ignore Web Awesome components. This is pretty easy because they all start with `sl-`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { fileURLToPath, URL } from 'url';
|
import { fileURLToPath, URL } from 'url';
|
||||||
@@ -49,7 +49,7 @@ export default defineConfig({
|
|||||||
vue({
|
vue({
|
||||||
template: {
|
template: {
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
isCustomElement: tag => tag.startsWith('sl-')
|
isCustomElement: tag => tag.startsWith('wa-')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -62,7 +62,7 @@ export default defineConfig({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can start using Shoelace components in your app!
|
Now you can start using Web Awesome components in your app!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ Now you can start using Shoelace components in your app!
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>QR code generator</h1>
|
<h1>QR code generator</h1>
|
||||||
|
|
||||||
<sl-input maxlength="255" clearable label="Value" v-model="qrCode"></sl-input>
|
<wa-input maxlength="255" clearable label="Value" v-model="qrCode"></wa-input>
|
||||||
|
|
||||||
<sl-qr-code :value="qrCode"></sl-qr-code>
|
<wa-qr-code :value="qrCode"></wa-qr-code>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ Now you can start using Shoelace components in your app!
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
sl-input {
|
wa-input {
|
||||||
margin: var(--sl-spacing-large) 0;
|
margin: var(--wa-space-l) 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
@@ -104,24 +104,37 @@ Now you can start using Shoelace components in your app!
|
|||||||
When binding complex data such as objects and arrays, use the `.prop` modifier to make Vue bind them as a property instead of an attribute.
|
When binding complex data such as objects and arrays, use the `.prop` modifier to make Vue bind them as a property instead of an attribute.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-color-picker :swatches.prop="mySwatches" />
|
<wa-color-picker :swatches.prop="mySwatches" />
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Two-way Binding
|
||||||
|
|
||||||
|
One caveat is there's currently [no support for v-model on custom elements](https://github.com/vuejs/vue/issues/7830), but you can still achieve two-way binding manually.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- This doesn't work -->
|
||||||
|
<wa-input v-model="name"></wa-input>
|
||||||
|
<!-- This works, but it's a bit longer -->
|
||||||
|
<wa-input :value="name" @input="name = $event.target.value"></wa-input>
|
||||||
|
```
|
||||||
|
|
||||||
|
If that's too verbose for your liking, you can use a custom directive instead. [This utility](https://www.npmjs.com/package/@shoelace-style/vue-sl-model) adds a custom directive that will work just like `v-model` but for Web Awesome components.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Are you using Shoelace with Vue? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/vue.md)
|
Are you using Web Awesome with Vue? [Help us improve this page!](https://github.com/shoelace-style/shoelace/blob/next/docs/frameworks/vue.md)
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
To use Shoelace components with slots, follow the Vue documentation on using [slots with custom elements](https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue).
|
To use Web Awesome components with slots, follow the Vue documentation on using [slots with custom elements](https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue).
|
||||||
|
|
||||||
Here is an example:
|
Here is an example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-drawer label="Drawer" placement="start" class="drawer-placement-start" :open="drawerIsOpen">
|
<wa-drawer label="Drawer" placement="start" class="drawer-placement-start" :open="drawerIsOpen">
|
||||||
This drawer slides in from the start.
|
This drawer slides in from the start.
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<sl-button variant="primary" @click=" drawerIsOpen = false">Close</sl-button>
|
<wa-button variant="brand" @click=" drawerIsOpen = false">Close</wa-button>
|
||||||
</div>
|
</div>
|
||||||
</sl-drawer>
|
</wa-drawer>
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Customizing
|
title: Customizing
|
||||||
description: Learn how to customize Shoelace through parts and custom properties.
|
description: Learn how to customize Web Awesome through parts and custom properties.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Customizing
|
# Customizing
|
||||||
|
|
||||||
Shoelace components can be customized at a high level through design tokens. This gives you control over theme colors and general styling. For more advanced customizations, you can make use of CSS parts and custom properties to target individual components.
|
Web Awesome components can be customized at a high level through design tokens. This gives you control over theme colors and general styling. For more advanced customizations, you can make use of CSS parts and custom properties to target individual components.
|
||||||
|
|
||||||
## Design Tokens
|
## Design Tokens
|
||||||
|
|
||||||
Shoelace makes use of several design tokens to provide a consistent appearance across components. You can customize them and use them in your own application with pure CSS — no preprocessor required.
|
Web Awesome makes use of several design tokens to provide a consistent appearance across components. You can customize them and use them in your own application with pure CSS — no preprocessor required.
|
||||||
|
|
||||||
Design tokens offer a high-level way to customize the library with minimal effort. There are no component-specific variables, however, as design tokens are intended to be generic and highly reusable. To customize an individual component, refer to the section entitled [CSS Parts](#css-parts).
|
Design tokens offer a high-level way to customize the library with minimal effort. There are no component-specific variables, however, as design tokens are intended to be generic and highly reusable. To customize an individual component, refer to the section entitled [CSS Parts](#css-parts).
|
||||||
|
|
||||||
@@ -35,18 +35,18 @@ To customize a design token, simply override it in your stylesheet using a `:roo
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Many design tokens are described further along in this documentation. For a complete list, refer to `src/themes/light.css` in the project's [source code](https://github.com/shoelace-style/shoelace/blob/current/src/themes/light.css).
|
Many design tokens are described further along in this documentation. For a complete list, refer to `src/themes/default.css` in the project's [source code](https://github.com/shoelace-style/shoelace/blob/current/src/themes/default.css).
|
||||||
|
|
||||||
## CSS Parts
|
## CSS Parts
|
||||||
|
|
||||||
Whereas design tokens offer a high-level way to customize the library, CSS parts offer a low-level way to customize individual components. Again, this is done with pure CSS — no preprocessor required.
|
Whereas design tokens offer a high-level way to customize the library, CSS parts offer a low-level way to customize individual components. Again, this is done with pure CSS — no preprocessor required.
|
||||||
|
|
||||||
Shoelace components use a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) to encapsulate their styles and behaviors. As a result, you can't simply target their internals with the usual CSS selectors. Instead, components expose "parts" that can be targeted with the [CSS part selector](https://developer.mozilla.org/en-US/docs/Web/CSS/::part), or `::part()`.
|
Web Awesome components use a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) to encapsulate their styles and behaviors. As a result, you can't simply target their internals with the usual CSS selectors. Instead, components expose "parts" that can be targeted with the [CSS part selector](https://developer.mozilla.org/en-US/docs/Web/CSS/::part), or `::part()`.
|
||||||
|
|
||||||
Here's an example that modifies buttons with the `tomato-button` class.
|
Here's an example that modifies buttons with the `tomato-button` class.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<sl-button class="tomato-button"> Tomato Button </sl-button>
|
<wa-button class="tomato-button"> Tomato Button </wa-button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tomato-button::part(base) {
|
.tomato-button::part(base) {
|
||||||
@@ -89,7 +89,7 @@ For convenience, some components expose CSS custom properties you can override.
|
|||||||
You can set custom properties on a component in your stylesheet.
|
You can set custom properties on a component in your stylesheet.
|
||||||
|
|
||||||
```css
|
```css
|
||||||
sl-avatar {
|
wa-avatar {
|
||||||
--size: 6rem;
|
--size: 6rem;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -97,7 +97,7 @@ sl-avatar {
|
|||||||
This will also work if you need to target a subset of components with a specific class.
|
This will also work if you need to target a subset of components with a specific class.
|
||||||
|
|
||||||
```css
|
```css
|
||||||
sl-avatar.your-class {
|
wa-avatar.your-class {
|
||||||
--size: 6rem;
|
--size: 6rem;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -105,14 +105,14 @@ sl-avatar.your-class {
|
|||||||
Alternatively, you can set them inline directly on the element.
|
Alternatively, you can set them inline directly on the element.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<sl-avatar style="--size: 6rem;"></sl-avatar>
|
<wa-avatar style="--size: 6rem;"></wa-avatar>
|
||||||
```
|
```
|
||||||
|
|
||||||
Not all components expose CSS custom properties. For those that do, they can be found in the component's API documentation.
|
Not all components expose CSS custom properties. For those that do, they can be found in the component's API documentation.
|
||||||
|
|
||||||
## Animations
|
## Animations
|
||||||
|
|
||||||
Some components use animation, such as when a dialog is shown or hidden. Animations are performed using the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) rather than CSS. However, you can still customize them through Shoelace's animation registry. If a component has customizable animations, they'll be listed in the "Animation" section of its documentation.
|
Some components use animation, such as when a dialog is shown or hidden. Animations are performed using the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) rather than CSS. However, you can still customize them through Web Awesome's animation registry. If a component has customizable animations, they'll be listed in the "Animation" section of its documentation.
|
||||||
|
|
||||||
To customize a default animation, use the `setDefaultAnimation()` method. The function accepts an animation name (found in the component's docs) and an object with `keyframes`, and `options` or `null` to disable the animation.
|
To customize a default animation, use the `setDefaultAnimation()` method. The function accepts an animation name (found in the component's docs) and an object with `keyframes`, and `options` or `null` to disable the animation.
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Form Controls
|
title: Form Controls
|
||||||
description: Some things to note about Shoelace and forms.
|
description: Some things to note about Web Awesome and forms.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Form Controls
|
# Form Controls
|
||||||
|
|
||||||
Every Shoelace component makes use of a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) to encapsulate markup, styles, and behavior. One caveat of this approach is that native `<form>` elements do not recognize form controls located inside a shadow root.
|
Every Web Awesome component makes use of a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) to encapsulate markup, styles, and behavior. One caveat of this approach is that native `<form>` elements do not recognize form controls located inside a shadow root.
|
||||||
|
|
||||||
Shoelace solves this problem by using the [`formdata`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event) event, which is [available in all modern browsers](https://caniuse.com/mdn-api_htmlformelement_formdata_event). This means, when a form is submitted, Shoelace form controls will automatically append their values to the `FormData` object that's used to submit the form. In most cases, things will "just work." However, if you're using a form serialization library, it might need to be adapted to recognize Shoelace form controls.
|
Web Awesome solves this problem by using the [`formdata`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event) event, which is [available in all modern browsers](https://caniuse.com/mdn-api_htmlformelement_formdata_event). This means, when a form is submitted, Web Awesome form controls will automatically append their values to the `FormData` object that's used to submit the form. In most cases, things will "just work." However, if you're using a form serialization library, it might need to be adapted to recognize Web Awesome form controls.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Shoelace uses event listeners to intercept the form's `formdata` and `submit` events. This allows it to inject data and trigger validation as necessary. If you're also attaching an event listener to the form, _you must attach it after Shoelace form controls are connected to the DOM_, otherwise your logic will run before Shoelace has a chance to inject form data and validate form controls.
|
Web Awesome uses event listeners to intercept the form's `formdata` and `submit` events. This allows it to inject data and trigger validation as necessary. If you're also attaching an event listener to the form, _you must attach it after Web Awesome form controls are connected to the DOM_, otherwise your logic will run before Web Awesome has a chance to inject form data and validate form controls.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Data Serialization
|
## Data Serialization
|
||||||
@@ -27,7 +27,7 @@ const data = new FormData(form);
|
|||||||
// All form control data is available in a FormData object
|
// All form control data is available in a FormData object
|
||||||
```
|
```
|
||||||
|
|
||||||
However, some folks find `FormData` tricky to work with or they need to pass a JSON payload to their server. To accommodate this, Shoelace offers a serialization utility that gathers form data and returns a simple JavaScript object instead.
|
However, some folks find `FormData` tricky to work with or they need to pass a JSON payload to their server. To accommodate this, Web Awesome offers a serialization utility that gathers form data and returns a simple JavaScript object instead.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { serialize } from '@shoelace-style/shoelace/dist/utilities/form.js';
|
import { serialize } from '@shoelace-style/shoelace/dist/utilities/form.js';
|
||||||
@@ -42,7 +42,7 @@ This results in an object with name/value pairs that map to each form control. I
|
|||||||
|
|
||||||
## Constraint Validation
|
## Constraint Validation
|
||||||
|
|
||||||
Client-side validation can be enabled through the browser's [Constraint Validation API](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation) for Shoelace form controls. You can activate it using attributes such as `required`, `pattern`, `minlength`, `maxlength`, etc. Shoelace implements many of the same attributes as native form controls, but check the documentation for a list of supported properties for each component.
|
Client-side validation can be enabled through the browser's [Constraint Validation API](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation) for Web Awesome form controls. You can activate it using attributes such as `required`, `pattern`, `minlength`, `maxlength`, etc. Web Awesome implements many of the same attributes as native form controls, but check the documentation for a list of supported properties for each component.
|
||||||
|
|
||||||
If you don't want to use client-side validation, you can suppress this behavior by adding `novalidate` to the surrounding `<form>` element.
|
If you don't want to use client-side validation, you can suppress this behavior by adding `novalidate` to the surrounding `<form>` element.
|
||||||
|
|
||||||
@@ -56,26 +56,26 @@ Client-side validation can be used to improve the UX of forms, but it is not a r
|
|||||||
|
|
||||||
### Required Fields
|
### Required Fields
|
||||||
|
|
||||||
To make a field required, use the `required` attribute. Required fields will automatically receive a `*` after their labels. This is configurable through the `--sl-input-required-content` custom property.
|
To make a field required, use the `required` attribute. Required fields will automatically receive a `*` after their labels. This is configurable through the `--wa-input-required-content` custom property.
|
||||||
|
|
||||||
The form will not be submitted if a required field is incomplete.
|
The form will not be submitted if a required field is incomplete.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="input-validation-required">
|
<form class="input-validation-required">
|
||||||
<sl-input name="name" label="Name" required></sl-input>
|
<wa-input name="name" label="Name" required></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-select label="Favorite Animal" clearable required>
|
<wa-select label="Favorite Animal" clearable required>
|
||||||
<sl-option value="birds">Birds</sl-option>
|
<wa-option value="birds">Birds</wa-option>
|
||||||
<sl-option value="cats">Cats</sl-option>
|
<wa-option value="cats">Cats</wa-option>
|
||||||
<sl-option value="dogs">Dogs</sl-option>
|
<wa-option value="dogs">Dogs</wa-option>
|
||||||
<sl-option value="other">Other</sl-option>
|
<wa-option value="other">Other</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
<br />
|
<br />
|
||||||
<sl-textarea name="comment" label="Comment" required></sl-textarea>
|
<wa-textarea name="comment" label="Comment" required></wa-textarea>
|
||||||
<br />
|
<br />
|
||||||
<sl-checkbox required>Check me before submitting</sl-checkbox>
|
<wa-checkbox required>Check me before submitting</wa-checkbox>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -83,12 +83,12 @@ The form will not be submitted if a required field is incomplete.
|
|||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-checkbox'),
|
customElements.whenDefined('wa-checkbox'),
|
||||||
customElements.whenDefined('sl-input'),
|
customElements.whenDefined('wa-input'),
|
||||||
customElements.whenDefined('sl-option'),
|
customElements.whenDefined('wa-option'),
|
||||||
customElements.whenDefined('sl-select'),
|
customElements.whenDefined('wa-select'),
|
||||||
customElements.whenDefined('sl-textarea')
|
customElements.whenDefined('wa-textarea')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -99,12 +99,12 @@ The form will not be submitted if a required field is incomplete.
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlCheckbox from '@shoelace-style/shoelace/dist/react/sl-checkbox';
|
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
import SlMenuItem from '@shoelace-style/shoelace/dist/react/sl-menu-item';
|
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
|
||||||
import SlSelect from '@shoelace-style/shoelace/dist/react/sl-select';
|
import WaSelect from '@shoelace-style/shoelace/dist/react/select';
|
||||||
import SlTextarea from '@shoelace-style/shoelace/dist/react/sl-textarea';
|
import WaTextarea from '@shoelace-style/shoelace/dist/react/textarea';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSubmit(event) {
|
function handleSubmit(event) {
|
||||||
@@ -114,23 +114,23 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<SlInput name="name" label="Name" required />
|
<WaInput name="name" label="Name" required />
|
||||||
<br />
|
<br />
|
||||||
<SlSelect label="Favorite Animal" clearable required>
|
<WaSelect label="Favorite Animal" clearable required>
|
||||||
<SlMenuItem value="birds">Birds</SlMenuItem>
|
<WaMenuItem value="birds">Birds</WaMenuItem>
|
||||||
<SlMenuItem value="cats">Cats</SlMenuItem>
|
<WaMenuItem value="cats">Cats</WaMenuItem>
|
||||||
<SlMenuItem value="dogs">Dogs</SlMenuItem>
|
<WaMenuItem value="dogs">Dogs</WaMenuItem>
|
||||||
<SlMenuItem value="other">Other</SlMenuItem>
|
<WaMenuItem value="other">Other</WaMenuItem>
|
||||||
</SlSelect>
|
</WaSelect>
|
||||||
<br />
|
<br />
|
||||||
<SlTextarea name="comment" label="Comment" required></SlTextarea>
|
<WaTextarea name="comment" label="Comment" required></WaTextarea>
|
||||||
<br />
|
<br />
|
||||||
<SlCheckbox required>Check me before submitting</SlCheckbox>
|
<WaCheckbox required>Check me before submitting</WaCheckbox>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -138,14 +138,14 @@ const App = () => {
|
|||||||
|
|
||||||
### Input Patterns
|
### Input Patterns
|
||||||
|
|
||||||
To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern), use the `pattern` attribute. This example only allows the letters A-Z, so the form will not submit if a number or symbol is entered. This only works with `<sl-input>` elements.
|
To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern), use the `pattern` attribute. This example only allows the letters A-Z, so the form will not submit if a number or symbol is entered. This only works with `<wa-input>` elements.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="input-validation-pattern">
|
<form class="input-validation-pattern">
|
||||||
<sl-input name="letters" required label="Letters" pattern="[A-Za-z]+"></sl-input>
|
<wa-input name="letters" required label="Letters" pattern="[A-Za-z]+"></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
<sl-button type="reset" variant="default">Reset</sl-button>
|
<wa-button type="reset" variant="default">Reset</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -153,8 +153,8 @@ To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/
|
|||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-input')
|
customElements.whenDefined('wa-input')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -165,8 +165,8 @@ To restrict a value to a specific [pattern](https://developer.mozilla.org/en-US/
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSubmit(event) {
|
function handleSubmit(event) {
|
||||||
@@ -176,11 +176,11 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<SlInput name="letters" required label="Letters" pattern="[A-Za-z]+" />
|
<WaInput name="letters" required label="Letters" pattern="[A-Za-z]+" />
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -192,12 +192,12 @@ Some input types will automatically trigger constraints, such as `email` and `ur
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="input-validation-type">
|
<form class="input-validation-type">
|
||||||
<sl-input type="email" label="Email" placeholder="you@example.com" required></sl-input>
|
<wa-input type="email" label="Email" placeholder="you@example.com" required></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-input type="url" label="URL" placeholder="https://example.com/" required></sl-input>
|
<wa-input type="url" label="URL" placeholder="https://example.com/" required></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
<sl-button type="reset" variant="default">Reset</sl-button>
|
<wa-button type="reset" variant="default">Reset</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -205,8 +205,8 @@ Some input types will automatically trigger constraints, such as `email` and `ur
|
|||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-input')
|
customElements.whenDefined('wa-input')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -217,8 +217,8 @@ Some input types will automatically trigger constraints, such as `email` and `ur
|
|||||||
```
|
```
|
||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
function handleSubmit(event) {
|
function handleSubmit(event) {
|
||||||
@@ -228,13 +228,13 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<SlInput type="email" label="Email" placeholder="you@example.com" required />
|
<WaInput type="email" label="Email" placeholder="you@example.com" required />
|
||||||
<br />
|
<br />
|
||||||
<SlInput type="url" label="URL" placeholder="https://example.com/" required />
|
<WaInput type="url" label="URL" placeholder="https://example.com/" required />
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -246,31 +246,31 @@ To create a custom validation error, pass a non-empty string to the `setCustomVa
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="input-validation-custom">
|
<form class="input-validation-custom">
|
||||||
<sl-input label="Type “shoelace”" required></sl-input>
|
<wa-input label="Type awesome" required></wa-input>
|
||||||
<br />
|
<br />
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
<sl-button type="reset" variant="default">Reset</sl-button>
|
<wa-button type="reset" variant="default">Reset</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const form = document.querySelector('.input-validation-custom');
|
const form = document.querySelector('.input-validation-custom');
|
||||||
const input = form.querySelector('sl-input');
|
const input = form.querySelector('wa-input');
|
||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-input')
|
customElements.whenDefined('wa-input')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
alert('All fields are valid!');
|
alert('All fields are valid!');
|
||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener('sl-input', () => {
|
input.addEventListener('wa-input', () => {
|
||||||
if (input.value === 'shoelace') {
|
if (input.value === 'awesome') {
|
||||||
input.setCustomValidity('');
|
input.setCustomValidity('');
|
||||||
} else {
|
} else {
|
||||||
input.setCustomValidity("Hey, you're supposed to type 'shoelace' before submitting this!");
|
input.setCustomValidity("Hey, you're supposed to type 'awesome' before submitting this!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -279,8 +279,8 @@ To create a custom validation error, pass a non-empty string to the `setCustomVa
|
|||||||
|
|
||||||
```jsx:react
|
```jsx:react
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import SlButton from '@shoelace-style/shoelace/dist/react/sl-button';
|
import WaButton from '@shoelace-style/shoelace/dist/react/button';
|
||||||
import SlInput from '@shoelace-style/shoelace/dist/react/sl-input';
|
import WaInput from '@shoelace-style/shoelace/dist/react/input';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const input = useRef(null);
|
const input = useRef(null);
|
||||||
@@ -289,10 +289,10 @@ const App = () => {
|
|||||||
function handleInput(event) {
|
function handleInput(event) {
|
||||||
setValue(event.target.value);
|
setValue(event.target.value);
|
||||||
|
|
||||||
if (event.target.value === 'shoelace') {
|
if (event.target.value === 'awesome') {
|
||||||
input.current.setCustomValidity('');
|
input.current.setCustomValidity('');
|
||||||
} else {
|
} else {
|
||||||
input.current.setCustomValidity("Hey, you're supposed to type 'shoelace' before submitting this!");
|
input.current.setCustomValidity("Hey, you're supposed to type 'awesome' before submitting this!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +303,11 @@ const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<SlInput ref={input} label="Type 'shoelace'" required value={value} onSlInput={handleInput} />
|
<WaInput ref={input} label="Type 'awesome'" required value={value} onWaInput={handleInput} />
|
||||||
<br />
|
<br />
|
||||||
<SlButton type="submit" variant="primary">
|
<WaButton type="submit" variant="brand">
|
||||||
Submit
|
Submit
|
||||||
</SlButton>
|
</WaButton>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -319,7 +319,7 @@ Custom validation can be applied to any form control that supports the `setCusto
|
|||||||
|
|
||||||
## Custom Validation Styles
|
## Custom Validation Styles
|
||||||
|
|
||||||
Due to the many ways form controls are used, Shoelace doesn't provide out of the box validation styles for form controls as part of its default theme. Instead, the following attributes will be applied to reflect a control's validity as users interact with it. You can use them to create custom styles for any of the validation states you're interested in.
|
Due to the many ways form controls are used, Web Awesome doesn't provide out of the box validation styles for form controls as part of its default theme. Instead, the following attributes will be applied to reflect a control's validity as users interact with it. You can use them to create custom styles for any of the validation states you're interested in.
|
||||||
|
|
||||||
- `data-required` - the form control is required
|
- `data-required` - the form control is required
|
||||||
- `data-optional` - the form control is optional
|
- `data-optional` - the form control is optional
|
||||||
@@ -331,7 +331,7 @@ Due to the many ways form controls are used, Shoelace doesn't provide out of the
|
|||||||
These attributes map to the browser's built-in pseudo classes for validation: [`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required), [`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional), [`:invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid), [`:valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:valid), and the proposed [`:user-invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-invalid) and [`:user-valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-valid).
|
These attributes map to the browser's built-in pseudo classes for validation: [`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required), [`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional), [`:invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid), [`:valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:valid), and the proposed [`:user-invalid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-invalid) and [`:user-valid`](https://developer.mozilla.org/en-US/docs/Web/CSS/:user-valid).
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
In the future, data attributes will be replaced with custom pseudo classes such as `:--valid` and `:--invalid`. Shoelace is using data attributes as a workaround until browsers support custom states through [`ElementInternals.states`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states).
|
In the future, data attributes will be replaced with custom pseudo classes such as `:--valid` and `:--invalid`. Web Awesome is using data attributes as a workaround until browsers support custom states through [`ElementInternals.states`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Styling Invalid Form Controls
|
### Styling Invalid Form Controls
|
||||||
@@ -342,25 +342,25 @@ This example demonstrates custom validation styles using `data-user-invalid` and
|
|||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="validity-styles">
|
<form class="validity-styles">
|
||||||
<sl-input
|
<wa-input
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
help-text="What would you like people to call you?"
|
help-text="What would you like people to call you?"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
required
|
required
|
||||||
></sl-input>
|
></wa-input>
|
||||||
|
|
||||||
<sl-select name="animal" label="Favorite Animal" help-text="Select the best option." clearable required>
|
<wa-select name="animal" label="Favorite Animal" help-text="Select the best option." clearable required>
|
||||||
<sl-option value="birds">Birds</sl-option>
|
<wa-option value="birds">Birds</wa-option>
|
||||||
<sl-option value="cats">Cats</sl-option>
|
<wa-option value="cats">Cats</wa-option>
|
||||||
<sl-option value="dogs">Dogs</sl-option>
|
<wa-option value="dogs">Dogs</wa-option>
|
||||||
<sl-option value="other">Other</sl-option>
|
<wa-option value="other">Other</wa-option>
|
||||||
</sl-select>
|
</wa-select>
|
||||||
|
|
||||||
<sl-checkbox value="accept" required>Accept terms and conditions</sl-checkbox>
|
<wa-checkbox value="accept" required>Accept terms and conditions</wa-checkbox>
|
||||||
|
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
<sl-button type="reset" variant="default">Reset</sl-button>
|
<wa-button type="reset" variant="default">Reset</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -368,11 +368,11 @@ This example demonstrates custom validation styles using `data-user-invalid` and
|
|||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-checkbox'),
|
customElements.whenDefined('wa-checkbox'),
|
||||||
customElements.whenDefined('sl-input'),
|
customElements.whenDefined('wa-input'),
|
||||||
customElements.whenDefined('sl-option'),
|
customElements.whenDefined('wa-option'),
|
||||||
customElements.whenDefined('sl-select')
|
customElements.whenDefined('wa-select')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
form.addEventListener('submit', event => {
|
form.addEventListener('submit', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -382,98 +382,98 @@ This example demonstrates custom validation styles using `data-user-invalid` and
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.validity-styles sl-input,
|
.validity-styles wa-input,
|
||||||
.validity-styles sl-select,
|
.validity-styles wa-select,
|
||||||
.validity-styles sl-checkbox {
|
.validity-styles wa-checkbox {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: var(--sl-spacing-medium);
|
margin-bottom: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* user invalid styles */
|
/* user invalid styles */
|
||||||
.validity-styles sl-input[data-user-invalid]::part(base),
|
.validity-styles wa-input[data-user-invalid]::part(base),
|
||||||
.validity-styles sl-select[data-user-invalid]::part(combobox),
|
.validity-styles wa-select[data-user-invalid]::part(combobox),
|
||||||
.validity-styles sl-checkbox[data-user-invalid]::part(control) {
|
.validity-styles wa-checkbox[data-user-invalid]::part(control) {
|
||||||
border-color: var(--sl-color-danger-600);
|
border-color: var(--sl-color-danger-600);
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles [data-user-invalid]::part(form-control-label),
|
.validity-styles [data-user-invalid]::part(form-control-label),
|
||||||
.validity-styles [data-user-invalid]::part(form-control-help-text),
|
.validity-styles [data-user-invalid]::part(form-control-help-text),
|
||||||
.validity-styles sl-checkbox[data-user-invalid]::part(label) {
|
.validity-styles wa-checkbox[data-user-invalid]::part(label) {
|
||||||
color: var(--sl-color-danger-700);
|
color: var(--sl-color-danger-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles sl-checkbox[data-user-invalid]::part(control) {
|
.validity-styles wa-checkbox[data-user-invalid]::part(control) {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles sl-input:focus-within[data-user-invalid]::part(base),
|
.validity-styles wa-input:focus-within[data-user-invalid]::part(base),
|
||||||
.validity-styles sl-select:focus-within[data-user-invalid]::part(combobox),
|
.validity-styles wa-select:focus-within[data-user-invalid]::part(combobox),
|
||||||
.validity-styles sl-checkbox:focus-within[data-user-invalid]::part(control) {
|
.validity-styles wa-checkbox:focus-within[data-user-invalid]::part(control) {
|
||||||
border-color: var(--sl-color-danger-600);
|
border-color: var(--sl-color-danger-600);
|
||||||
box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-color-danger-300);
|
box-shadow: 0 0 0 var(--wa-focus-ring-width) var(--sl-color-danger-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User valid styles */
|
/* User valid styles */
|
||||||
.validity-styles sl-input[data-user-valid]::part(base),
|
.validity-styles wa-input[data-user-valid]::part(base),
|
||||||
.validity-styles sl-select[data-user-valid]::part(combobox),
|
.validity-styles wa-select[data-user-valid]::part(combobox),
|
||||||
.validity-styles sl-checkbox[data-user-valid]::part(control) {
|
.validity-styles wa-checkbox[data-user-valid]::part(control) {
|
||||||
border-color: var(--sl-color-success-600);
|
border-color: var(--sl-color-success-600);
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles [data-user-valid]::part(form-control-label),
|
.validity-styles [data-user-valid]::part(form-control-label),
|
||||||
.validity-styles [data-user-valid]::part(form-control-help-text),
|
.validity-styles [data-user-valid]::part(form-control-help-text),
|
||||||
.validity-styles sl-checkbox[data-user-valid]::part(label) {
|
.validity-styles wa-checkbox[data-user-valid]::part(label) {
|
||||||
color: var(--sl-color-success-700);
|
color: var(--sl-color-success-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles sl-checkbox[data-user-valid]::part(control) {
|
.validity-styles wa-checkbox[data-user-valid]::part(control) {
|
||||||
background-color: var(--sl-color-success-600);
|
background-color: var(--sl-color-success-600);
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.validity-styles sl-input:focus-within[data-user-valid]::part(base),
|
.validity-styles wa-input:focus-within[data-user-valid]::part(base),
|
||||||
.validity-styles sl-select:focus-within[data-user-valid]::part(combobox),
|
.validity-styles wa-select:focus-within[data-user-valid]::part(combobox),
|
||||||
.validity-styles sl-checkbox:focus-within[data-user-valid]::part(control) {
|
.validity-styles wa-checkbox:focus-within[data-user-valid]::part(control) {
|
||||||
border-color: var(--sl-color-success-600);
|
border-color: var(--sl-color-success-600);
|
||||||
box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-color-success-300);
|
box-shadow: 0 0 0 var(--wa-focus-ring-width) var(--sl-color-success-300);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inline Form Validation
|
## Inline Form Validation
|
||||||
|
|
||||||
By default, Shoelace form controls use the browser's tooltip-style error messages. No mechanism is provided to show errors inline, as there are too many opinions on how that would work when combined with native form controls and other custom elements. You can, however, implement your own solution using the following technique.
|
By default, Web Awesome form controls use the browser's tooltip-style error messages. No mechanism is provided to show errors inline, as there are too many opinions on how that would work when combined with native form controls and other custom elements. You can, however, implement your own solution using the following technique.
|
||||||
|
|
||||||
To disable the browser's error messages, you need to cancel the `sl-invalid` event. Then you can apply your own inline validation errors. This example demonstrates a primitive way to do this.
|
To disable the browser's error messages, you need to cancel the `wa-invalid` event. Then you can apply your own inline validation errors. This example demonstrates a primitive way to do this.
|
||||||
|
|
||||||
```html:preview
|
```html:preview
|
||||||
<form class="inline-validation">
|
<form class="inline-validation">
|
||||||
<sl-input
|
<wa-input
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
help-text="What would you like people to call you?"
|
help-text="What would you like people to call you?"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
required
|
required
|
||||||
></sl-input>
|
></wa-input>
|
||||||
|
|
||||||
<div id="name-error" aria-live="polite" hidden></div>
|
<div id="name-error" aria-live="polite" hidden></div>
|
||||||
|
|
||||||
<sl-button type="submit" variant="primary">Submit</sl-button>
|
<wa-button type="submit" variant="brand">Submit</wa-button>
|
||||||
<sl-button type="reset" variant="default">Reset</sl-button>
|
<wa-button type="reset" variant="default">Reset</wa-button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script type="module">
|
||||||
const form = document.querySelector('.inline-validation');
|
const form = document.querySelector('.inline-validation');
|
||||||
const nameError = document.querySelector('#name-error');
|
const nameError = document.querySelector('#name-error');
|
||||||
|
|
||||||
// Wait for controls to be defined before attaching form listeners
|
// Wait for controls to be defined before attaching form listeners
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
customElements.whenDefined('sl-button'),
|
customElements.whenDefined('wa-button'),
|
||||||
customElements.whenDefined('sl-input')
|
customElements.whenDefined('wa-input')
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
// A form control is invalid
|
// A form control is invalid
|
||||||
form.addEventListener(
|
form.addEventListener(
|
||||||
'sl-invalid',
|
'wa-invalid',
|
||||||
event => {
|
event => {
|
||||||
// Suppress the browser's constraint validation message
|
// Suppress the browser's constraint validation message
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -483,7 +483,7 @@ To disable the browser's error messages, you need to cancel the `sl-invalid` eve
|
|||||||
|
|
||||||
event.target.focus();
|
event.target.focus();
|
||||||
},
|
},
|
||||||
{ capture: true } // you must use capture since sl-invalid doesn't bubble!
|
{ capture: true } // you must use capture since wa-invalid doesn't bubble!
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle form submit
|
// Handle form submit
|
||||||
@@ -504,20 +504,20 @@ To disable the browser's error messages, you need to cancel the `sl-invalid` eve
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
#name-error {
|
#name-error {
|
||||||
font-size: var(--sl-input-help-text-font-size-medium);
|
font-size: var(--wa-input-help-text-font-size-medium);
|
||||||
color: var(--sl-color-danger-700);
|
color: var(--sl-color-danger-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
#name-error ~ sl-button {
|
#name-error ~ wa-button {
|
||||||
margin-top: var(--sl-spacing-medium);
|
margin-top: var(--wa-space-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-validation sl-input {
|
.inline-validation wa-input {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* user invalid styles */
|
/* user invalid styles */
|
||||||
.inline-validation sl-input[data-user-invalid]::part(base) {
|
.inline-validation wa-input[data-user-invalid]::part(base) {
|
||||||
border-color: var(--sl-color-danger-600);
|
border-color: var(--sl-color-danger-600);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,13 +526,13 @@ To disable the browser's error messages, you need to cancel the `sl-invalid` eve
|
|||||||
color: var(--sl-color-danger-700);
|
color: var(--sl-color-danger-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-validation sl-input:focus-within[data-user-invalid]::part(base) {
|
.inline-validation wa-input:focus-within[data-user-invalid]::part(base) {
|
||||||
border-color: var(--sl-color-danger-600);
|
border-color: var(--sl-color-danger-600);
|
||||||
box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-color-danger-300);
|
box-shadow: 0 0 0 var(--wa-focus-ring-width) var(--sl-color-danger-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User valid styles */
|
/* User valid styles */
|
||||||
.inline-validation sl-input[data-user-valid]::part(base) {
|
.inline-validation wa-input[data-user-valid]::part(base) {
|
||||||
border-color: var(--sl-color-success-600);
|
border-color: var(--sl-color-success-600);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,9 +541,9 @@ To disable the browser's error messages, you need to cancel the `sl-invalid` eve
|
|||||||
color: var(--sl-color-success-700);
|
color: var(--sl-color-success-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-validation sl-input:focus-within[data-user-valid]::part(base) {
|
.inline-validation wa-input:focus-within[data-user-valid]::part(base) {
|
||||||
border-color: var(--sl-color-success-600);
|
border-color: var(--sl-color-success-600);
|
||||||
box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-color-success-300);
|
box-shadow: 0 0 0 var(--wa-focus-ring-width) var(--sl-color-success-300);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
@@ -554,7 +554,7 @@ This example is meant to demonstrate the concept of providing your own error mes
|
|||||||
|
|
||||||
## Getting Associated Form Controls
|
## Getting Associated Form Controls
|
||||||
|
|
||||||
At this time, using [`HTMLFormElement.elements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements) will not return Shoelace form controls because the browser is unaware of their status as custom element form controls. Fortunately, Shoelace provides an `elements()` function that does something very similar. However, instead of returning an [`HTMLFormControlsCollection`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection), it returns an array of HTML and Shoelace form controls in the order they appear in the DOM.
|
At this time, using [`HTMLFormElement.elements`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements) will not return Web Awesome form controls because the browser is unaware of their status as custom element form controls. Fortunately, Web Awesome provides an `elements()` function that does something very similar. However, instead of returning an [`HTMLFormControlsCollection`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection), it returns an array of HTML and Web Awesome form controls in the order they appear in the DOM.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { getFormControls } from '@shoelace-style/shoelace/dist/utilities/form.js';
|
import { getFormControls } from '@shoelace-style/shoelace/dist/utilities/form.js';
|
||||||
@@ -562,7 +562,7 @@ import { getFormControls } from '@shoelace-style/shoelace/dist/utilities/form.js
|
|||||||
const form = document.querySelector('#my-form');
|
const form = document.querySelector('#my-form');
|
||||||
const formControls = getFormControls(form);
|
const formControls = getFormControls(form);
|
||||||
|
|
||||||
console.log(formControls); // e.g. [input, sl-input, ...]
|
console.log(formControls); // e.g. [input, wa-input, ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|||||||
@@ -6,44 +6,44 @@ meta:
|
|||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
You can load Shoelace via CDN or by installing it locally. If you're using a framework, make sure to check out the pages for [React](/frameworks/react), [Vue](/frameworks/vue), and [Angular](/frameworks/angular) for additional information.
|
You can load Web Awesome via CDN or by installing it locally. If you're using a framework, make sure to check out the pages for [React](/frameworks/react), [Vue](/frameworks/vue), and [Angular](/frameworks/angular) for additional information.
|
||||||
|
|
||||||
## CDN Installation (Easiest)
|
## CDN Installation (Easiest)
|
||||||
|
|
||||||
<sl-tab-group>
|
<wa-tab-group>
|
||||||
<sl-tab slot="nav" panel="autoloader" active>Autoloader</sl-tab>
|
<wa-tab slot="nav" panel="autoloader" active>Autoloader</wa-tab>
|
||||||
<sl-tab slot="nav" panel="traditional">Traditional Loader</sl-tab>
|
<wa-tab slot="nav" panel="traditional">Traditional Loader</wa-tab>
|
||||||
|
|
||||||
<sl-tab-panel name="autoloader">
|
<wa-tab-panel name="autoloader">
|
||||||
|
|
||||||
The experimental autoloader is the easiest and most efficient way to use Shoelace. A lightweight script watches the DOM for unregistered Shoelace elements and lazy loads them for you — even if they're added dynamically.
|
The experimental autoloader is the easiest and most efficient way to use Web Awesome. A lightweight script watches the DOM for unregistered Web Awesome elements and lazy loads them for you — even if they're added dynamically.
|
||||||
|
|
||||||
While convenient, autoloading may lead to a [Flash of Undefined Custom Elements](https://www.abeautifulsite.net/posts/flash-of-undefined-custom-elements/). The linked article describes some ways to alleviate it.
|
While convenient, autoloading may lead to a [Flash of Undefined Custom Elements](https://www.abeautifulsite.net/posts/flash-of-undefined-custom-elements/). The linked article describes some ways to alleviate it.
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/light.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/default.css" />
|
||||||
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/shoelace-autoloader.js"></script>
|
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/autoloader.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
|
|
||||||
<sl-tab-panel name="traditional">
|
<wa-tab-panel name="traditional">
|
||||||
|
|
||||||
The traditional CDN loader registers all Shoelace elements up front. Note that, if you're only using a handful of components, it will be much more efficient to stick with the autoloader. However, you can also [cherry pick](#cherry-picking) components if you want to load specific ones up front.
|
The traditional CDN loader registers all Web Awesome elements up front. Note that, if you're only using a handful of components, it will be much more efficient to stick with the autoloader. However, you can also [cherry pick](#cherry-picking) components if you want to load specific ones up front.
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/light.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/default.css" />
|
||||||
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/shoelace.js" ></script>
|
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/autoloader.js" ></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
</sl-tab-panel>
|
</wa-tab-panel>
|
||||||
</sl-tab-group>
|
</wa-tab-group>
|
||||||
|
|
||||||
### Dark Theme
|
### Dark Theme
|
||||||
|
|
||||||
The code above will load the light theme. If you want to use the [dark theme](/getting-started/themes#dark-theme) instead, update the stylesheet as shown below and add `<html class="sl-theme-dark">` to your page.
|
The code above will load the light theme. If you want to use the [dark theme](/getting-started/themes#dark-theme) instead, update the stylesheet as shown below and add `<html class="wa-theme-default-dark">` to your page.
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
```html
|
```html
|
||||||
@@ -58,21 +58,21 @@ If you want to load the light or dark theme based on the user's `prefers-color-s
|
|||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
media="(prefers-color-scheme:light)"
|
media="(prefers-color-scheme:light)"
|
||||||
href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/light.css"
|
href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/default.css"
|
||||||
/>
|
/>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
media="(prefers-color-scheme:dark)"
|
media="(prefers-color-scheme:dark)"
|
||||||
href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/dark.css"
|
href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/themes/dark.css"
|
||||||
onload="document.documentElement.classList.add('sl-theme-dark');"
|
onload="document.documentElement.classList.add('wa-theme-default-dark');"
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can [start using Shoelace!](/getting-started/usage)
|
Now you can [start using Web Awesome!](/getting-started/usage)
|
||||||
|
|
||||||
## npm installation
|
## npm installation
|
||||||
|
|
||||||
If you don't want to use the CDN, you can install Shoelace from npm with the following command.
|
If you don't want to use the CDN, you can install Web Awesome from npm with the following command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
@@ -83,25 +83,25 @@ It's up to you to make the source files available to your app. One way to do thi
|
|||||||
Once you've done that, add the following tags to your page. Make sure to update `href` and `src` so they point to the route you created.
|
Once you've done that, add the following tags to your page. Make sure to update `href` and `src` so they point to the route you created.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="/shoelace/%NPMDIR%/themes/light.css" />
|
<link rel="stylesheet" href="/shoelace/%NPMDIR%/themes/default.css" />
|
||||||
<script type="module" src="/shoelace/%NPMDIR%/shoelace.js"></script>
|
<script type="module" src="/shoelace/%NPMDIR%/autoloader.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, [you can use a bundler](#bundling).
|
Alternatively, [you can use a bundler](#bundling).
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
For clarity, the docs will usually show imports from `@shoelace-style/shoelace`. If you're not using a module resolver or bundler, you'll need to adjust these paths to point to the folder Shoelace is in.
|
For clarity, the docs will usually show imports from `@shoelace-style/shoelace`. If you're not using a module resolver or bundler, you'll need to adjust these paths to point to the folder Web Awesome is in.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Setting the Base Path
|
## Setting the Base Path
|
||||||
|
|
||||||
Some components rely on assets (icons, images, etc.) and Shoelace needs to know where they're located. For convenience, Shoelace will try to auto-detect the correct location based on the script you've loaded it from. This assumes assets are colocated with `shoelace.js` or `shoelace-autoloader.js` and will "just work" for most users.
|
Some components rely on assets (icons, images, etc.) and Web Awesome needs to know where they're located. For convenience, Web Awesome will try to auto-detect the correct location based on the script you've loaded it from. This assumes assets are colocated with `autoloader.js` and will "just work" for most users.
|
||||||
|
|
||||||
However, if you're [cherry picking](#cherry-picking) or [bundling](#bundling) Shoelace, you'll need to set the base path. You can do this one of two ways.
|
However, if you're [cherry picking](#cherry-picking) or [bundling](#bundling) Web Awesome, you'll need to set the base path. You can do this one of two ways.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- Option 1: the data-shoelace attribute -->
|
<!-- Option 1: the data-webawesome attribute -->
|
||||||
<script src="bundle.js" data-shoelace="/path/to/shoelace/%NPMDIR%"></script>
|
<script src="bundle.js" data-webawesome="/path/to/shoelace/%NPMDIR%"></script>
|
||||||
|
|
||||||
<!-- Option 2: the setBasePath() method -->
|
<!-- Option 2: the setBasePath() method -->
|
||||||
<script src="bundle.js"></script>
|
<script src="bundle.js"></script>
|
||||||
@@ -117,7 +117,7 @@ An easy way to make sure the base path is configured properly is to check if [ic
|
|||||||
|
|
||||||
### Referencing Assets
|
### Referencing Assets
|
||||||
|
|
||||||
Most of the magic behind assets is handled internally by Shoelace, but if you need to reference the base path for any reason, the same module exports a function called `getBasePath()`. An optional string argument can be passed, allowing you to get the full path to any asset.
|
Most of the magic behind assets is handled internally by Web Awesome, but if you need to reference the base path for any reason, the same module exports a function called `getBasePath()`. An optional string argument can be passed, allowing you to get the full path to any asset.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -139,33 +139,29 @@ Most of the magic behind assets is handled internally by Shoelace, but if you ne
|
|||||||
|
|
||||||
Cherry picking can be done from [the CDN](#cdn-installation-easiest) or from [npm](#npm-installation). This approach will load only the components you need up front, while limiting the number of files the browser has to download. The disadvantage is that you need to import each individual component.
|
Cherry picking can be done from [the CDN](#cdn-installation-easiest) or from [npm](#npm-installation). This approach will load only the components you need up front, while limiting the number of files the browser has to download. The disadvantage is that you need to import each individual component.
|
||||||
|
|
||||||
Here's an example that loads only the button component. Again, if you're not using a module resolver, you'll need to adjust the path to point to the folder Shoelace is in.
|
Here's an example that loads only the button component. Again, if you're not using a module resolver, you'll need to adjust the path to point to the folder Web Awesome is in.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="/path/to/shoelace/%NPMDIR%/themes/light.css" />
|
<link rel="stylesheet" href="/path/to/shoelace/%NPMDIR%/themes/default.css" />
|
||||||
|
|
||||||
<script type="module" data-shoelace="/path/to/shoelace/%NPMDIR%">
|
<script type="module" data-webawesome="/path/to/shoelace/%NPMDIR%">
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
import '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
||||||
|
|
||||||
// <sl-button> is ready to use!
|
// <wa-button> is ready to use!
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
You can copy and paste the code to import a component from the "Importing" section of the component's documentation. Note that some components have dependencies that are automatically imported when you cherry pick. If a component has dependencies, they will be listed in the "Dependencies" section of its docs.
|
You can copy and paste the code to import a component from the "Importing" section of the component's documentation. Note that some components have dependencies that are automatically imported when you cherry pick. If a component has dependencies, they will be listed in the "Dependencies" section of its docs.
|
||||||
|
|
||||||
:::warning
|
|
||||||
Never cherry pick components or utilities from `shoelace.js` as this will cause the browser to load the entire library. Instead, cherry pick from specific modules as shown above.
|
|
||||||
:::
|
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
You will see files named `chunk.[hash].js` in the `chunks` directory. Never import these files directly, as they are generated and change from version to version.
|
You will see files named `chunk.[hash].js` in the `chunks` directory. Never import these files directly, as they are generated and change from version to version.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Bundling
|
## Bundling
|
||||||
|
|
||||||
Shoelace is distributed as a collection of standard ES modules that [all modern browsers can understand](https://caniuse.com/es6-module). However, importing a lot of modules can result in a lot of HTTP requests and potentially longer load times. Using a CDN can alleviate this, but some users may wish to further optimize their imports with a bundler.
|
Web Awesome is distributed as a collection of standard ES modules that [all modern browsers can understand](https://caniuse.com/es6-module). However, importing a lot of modules can result in a lot of HTTP requests and potentially longer load times. Using a CDN can alleviate this, but some users may wish to further optimize their imports with a bundler.
|
||||||
|
|
||||||
To use Shoelace with a bundler, first install Shoelace along with your bundler of choice.
|
To use Web Awesome with a bundler, first install Web Awesome along with your bundler of choice.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @shoelace-style/shoelace
|
npm install @shoelace-style/shoelace
|
||||||
@@ -176,20 +172,20 @@ Now it's time to configure your bundler. Configurations vary for each tool, but
|
|||||||
- [Example webpack config](https://github.com/shoelace-style/webpack-example/blob/master/webpack.config.js)
|
- [Example webpack config](https://github.com/shoelace-style/webpack-example/blob/master/webpack.config.js)
|
||||||
- [Example Rollup config](https://github.com/shoelace-style/rollup-example/blob/master/rollup.config.js)
|
- [Example Rollup config](https://github.com/shoelace-style/rollup-example/blob/master/rollup.config.js)
|
||||||
|
|
||||||
Once your bundler is configured, you'll be able to import Shoelace components and utilities.
|
Once your bundler is configured, you'll be able to import Web Awesome components and utilities.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/themes/light.css';
|
import '@shoelace-style/shoelace/%NPMDIR%/themes/default.css';
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
import '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/components/icon/icon.js';
|
import '@shoelace-style/shoelace/%NPMDIR%/components/icon/icon.js';
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/components/input/input.js';
|
import '@shoelace-style/shoelace/%NPMDIR%/components/input/input.js';
|
||||||
import '@shoelace-style/shoelace/%NPMDIR%/components/rating/rating.js';
|
import '@shoelace-style/shoelace/%NPMDIR%/components/rating/rating.js';
|
||||||
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path.js';
|
import { setBasePath } from '@shoelace-style/shoelace/%NPMDIR%/utilities/base-path.js';
|
||||||
|
|
||||||
// Set the base path to the folder you copied Shoelace's assets to
|
// Set the base path to the folder you copied Web Awesome's assets to
|
||||||
setBasePath('/path/to/shoelace/%NPMDIR%
|
setBasePath('/path/to/shoelace/%NPMDIR%');
|
||||||
|
|
||||||
// <sl-button>, <sl-icon>, <sl-input>, and <sl-rating> are ready to use!
|
// <wa-button>, <wa-icon>, <wa-input>, and <wa-rating> are ready to use!
|
||||||
```
|
```
|
||||||
|
|
||||||
:::warning
|
:::warning
|
||||||
@@ -201,8 +197,8 @@ Component modules include side effects for registration purposes. Because of thi
|
|||||||
By default, imports to components will auto-register themselves. This may not be ideal in all cases. To import just the component's class without auto-registering it's tag we can do the following:
|
By default, imports to components will auto-register themselves. This may not be ideal in all cases. To import just the component's class without auto-registering it's tag we can do the following:
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- import SlButton from '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
- import WaButton from '@shoelace-style/shoelace/%NPMDIR%/components/button/button.js';
|
||||||
+ import SlButton from '@shoelace-style/shoelace/%NPMDIR%/components/button/button.component.js';
|
+ import WaButton from '@shoelace-style/shoelace/%NPMDIR%/components/button/button.component.js';
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice how the import ends with `.component.js`. This is the current convention to convey the import does not register itself.
|
Notice how the import ends with `.component.js`. This is the current convention to convey the import does not register itself.
|
||||||
@@ -220,4 +216,4 @@ TL;DR:
|
|||||||
- `@shoelace-style/shoelace/%CDNDIR%` is for CDN users
|
- `@shoelace-style/shoelace/%CDNDIR%` is for CDN users
|
||||||
- `@shoelace-style/shoelace/%NPMDIR%` is for npm users
|
- `@shoelace-style/shoelace/%NPMDIR%` is for npm users
|
||||||
|
|
||||||
This change was introduced in `v2.5.0` to address issues around installations from npm loading multiple versions of libraries (such as the Lit) that Shoelace uses internally.
|
This change was introduced in `v2.5.0` to address issues around installations from npm loading multiple versions of libraries (such as the Lit) that Web Awesome uses internally.
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
meta:
|
meta:
|
||||||
title: Localization
|
title: Localization
|
||||||
description: Discover how to localize Shoelace with minimal effort.
|
description: Discover how to localize Web Awesome with minimal effort.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Localization
|
# Localization
|
||||||
|
|
||||||
Components can be localized by importing the appropriate translation file and setting the desired [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) and/or [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) on the `<html>` element. Here's an example that renders Shoelace components in Spanish.
|
Components can be localized by importing the appropriate translation file and setting the desired [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) and/or [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) on the `<html>` element. Here's an example that renders Web Awesome components in Spanish.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<html lang="es">
|
<html lang="es">
|
||||||
@@ -24,9 +24,9 @@ Through the magic of a mutation observer, changing the `lang` attribute will aut
|
|||||||
|
|
||||||
## Available Translations
|
## Available Translations
|
||||||
|
|
||||||
Shoelace ships with a number of translations. The default is English (US), which also serves as the fallback locale. As such, you do not need to import the English translation. To see a list of all available translations in the latest version, [refer to this directory](https://github.com/shoelace-style/shoelace/tree/current/src/translations).
|
Web Awesome ships with a number of translations. The default is English (US), which also serves as the fallback locale. As such, you do not need to import the English translation. To see a list of all available translations in the latest version, [refer to this directory](https://github.com/shoelace-style/shoelace/tree/current/src/translations).
|
||||||
|
|
||||||
The location of translations depends on how you're consuming Shoelace.
|
The location of translations depends on how you're consuming Web Awesome.
|
||||||
|
|
||||||
- If you're using the CDN, [import them from the CDN](https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace?path=%CDNDIR%%2Ftranslations)
|
- If you're using the CDN, [import them from the CDN](https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace?path=%CDNDIR%%2Ftranslations)
|
||||||
- If you're using a bundler, import them from `@shoelace-style/shoelace/%NPMDIR%/translations/[lang].js`
|
- If you're using a bundler, import them from `@shoelace-style/shoelace/%NPMDIR%/translations/[lang].js`
|
||||||
@@ -49,7 +49,7 @@ The locale set by `<html lang="...">` is the default locale for the document. If
|
|||||||
2. Look for `es`
|
2. Look for `es`
|
||||||
3. Fall back to `en`
|
3. Fall back to `en`
|
||||||
|
|
||||||
Shoelace uses English as a fallback to provide a better experience than rendering nothing or throwing an error.
|
Web Awesome uses English as a fallback to provide a better experience than rendering nothing or throwing an error.
|
||||||
|
|
||||||
### Submitting New Translations or Improvements
|
### Submitting New Translations or Improvements
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ Regional translations are welcome! For example, if a German translation (`de`) e
|
|||||||
If you have any questions, please start a [discussion](https://github.com/shoelace-style/shoelace/discussions) or ask in the [community chat](https://discord.gg/mg8f26C).
|
If you have any questions, please start a [discussion](https://github.com/shoelace-style/shoelace/discussions) or ask in the [community chat](https://discord.gg/mg8f26C).
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Shoelace provides a localization mechanism for component internals. This is not designed to be used as localization tool for your entire application. You should use a more appropriate tool such as [i18next](https://www.i18next.com/) if you need to localize content in your app.
|
Web Awesome provides a localization mechanism for component internals. This is not designed to be used as localization tool for your entire application. You should use a more appropriate tool such as [i18next](https://www.i18next.com/) if you need to localize content in your app.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Multiple Locales Per Page
|
## Multiple Locales Per Page
|
||||||
@@ -72,8 +72,8 @@ You can use a different locale for an individual component by setting its `lang`
|
|||||||
...
|
...
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<sl-button><!-- Spanish --></sl-button>
|
<wa-button><!-- Spanish --></wa-button>
|
||||||
<sl-button lang="ru"><!-- Russian --></sl-button>
|
<wa-button lang="ru"><!-- Russian --></wa-button>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
@@ -86,7 +86,7 @@ For performance reasons, the `lang` and `dir` attributes must be on the componen
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div lang="ru">
|
<div lang="ru">
|
||||||
<sl-button><!-- still in Spanish --></sl-button>
|
<wa-button><!-- still in Spanish --></wa-button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user