Compare commits

..

84 Commits

Author SHA1 Message Date
Cory LaViska
1329d4475a eslint 2023-11-02 13:20:43 -04:00
Cory LaViska
f5448f3f09 prettier 2023-11-02 13:16:52 -04:00
Cory LaViska
b33efe697b add recommended styles 2023-11-02 13:10:43 -04:00
Cory LaViska
306911d663 add layout examples link 2023-11-02 13:04:39 -04:00
Cory LaViska
c0e49cc4ab fix markup 2023-11-02 12:00:19 -04:00
Cory LaViska
64ac34447c fix missing </div> 2023-11-02 12:00:11 -04:00
Cory LaViska
667e78243c remove preview 2023-11-02 11:52:08 -04:00
Cory LaViska
93883537a0 layouts docs 2023-11-02 11:16:33 -04:00
Cory LaViska
900d4b74e3 update name 2023-11-02 11:16:26 -04:00
Cory LaViska
c371dae683 use slot names 2023-11-02 11:15:58 -04:00
Cory LaViska
ecf2da5201 Merge branch 'next' into layouts-review 2023-11-02 08:53:41 -04:00
Cory LaViska
5383411572 fix metadata 2023-11-01 13:25:25 -04:00
Cory LaViska
af3958cc63 fix margin 2023-11-01 13:01:32 -04:00
Cory LaViska
30561d565b Merge branch 'next' into layouts-review 2023-11-01 11:20:04 -04:00
Cory LaViska
4340f89830 Merge branch 'konnorrogers/layouts' into layouts-review 2023-10-24 14:55:07 -04:00
Cory LaViska
9a46c29072 fixes/updates 2023-10-24 14:54:31 -04:00
konnorrogers
55bc5f0432 Merge branch 'konnorrogers/layouts' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-10-24 11:54:53 -04:00
konnorrogers
dc7c68d6c5 add themer to sport-awesome 2023-10-24 11:53:53 -04:00
Cory LaViska
213bde0f7f fix prettier command 2023-10-24 10:01:07 -04:00
Cory LaViska
c195b9f444 prettier 2023-10-24 09:57:01 -04:00
Cory LaViska
58a9f04623 Merge branch 'next' into konnorrogers/layouts 2023-10-24 09:53:40 -04:00
konnorrogers
b134911703 update layout playground 2023-10-23 14:14:59 -04:00
konnorrogers
0fa4810ddb Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-10-23 11:41:36 -04:00
konnorrogers
1f09a53fab layouts 2023-10-20 16:03:52 -04:00
konnorrogers
2d95eedbac fix playgrounds 2023-10-20 16:01:10 -04:00
konnorrogers
26d83f37d6 with different base settings 2023-10-20 15:29:33 -04:00
konnorrogers
a751053803 try with all sandbox settings on 2023-10-20 15:26:35 -04:00
konnorrogers
44a7dd5089 try 1.0.1 2023-10-20 15:03:01 -04:00
konnorrogers
902ab85f32 fix playgrounds 2023-10-20 14:24:27 -04:00
konnorrogers
21647001a4 update light-preview 2023-10-20 14:04:27 -04:00
konnorrogers
a0ee2256c4 update light-pen 2023-10-20 12:09:02 -04:00
konnorrogers
51f5c30526 update sport awesome, rename to .html and .css 2023-10-20 11:58:18 -04:00
konnorrogers
9e0aa9c2ec move flow to sport-awesome 2023-10-19 14:36:52 -04:00
konnorrogers
15a9c63040 Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-10-19 12:54:04 -04:00
konnorrogers
a1a09a2b2b finish up sport awesome 2023-10-18 16:10:18 -04:00
konnorrogers
1df6afa541 finish up sport awesome 2023-10-18 13:49:09 -04:00
konnorrogers
d4e2abe218 Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-10-18 11:24:46 -04:00
konnorrogers
ac94d838f0 continued work on sportawesome 2023-10-16 16:31:50 -04:00
konnorrogers
23a0f4afdc working on sportawesome 2023-10-16 12:26:46 -04:00
konnorrogers
00f23c485d update layout stuff 2023-10-13 10:59:19 -04:00
konnorrogers
7a31446162 add disable-sticky 2023-10-12 12:55:33 -04:00
konnorrogers
11893fe80c Merge branch 'next' into konnorrogers/layouts 2023-10-12 12:18:10 -04:00
konnorrogers
e23adf4d11 use toggle-navigation 2023-10-12 12:15:24 -04:00
konnorrogers
739a6033af more notes to layout 2023-10-04 16:21:19 -04:00
konnorrogers
ed43baa459 update to use <current> on the nav-item 2023-10-04 15:58:58 -04:00
konnorrogers
9cbc27a6ef refactor nav-item to use a 'string' for 'current' 2023-10-04 15:52:38 -04:00
konnorrogers
b017c4df1e add support for data-wa-layout-navigation-toggle 2023-10-02 16:14:23 -04:00
konnorrogers
27aaa82a9c Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-10-02 14:45:02 -04:00
konnorrogers
57194ed12d readd nav button 2023-10-02 12:20:29 -04:00
konnorrogers
74d5b4c3f4 remove navigation button 2023-10-02 11:58:56 -04:00
konnorrogers
e95bfab77b update 2023-09-29 10:20:27 -04:00
konnorrogers
78785b872d Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-29 10:19:38 -04:00
konnorrogers
6f0c41cddf apply lindsay's tweaks 2023-09-28 17:29:40 -04:00
konnorrogers
52bda73657 apply lindsay's tweaks 2023-09-28 16:53:29 -04:00
konnorrogers
aaf845c72a prettier 2023-09-25 16:25:02 -04:00
konnorrogers
fc66179dc0 fix react examples 2023-09-25 16:07:16 -04:00
konnorrogers
67702b8d89 more nav-group / nav-item fixes 2023-09-25 12:25:06 -04:00
konnorrogers
81ff1422e8 working on nav group / nav-items 2023-09-22 14:26:25 -04:00
konnorrogers
27984299e0 remove align-items: stretch 2023-09-21 12:58:55 -04:00
konnorrogers
0cac319988 working on nav group / nav-items 2023-09-21 12:52:41 -04:00
konnorrogers
0509fb041f Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-21 10:05:16 -04:00
konnorrogers
32bc7f2207 more work on nav items 2023-09-20 18:14:25 -04:00
konnorrogers
7c73b6a458 Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-20 14:23:28 -04:00
konnorrogers
6b579a6946 move to nav-item + nav-group 2023-09-19 17:45:11 -04:00
konnorrogers
896fe76a8d continued layout work 2023-09-18 16:35:05 -04:00
konnorrogers
ed1621410b update to example.njk 2023-09-15 14:08:49 -04:00
konnorrogers
29e591e69b Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-15 12:56:59 -04:00
konnorrogers
396e632679 working on navigation 2023-09-15 12:36:16 -04:00
konnorrogers
316f8eb16d use brand button 2023-09-14 14:14:55 -04:00
konnorrogers
131b1ee57e adding layout examples 2023-09-14 14:10:43 -04:00
konnorrogers
75004768bb push up docs 2023-09-13 15:51:39 -04:00
konnorrogers
c8067674f6 fix doc layouts 2023-09-12 17:16:57 -04:00
konnorrogers
caf4dc5526 working on semantic tokens 2023-09-12 16:24:40 -04:00
konnorrogers
93841348e1 Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-12 14:46:53 -04:00
konnorrogers
8ad392a5ac update to WA3 2023-09-12 14:35:03 -04:00
konnorrogers
6fc8a5166e Merge branch 'next' of https://github.com/shoelace-style/webawesome into konnorrogers/layouts 2023-09-11 15:46:09 -04:00
konnorrogers
0e27e1dd3d update to latest light-pen 2023-09-07 13:05:22 -04:00
Konnor Rogers
1b33f38280 use <script text/plain 2023-09-02 09:59:59 -04:00
Konnor Rogers
340869fa91 try with new setup 2023-09-02 01:20:54 -04:00
konnorrogers
06ff11114a fix templates 2023-08-30 16:35:01 -04:00
konnorrogers
ebe30a5ce8 fix duplicate binding 2023-08-30 15:56:47 -04:00
konnorrogers
4c84dec601 rename to .njk 2023-08-30 15:53:13 -04:00
konnorrogers
ece156de0b fix templates 2023-08-30 15:51:02 -04:00
konnorrogers
191f7d708c create layouts 2023-08-30 15:28:33 -04:00
436 changed files with 31468 additions and 23729 deletions

View File

@@ -35,7 +35,7 @@ This Code of Conduct applies within all project spaces, and it also applies when
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@fontawesome.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at cory@abeautifulsite.net. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: [claviska]

2
.github/SECURITY.md vendored
View File

@@ -2,6 +2,6 @@
We take security issues in Web Awesome very seriously and appreciate your efforts to disclose your findings responsibly.
To report a security issue, email [support@fontawesome.com](mailto:support@fontawesome.com) and include "WEB AWESOME 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.

2
.gitignore vendored
View File

@@ -5,8 +5,6 @@ package.json
package-lock.json
dist
docs/assets/images/sprite.svg
docs/public/pagefind
node_modules
src/react
cdn
.astro

View File

@@ -1,5 +1,4 @@
*.hbs
*.mdx
.cache
.github
cspell.json

View File

@@ -2,7 +2,7 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
},
"debug.enableStatusBarColor": false
}

View File

@@ -1,5 +1,7 @@
# Web Awesome
A forward-thinking library of web components.
- Works with all frameworks 🧩
- Works with CDNs 🚛
- Fully customizable with CSS 🎨

View File

@@ -21,6 +21,7 @@
"cdndir",
"chatbubble",
"checkmark",
"claviska",
"Clippy",
"codebases",
"codepen",
@@ -46,7 +47,6 @@
"dropdowns",
"easings",
"endraw",
"endregion",
"enterkeyhint",
"eqeqeq",
"erroneou",
@@ -85,6 +85,7 @@
"Kool",
"labelledby",
"Laravel",
"LaViska",
"linkify",
"listbox",
"listitem",
@@ -101,7 +102,6 @@
"monospace",
"mousedown",
"mousemove",
"mouseout",
"mouseup",
"multiselectable",
"nextjs",
@@ -172,12 +172,10 @@
"valuenow",
"valuetext",
"viewports",
"Vuejs",
"WCAG",
"webawesome",
"WEBP",
"Webpacker",
"xmark"
"Webpacker"
],
"ignorePaths": [
"package.json",

View File

@@ -1,7 +1,6 @@
import * as path from 'path';
import { customElementJetBrainsPlugin } from 'custom-element-jet-brains-integration';
import { customElementVsCodePlugin } from 'custom-element-vs-code-integration';
import { customElementVuejsPlugin } from 'custom-element-vuejs-integration';
import { parse } from 'comment-parser';
import { pascalCase } from 'pascal-case';
import commandLineArgs from 'command-line-args';
@@ -39,7 +38,6 @@ export default {
customElementsManifest.package = { name, description, version, author, homepage, license };
}
},
// Infer tag names because we no longer use @customElement decorators.
{
name: 'wa-infer-tag-names',
@@ -68,7 +66,6 @@ export default {
}
}
},
// Parse custom jsDoc tags
{
name: 'wa-custom-tags',
@@ -140,7 +137,6 @@ export default {
}
}
},
{
name: 'wa-react-event-names',
analyzePhase({ ts, node, moduleDoc }) {
@@ -159,7 +155,6 @@ export default {
}
}
},
{
name: 'wa-translate-module-paths',
packageLinkPhase({ customElementsManifest }) {
@@ -196,7 +191,6 @@ export default {
});
}
},
// Generate custom VS Code data
customElementVsCodePlugin({
outdir,
@@ -208,7 +202,6 @@ export default {
}
]
}),
customElementJetBrainsPlugin({
outdir: './dist',
excludeCss: true,
@@ -219,12 +212,6 @@ export default {
url: `https://shoelace.style/components/${tag.replace('wa-', '')}`
};
}
}),
customElementVuejsPlugin({
outdir: './dist/types/vue',
fileName: 'index.d.ts',
componentTypePath: (_, tag) => `../../components/${tag.replace('wa-', '')}/${tag.replace('wa-', '')}.component.js`
})
]
};

View File

@@ -1,4 +0,0 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

View File

@@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

View File

@@ -0,0 +1,349 @@
{% extends "default.njk" %}
{# Find the component based on the `tag` front matter #}
{% set component = getComponent('wa-' + page.fileSlug) %}
{% block content %}
{# Determine the badge variant #}
{% if component.status == 'stable' %}
{% set badgeVariant = 'brand' %}
{% elseif component.status == 'experimental' %}
{% set badgeVariant = 'warning' %}
{% elseif component.status == 'planned' %}
{% set badgeVariant = 'neutral' %}
{% elseif component.status == 'deprecated' %}
{% set badgeVariant = 'danger' %}
{% else %}
{% set badgeVariant = 'neutral' %}
{% endif %}
{# Header #}
<header class="component-header">
<h1>{{ component.name | classNameToComponentName }}</h1>
<div class="component-header__tag">
<code>&lt;{{ component.tagName }}&gt; | {{ component.name }}</code>
</div>
<div class="component-header__info">
<wa-badge variant="neutral" pill>
Since {{component.since or '?' }}
</wa-badge>
<wa-badge variant="{{ badgeVariant }}" pill style="text-transform: capitalize;">
{{ component.status }}
</wa-badge>
</div>
</header>
<p class="component-summary">
{% if component.summary %}
{{ component.summary | markdownInline | safe }}
{% endif %}
</p>
{# Markdown content #}
{{ content | safe }}
{# Importing #}
<h2>Importing</h2>
<p>
If you're using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use
any of the following snippets to <a href="/getting-started/installation#cherry-picking">cherry pick</a> this component.
</p>
<wa-tab-group>
<wa-tab slot="nav" panel="script">Script</wa-tab>
<wa-tab slot="nav" panel="import">Import</wa-tab>
<wa-tab slot="nav" panel="bundler">Bundler</wa-tab>
<wa-tab slot="nav" panel="react">React</wa-tab>
<wa-tab-panel name="script">
<p>
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
using a script tag:
</p>
<pre><code class="language-html">&lt;script type=&quot;module&quot; src=&quot;https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}&quot;&gt;&lt;/script&gt;</code></pre>
</wa-tab-panel>
<wa-tab-panel name="import">
<p>
To import this component from <a href="https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace">the CDN</a>
using a JavaScript import:
</p>
<pre><code class="language-js">import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@{{ meta.version }}/{{ meta.cdndir }}/{{ component.path }}';</code></pre>
</wa-tab-panel>
<wa-tab-panel name="bundler">
<p>
To import this component using <a href="{{ rootUrl('/getting-started/installation#bundling') }}">a bundler</a>:
</p>
<pre><code class="language-js">import '@shoelace-style/shoelace/{{ meta.npmdir }}/{{ component.path }}';</code></pre>
</wa-tab-panel>
<wa-tab-panel name="react">
<p>
To import this component as a <a href="/frameworks/react">React component</a>:
</p>
<pre><code class="language-js">import {{ component.name }} from '@shoelace-style/shoelace/{{ meta.npmdir }}/react/{{ component.tagNameWithoutPrefix }}';</code></pre>
</wa-tab-panel>
</wa-tab-group>
{# Slots #}
{% if component.slots.length %}
<h2>Slots</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
</tr>
</thead>
<tbody>
{% for slot in component.slots %}
<tr>
<td class="nowrap">
{% if slot.name %}
<code>{{ slot.name }}</code>
{% else %}
(default)
{% endif %}
</td>
<td>{{ slot.description | markdownInline | safe }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#slots') }}">using slots</a>.</em></p>
{% endif %}
{# Properties #}
{% if component.properties.length %}
<h2>Properties</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
<th class="table-reflects">Reflects</th>
<th class="table-type">Type</th>
<th class="table-default">Default</th>
</tr>
</thead>
<tbody>
{% for prop in component.properties %}
<tr>
<td>
<code class="nowrap">{{ prop.name }}</code>
{% if prop.attribute | length > 0 %}
{% if prop.attribute != prop.name %}
<br>
<wa-tooltip content="This attribute is different from its property">
<small>
<code class="nowrap">
{{ prop.attribute }}
</code>
</small>
</wa-tooltip>
{% endif %}
{% endif %}
</td>
<td>
{{ prop.description | markdownInline | safe }}
</td>
<td style="text-align: center;">
{% if prop.reflects %}
<wa-icon label="yes" name="check-lg"></wa-icon>
{% endif %}
</td>
<td>
{% if prop.type.text %}
<code>{{ prop.type.text | markdownInline | safe }}</code>
{% else %}
-
{% endif %}
</td>
<td>
{% if prop.default %}
<code>{{ prop.default | markdownInline | safe }}</code>
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<td class="nowrap"><code>updateComplete</code></td>
<td>
A read-only promise that resolves when the component has
<a href="/getting-started/usage?#component-rendering-and-updating">finished updating</a>.
</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#attributes-and-properties') }}">attributes and properties</a>.</em></p>
{% endif %}
{# Events #}
{% if component.events.length %}
<h2>Events</h2>
<table>
<thead>
<tr>
<th class="table-name" data-flavor="html">Name</th>
<th class="table-name" data-flavor="react">React Event</th>
<th class="table-description">Description</th>
<th class="table-event-detail">Event Detail</th>
</tr>
</thead>
<tbody>
{% for event in component.events %}
<tr>
<td data-flavor="html"><code class="nowrap">{{ event.name }}</code></td>
<td data-flavor="react"><code class="nowrap">{{ event.reactName }}</code></td>
<td>{{ event.description | markdownInline | safe }}</td>
<td>
{% if event.type.text %}
<code>{{ event.type.text }}</code>
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#events') }}">events</a>.</em></p>
{% endif %}
{# Methods #}
{% if component.methods.length %}
<h2>Methods</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
<th class="table-arguments">Arguments</th>
</tr>
</thead>
<tbody>
{% for method in component.methods %}
<tr>
<td class="nowrap"><code>{{ method.name }}()</code></td>
<td>{{ method.description | markdownInline | safe }}</td>
<td>
{% if method.parameters.length %}
<code>
{% for param in method.parameters %}
{{ param.name }}: {{ param.type.text }}{% if not loop.last %},{% endif %}
{% endfor %}
</code>
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#methods') }}">methods</a>.</em></p>
{% endif %}
{# Custom Properties #}
{% if component.cssProperties.length %}
<h2>Custom Properties</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
<th class="table-default">Default</th>
</tr>
</thead>
<tbody>
{% for cssProperty in component.cssProperties %}
<tr>
<td class="nowrap"><code>{{ cssProperty.name }}</code></td>
<td>{{ cssProperty.description | markdownInline | safe }}</td>
<td>{{ cssProperty.default }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/usage#custom-properties') }}">customizing CSS custom properties</a>.</em></p>
{% endif %}
{# CSS Parts #}
{% if component.cssParts.length %}
<h2>Parts</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
</tr>
</thead>
<tbody>
{% for cssPart in component.cssParts %}
<tr>
<td class="nowrap"><code>{{ cssPart.name }}</code></td>
<td>{{ cssPart.description | markdownInline | safe }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/customizing/#css-parts') }}">customizing CSS parts</a>.</em></p>
{% endif %}
{# Animations #}
{% if component.animations.length %}
<h2>Animations</h2>
<table>
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
</tr>
</thead>
<tbody>
{% for animation in component.animations %}
<tr>
<td class="nowrap"><code>{{ animation.name }}</code></td>
<td>{{ animation.description | markdownInline | safe }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p><em>Learn more about <a href="{{ rootUrl('/getting-started/customizing#animations') }}">customizing animations</a>.</em></p>
{% endif %}
{# Dependencies #}
{% if component.dependencies.length %}
<h2>Dependencies</h2>
<p>This component automatically imports the following dependencies.</p>
<ul>
{% for dependency in component.dependencies %}
<li><code>&lt;{{ dependency }}&gt;</code></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

129
docs/_includes/default.njk Normal file
View File

@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html
lang="en"
data-layout="{{ layout }}"
data-wa-version="{{ meta.version }}"
>
<head>
{# Metadata #}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="{{ meta.description }}" />
<title>{{ meta.title }}</title>
{# Opt out of Turbo caching #}
<meta name="turbo-cache-control">
{# Stylesheets #}
<link rel="stylesheet" href="{{ assetUrl('styles/docs.css') }}" />
<link rel="stylesheet" href="{{ assetUrl('styles/code-previews.css') }}" />
<link rel="stylesheet" href="{{ assetUrl('styles/search.css') }}" />
{# Favicons #}
<link rel="icon" href="{{ assetUrl('images/favicon.svg') }}" type="image/x-icon" />
{# Twitter Cards #}
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="shoelace_style" />
<meta name="twitter:image" content="{{ assetUrl(meta.image, true) }}" />
{# OpenGraph #}
<meta property="og:url" content="{{ rootUrl(page.url, true) }}" />
<meta property="og:title" content="{{ meta.title }}" />
<meta property="og:description" content="{{ meta.description }}" />
<meta property="og:image" content="{{ assetUrl(meta.image, true) }}" />
{# Web Awesome #}
<link rel="stylesheet" href="/dist/themes/applied.css" />
<link rel="stylesheet" href="/dist/themes/forms.css" />
<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 #}
<script>
(() => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = localStorage.getItem('theme') || 'auto';
document.documentElement.classList.toggle('wa-theme-default-dark', theme === 'dark' || (theme === 'auto' && prefersDark));
})();
</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 #}
<script src="{{ assetUrl('scripts/turbo.js') }}" type="module"></script>
<script src="{{ assetUrl('scripts/docs.js') }}" defer></script>
<script src="{{ assetUrl('scripts/code-previews.js') }}" defer></script>
<script src="{{ assetUrl('scripts/lunr.js') }}" defer></script>
<script src="{{ assetUrl('scripts/search.js') }}" defer></script>
</head>
<body>
<a id="skip-to-content" class="wa-visually-hidden" href="#main-content" data-smooth-link="false">
Skip to main content
</a>
{# Menu toggle #}
<button id="menu-toggle" type="button" aria-label="Menu">
<svg width="148" height="148" viewBox="0 0 148 148" xmlns="http://www.w3.org/2000/svg">
<g stroke="currentColor" stroke-width="18" fill="none" fill-rule="evenodd" stroke-linecap="round">
<path d="M9.5 125.5h129M9.5 74.5h129M9.5 23.5h129"></path>
</g>
</svg>
</button>
<aside id="sidebar" data-preserve-scroll>
<header>
<a href="/">
{% include 'logo.njk' %}
</a>
<div class="sidebar-version">
{{ meta.version }}
</div>
</header>
<div class="sidebar-buttons">
<wa-button size="small" class="repo-button repo-button--github" href="https://github.com/shoelace-style/shoelace" target="_blank">
<wa-icon slot="prefix" name="github"></wa-icon> Code
</wa-button>
<wa-button size="small" class="repo-button repo-button--star" href="https://github.com/shoelace-style/shoelace/stargazers" target="_blank">
<wa-icon slot="prefix" name="star-fill"></wa-icon> Star
</wa-button>
<wa-button size="small" class="repo-button repo-button--twitter" href="https://twitter.com/shoelace_style" target="_blank">
<wa-icon slot="prefix" name="twitter"></wa-icon> Follow
</wa-button>
</div>
<button class="search-box" type="button" title="Press / to search" aria-label="Search" data-plugin="search">
<wa-icon name="search"></wa-icon>
<span>Search</span>
</button>
<nav>
{% include 'sidebar.njk' %}
</nav>
</aside>
{# Content #}
<main>
<a id="main-content"></a>
<article id="content" class="content{% if toc %} content--with-toc{% endif %}">
{% if toc %}
<div class="content__toc">
<ul>
<li class="top"><a href="#">{{ meta.title }}</a></li>
</ul>
</div>
{% endif %}
<div class="content__body">
{% block content %}
{{ content | safe }}
{% endblock %}
</div>
</article>
</main>
</body>
</html>

View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html
lang="en"
data-layout="{{ layout }}"
data-shoelace-version="{{ meta.version }}"
>
<head>
{# Metadata #}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="{{ meta.description }}" />
<title>{{ meta.title }}</title>
{# Opt out of Turbo caching #}
<meta name="turbo-cache-control" content="no-cache">
<meta name="turbo-cache-control" content="no-preview">
{# Favicons #}
<link rel="icon" href="{{ assetUrl('images/favicon.svg') }}" type="image/x-icon" />
{# Twitter Cards #}
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="shoelace_style" />
<meta name="twitter:image" content="{{ assetUrl(meta.image, true) }}" />
{# OpenGraph #}
<meta property="og:url" content="{{ rootUrl(page.url, true) }}" />
<meta property="og:title" content="{{ meta.title }}" />
<meta property="og:description" content="{{ meta.description }}" />
<meta property="og:image" content="{{ assetUrl(meta.image, true) }}" />
{# WebAwesome #}
<link rel="stylesheet" href="/dist/themes/default.css" />
<link rel="stylesheet" href="/dist/themes/applied.css" />
<script type="module" src="/dist/webawesome.js"></script>
{# Set the initial theme and menu states here to prevent flashing #}
<script>
(() => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = localStorage.getItem('theme') || 'auto';
document.documentElement.classList.toggle('wa-theme-dark', theme === 'dark' || (theme === 'auto' && prefersDark));
if (window.Turbo) {
window.Turbo.session.drive = false
}
})();
</script>
<style>
*, *:before, *:after {
box-sizing: border-box;
}
html, body {
height: 100%;
min-height: 100%;
}
body {
margin: 0;
}
[hidden] {
display: none !important;
}
</style>
</head>
<body>
{% block content %}
{{ content | safe }}
{% endblock %}
</body>
</html>

View File

@@ -1,3 +1,13 @@
html {
min-height: 100%;
height: auto;
}
body {
padding: 0;
height: auto;
}
.grid {
font-size: 1.35rem;
text-align: center;

View File

@@ -1,4 +1,4 @@
<wa-page main-id="main-content" class="wa-theme-light">
<wa-layout main-id="main-content" class="wa-theme-light">
<header slot="banner" class="grid banner">banner</header>
<header slot="header" class="grid header">header</header>
@@ -13,4 +13,6 @@
<aside class="grid" slot="aside">aside</aside>
<footer class="grid" slot="footer">footer</footer>
</wa-page>
</wa-layout>
{% include "layout-widget.njk" %}

View File

@@ -0,0 +1,216 @@
html {
min-height: 100%;
height: auto;
}
body {
padding: 0;
height: auto;
}
main {
min-height: 100%;
padding: 1rem 2rem;
}
/* Layout */
wa-layout {
background-color: var(--wa-color-neutral-95);
color: var(--wa-color-neutral-20);
}
wa-card :is(p, h3) {
margin: 0;
}
wa-layout::part(header) {
/** Because headers are sticky, this keeps text from leaking through. */
background-color: var(--wa-color-white);
}
wa-layout::part(drawer__panel) {
height: 100%;
}
wa-layout[view='mobile'] {
background-color: var(--wa-color-white);
--menu-width: 0px;
}
wa-layout[view='mobile']::part(header) {
padding: 0.25rem;
border-bottom: 1px solid var(--wa-color-neutral-70);
}
wa-layout[view='mobile']::part(navigation) {
display: none;
}
wa-layout[view='desktop']::part(main) {
padding-top: 1rem;
}
wa-layout[view='desktop'] {
--menu-width: 250px;
}
wa-layout[view='desktop']::part(navigation) {
padding-top: 1.9rem;
}
wa-layout[view='desktop'] > [slot='header'] {
display: none;
}
wa-layout[view='desktop']::part(header) {
display: none;
}
wa-layout[view='desktop'] main {
background-color: var(--wa-color-white);
box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.05);
border: 1px solid var(--wa-color-neutral-80);
border-top-left-radius: 8px;
}
/* Navigation / Lists */
/* Highlights */
.highlight {
font-size: 0.85em;
padding: 0.4em 0.6em;
border-radius: 6px;
display: inline-block;
}
.highlight--success {
background-color: var(--wa-color-success-fill-muted);
color: var(--wa-color-success-text-on-muted);
}
.highlight--danger {
background-color: var(--wa-color-red-90);
color: var(--wa-color-red-30);
}
/* Text */
.text--light {
color: var(--wa-color-neutral-40);
}
/* Cards */
.wa-card--muted::part(base) {
--border-color: transparent;
background-color: transparent;
display: grid;
height: 100%;
box-shadow: none;
}
.wa-card--muted::part(body) {
display: grid;
align-content: flex-end;
gap: var(--padding);
}
/* Buttons */
.wa-button--card {
--border-radius: 8px;
--padding: 1rem 0px;
}
.wa-button--card.wa-button--muted {
--background-color: var(--wa-color-neutral-95);
}
.wa-button--card::part(base) {
height: 100%;
border-radius: var(--border-radius);
padding: var(--padding);
}
.wa-button--card::part(label) {
width: 100%;
}
.wa-button--muted {
--text-color: var(--wa-color-neutral-30);
--text-color-active: var(--wa-color-neutral-30);
--background-color: transparent;
--background-color-active: var(--wa-color-neutral-90);
--border-color: transparent;
--border-color-active: var(--wa-color-neutral-80);
}
.wa-button--muted::part(base) {
background-color: var(--background-color);
color: var(--text-color);
border-color: var(--border-color);
}
.wa-button--muted:is(:focus-within)::part(base) {
background-color: var(--background-color);
color: var(--text-color-active);
border-color: var(--border-color-active);
}
.wa-button--muted:is(:hover)::part(base) {
background-color: var(--background-color-active);
color: var(--text-color-active);
border-color: var(--border-color-active);
}
.wa-button--logo::part(base) {
font-size: 1.5rem;
color: var(--wa-color-neutral-30);
}
.wa-button--square::part(base) {
border-radius: 0px;
}
.wa-button--stretch {
width: 100%;
}
.wa-button--stretch::part(label) {
flex: 1 1 auto;
}
.wa-button--nav-footer {
--border-color: var(--wa-color-neutral-70);
--wa-spacing-large: 8px;
}
wa-layout[view='desktop'] .wa-button--nav-footer::part(base) {
--border-color: transparent;
border-top-color: var(--wa-color-neutral-70);
}
/* Tables */
table {
max-width: 100%;
border: none;
border-collapse: collapse;
color: inherit;
}
table tr {
border-bottom: 1px solid var(--wa-color-neutral-70);
}
table th {
font-weight: var(--wa-font-weight-semibold);
text-align: left;
padding: 0.75rem 1rem;
}
table td {
line-height: var(--wa-line-height-normal);
padding: 1rem;
}
* > table {
max-width: 100%;
overflow-x: auto;
}

View File

@@ -1,17 +1,5 @@
<wa-page main-id="main-content" class="wa-theme-light">
<header slot="header" style="display: flex; align-items: center; justify-content: space-between">
<wa-button
href="#"
variant="text"
style="padding: 0 0.4rem"
class="wa-button--logo wa-button--muted"
size="large"
slot="navigation-header"
>
<wa-icon name="music" slot="prefix" style="font-size: 2rem"></wa-icon>
Music Awesome
</wa-button>
<wa-layout main-id="main-content" class="wa-theme-light">
<header slot="header">
<wa-icon-button name="list" style="font-size: 1.5rem" data-toggle-nav></wa-icon-button>
</header>
<wa-button
@@ -22,63 +10,49 @@
size="large"
slot="navigation-header"
>
<wa-icon name="music" slot="prefix" style="font-size: 2rem"></wa-icon>
Music Awesome
<wa-icon name="music-note" slot="prefix" style="font-size: 2rem"></wa-icon>
Musicify
</wa-button>
<nav style="padding: 1rem" slot="navigation">
<ul class="nav-list" role="list" style="">
<li>
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="search" slot="prefix"></wa-icon>
Search
</wa-button>
</li>
<wa-nav-group style="height: 100%">
<wa-nav-item href="#">
<wa-icon name="search" slot="prefix"></wa-icon>
Search
</wa-nav-item>
<li>
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="bell" slot="prefix"></wa-icon>
Notifications
</wa-button>
</li>
<wa-nav-item href="#">
<wa-icon name="bell" slot="prefix"></wa-icon>
Notifications
</wa-nav-item>
<wa-divider></wa-divider>
<li>
<wa-button href="#" variant="brand" aria-current="page">
<wa-icon name="house" slot="prefix"></wa-icon>
Home
</wa-button>
</li>
<wa-nav-item href="#" current="page">
<wa-icon name="house-door" slot="prefix"></wa-icon>
Home
</wa-nav-item>
<li>
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="play" slot="prefix"></wa-icon>
Playlists
</wa-button>
</li>
<wa-nav-item href="#">
<wa-icon name="music-note-list" slot="prefix"></wa-icon>
Playlists
</wa-nav-item>
<li>
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="compact-disc" slot="prefix"></wa-icon>
Tracks
</wa-button>
</li>
<wa-nav-item href="#">
<wa-icon name="file-earmark-music" slot="prefix"></wa-icon>
Tracks
</wa-nav-item>
<li>
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="gear" slot="prefix"></wa-icon>
Settings
</wa-button>
</li>
<wa-nav-item href="#">
<wa-icon name="gear" slot="prefix"></wa-icon>
Settings
</wa-nav-item>
<li style="margin-top: auto">
<wa-button class="wa-button--muted" href="#" outline>
<wa-icon name="question-circle" slot="prefix"></wa-icon>
Help
</wa-button>
</li>
</ul>
<wa-nav-item href="#" style="margin-top: auto">
<wa-icon name="question-circle" slot="prefix"></wa-icon>
Help
</wa-nav-item>
</wa-nav-group>
</nav>
<!-- Hacky override to make padding 8px -->
@@ -110,8 +84,8 @@
<h1 style="margin: 0.5rem 0 2rem 0">Good Evening, Konnor Rogers</h1>
<section>
<div style="display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 8px">
<h2 style="margin: 0">Overview</h2>
<div style="display: flex; justify-content: space-between; flex-wrap: wrap; align-items: flex-end; gap: 8px">
<h2 style="">Overview</h2>
<wa-select value="monthly">
<wa-option value="daily">Daily</wa-option>
@@ -202,7 +176,7 @@
gap: 16px;
"
>
<wa-button class="wa-button--card wa-button--muted" href="#" outline>
<wa-button variant="neutral" class="wa-button--card wa-button--muted" href="#">
<div style="display: flex; gap: 1rem">
<img
src="https://via.placeholder.com/100x100"
@@ -233,7 +207,7 @@
</div>
</wa-button>
<wa-button class="wa-button--card wa-button--muted" outline href="#">
<wa-button variant="neutral" class="wa-button--card wa-button--muted" href="#">
<div style="display: flex; gap: 1rem">
<img
src="https://via.placeholder.com/100x100"
@@ -264,7 +238,7 @@
</div>
</wa-button>
<wa-button class="wa-button--card wa-button--muted" outline href="#">
<wa-button variant="neutral" class="wa-button--card wa-button--muted" href="#">
<div style="display: flex; gap: 1rem">
<img
src="https://via.placeholder.com/100x100"
@@ -451,4 +425,4 @@
</div>
</section>
</main>
</wa-page>
</wa-layout>

View File

@@ -1,3 +1,13 @@
html {
min-height: 100%;
height: auto;
}
body {
padding: 0;
height: auto;
}
.grid {
font-size: 1.35rem;
text-align: center;

View File

@@ -1,4 +1,4 @@
<wa-page>
<wa-layout>
<div slot="navigation">
<div style="padding: 2rem">
<a href="#">Option 1</a><br />
@@ -18,10 +18,10 @@
<wa-dialog id="dialog"> I'm just a lowly dialog. </wa-dialog>
<wa-button>Open Dialog</wa-button>
</wa-page>
</wa-layout>
<style>
wa-page {
wa-layout {
--menu-width: 260px;
outline: dashed 1px dodgerblue;
@@ -29,11 +29,11 @@
margin: 0 auto;
}
wa-page::part(menu) {
wa-layout::part(menu) {
border-right: solid 1px #ececec;
}
wa-page::part(main-content) {
wa-layout::part(main-content) {
padding: 2rem;
}
</style>

View File

@@ -0,0 +1,9 @@
html {
min-height: 100%;
height: auto;
}
body {
padding: 0;
height: auto;
}

View File

@@ -0,0 +1 @@
<wa-layout main-id="main-content" class="wa-theme-light"> </wa-layout>

View File

@@ -1,8 +1,12 @@
.wa-button--muted {
--border-color: transparent;
--background: transparent;
--background-hover: var(--wa-color-neutral-fill-subtle);
--border-color-hover: var(--wa-color-neutral-border-subtle);
html {
min-height: 100%;
height: auto;
}
body {
padding: 0 !important;
height: auto;
margin: 0;
}
/** https://andy-bell.co.uk/my-favourite-3-lines-of-css/ */
@@ -16,46 +20,35 @@ img {
height: auto;
}
.navigation {
display: flex;
flex-direction: column;
}
.navigation--desktop {
.navigation--desktop::part(nav-items) {
gap: 2rem;
}
.navigation--top {
.navigation--top::part(nav-items) {
flex-direction: row;
}
.navigation--top wa-button {
.navigation--top wa-nav-item {
font-size: 1.4rem;
font-weight: bold;
--border-color: transparent;
&::part(base) {
color: var(--wa-color-brand-text-on-spot);
}
&:hover::part(base) {
color: var(--wa-color-text-normal);
}
}
.navigation--top [aria-current='page'] {
&::part(base) {
text-decoration: underline;
text-decoration-color: var(--wa-color-danger-spot);
text-decoration-thickness: 4px;
text-underline-offset: 8px;
}
.navigation--top wa-nav-item::part(content) {
text-align: center;
justify-content: center;
}
.navigation--top wa-nav-item {
--text-color: var(--wa-color-brand-text-on-vivid);
--text-color-hover: var(--wa-color-text-normal);
--background-color: transparent;
--background-color-hover: var(--wa-color-neutral-fill-muted-alt);
}
.header {
display: flex;
border-bottom: var(--wa-panel-border-width) var(--wa-panel-border-style) var(--wa-color-brand-fill-highlight);
background-color: var(--wa-color-surface-default);
border-bottom: var(--wa-panel-border-width) var(--wa-panel-border-style) var(--wa-color-brand-fill-vivid-alt);
background-color: var(--wa-color-white);
}
.header > * {
@@ -68,7 +61,7 @@ img {
clip-path: polygon(var(--wa-space-2xl) 0, 100% 0, 100% 100%, 0 100%);
padding-inline-start: calc(var(--wa-space-2xl) + var(--wa-space-xs));
padding-inline-end: var(--wa-space-m);
background-color: var(--wa-color-brand-spot-darker);
background-color: var(--wa-color-brand-fill-vivid-alt);
width: 100%;
}
@@ -101,23 +94,15 @@ a.logo:is(:hover, :focus) {
width: 100%;
}
.navigation--desktop [aria-current='page'] {
.navigation--desktop wa-nav-item[current='page'] {
text-decoration: underline;
text-underline-offset: 8px;
text-decoration-thickness: 4px;
text-decoration-color: var(--wa-color-brand-outline-muted-alt);
}
.navigation-list {
display: grid;
grid-template-columns: auto;
place-content: center;
margin: 0;
list-style-type: '';
}
.navigation--desktop wa-nav-item[current='page']:hover {
text-decoration-color: var(--wa-color-brand-border-highlight);
text-decoration-color: var(--wa-color-brand-outline-vivid);
}
.navigation--extra {
@@ -128,12 +113,12 @@ a.logo:is(:hover, :focus) {
margin-inline-start: auto;
}
wa-page[view='desktop'] [data-toggle-nav],
wa-page[view='desktop']::part(navigation) {
wa-layout[view='desktop'] [data-toggle-nav],
wa-layout[view='desktop']::part(navigation) {
display: none;
}
wa-page[view='mobile'] .navigation--desktop {
wa-layout[view='mobile'] .navigation--desktop {
display: none;
}
@@ -157,7 +142,7 @@ wa-page[view='mobile'] .navigation--desktop {
border-collapse: separate;
border-spacing: 0;
border-radius: var(--wa-panel-corners);
border: var(--wa-panel-border-width) var(--wa-panel-border-style) var(--wa-color-surface-border);
border: var(--wa-panel-border-width) var(--wa-panel-border-style) var(--wa-color-surface-outline);
}
.table-scroll {
@@ -178,7 +163,7 @@ wa-page[view='mobile'] .navigation--desktop {
text-align: end;
}
.navigation--top.navigation--social {
.navigation--top.navigation--social::part(nav-items) {
justify-content: flex-end;
}

View File

@@ -1,89 +1,63 @@
<wa-page
main-id="main-content"
class="wa-theme-light preview-container"
mobile-breakpoint="1000"
disable-sticky="banner"
>
<wa-layout main-id="main-content" class="wa-theme-light" mobile-breakpoint="925" disable-sticky="banner">
<header class="layout-banner" slot="banner">Reminder! Get your insurance paperwork in by Oct 12!</header>
<header class="header" slot="header">
<a href="#" class="logo"> <span>Sport</span> <span class="logo__accent">Awesome</span> </a>
<div class="header__navigation">
<nav class="navigation navigation--top navigation--desktop">
<wa-button class="wa-button--muted" outline href="#" aria-current="page">Home</wa-button>
<wa-button class="wa-button--muted" outline href="#">Schedule</wa-button>
<wa-button class="wa-button--muted" outline href="#">Roster</wa-button>
<wa-button class="wa-button--muted" outline href="#">Stats</wa-button>
<wa-button class="wa-button--muted" outline href="#">Videos</wa-button>
</nav>
<wa-nav-group class="navigation navigation--top navigation--desktop">
<wa-nav-item href="#" current="page">Home</wa-nav-item>
<wa-nav-item href="#">Schedule</wa-nav-item>
<wa-nav-item href="#">Roster</wa-nav-item>
<wa-nav-item href="#">Stats</wa-nav-item>
<wa-nav-item href="#">Videos</wa-nav-item>
</wa-nav-group>
<nav class="navigation navigation--top navigation--social">
<wa-button outline class="wa-button--muted social-link" href="#">
<wa-icon name="instagram" family="brands"></wa-icon>
</wa-button>
<wa-button outline class="wa-button--muted social-link" href="#"
><wa-icon name="facebook" family="brands"></wa-icon
></wa-button>
<wa-button outline class="wa-button--muted" data-toggle-nav href="#"><wa-icon name="list"></wa-icon></wa-button>
</nav>
<wa-nav-group class="navigation navigation--top navigation--social">
<wa-nav-item class="social-link" href="#"><wa-icon name="instagram"></wa-icon></wa-nav-item>
<wa-nav-item class="social-link" href="#"><wa-icon name="facebook"></wa-icon></wa-nav-item>
<wa-nav-item data-toggle-nav href="#"><wa-icon name="list"></wa-icon></wa-nav-item>
</wa-nav-group>
</div>
</header>
<a href="#" class="logo" slot="navigation-header"> Sport <span class="logo__accent">Awesome</span> </a>
<nav slot="navigation">
<ul role="list" class="navigation-list">
<li>
<wa-button class="wa-button--muted" outline href="#" aria-current="page">
<wa-icon name="house" slot="prefix"></wa-icon>
Home
</wa-button>
</li>
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="calendar" slot="prefix"></wa-icon>
Schedule
</wa-button>
</li>
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="people" slot="prefix"></wa-icon>
Roster
</wa-button>
</li>
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="chart-simple" slot="prefix"></wa-icon>
Stats
</wa-button>
</li>
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="video" slot="prefix"></wa-icon>
Videos
</wa-button>
</li>
</ul>
<wa-nav-group slot="navigation">
<wa-nav-item href="#" current="page">
<wa-icon name="house-door" slot="prefix"></wa-icon>
Home
</wa-nav-item>
<wa-nav-item href="#">
<wa-icon name="calendar" slot="prefix"></wa-icon>
Schedule
</wa-nav-item>
<wa-nav-item href="#">
<wa-icon name="people" slot="prefix"></wa-icon>
Roster
</wa-nav-item>
<wa-nav-item href="#">
<wa-icon name="graph-up-arrow" slot="prefix"></wa-icon>
Stats
</wa-nav-item>
<wa-nav-item href="#">
<wa-icon name="camera-video" slot="prefix"></wa-icon>
Videos
</wa-nav-item>
<wa-divider></wa-divider>
<ul role="list" class="navigation-list">
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="instagram" family="brands" slot="prefix"></wa-icon>
Instagram
</wa-button>
</li>
<li>
<wa-button class="wa-button--muted" outline href="#">
<wa-icon name="facebook" family="brands" slot="prefix"></wa-icon>
Facebook
</wa-button>
</li>
</ul>
</nav>
<wa-nav-group>
<wa-nav-item href="#">
<wa-icon name="instagram" slot="prefix"></wa-icon>
Instagram
</wa-nav-item>
<wa-nav-item href="#">
<wa-icon name="facebook" slot="prefix"></wa-icon>
Facebook
</wa-nav-item>
</wa-nav-group>
</wa-nav-group>
<main id="main-content" class="flow" style="padding: var(--wa-space-m)">
<div style="display: flex; flex-wrap: wrap; gap: var(--wa-space-m)">
@@ -118,8 +92,8 @@
style="
font-size: 1.4rem;
font-weight: bold;
color: var(--wa-color-brand-text-on-spot);
background-color: var(--wa-color-brand-spot-darker);
color: var(--wa-color-brand-text-on-vivid);
background-color: var(--wa-color-brand-fill-vivid-alt);
padding: var(--wa-space-m);
text-align: center;
border-top-left-radius: inherit;
@@ -131,8 +105,8 @@
<div
style="
color: var(--wa-color-danger-text-on-spot);
background-color: var(--wa-color-danger-spot-darker);
color: var(--wa-color-brand-text-on-vivid);
background-color: var(--wa-color-danger-fill-vivid-alt);
padding: var(--wa-space-s);
text-align: center;
font-weight: bold;
@@ -143,8 +117,7 @@
<div
style="
background-color: var(--wa-color-neutral-fill-highlight);
color: var(--wa-color-neutral-text-on-fill);
background-color: var(--wa-color-neutral-90);
padding: var(--wa-space-m);
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
@@ -367,4 +340,4 @@
>
© 2023 - Sport Awesome
</footer>
</wa-page>
</wa-layout>

View File

@@ -1,3 +1,4 @@
<!-- playground-hide -->
<style>
.layout-widget {
position: fixed;
@@ -6,6 +7,7 @@
bottom: 4rem;
left: 4rem;
}
.layout-widget:not(:defined) {
display: none;
}
@@ -19,51 +21,72 @@
<script type="module">
const layoutWidget = document.querySelector("#js-layout-widget")
const docFrag = new DocumentFragment()
function makeMenuItem (type, slot) {
const menuItem = Object.assign(document.createElement("wa-menu-item"), {
type: "checkbox",
textContent: `${type} ${slot}`
})
menuItem.setAttribute("value", `${type}-${slot}`)
return menuItem
}
document.querySelectorAll("wa-page > [slot]").forEach((el) => {
document.querySelectorAll("wa-layout > [slot]").forEach((el) => {
const slot = el.getAttribute("slot");
docFrag.append(makeMenuItem("toggle", slot), makeMenuItem("overflow", slot), document.createElement("wa-divider"))
})
docFrag.append(makeMenuItem("toggle", "main"), makeMenuItem("overflow", "main"))
layoutWidget.querySelector("wa-menu").append(docFrag)
function capitalize(string) {
return string.split(/\s+/).map((str) => str[0].toUppercase() + str.slice(1)).join(" ")
}
function handleSelect (e) {
const item = e.detail.item
const val = item.getAttribute("value")
if (val === "footer-0") {
}
const slot = val.split("-").slice(1).join("-")
let el
if (slot === "main") {
el = document.querySelector(`main`)
} else {
el = document.querySelector(`wa-page > [slot='${slot}']`)
el = document.querySelector(`wa-layout > [slot='${slot}']`)
}
if (val.startsWith("overflow")) {
if (item.checked) {
el.textContent = "lorem ".repeat(1_000)
return
}
el.textContent = slot
return
}
if (val.startsWith("toggle")) {
if (item.checked) {
el.setAttribute("hidden", "")
return
}
el.removeAttribute("hidden")
return
}
}
layoutWidget.addEventListener("wa-select", handleSelect);
</script>
{% if in_playground %}
&lt;/script>
{% else %}
</script>
{% endif %}
<!-- playground-hide-end -->

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -0,0 +1,124 @@
<script type="module">
import "https://cdn.jsdelivr.net/npm/light-pen@1.1.3/+esm"
</script>
<div style="display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); min-height: 100%; grid-template-rows: minmax(0, 1fr); gap: 8px; ">
<!-- 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="glassy">Glassy</wa-option>
<wa-option value="mellow">Mellow</wa-option>
<wa-option value="playful">Playful</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 type="module">
const container = document.getElementById('knobs');
const iframeDocument = () => document.querySelector("light-pen").iframeElem.contentWindow.document
const themeStylesheet = () => iframeDocument().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 => {
iframeDocument().documentElement.style.setProperty('--wa-font-family-heading', event.target.value);
});
// Body text
container.querySelector('[name="body-text"]').addEventListener('wa-input', event => {
iframeDocument().documentElement.style.setProperty('--wa-font-family-body', event.target.value);
});
// Corners
container.querySelector('[name="corners"]').addEventListener('wa-input', event => {
iframeDocument().documentElement.style.setProperty('--wa-corners-base', `${event.target.value}rem`);
});
// Border width
container.querySelector('[name="border-width"]').addEventListener('wa-input', event => {
iframeDocument().documentElement.style.setProperty('--wa-border-width-base', `${event.target.value / 16}rem`);
});
// Border style
container.querySelector('[name="border-style"]').addEventListener('wa-input', event => {
iframeDocument().documentElement.style.setProperty('--wa-border-style', event.target.value);
});
// Spacing style
container.querySelector('[name="spacing"]').addEventListener('wa-input', event => {
iframeDocument().documentElement.style.setProperty('--wa-space-base', `${event.target.value}rem`);
});
</script>
<style>
:root {
--knobs-width: 300px;
}
#knobs {
background: var(--wa-color-surface-default);
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-radius: var(--wa-corners-2x);
box-shadow: var(--wa-shadow-level-2);
width: var(--knobs-width);
padding: 2rem;
margin-inline: auto;
margin-block: 0;
}
#knobs p {
margin: 0;
}
</style>
<light-pen style="height: 100%;" resize-position="30">
<script type="text/plain" slot="html">
<link id="theme-stylesheet" href="/dist/themes/default.css" rel="stylesheet">
<link id="applied-stylesheet" href="/dist/themes/applied.css"" rel="stylesheet">
{% include html_file %}
</script>
<script type="text/plain" slot="css">
@import "/dist/themes/applied.css";
{% include css_file %}
</script>
<script type="text/plain" slot="js">
import { setBasePath } from "/dist/utilities/base-path.js";
setBasePath("/dist");
import("/dist/autoloader.js");
</script>
</light-pen>
<div>

View File

@@ -0,0 +1,85 @@
<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>
<li><a href="/layouts/index.html">Layout Examples</a></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>
</ul>
</li>
<li>
<h2>Getting Started</h2>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/getting-started/installation">Installation</a></li>
<li><a href="/getting-started/usage">Usage</a></li>
<li><a href="/getting-started/themes">Themes</a></li>
<li><a href="/getting-started/customizing">Customizing</a></li>
<li><a href="/getting-started/form-controls">Form Controls</a></li>
<li><a href="/getting-started/localization">Localization</a></li>
</ul>
</li>
<li>
<h2>Frameworks</h2>
<ul>
<li><a href="/frameworks/react">React</a></li>
<li><a href="/frameworks/vue">Vue</a></li>
<li><a href="/frameworks/angular">Angular</a></li>
</ul>
</li>
<li>
<h2>Resources</h2>
<ul>
<li><a href="/resources/community">Community</a></li>
<li><a href="https://github.com/shoelace-style/shoelace/discussions">Help &amp; Support</a></li>
<li><a href="/resources/accessibility">Accessibility</a></li>
<li><a href="/resources/contributing">Contributing</a></li>
<li><a href="/resources/changelog">Changelog</a></li>
</ul>
</li>
<li>
<h2>Components</h2>
<ul>
{% for component in meta.components %}
<li>
<a href="/components/{{ component.tagName | removeWaPrefix }}">
{{ component.name | classNameToComponentName }}
</a>
</li>
{% endfor %}
</ul>
</li>
<li>
<h2>Design Tokens</h2>
<ul>
<li><a href="/tokens/typography">Typography</a></li>
<li><a href="/tokens/color">Color</a></li>
<li><a href="/tokens/spacing">Spacing</a></li>
<li><a href="/tokens/borders">Borders</a></li>
<li><a href="/tokens/shadows">Shadows</a></li>
<li><a href="/tokens/transition">Transition</a></li>
<li><a href="/tokens/z-index">Z-index</a></li>
<li><a href="/tokens/more">More Tokens</a></li>
</ul>
</li>
<li>
<h2>Tutorials</h2>
<ul>
<li><a href="/tutorials/integrating-with-laravel">Integrating with Laravel</a></li>
<li><a href="/tutorials/integrating-with-nextjs">Integrating with NextJS</a></li>
<li><a href="/tutorials/integrating-with-rails">Integrating with Rails</a></li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,35 @@
function normalizePathname(pathname) {
// Remove /index.html
if (pathname.endsWith('/index.html')) {
pathname = pathname.replace(/\/index\.html/, '');
}
// Remove trailing slashes
return pathname.replace(/\/$/, '');
}
/**
* Adds a class name to links that are currently active.
*/
module.exports = function (doc, options) {
options = {
className: 'active-link', // the class to add to active links
pathname: undefined, // the current pathname to compare
within: 'body', // element containing the target links
...options
};
const within = doc.querySelector(options.within);
if (!within) {
return doc;
}
within.querySelectorAll('a').forEach(link => {
if (normalizePathname(options.pathname) === normalizePathname(link.pathname)) {
link.classList.add(options.className);
}
});
return doc;
};

View File

@@ -0,0 +1,64 @@
const { createSlug } = require('./strings.cjs');
/**
* Turns headings into clickable, deep linkable anchors. The provided doc should be a document object provided by JSDOM.
* The same document will be returned with the appropriate DOM manipulations.
*/
module.exports = function (doc, options) {
options = {
levels: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], // the headings to convert
className: 'anchor-heading', // the class name to add
within: 'body', // the element containing the target headings
...options
};
const within = doc.querySelector(options.within);
if (!within) {
return doc;
}
within.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach(heading => {
const hasAnchor = heading.querySelector('a');
const anchor = doc.createElement('a');
let id = heading.textContent ?? '';
let suffix = 0;
// Skip heading levels we don't care about
if (!options.levels?.includes(heading.tagName.toLowerCase())) {
return;
}
// Convert dots to underscores
id = id.replace(/\./g, '_');
// Turn it into a slug
id = createSlug(id);
// Make sure it starts with a letter
if (!/^[a-z]/i.test(id)) {
id = `id_${id}`;
}
// Make sure the id is unique
const originalId = id;
while (doc.getElementById(id) !== null) {
id = `${originalId}-${++suffix}`;
}
if (hasAnchor || !id) return;
heading.setAttribute('id', id);
anchor.setAttribute('href', `#${encodeURIComponent(id)}`);
anchor.setAttribute('aria-label', `Direct link to "${heading.textContent}"`);
if (options.className) {
heading.classList.add(options.className);
}
// Append the anchor
heading.append(anchor);
});
return doc;
};

View File

@@ -1,20 +1,17 @@
const customElementsManifest = require('../../dist/custom-elements.json');
//
// Export it here so we can import it elsewhere and use the same version
//
import * as path from 'node:path';
import * as fs from 'node:fs';
// We make it a function to lazy evaluate for re-renders
export const customElementsManifest = () =>
JSON.parse(fs.readFileSync(path.join(process.cwd(), '/../dist/custom-elements.json')), { encoding: 'utf-8' });
module.exports.customElementsManifest = customElementsManifest;
//
// Gets all components from custom-elements.json and returns them in a more documentation-friendly format.
//
export function getAllComponents() {
module.exports.getAllComponents = function () {
const allComponents = [];
customElementsManifest().modules?.forEach(module => {
customElementsManifest.modules?.forEach(module => {
module.declarations?.forEach(declaration => {
if (declaration.customElement) {
// Generate the dist path based on the src path and attach it to the component
@@ -71,31 +68,4 @@ export function getAllComponents() {
if (a.name > b.name) return 1;
return 0;
});
}
export function getComponent(tagName) {
const allComponents = getAllComponents();
const component = allComponents.find(c => c.tagName === tagName);
if (!component) {
throw new Error(
`Unable to find a component called "${tagName}". Make sure the file name is the same as the component's tag ` +
`name (minus the wa- prefix). ${allComponents}`
);
}
component.hasSlots = Boolean(component.slots?.length);
component.hasProperties = Boolean(component.properties?.length);
component.hasEvents = Boolean(component.events?.length);
component.hasMethods = Boolean(component.methods?.length);
component.hasCssProperties = Boolean(component.cssProperties?.length);
component.hasCssParts = Boolean(component.cssParts?.length);
component.hasAnimations = Boolean(component.animations?.length);
component.hasDependencies = Boolean(component.dependencies?.length);
return component;
}
export function getComponentFromFileName(filename) {
const { name } = path.parse(filename);
const tagName = 'wa-' + name;
return getComponent(tagName);
}
};

View File

@@ -0,0 +1,138 @@
let count = 1;
function escapeHtml(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
/**
* Turns code fields with the :preview suffix into interactive code previews.
*/
module.exports = function (doc, options) {
options = {
within: 'body', // the element containing the code fields to convert
...options
};
const within = doc.querySelector(options.within);
if (!within) {
return doc;
}
within.querySelectorAll('[class*=":preview"]').forEach(code => {
const pre = code.closest('pre');
if (!pre) {
return;
}
const adjacentPre = pre.nextElementSibling?.tagName.toLowerCase() === 'pre' ? pre.nextElementSibling : null;
const reactCode = adjacentPre?.querySelector('code[class$="react"]');
const sourceGroupId = `code-preview-source-group-${count}`;
const isExpanded = code.getAttribute('class').includes(':expanded');
const noCodePen = code.getAttribute('class').includes(':no-codepen');
count++;
const htmlButton = `
<button type="button"
title="Show HTML code"
class="code-preview__button code-preview__button--html"
>
HTML
</button>
`;
const reactButton = `
<button type="button" title="Show React code" class="code-preview__button code-preview__button--react">
React
</button>
`;
const codePenButton = `
<button type="button" class="code-preview__button code-preview__button--codepen" title="Edit on CodePen">
<svg
width="138"
height="26"
viewBox="0 0 138 26"
fill="none"
stroke="currentColor"
stroke-width="2.3"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M80 6h-9v14h9 M114 6h-9 v14h9 M111 13h-6 M77 13h-6 M122 20V6l11 14V6 M22 16.7L33 24l11-7.3V9.3L33 2L22 9.3V16.7z M44 16.7L33 9.3l-11 7.4 M22 9.3l11 7.3 l11-7.3 M33 2v7.3 M33 16.7V24 M88 14h6c2.2 0 4-1.8 4-4s-1.8-4-4-4h-6v14 M15 8c-1.3-1.3-3-2-5-2c-4 0-7 3-7 7s3 7 7 7 c2 0 3.7-0.8 5-2 M64 13c0 4-3 7-7 7h-5V6h5C61 6 64 9 64 13z" />
</svg>
</button>
`;
const codePreview = `
<div class="code-preview ${isExpanded ? 'code-preview--expanded' : ''}">
<div class="code-preview__preview">
${code.textContent}
<div class="code-preview__resizer">
<wa-icon name="grip-vertical"></wa-icon>
</div>
</div>
<div class="code-preview__source-group" id="${sourceGroupId}">
<div class="code-preview__source code-preview__source--html" ${reactCode ? 'data-flavor="html"' : ''}>
<pre><code class="language-html">${escapeHtml(code.textContent)}</code></pre>
</div>
${
reactCode
? `
<div class="code-preview__source code-preview__source--react" data-flavor="react">
<pre><code class="language-jsx">${escapeHtml(reactCode.textContent)}</code></pre>
</div>
`
: ''
}
</div>
<div class="code-preview__buttons">
<button
type="button"
class="code-preview__button code-preview__toggle"
aria-expanded="${isExpanded ? 'true' : 'false'}"
aria-controls="${sourceGroupId}"
>
Source
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
${reactCode ? ` ${htmlButton} ${reactButton} ` : ''}
${noCodePen ? '' : codePenButton}
</div>
</div>
`;
pre.insertAdjacentHTML('afterend', codePreview);
pre.remove();
if (adjacentPre) {
adjacentPre.remove();
}
});
// Wrap code preview scripts in anonymous functions so they don't run in the global scope
doc.querySelectorAll('.code-preview__preview script').forEach(script => {
if (script.type === 'module') {
// Modules are already scoped
script.textContent = script.innerHTML;
} else {
// Wrap non-modules in an anonymous function so they don't run in the global scope
script.textContent = `(() => { ${script.innerHTML} })();`;
}
});
return doc;
};

View File

@@ -0,0 +1,23 @@
let codeBlockId = 0;
/**
* 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.
*/
module.exports = function (doc) {
doc.querySelectorAll('pre > code').forEach(code => {
const pre = code.closest('pre');
const button = doc.createElement('wa-copy-button');
if (!code.id) {
code.id = `code-block-${++codeBlockId}`;
}
button.classList.add('copy-code-button');
button.setAttribute('from', code.id);
pre.append(button);
});
return doc;
};

View File

@@ -0,0 +1,41 @@
const { isExternalLink } = require('./strings.cjs');
/**
* Transforms external links to make them safer and optionally add a target. The provided doc should be a document
* object provided by JSDOM. The same document will be returned with the appropriate DOM manipulations.
*/
module.exports = function (doc, options) {
options = {
className: 'external-link', // the class name to add to links
noopener: true, // sets rel="noopener"
noreferrer: true, // sets rel="noreferrer"
ignore: () => false, // callback function to filter links that should be ignored
within: 'body', // element that contains the target links
target: '', // sets the target attribute
...options
};
const within = doc.querySelector(options.within);
if (within) {
within.querySelectorAll('a').forEach(link => {
if (isExternalLink(link) && !options.ignore(link)) {
link.classList.add(options.className);
const rel = [];
if (options.noopener) rel.push('noopener');
if (options.noreferrer) rel.push('noreferrer');
if (rel.length) {
link.setAttribute('rel', rel.join(' '));
}
if (options.target) {
link.setAttribute('target', options.target);
}
}
});
}
return doc;
};

View File

@@ -0,0 +1,63 @@
const Prism = require('prismjs');
const PrismLoader = require('prismjs/components/index.js');
PrismLoader('diff');
PrismLoader.silent = true;
/** Highlights a code string. */
function highlight(code, language) {
const alias = language.replace(/^diff-/, '');
const isDiff = /^diff-/i.test(language);
// Auto-load the target language
if (!Prism.languages[alias]) {
PrismLoader(alias);
if (!Prism.languages[alias]) {
throw new Error(`Unsupported language for code highlighting: "${language}"`);
}
}
// Register diff-* languages to use the diff grammar
if (isDiff) {
Prism.languages[language] = Prism.languages.diff;
}
return Prism.highlight(code, Prism.languages[language], language);
}
/**
* Highlights all code fields that have a language parameter. If the language has a colon in its name, the first chunk
* will be the language used and additional chunks will be applied as classes to the `<pre>`. For example, a code field
* tagged with "html:preview" will be rendered as `<pre class="language-html preview">`.
*
* The provided doc should be a document object provided by JSDOM. The same document will be returned with the
* appropriate DOM manipulations.
*/
module.exports = function (doc) {
doc.querySelectorAll('pre > code[class]').forEach(code => {
// Look for class="language-*" and split colons into separate classes
code.classList.forEach(className => {
if (className.startsWith('language-')) {
//
// We use certain suffixes to indicate code previews, expanded states, etc. The class might look something like
// this:
//
// class="language-html:preview:expanded"
//
// The language will always come first, so we need to drop the "language-" prefix and everything after the first
// color to get the highlighter language.
//
const language = className.replace(/^language-/, '').split(':')[0];
try {
code.innerHTML = highlight(code.textContent ?? '', language);
} catch (err) {
// Language not found, skip it
}
}
});
});
return doc;
};

View File

@@ -0,0 +1,75 @@
const MarkdownIt = require('markdown-it');
const markdownItContainer = require('markdown-it-container');
const markdownItIns = require('markdown-it-ins');
const markdownItKbd = require('markdown-it-kbd');
const markdownItMark = require('markdown-it-mark');
const markdownItReplaceIt = require('markdown-it-replace-it');
const markdown = MarkdownIt({
html: true,
xhtmlOut: false,
breaks: false,
langPrefix: 'language-',
linkify: false,
typographer: false
});
// Third-party plugins
markdown.use(markdownItContainer);
markdown.use(markdownItIns);
markdown.use(markdownItKbd);
markdown.use(markdownItMark);
markdown.use(markdownItReplaceIt);
// Callouts
['tip', 'warning', 'danger'].forEach(type => {
const variant = type === 'tip' ? 'brand' : type;
let icon = 'info-circle';
if (type === 'warning') icon = 'exclamation-circle';
if (type === 'danger') icon = 'exclamation-triangle';
markdown.use(markdownItContainer, type, {
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
return `
<wa-alert class="callout" variant="${variant}" open>
<wa-icon slot="icon" name="${icon}"></wa-icon>
`;
}
return '</wa-alert>\n';
}
});
});
// Asides
markdown.use(markdownItContainer, 'aside', {
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
return `<aside>`;
}
return '</aside>\n';
}
});
// Details
markdown.use(markdownItContainer, 'details', {
validate: params => params.trim().match(/^details\s+(.*)$/),
render: (tokens, idx) => {
const m = tokens[idx].info.trim().match(/^details\s+(.*)$/);
if (tokens[idx].nesting === 1) {
return `<details>\n<summary><span>${markdown.utils.escapeHtml(m[1])}</span></summary>\n`;
}
return '</details>\n';
}
});
// Replace [#1234] with a link to GitHub issues
markdownItReplaceIt.replacements.push({
name: 'github-issues',
re: /\[#([0-9]+)\]/gs,
sub: '<a href="https://github.com/shoelace-style/shoelace/issues/$1">#$1</a>',
html: true,
default: true
});
module.exports = markdown;

View File

@@ -0,0 +1,26 @@
const { format } = require('prettier');
/** Formats markup using prettier. */
module.exports = function (content, options) {
options = {
arrowParens: 'avoid',
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
bracketSameLine: false,
jsxSingleQuote: false,
parser: 'html',
printWidth: 120,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'none',
useTabs: false,
...options
};
return format(content, options);
};

View File

@@ -0,0 +1,24 @@
/**
* @typedef {object} Replacement
* @property {string | RegExp} pattern
* @property {string} replacement
*/
/**
* @typedef {Array<Replacement>} Replacements
*/
/**
* @param {Document} content
* @param {Replacements} 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 => {
html = html.replaceAll(replacement.pattern, replacement.replacement);
});
content.body.innerHTML = html;
};

View File

@@ -0,0 +1,26 @@
/**
* Turns tables into scrollable tables
* The same document will be returned with the appropriate DOM manipulations.
*/
module.exports = function (doc, options) {
// We don't want to run this on layouts.
if (doc.querySelector("[data-layout='layout-example.njk']")) {
return;
}
const tables = [...doc.querySelectorAll('table')];
options = {
className: 'table-scroll', // the class name to add to the table's container
...options
};
tables.forEach(table => {
const div = doc.createElement('div');
div.classList.add(options.className);
table.insertAdjacentElement('beforebegin', div);
div.append(table);
});
return doc;
};

View File

@@ -0,0 +1,16 @@
const slugify = require('slugify');
/** Creates a slug from an arbitrary string of text. */
module.exports.createSlug = function (text) {
return slugify(String(text), {
remove: /[^\w|\s]/g,
lower: true
});
};
/** Determines whether or not a link is external. */
module.exports.isExternalLink = function (link) {
// We use the "internal" hostname when initializing JSDOM so we know that those are local links
if (!link.hostname || link.hostname === 'internal') return false;
return true;
};

View File

@@ -0,0 +1,42 @@
/**
* Generates an in-page table of contents based on headings.
*/
module.exports = function (doc, options) {
options = {
levels: ['h2'], // headings to include (they must have an id)
container: 'nav', // the container to append links to
listItem: true, // if true, links will be wrapped in <li>
within: 'body', // the element containing the headings to summarize
...options
};
const container = doc.querySelector(options.container);
const within = doc.querySelector(options.within);
const headingSelector = options.levels.map(h => `${h}[id]`).join(', ');
if (!container || !within) {
return doc;
}
within.querySelectorAll(headingSelector).forEach(heading => {
const listItem = doc.createElement('li');
const link = doc.createElement('a');
const level = heading.tagName.slice(1);
link.href = `#${heading.id}`;
link.textContent = heading.textContent;
if (options.listItem) {
// List item + link
listItem.setAttribute('data-level', level);
listItem.append(link);
container.append(listItem);
} else {
// Link only
link.setAttribute('data-level', level);
container.append(link);
}
});
return doc;
};

View File

@@ -0,0 +1,23 @@
const smartquotes = require('smartquotes');
smartquotes.replacements.push([/---/g, '\u2014']); // em dash
smartquotes.replacements.push([/--/g, '\u2013']); // en dash
smartquotes.replacements.push([/\.\.\./g, '\u2026']); // ellipsis
smartquotes.replacements.push([/\(c\)/gi, '\u00A9']); // copyright
smartquotes.replacements.push([/\(r\)/gi, '\u00AE']); // registered trademark
smartquotes.replacements.push([/\?!/g, '\u2048']); // ?!
smartquotes.replacements.push([/!!/g, '\u203C']); // !!
smartquotes.replacements.push([/\?\?/g, '\u2047']); // ??
smartquotes.replacements.push([/([0-9]\s?)-(\s?[0-9])/g, '$1\u2013$2']); // number ranges use en dash
/**
* Improves typography by adding smart quotes and similar corrections within the specified element(s).
*
* The provided doc should be a document object provided by JSDOM. The same document will be returned with the
* appropriate DOM manipulations.
*/
module.exports = function (doc, selector = 'body') {
const elements = [...doc.querySelectorAll(selector)];
elements.forEach(el => smartquotes.element(el));
return doc;
};

View File

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@@ -1,3 +0,0 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.63 3.625C11.63 4.27911 11.2435 4.84296 10.6865 5.10064L14 8L17.2622 7.34755C17.0968 7.10642 17 6.81452 17 6.5C17 5.67157 17.6716 5 18.5 5C19.3284 5 20 5.67157 20 6.5C20 7.31157 19.3555 7.9726 18.5504 7.99917L15.0307 15.8207C14.7077 16.5384 13.9939 17 13.2068 17H6.79317C6.00615 17 5.29229 16.5384 4.96933 15.8207L1.44963 7.99917C0.64452 7.9726 0 7.31157 0 6.5C0 5.67157 0.671573 5 1.5 5C2.32843 5 3 5.67157 3 6.5C3 6.81452 2.9032 7.10642 2.73777 7.34755L6 8L9.31702 5.09761C8.76346 4.83855 8.38 4.27656 8.38 3.625C8.38 2.72754 9.10754 2 10.005 2C10.9025 2 11.63 2.72754 11.63 3.625Z" fill="currentColor"/>
</svg>

Before

Width:  |  Height:  |  Size: 722 B

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -8,6 +8,33 @@
return html;
}
function getAdjacentExample(name, pre) {
let currentPre = pre.nextElementSibling;
while (currentPre?.tagName.toLowerCase() === 'pre') {
if (currentPre?.getAttribute('data-lang').split(' ').includes(name)) {
return currentPre;
}
currentPre = currentPre.nextElementSibling;
}
return null;
}
function runScript(script) {
const newScript = document.createElement('script');
if (script.type === 'module') {
newScript.type = 'module';
newScript.textContent = script.innerHTML;
} else {
newScript.appendChild(document.createTextNode(`(() => { ${script.innerHTML} })();`));
}
script.parentNode.replaceChild(newScript, script);
}
function getFlavor() {
return sessionStorage.getItem('flavor') || 'html';
}
@@ -37,7 +64,7 @@
});
}
const waVersion = document.querySelector("meta[name='wa-version']").getAttribute('content');
const waVersion = document.documentElement.getAttribute('data-wa-version');
const reactVersion = '18.2.0';
const cdndir = 'cdn';
const npmdir = 'dist';
@@ -213,5 +240,4 @@
// Set the initial flavor
window.addEventListener('turbo:load', syncFlavor);
syncFlavor();
})();

210
docs/assets/scripts/docs.js Normal file
View File

@@ -0,0 +1,210 @@
//
// Sidebar
//
// When the sidebar is hidden, we apply the inert attribute to prevent focus from reaching it. Due to the many states
// the sidebar can have (e.g. static, hidden, expanded), we test for visibility by checking to see if it's placed
// offscreen or not. Then, on resize/transition we make sure to update the attribute accordingly.
//
(() => {
function getSidebar() {
return document.getElementById('sidebar');
}
function isSidebarOpen() {
return document.documentElement.classList.contains('sidebar-open');
}
function isSidebarVisible() {
return getSidebar()?.getBoundingClientRect().x >= 0;
}
function toggleSidebar(force) {
const isOpen = typeof force === 'boolean' ? force : !isSidebarOpen();
return document.documentElement.classList.toggle('sidebar-open', isOpen);
}
function updateInert() {
const sidebar = getSidebar();
if (sidebar) {
sidebar.inert = !isSidebarVisible();
}
}
// Toggle the menu
document.addEventListener('click', event => {
const menuToggle = event.target.closest('#menu-toggle');
if (!menuToggle) return;
toggleSidebar();
});
// Update the sidebar's inert state when the window resizes and when the sidebar transitions
window.addEventListener('resize', () => toggleSidebar(false));
document.addEventListener('transitionend', event => {
const sidebar = event.target.closest('#sidebar');
if (!sidebar) return;
updateInert();
});
// Close when a menu item is selected on mobile
document.addEventListener('click', event => {
const sidebar = event.target.closest('#sidebar');
const link = event.target.closest('a');
if (!sidebar || !link) return;
if (isSidebarOpen()) {
toggleSidebar();
}
});
// Close when open and escape is pressed
document.addEventListener('keydown', event => {
if (event.key === 'Escape' && isSidebarOpen()) {
event.stopImmediatePropagation();
toggleSidebar();
}
});
// Close when clicking outside of the sidebar
document.addEventListener('mousedown', event => {
if (isSidebarOpen() & !event.target?.closest('#sidebar, #menu-toggle')) {
event.stopImmediatePropagation();
toggleSidebar();
}
});
updateInert();
})();
//
// Open details when printing
//
(() => {
const detailsOpenOnPrint = new Set();
window.addEventListener('beforeprint', () => {
detailsOpenOnPrint.clear();
document.querySelectorAll('details').forEach(details => {
if (details.open) {
detailsOpenOnPrint.add(details);
}
details.open = true;
});
});
window.addEventListener('afterprint', () => {
document.querySelectorAll('details').forEach(details => {
details.open = detailsOpenOnPrint.has(details);
});
detailsOpenOnPrint.clear();
});
})();
//
// Smooth links
//
(() => {
document.addEventListener('click', event => {
const link = event.target.closest('a');
const id = (link?.hash ?? '').substr(1);
const isFragment = link?.hasAttribute('href') && link?.getAttribute('href').startsWith('#');
if (!link || !isFragment || link.getAttribute('data-smooth-link') === 'false') {
return;
}
// Scroll to the top
if (link.hash === '') {
event.preventDefault();
window.scroll({ top: 0, behavior: 'smooth' });
history.pushState(undefined, undefined, location.pathname);
}
// Scroll to an id
if (id) {
const target = document.getElementById(id);
if (target) {
event.preventDefault();
window.scroll({ top: target.offsetTop, behavior: 'smooth' });
history.pushState(undefined, undefined, `#${id}`);
}
}
});
})();
//
// Table of Contents scrollspy
//
(() => {
// This will be stale if its not a function.
const getLinks = () => [...document.querySelectorAll('.content__toc a')];
const linkTargets = new WeakMap();
const visibleTargets = new WeakSet();
const observer = new IntersectionObserver(handleIntersect, { rootMargin: '0px 0px' });
let debounce;
function handleIntersect(entries) {
entries.forEach(entry => {
// Remember which targets are visible
if (entry.isIntersecting) {
visibleTargets.add(entry.target);
} else {
visibleTargets.delete(entry.target);
}
});
updateActiveLinks();
}
function updateActiveLinks() {
const links = getLinks();
// Find the first visible target and activate the respective link
links.find(link => {
const target = linkTargets.get(link);
if (target && visibleTargets.has(target)) {
links.forEach(el => el.classList.toggle('active', el === link));
return true;
}
return false;
});
}
// Observe link targets
function observeLinks() {
getLinks().forEach(link => {
const hash = link.hash.slice(1);
const target = hash ? document.querySelector(`.content__body #${hash}`) : null;
if (target) {
linkTargets.set(link, target);
observer.observe(target);
}
});
}
observeLinks();
document.addEventListener('turbo:load', updateActiveLinks);
document.addEventListener('turbo:load', observeLinks);
})();
//
// Show custom versions in the sidebar
//
(() => {
function updateVersion() {
const el = document.querySelector('.sidebar-version');
if (!el) return;
if (location.hostname === 'next.shoelace.style') el.textContent = 'Next';
if (location.hostname === 'localhost') el.textContent = 'Development';
}
updateVersion();
document.addEventListener('turbo:load', updateVersion);
})();

View File

@@ -0,0 +1,384 @@
(() => {
// Append the search dialog to the body
const siteSearch = document.createElement('div');
const scrollbarWidth = Math.abs(window.innerWidth - document.documentElement.clientWidth);
siteSearch.classList.add('search');
siteSearch.innerHTML = `
<div class="search__overlay"></div>
<dialog id="search-dialog" class="search__dialog">
<div class="search__content">
<div class="search__header">
<div id="search-combobox" class="search__input-wrapper">
<wa-icon name="search"></wa-icon>
<input
id="search-input"
class="search__input"
type="search"
placeholder="Search"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
enterkeyhint="go"
spellcheck="false"
maxlength="100"
role="combobox"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="search-listbox"
aria-haspopup="listbox"
aria-activedescendant
>
<button type="button" class="search__clear-button" aria-label="Clear entry" tabindex="-1" hidden>
<wa-icon name="x-circle-fill"></wa-icon>
</button>
</div>
</div>
<div class="search__body">
<ul
id="search-listbox"
class="search__results"
role="listbox"
aria-label="Search results"
></ul>
<div class="search__empty">No matching pages</div>
</div>
<footer class="search__footer">
<small><kbd>↑</kbd> <kbd>↓</kbd> Navigate</small>
<small><kbd>↲</kbd> Select</small>
<small><kbd>Esc</kbd> Close</small>
</footer>
</div>
</dialog>
`;
const overlay = siteSearch.querySelector('.search__overlay');
const dialog = siteSearch.querySelector('.search__dialog');
const input = siteSearch.querySelector('.search__input');
const clearButton = siteSearch.querySelector('.search__clear-button');
const results = siteSearch.querySelector('.search__results');
const version = document.documentElement.getAttribute('data-wa-version');
const key = `search_${version}`;
const searchDebounce = 50;
const animationDuration = 150;
let isShowing = false;
let searchTimeout;
let searchIndex;
let map;
const loadSearchIndex = new Promise(resolve => {
const cache = localStorage.getItem(key);
const wait = 'requestIdleCallback' in window ? requestIdleCallback : requestAnimationFrame;
// Cleanup older search indices (everything before this version)
try {
const items = { ...localStorage };
Object.keys(items).forEach(k => {
if (key > k) {
localStorage.removeItem(k);
}
});
} catch {
/* do nothing */
}
// Look for a cached index
try {
if (cache) {
const data = JSON.parse(cache);
searchIndex = window.lunr.Index.load(data.searchIndex);
map = data.map;
return resolve();
}
} catch {
/* do nothing */
}
// Wait until idle to fetch the index
wait(() => {
fetch('/assets/search.json')
.then(res => res.json())
.then(data => {
if (!window.lunr) {
console.error('The Lunr search client has not yet been loaded.');
}
searchIndex = window.lunr.Index.load(data.searchIndex);
map = data.map;
// Cache the search index for this version
if (version) {
try {
localStorage.setItem(key, JSON.stringify(data));
} catch (err) {
console.warn(`Unable to cache the search index: ${err}`);
}
}
resolve();
});
});
});
async function show() {
isShowing = true;
document.body.append(siteSearch);
document.body.classList.add('search-visible');
document.body.style.setProperty('--docs-search-scroll-lock-size', `${scrollbarWidth}px`);
clearButton.hidden = true;
requestAnimationFrame(() => input.focus());
updateResults();
dialog.showModal();
await Promise.all([
dialog.animate(
[
{ opacity: 0, transform: 'scale(.9)', transformOrigin: 'top' },
{ opacity: 1, transform: 'scale(1)', transformOrigin: 'top' }
],
{ duration: animationDuration }
).finished,
overlay.animate([{ opacity: 0 }, { opacity: 1 }], { duration: animationDuration }).finished
]);
dialog.addEventListener('mousedown', handleMouseDown);
dialog.addEventListener('keydown', handleKeyDown);
}
async function hide() {
isShowing = false;
await Promise.all([
dialog.animate(
[
{ opacity: 1, transform: 'scale(1)', transformOrigin: 'top' },
{ opacity: 0, transform: 'scale(.9)', transformOrigin: 'top' }
],
{ duration: animationDuration }
).finished,
overlay.animate([{ opacity: 1 }, { opacity: 0 }], { duration: animationDuration }).finished
]);
dialog.close();
input.blur(); // otherwise Safari will scroll to the bottom of the page on close
input.value = '';
document.body.classList.remove('search-visible');
document.body.style.removeProperty('--docs-search-scroll-lock-size');
siteSearch.remove();
updateResults();
dialog.removeEventListener('mousedown', handleMouseDown);
dialog.removeEventListener('keydown', handleKeyDown);
}
function handleInput() {
clearButton.hidden = input.value === '';
// Debounce search queries
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => updateResults(input.value), searchDebounce);
}
function handleClear() {
clearButton.hidden = true;
input.value = '';
input.focus();
updateResults();
}
function handleMouseDown(event) {
if (!event.target.closest('.search__content')) {
hide();
}
}
function handleKeyDown(event) {
// Close when pressing escape
if (event.key === 'Escape') {
event.preventDefault(); // prevent <dialog> from closing immediately so it can animate
event.stopImmediatePropagation();
hide();
return;
}
// Handle keyboard selections
if (['ArrowDown', 'ArrowUp', 'Home', 'End', 'Enter'].includes(event.key)) {
event.preventDefault();
const currentEl = results.querySelector('[data-selected="true"]');
const items = [...results.querySelectorAll('li')];
const index = items.indexOf(currentEl);
let nextEl;
if (items.length === 0) {
return;
}
switch (event.key) {
case 'ArrowUp':
nextEl = items[Math.max(0, index - 1)];
break;
case 'ArrowDown':
nextEl = items[Math.min(items.length - 1, index + 1)];
break;
case 'Home':
nextEl = items[0];
break;
case 'End':
nextEl = items[items.length - 1];
break;
case 'Enter':
currentEl?.querySelector('a')?.click();
break;
}
// Update the selected item
items.forEach(item => {
if (item === nextEl) {
input.setAttribute('aria-activedescendant', item.id);
item.setAttribute('data-selected', 'true');
nextEl.scrollIntoView({ block: 'nearest' });
} else {
item.setAttribute('data-selected', 'false');
}
});
}
}
async function updateResults(query = '') {
try {
await loadSearchIndex;
const hasQuery = query.length > 0;
const searchTerms = query
.split(' ')
.map((term, index, arr) => {
// Search API: https://lunrjs.com/guides/searching.html
if (index === arr.length - 1) {
// The last term is not mandatory and 1x fuzzy. We also duplicate it with a wildcard to match partial words
// as the user types.
return `${term}~1 ${term}*`;
} else {
// All other terms are mandatory and 1x fuzzy
return `+${term}~1`;
}
})
.join(' ');
const matches = hasQuery ? searchIndex.search(searchTerms) : [];
const hasResults = hasQuery && matches.length > 0;
siteSearch.classList.toggle('search--has-results', hasQuery && hasResults);
siteSearch.classList.toggle('search--no-results', hasQuery && !hasResults);
input.setAttribute('aria-activedescendant', '');
results.innerHTML = '';
matches.forEach((match, index) => {
const page = map[match.ref];
const li = document.createElement('li');
const a = document.createElement('a');
const displayTitle = page.title ?? '';
const displayDescription = page.description ?? '';
const displayUrl = page.url.replace(/^\//, '').replace(/\/$/, '');
let icon = 'file-text';
a.setAttribute('role', 'option');
a.setAttribute('id', `search-result-item-${match.ref}`);
if (page.url.includes('getting-started/')) {
icon = 'lightbulb';
}
if (page.url.includes('resources/')) {
icon = 'book';
}
if (page.url.includes('components/')) {
icon = 'puzzle';
}
if (page.url.includes('tokens/')) {
icon = 'palette2';
}
if (page.url.includes('utilities/')) {
icon = 'wrench';
}
if (page.url.includes('tutorials/')) {
icon = 'joystick';
}
li.classList.add('search__result');
li.setAttribute('role', 'option');
li.setAttribute('id', `search-result-item-${match.ref}`);
li.setAttribute('data-selected', index === 0 ? 'true' : 'false');
a.href = page.url;
a.innerHTML = `
<div class="search__result-icon" aria-hidden="true">
<wa-icon name="${icon}"></wa-icon>
</div>
<div class="search__result__details">
<div class="search__result-title"></div>
<div class="search__result-description"></div>
<div class="search__result-url"></div>
</div>
`;
a.querySelector('.search__result-title').textContent = displayTitle;
a.querySelector('.search__result-description').textContent = displayDescription;
a.querySelector('.search__result-url').textContent = displayUrl;
li.appendChild(a);
results.appendChild(li);
});
} catch {
// Ignore query errors as the user types
}
}
// Show the search dialog when clicking on data-plugin="search"
document.addEventListener('click', event => {
const searchButton = event.target.closest('[data-plugin="search"]');
if (searchButton) {
show();
}
});
// Show the search dialog when slash (or CMD+K) is pressed and focus is not inside a form element
document.addEventListener('keydown', event => {
if (
!isShowing &&
(event.key === '/' || (event.key === 'k' && (event.metaKey || event.ctrlKey))) &&
!event.composedPath().some(el => ['input', 'textarea'].includes(el?.tagName?.toLowerCase()))
) {
event.preventDefault();
show();
}
});
// Purge cache when we press CMD+CTRL+R
document.addEventListener('keydown', event => {
if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.key === 'r') {
localStorage.clear();
}
});
input.addEventListener('input', handleInput);
clearButton.addEventListener('click', handleClear);
// Close when a result is selected
results.addEventListener('click', event => {
if (event.target.closest('a')) {
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());
});
})();

View File

@@ -0,0 +1,29 @@
import * as Turbo from 'https://cdn.jsdelivr.net/npm/@hotwired/turbo@7.3.0/+esm';
(() => {
if (!window.scrollPositions) {
window.scrollPositions = {};
}
function preserveScroll() {
document.querySelectorAll('[data-preserve-scroll').forEach(element => {
scrollPositions[element.id] = element.scrollTop;
});
}
function restoreScroll(event) {
document.querySelectorAll('[data-preserve-scroll').forEach(element => {
element.scrollTop = scrollPositions[element.id];
});
if (event.detail && event.detail.newBody) {
event.detail.newBody.querySelectorAll('[data-preserve-scroll').forEach(element => {
element.scrollTop = scrollPositions[element.id];
});
}
}
window.addEventListener('turbo:before-cache', preserveScroll);
window.addEventListener('turbo:before-render', restoreScroll);
window.addEventListener('turbo:render', restoreScroll);
})();

View File

@@ -1,17 +1,17 @@
/* Interactive code blocks */
.code-preview {
position: relative;
border-radius: var(--wa-corners-s);
background-color: var(--wa-color-neutral-fill-subtle);
border-radius: var(--wa-corners-1x);
background-color: var(--wa-color-surface-lowered);
margin-bottom: var(--wa-space-xl);
}
.code-preview__preview {
position: relative;
border: var(--wa-border-style) var(--wa-border-width-s) var(--wa-color-surface-border);
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-bottom: none;
border-top-left-radius: var(--wa-corners-s);
border-top-right-radius: var(--wa-corners-s);
border-top-left-radius: var(--wa-corners-1x);
border-top-right-radius: var(--wa-corners-1x);
background-color: var(--wa-color-surface-default);
min-width: 20rem;
max-width: 100%;
@@ -39,11 +39,11 @@
right: 0;
bottom: 0;
width: 1.75rem;
font-size: var(--wa-font-size-xs);
font-size: 20px;
color: var(--wa-color-text-quiet);
background-color: var(--wa-color-surface-default);
border-left: var(--wa-border-style) var(--wa-border-width-s) var(--wa-color-surface-border);
border-top-right-radius: var(--wa-corners-s);
border-left: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-top-right-radius: var(--wa-corners-1x);
cursor: ew-resize;
}
@@ -58,7 +58,7 @@
}
.code-preview__source {
border: var(--wa-border-style) var(--wa-border-width-s) var(--wa-color-surface-border);
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-bottom: none;
border-radius: 0 !important;
display: none;
@@ -74,9 +74,9 @@
.code-preview__buttons {
position: relative;
border: var(--wa-border-style) var(--wa-border-width-s) var(--wa-color-surface-border);
border-bottom-left-radius: var(--wa-corners-s);
border-bottom-right-radius: var(--wa-corners-s);
border: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-bottom-left-radius: var(--wa-corners-1x);
border-bottom-right-radius: var(--wa-corners-1x);
display: flex;
}
@@ -97,7 +97,7 @@
}
.code-preview__button:not(:last-of-type) {
border-right: var(--wa-border-style) var(--wa-border-width-s) var(--wa-color-surface-border);
border-right: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
}
.code-preview__button--html,
@@ -120,18 +120,18 @@
}
.code-preview__button:first-of-type {
border-bottom-left-radius: var(--wa-corners-s);
border-bottom-left-radius: var(--wa-corners-1x);
}
.code-preview__button:last-of-type {
border-bottom-right-radius: var(--wa-corners-s);
border-bottom-right-radius: var(--wa-corners-1x);
}
.code-preview__button:hover,
.code-preview__button:active {
box-shadow: 0 0 0 var(--wa-border-width-s) var(--wa-color-brand-border-subtle);
box-shadow: 0 0 0 var(--wa-border-width-thin) var(--wa-color-brand-outline-muted);
border-right-color: transparent;
background-color: var(--wa-color-brand-fill-subtle);
background-color: var(--wa-color-brand-fill-muted);
color: var(--wa-color-brand-text-on-surface);
z-index: 1;
}

940
docs/assets/styles/docs.css Normal file
View File

@@ -0,0 +1,940 @@
:root {
--docs-background-color: var(--wa-color-surface-default);
--docs-content-max-width: 860px;
--docs-sidebar-width: 320px;
--docs-sidebar-transition-speed: 250ms;
--docs-content-toc-max-width: 260px;
--docs-content-padding: 2rem;
--docs-content-vertical-spacing: 2rem;
--docs-search-overlay-background: rgb(0 0 0 / 0.2);
}
/* Light theme */
:root {
color-scheme: normal;
--docs-overlay-color: hsl(240 3.8% 46.1% / 33%);
--docs-shadow-x-small: 0 1px 2px hsl(240 3.8% 46.1% / 12%);
--docs-shadow-small: 0 1px 2px hsl(240 3.8% 46.1% / 24%);
--docs-shadow-medium: 0 2px 4px hsl(240 3.8% 46.1% / 24%);
--docs-shadow-large: 0 2px 8px hsl(240 3.8% 46.1% / 24%);
--docs-shadow-x-large: 0 4px 16px hsl(240 3.8% 46.1% / 24%);
}
/* Utils */
html.wa-theme-dark .only-light,
html:not(.wa-theme-dark) .only-dark {
display: none !important;
}
.nowrap {
white-space: nowrap;
}
.visually-hidden:not(:focus-within) {
position: absolute !important;
width: 1px !important;
height: 1px !important;
clip: rect(0 0 0 0) !important;
clip-path: inset(50%) !important;
border: none !important;
overflow: hidden !important;
white-space: nowrap !important;
padding: 0 !important;
}
@media screen and (max-width: 900px) {
:root {
--docs-content-padding: 1rem;
}
}
html {
height: 100%;
box-sizing: border-box;
line-height: var(--wa-font-line-height-regular);
padding: 0;
margin: 0;
}
body {
height: 100%;
padding: 0;
margin: 0;
overflow-x: hidden;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
/* Common elements */
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 3rem 0 1.5rem 0;
}
h1:first-of-type {
margin-top: 1rem;
}
.badges img {
border-radius: var(--wa-corners-1x);
}
.callout img {
width: 100%;
margin-left: 0;
margin-right: 0;
}
/* Color matching logos */
svg.logo {
color: var(--wa-color-brand-text-on-surface);
}
/* Anchor headings */
.anchor-heading {
position: relative;
color: inherit;
text-decoration: none;
}
.anchor-heading a {
text-decoration: none;
color: inherit;
}
.anchor-heading a::after {
content: '#';
color: color-mix(in oklab, var(--wa-color-text-link) 100%, var(--wa-color-tint-hover));
margin-inline: 0.5rem;
opacity: 0;
transition: 100ms opacity;
}
.anchor-heading:hover a::after,
.anchor-heading:focus-within a::after {
opacity: 1;
}
/* External links */
.external-link__icon {
width: 0.75em;
height: 0.75em;
vertical-align: 0;
margin-left: 0.25em;
margin-right: 0.125em;
}
/* Tables */
table th p:first-child,
table td p:first-child {
margin-top: 0;
}
table th p:last-child,
table td p:last-child {
margin-bottom: 0;
}
.table-scroll {
max-width: 100%;
overflow-x: auto;
}
.table-scroll code {
white-space: nowrap;
}
th.table-name,
th.table-event-detail {
min-width: 15ch;
}
th.table-description {
min-width: 50ch !important;
max-width: 70ch;
}
/* Code blocks */
pre:not(:last-child) {
margin-bottom: 1.5rem;
}
pre {
position: relative;
}
pre > code {
display: block;
background: none !important;
border-radius: 0;
hyphens: none;
tab-size: 2;
white-space: pre;
padding: 1rem;
margin: -1rem;
overflow: auto;
}
pre .token.comment {
color: var(--wa-color-neutral-40);
}
pre .token.prolog,
pre .token.doctype,
pre .token.cdata,
pre .token.operator,
pre .token.punctuation {
color: var(--wa-color-neutral-40);
}
.namespace {
opacity: 0.7;
}
pre .token.property,
pre .token.keyword,
pre .token.tag,
pre .token.url {
color: var(--wa-color-blue-40);
}
pre .token.symbol,
pre .token.deleted {
color: var(--wa-color-red-40);
}
pre .token.boolean,
pre .token.constant,
pre .token.selector,
pre .token.attr-name,
pre .token.string,
pre .token.char,
pre .token.builtin,
pre .token.inserted {
color: var(--wa-color-green-40);
}
pre .token.atrule,
pre .token.attr-value,
pre .token.number,
pre .token.variable {
color: #5c47ae; /* purple-40 */
}
pre .token.function,
pre .token.class-name,
pre .token.regex {
color: #c86d2c; /* orange-40 */
}
pre .token.important {
color: var(--wa-color-red-40);
}
pre .token.important,
pre .token.bold {
font-weight: bold;
}
pre .token.italic {
font-style: italic;
}
/* Copy code button */
.copy-code-button {
position: absolute;
top: 0;
right: 0;
white-space: normal;
color: var(--wa-color-neutral-text-on-muted-alt);
transition:
150ms opacity,
150ms scale;
}
.copy-code-button::part(button) {
background-color: var(--wa-color-neutral-fill-muted);
border-radius: 0 var(--wa-corners-1x) 0 var(--wa-corners-1x);
padding: 0.75rem;
}
.copy-code-button::part(button):hover {
background-color: color-mix(in oklab, var(--wa-color-neutral-fill-muted), var(--wa-color-tint-hover));
}
.copy-code-button::part(button):active {
background-color: color-mix(in oklab, var(--wa-color-neutral-fill-muted), var(--wa-color-tint-active));
}
pre .copy-code-button {
opacity: 0;
scale: 0.75;
}
pre:hover .copy-code-button,
.copy-code-button:focus-within {
opacity: 1;
scale: 1;
}
/* Callouts */
.callout {
margin-bottom: var(--docs-content-vertical-spacing);
}
.callout > :first-child {
margin-top: 0;
}
.callout > :last-child {
margin-bottom: 0;
}
.callout a {
color: inherit;
}
.callout p {
margin-top: 0;
}
/* Aside */
.content aside {
float: right;
min-width: 300px;
max-width: 50%;
background: var(--wa-color-surface-lowered);
border-radius: var(--wa-corners-1x);
padding: var(--wa-space-m);
margin-left: var(--wa-space-m);
}
.content aside > :first-child {
margin-top: 0;
}
.content aside > :last-child {
margin-bottom: 0;
}
@media screen and (max-width: 600px) {
.content aside {
float: none;
width: calc(100% + (var(--docs-content-padding) * 2));
max-width: none;
margin: var(--docs-content-vertical-spacing) calc(-1 * var(--docs-content-padding));
}
}
/* Sidebar */
#sidebar {
position: fixed;
flex: 0;
top: 0;
left: 0;
bottom: 0;
z-index: 20;
width: var(--docs-sidebar-width);
background-color: var(--docs-background-color);
border-right: solid var(--wa-border-width-thin) var(--wa-color-surface-outline);
border-radius: 0;
padding: 2rem;
margin: 0;
overflow: auto;
scrollbar-width: thin;
transition: var(--docs-sidebar-transition-speed) translate ease-in-out;
}
#sidebar::-webkit-scrollbar {
width: 4px;
}
#sidebar::-webkit-scrollbar-thumb {
background: transparent;
border-radius: 9999px;
}
#sidebar:hover::-webkit-scrollbar-thumb {
background: var(--wa-color-neutral-60);
}
#sidebar:hover::-webkit-scrollbar-track {
background: var(--wa-color-neutral-95);
}
#sidebar > header {
margin-bottom: 1.5rem;
}
#sidebar > header h1 {
margin: 0;
}
#sidebar > header svg {
margin-bottom: var(--wa-space-s);
}
#sidebar > header a {
display: block;
}
#sidebar nav a {
text-decoration: none;
}
#sidebar nav h2 {
font-size: var(--wa-font-size-m);
font-weight: var(--wa-font-weight-medium);
border-bottom: solid var(--wa-border-width-thin) var(--wa-color-surface-outline);
margin: var(--wa-space-xl) 0 var(--wa-space-xs) 0;
}
#sidebar ul {
padding: 0;
margin: 0;
}
#sidebar ul li {
list-style: none;
padding: 0;
margin: 0.125rem 0.5rem;
}
#sidebar ul ul ul {
margin-left: 0.75rem;
}
#sidebar ul li a {
line-height: 1.33;
color: inherit;
display: inline-block;
padding: 0;
}
#sidebar ul li a:not(.active-link):hover {
color: var(--wa-color-text-link);
}
#sidebar nav .active-link {
color: var(--wa-color-text-link);
border-bottom: dashed 1px var(--wa-color-text-link);
}
#sidebar > header img {
display: block;
width: 100%;
height: auto;
margin: 0 auto;
}
@media screen and (max-width: 900px) {
#sidebar {
translate: -100%;
}
.sidebar-open #sidebar {
translate: 0;
}
}
.sidebar-version {
font-size: var(--wa-font-size-s);
color: var(--wa-color-text-quiet);
text-align: right;
margin-top: calc(-1 * var(--wa-space-s));
margin-bottom: calc(-1 * var(--wa-space-s));
}
.sidebar-buttons {
display: flex;
justify-content: space-between;
}
/* Main content */
main {
position: relative;
padding: var(--docs-content-vertical-spacing) var(--docs-content-padding)
calc(var(--docs-content-vertical-spacing) * 2) var(--docs-content-padding);
margin-left: var(--docs-sidebar-width);
}
.sidebar-open .content {
margin-left: 0;
}
.content__body > :last-child {
margin-bottom: 0;
}
@media screen and (max-width: 900px) {
main {
margin-left: 0;
}
}
/* Component layouts */
.content {
display: grid;
grid-template-columns: 100%;
gap: 2rem;
position: relative;
max-width: var(--docs-content-max-width);
margin: 0 auto;
}
.content--with-toc {
/* There's a 2rem gap, so we need to remove it from the column */
grid-template-columns: calc(75% - 2rem) min(25%, var(--docs-content-toc-max-width));
max-width: calc(var(--docs-content-max-width) + var(--docs-content-toc-max-width));
}
.content__body {
order: 1;
width: 100%;
}
.content:not(.content--with-toc) .content__toc {
display: none;
}
.content__toc {
order: 2;
display: flex;
flex-direction: column;
margin-top: 0;
}
.content__toc ul {
position: sticky;
top: 5rem;
max-height: calc(100vh - 6rem);
font-size: var(--wa-font-size-s);
line-height: 1.33;
border-left: var(--wa-border-style) var(--wa-border-width-thin) var(--wa-color-surface-outline);
list-style: none;
padding: 1rem 0;
margin: 0;
padding-left: 1rem;
overflow-y: auto;
}
.content__toc li {
padding: 0 0 0 0.5rem;
margin: 0;
}
.content__toc li[data-level='3'] {
margin-left: 1rem;
}
/* We don't use them, but just in case */
.content__toc li[data-level='4'],
.content__toc li[data-level='5'],
.content__toc li[data-level='6'] {
margin-left: 2rem;
}
.content__toc li:not(:last-of-type) {
margin-bottom: 0.6rem;
}
.content__toc a {
color: var(--wa-color-text-normal);
text-decoration: none;
}
.content__toc a:hover {
color: var(--wa-color-text-link);
}
.content__toc a.active {
color: var(--wa-color-brand-text-on-surface);
border-bottom: dashed 1px var(--wa-color-brand-text-on-surface);
}
.content__toc .top a {
font-weight: var(--wa-font-weight-medium);
color: var(--wa-color-text-quiet);
}
@media screen and (max-width: 1024px) {
.content {
grid-template-columns: 100%;
gap: 0;
}
.content__toc {
position: relative;
order: 1;
}
.content__toc ul {
display: flex;
justify-content: start;
gap: 1rem 1.5rem;
position: static;
border: none;
border-bottom: solid 1px var(--wa-color-surface-outline);
border-radius: 0;
padding: 1rem 1.5rem 1rem 0.5rem; /* extra right padding to hide the fade effect */
margin-top: 1rem;
overflow-x: auto;
}
.content__toc ul::after {
content: '';
position: absolute;
top: 0;
bottom: 1rem; /* don't cover the scrollbar */
right: 0;
width: 2rem;
background: linear-gradient(90deg, rgba(0 0 0 / 0) 0%, var(--wa-color-surface-default) 100%);
}
.content__toc li {
white-space: nowrap;
}
.content__toc li:not(:last-of-type) {
margin-bottom: 0;
}
.content__toc [data-level]:not([data-level='2']) {
display: none;
}
.content__body {
order: 2;
}
}
/* Menu toggle */
#menu-toggle {
display: none;
position: fixed;
z-index: 30;
top: 0.25rem;
left: 0.25rem;
height: auto;
width: auto;
color: var(--wa-color-neutral-fill-vivid-alt);
border: none;
border-radius: 50%;
background: var(--wa-color-surface-default);
padding: 0.5rem;
margin: 0;
cursor: pointer;
transition: 250ms rotate ease;
}
@media screen and (max-width: 900px) {
#menu-toggle {
display: flex;
}
}
#menu-toggle svg {
width: 1.25rem;
height: 1.25rem;
}
html.sidebar-open #menu-toggle {
rotate: 180deg;
}
/* Skip to main content */
#skip-to-content {
position: fixed;
top: var(--wa-space-m);
left: var(--wa-space-m);
z-index: 100;
text-align: center;
text-decoration: none;
border-radius: 9999px;
background: var(--wa-color-surface-default);
color: var(--wa-color-text-normal);
padding: var(--wa-space-s);
}
/* Print styles */
@media print {
a:not(.anchor-heading)[href]::after {
content: ' (' attr(href) ')';
}
details,
pre {
border: solid var(--wa-border-width-thin) var(--wa-color-surface-outline);
}
details summary {
list-style: none;
}
details summary span {
padding-left: 0;
}
details summary::marker,
details summary::-webkit-details-marker {
display: none;
}
.component-page__navigation,
.copy-code-button,
.code-preview__buttons,
.code-preview__resizer {
display: none !important;
}
.flavor-html .code-preview__source--html,
.flavor-react .code-preview__source--react {
display: block !important;
}
.flavor-html .code-preview__source--html > pre,
.flavor-react .code-preview__source--react > pre {
border: none;
}
.code-preview__source-group {
border-bottom: solid 1px var(--wa-border-width-thin);
border-bottom-left-radius: var(--wa-corners-1x);
border-bottom-right-radius: var(--wa-corners-1x);
}
#sidebar {
display: none;
}
#content {
margin-left: 0;
}
#menu-toggle,
#icon-toolbar,
.external-link__icon {
display: none;
}
}
/* Splash */
.splash {
display: flex;
padding-top: 2rem;
}
.splash-start {
min-width: 440px;
}
.splash li img {
width: 1em;
height: 1em;
vertical-align: -2px;
}
.splash svg {
margin-block-end: var(--wa-space-m);
}
.splash-end {
display: flex;
align-items: flex-end;
width: auto;
padding-left: 1rem;
}
.splash-image {
width: 100%;
height: auto;
}
.splash-start h1:first-of-type {
font-size: var(--wa-font-size-l);
font-weight: var(--wa-font-weight-normal);
margin: 0 0 0.5rem 0;
}
@media screen and (max-width: 1280px) {
.splash {
display: block;
}
.splash-start {
min-width: 0;
padding-bottom: 1rem;
}
.splash-end {
padding: 0;
}
.splash-image {
display: block;
max-width: 400px;
}
/* Shields */
.splash + p {
margin-top: 2rem;
}
}
/* Component headers */
.component-header h1 {
margin-bottom: 0;
}
.component-header__tag {
margin-bottom: 0.5rem;
}
.component-header__tag code {
background: none;
color: var(--wa-color-text-quiet);
font-size: var(--wa-font-size-l);
padding: 0;
margin: 0;
}
.component-header__info {
margin-bottom: var(--wa-space-2xl);
}
.component-summary {
font-size: var(--wa-font-size-l);
line-height: 1.6;
margin: 2rem 0;
}
/* Repo buttons */
.sidebar-buttons {
display: flex;
gap: 0.125rem;
justify-content: space-between;
}
.sidebar-buttons .repo-button {
flex: 1 1 auto;
}
.repo-button wa-icon {
color: var(--wa-color-text-inverse);
}
@media screen and (max-width: 400px) {
:not(.sidebar-buttons) > .repo-button {
width: 100%;
margin-bottom: 1rem;
}
}
body[data-page^='/tokens/'] .table-wrapper td:first-child,
body[data-page^='/tokens/'] .table-wrapper td:first-child code {
white-space: nowrap;
}
/* Border demos */
.border-demo {
height: 60px;
border-left: solid 1px var(--wa-color-brand-fill-vivid);
}
.corner-demo {
width: 3rem;
height: 3rem;
background: var(--wa-color-brand-fill-vivid);
}
/* Transition demo */
.transition-demo {
position: relative;
background: var(--wa-color-neutral-fill-muted);
width: 8rem;
height: 2rem;
}
.transition-demo:after {
content: '';
position: absolute;
background-color: var(--wa-color-brand-fill-vivid);
top: 0;
left: 0;
width: 0;
height: 100%;
transition-duration: inherit;
transition-property: width;
}
.transition-demo:hover:after {
width: 100%;
}
/* Spacing demo */
.spacing-demo {
background: var(--wa-color-brand-fill-vivid);
}
/* Shadow demo */
.shadow-demo {
background: transparent;
border-radius: 3px;
width: 4rem;
height: 4rem;
margin: 1rem;
}
/* Color palettes */
.color-palette {
display: grid;
grid-template-columns: 200px repeat(11, 1fr);
gap: var(--wa-space-m) 1px;
margin: var(--wa-space-2xl) 0;
}
.color-palette__name {
font-weight: var(--wa-font-weight-medium);
grid-template-columns: repeat(11, 1fr);
}
.color-palette__name code {
background: none;
font-size: var(--wa-font-size-s);
}
.color-palette__example {
font-size: var(--wa-font-size-s);
text-align: center;
}
.color-palette__swatch {
height: 3rem;
border-radius: var(--wa-corners-half);
}
.color-palette__swatch--border {
box-shadow: inset 0 0 0 1px var(--wa-color-surface-outline);
}
@media screen and (max-width: 1200px) {
.color-palette {
grid-template-columns: repeat(6, 1fr);
}
.color-palette__name {
grid-column-start: span 6;
}
}
.docs-grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 2rem;
}

View File

@@ -2,26 +2,26 @@
:root {
--docs-search-box-background: var(--wa-form-controls-background);
--docs-search-box-border-width: var(--wa-form-controls-border-width);
--docs-search-box-border-color: var(--wa-form-controls-resting-color);
--docs-search-box-border-color: var(--wa-form-controls-border-color-resting);
--docs-search-box-color: var(--wa-form-controls-placeholder-color);
--docs-search-dialog-background: var(--wa-color-surface-raised);
--docs-search-border-width: var(--wa-border-width-s);
--docs-search-border-color: var(--wa-color-surface-border);
--docs-search-border-width: var(--wa-border-width-thin);
--docs-search-border-color: var(--wa-color-surface-outline);
--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-border-radius: calc(2 * var(--wa-corners-1x));
--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-icon-color: var(--wa-color-neutral-fill-vivid);
--docs-search-icon-color-active: color-mix(in lch, var(--wa-color-neutral-fill-vivid), 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-result-background-hover: var(--wa-color-neutral-fill-muted-alt);
--docs-search-result-color-hover: var(--wa-color-neutral-text-on-muted);
--docs-search-result-background-active: var(--wa-color-brand-fill-vivid);
--docs-search-result-color-active: var(--wa-color-brand-text-on-vivid);
--docs-search-focus-ring: var(--wa-focus-ring);
--docs-search-overlay-background: rgb(0 0 0 / 0.33);
}

View File

@@ -1,148 +0,0 @@
import * as path from 'node:path';
import * as url from 'node:url';
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
// const __filename = url.fileURLToPath(import.meta.url);
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
import FullReload from 'vite-plugin-full-reload';
import { customElementsManifest } from './src/js/cem.js';
import { RemarkPluginFindAndReplace } from 'remark-plugin-find-and-replace';
import GithubAutolink from './src/plugins/github-autolink.ts';
import rehypeExternalLinks from 'rehype-external-links';
import remarkCodeHighlighter from './src/plugins/prism';
const version = customElementsManifest().package.version;
const cdndir = 'cdn';
const npmdir = 'dist';
function remarkFrontmatterPlugin() {
// All remark and rehype plugins return a separate function
return function (tree, file) {
const frontmatter = file.data.astro.frontmatter;
frontmatter.npmdir = npmdir;
frontmatter.cdndir = cdndir;
frontmatter.version = version;
};
}
// https://astro.build/config
export default defineConfig({
server: {
open: true,
port: 4000,
host: true
},
vite: {
server: {
watch: {
ignored: ['./public/pagefind/**/*.*'] // HERE
}
},
plugins: [
FullReload([
path.relative(__dirname, '../dist/custom-elements.json')
// path.relative(__dirname, './public/**/*.*')
])
]
},
outDir: '../_site',
site: 'https://shoelace.style',
markdown: {
syntaxHighlight: 'prism',
remarkPlugins: [
remarkFrontmatterPlugin,
RemarkPluginFindAndReplace({
replacements: [
{ pattern: '%VERSION%', replacement: version },
{ pattern: '%CDNDIR%', replacement: cdndir },
{ pattern: '%NPMDIR%', replacement: npmdir }
]
}),
GithubAutolink,
remarkCodeHighlighter
],
rehypePlugins: [
() =>
rehypeExternalLinks({
rel: ['nofollow', 'noopener', 'noreferrer'],
target: ['_blank'],
properties: {
class: 'external-link'
}
})
]
},
integrations: [
starlight({
expressiveCode: false,
title: 'Web Awesome',
social: {
github: 'https://github.com/shoelace-style/shoelace',
twitter: 'https://twitter.com/shoelace_style'
},
sidebar: [
{
label: 'Experimental',
autogenerate: { directory: 'experimental' }
},
{
label: 'Getting Started',
autogenerate: { directory: 'getting-started' }
},
{
label: 'Frameworks',
autogenerate: { directory: 'frameworks' }
},
{
label: 'Resources',
autogenerate: { directory: 'resources' },
items: [
{
label: 'Community',
link: '/resources/community'
},
{
label: 'Help & Support',
link: 'https://github.com/shoelace-style/shoelace/discussions'
},
{
label: 'Accessibility',
link: '/resources/accessibility'
},
{
label: 'Contributing',
link: '/resources/contributing'
},
{
label: 'Changelog',
link: '/resources/changelog'
}
]
},
{
label: 'Components',
autogenerate: { directory: 'components' }
},
{ label: 'Patterns', autogenerate: { directory: 'patterns' } },
{
label: 'Design Tokens',
autogenerate: { directory: 'tokens' }
},
{
label: 'Tutorials',
autogenerate: { directory: 'tutorials' }
}
],
// Component overrides
components: {
// Override the default `Head` component.
Head: './src/components/overrides/Head.astro',
TableOfContents: './src/components/overrides/TableOfContents.astro',
Search: './src/components/overrides/Search.astro'
}
})
]
});

256
docs/eleventy.config.cjs Normal file
View File

@@ -0,0 +1,256 @@
/* eslint-disable no-invalid-this */
const fs = require('fs');
const path = require('path');
const lunr = require('lunr');
const { capitalCase } = require('change-case');
const { JSDOM } = require('jsdom');
const { customElementsManifest, getAllComponents } = require('./_utilities/cem.cjs');
const webAwesomeFlavoredMarkdown = require('./_utilities/markdown.cjs');
const activeLinks = require('./_utilities/active-links.cjs');
const anchorHeadings = require('./_utilities/anchor-headings.cjs');
const codePreviews = require('./_utilities/code-previews.cjs');
const copyCodeButtons = require('./_utilities/copy-code-buttons.cjs');
const externalLinks = require('./_utilities/external-links.cjs');
const highlightCodeBlocks = require('./_utilities/highlight-code.cjs');
const tableOfContents = require('./_utilities/table-of-contents.cjs');
const prettier = require('./_utilities/prettier.cjs');
const scrollingTables = require('./_utilities/scrolling-tables.cjs');
const typography = require('./_utilities/typography.cjs');
const replacer = require('./_utilities/replacer.cjs');
const assetsDir = 'assets';
const cdndir = 'cdn';
const npmdir = 'dist';
const allComponents = getAllComponents();
let hasBuiltSearchIndex = false;
module.exports = function (eleventyConfig) {
//
// Global data
//
let baseUrl = 'https://shoelace.style/';
if (process.env.VERCEL_URL) {
baseUrl = process.env.VERCEL_URL;
if (!process.env.VERCEL_URL.match(/^https?/)) {
baseUrl = 'https://' + baseUrl;
}
}
eleventyConfig.addGlobalData('baseUrl', baseUrl); // the production URL
eleventyConfig.addGlobalData('layout', 'default'); // make 'default' the default layout
eleventyConfig.addGlobalData('toc', true); // enable the table of contents
eleventyConfig.addGlobalData('meta', {
title: 'Web Awesome',
description: 'A forward-thinking library of web components.',
image: 'images/og-image.png',
version: customElementsManifest.package.version,
components: allComponents,
cdndir,
npmdir
});
//
// Layout aliases
//
eleventyConfig.addLayoutAlias('default', 'default.njk');
//
// Copy assets
//
eleventyConfig.addPassthroughCopy(assetsDir);
eleventyConfig.setServerPassthroughCopyBehavior('passthrough'); // emulates passthrough copy during --serve
//
// Add additional extensions. This allows things like {% include "layout.css" %}
//
eleventyConfig.setTemplateFormats(['html', 'md', 'njk', 'css']);
//
// Functions
//
// Generates a URL relative to the site's root
eleventyConfig.addNunjucksGlobal('rootUrl', (value = '', absolute = false) => {
value = path.join('/', value);
return absolute ? new URL(value, eleventyConfig.globalData.baseUrl).toString() : value;
});
// Generates a URL relative to the site's asset directory
eleventyConfig.addNunjucksGlobal('assetUrl', (value = '', absolute = false) => {
value = path.join(`/${assetsDir}`, value);
return absolute ? new URL(value, eleventyConfig.globalData.baseUrl).toString() : value;
});
// Fetches a specific component's metadata
eleventyConfig.addNunjucksGlobal('getComponent', tagName => {
const component = allComponents.find(c => c.tagName === tagName);
if (!component) {
throw new Error(
`Unable to find a component called "${tagName}". Make sure the file name is the same as the component's tag ` +
`name (minus the wa- prefix).`
);
}
return component;
});
//
// Custom markdown syntaxes
//
eleventyConfig.setLibrary('md', webAwesomeFlavoredMarkdown);
//
// Filters
//
eleventyConfig.addFilter('markdown', content => {
return webAwesomeFlavoredMarkdown.render(content);
});
eleventyConfig.addFilter('markdownInline', content => {
return webAwesomeFlavoredMarkdown.renderInline(content);
});
eleventyConfig.addFilter('classNameToComponentName', className => {
let name = capitalCase(className.replace(/^Wa/, ''));
if (name === 'Qr Code') name = 'QR Code'; // manual override
return name;
});
eleventyConfig.addFilter('removeWaPrefix', tagName => {
return tagName.replace(/^wa-/, '');
});
//
// Transforms
//
eleventyConfig.addTransform('html-transform', function (content) {
// Parse the template and get a Document object
const doc = new JSDOM(content, {
// We must set a default URL so links are parsed with a hostname. Let's use a bogus TLD so we can easily
// identify which ones are internal and which ones are external.
url: `https://internal/`
}).window.document;
// DOM transforms
activeLinks(doc, { pathname: this.page.url });
anchorHeadings(doc, {
within: '#content .content__body',
levels: ['h2', 'h3', 'h4', 'h5']
});
tableOfContents(doc, {
levels: ['h2', 'h3'],
container: '#content .content__toc > ul',
within: '#content .content__body'
});
codePreviews(doc);
externalLinks(doc, { target: '_blank' });
highlightCodeBlocks(doc);
scrollingTables(doc);
copyCodeButtons(doc); // must be after codePreviews + highlightCodeBlocks
typography(doc, '#content');
replacer(doc, [
{ pattern: '%VERSION%', replacement: customElementsManifest.package.version },
{ pattern: '%CDNDIR%', replacement: cdndir },
{ pattern: '%NPMDIR%', replacement: npmdir }
]);
// Serialize the Document object to an HTML string and prepend the doctype
content = `<!DOCTYPE html>\n${doc.documentElement.outerHTML}`;
// String transforms
content = prettier(content);
return content;
});
//
// Build a search index
//
eleventyConfig.on('eleventy.after', ({ results }) => {
// We only want to build the search index on the first run so all pages get indexed.
if (hasBuiltSearchIndex) {
return;
}
const map = {};
const searchIndexFilename = path.join(eleventyConfig.dir.output, assetsDir, 'search.json');
const lunrInput = path.resolve('../node_modules/lunr/lunr.min.js');
const lunrOutput = path.join(eleventyConfig.dir.output, assetsDir, 'scripts/lunr.js');
const searchIndex = lunr(function () {
// The search index uses these field names extensively, so shortening them can save some serious bytes. The
// initial index file went from 468 KB => 401 KB by using single-character names!
this.ref('id'); // id
this.field('t', { boost: 50 }); // title
this.field('h', { boost: 25 }); // headings
this.field('c'); // content
results.forEach((result, index) => {
const url = path
.join('/', path.relative(eleventyConfig.dir.output, result.outputPath))
.replace(/\\/g, '/') // convert backslashes to forward slashes
.replace(/\/index.html$/, '/'); // convert trailing /index.html to /
const doc = new JSDOM(result.content, {
// We must set a default URL so links are parsed with a hostname. Let's use a bogus TLD so we can easily
// identify which ones are internal and which ones are external.
url: `https://internal/`
}).window.document;
const content = doc.querySelector('#content');
if (content) {
// Get title and headings
const title = (doc.querySelector('title')?.textContent || path.basename(result.outputPath)).trim();
const headings = [...content.querySelectorAll('h1, h2, h3, h4')]
.map(heading => heading.textContent)
.join(' ')
.replace(/\s+/g, ' ')
.trim();
// Remove code blocks and whitespace from content
[...content.querySelectorAll('code[class|=language]')].forEach(code => code.remove());
const textContent = content.textContent.replace(/\s+/g, ' ').trim();
// Update the index and map
this.add({ id: index, t: title, h: headings, c: textContent });
map[index] = { title, url };
}
});
});
// Copy the Lunr search client and write the index
fs.mkdirSync(path.dirname(lunrOutput), { recursive: true });
fs.copyFileSync(lunrInput, lunrOutput);
fs.writeFileSync(searchIndexFilename, JSON.stringify({ searchIndex, map }), 'utf-8');
hasBuiltSearchIndex = true;
});
//
// Send a signal to stdout that let's the build know we've reached this point
//
eleventyConfig.on('eleventy.after', () => {
console.log('[eleventy.after]');
});
//
// Dev server options (see https://www.11ty.dev/docs/dev-server/#options)
//
eleventyConfig.setServerOptions({
domDiff: false, // disable dom diffing so custom elements don't break on reload,
port: 4000, // if port 4000 is taken, 11ty will use the next one available
watch: ['cdn/**/*'] // additional files to watch that will trigger server updates (array of paths or globs)
});
//
// 11ty config
//
return {
dir: {
input: 'pages',
output: '../_site',
includes: '../_includes' // resolved relative to the input dir
},
markdownTemplateEngine: 'njk', // use Nunjucks instead of Liquid for markdown files
templateEngineOverride: ['njk'] // just Nunjucks and then markdown
};
};

19
docs/pages/404.md Normal file
View File

@@ -0,0 +1,19 @@
---
meta:
title: Page Not Found
description: "The page you were looking for couldn't be found."
permalink: 404.html
toc: false
---
<div style="text-align: center;">
# Page Not Found
![A UFO takes one of the little worker monsters](/assets/images/undraw-taken.svg)
The page you were looking for couldn't be found.
Press [[/]] to search, or [head back to the homepage](/).
</div>

View File

@@ -1,12 +1,13 @@
---
title: Alert
description: Alerts are used to display important messages inline or as toast notifications.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Alert
description: Alerts are used to display important messages inline or as toast notifications.
layout: component
---
```html:preview
<wa-alert open>
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
<wa-icon slot="icon" name="info-circle"></wa-icon>
This is a standard alert. You can customize its content and even the icon.
</wa-alert>
```
@@ -17,13 +18,13 @@ import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
const App = () => (
<WaAlert open>
<WaIcon slot="icon" name="circle-info" variant="regular" />
<WaIcon slot="icon" name="info-circle" />
This is a standard alert. You can customize its content and even the icon.
</WaAlert>
);
```
:::caution
:::warning
Alerts will not be visible if the `open` attribute is not present.
:::
@@ -35,7 +36,7 @@ Set the `variant` attribute to change the alert's variant.
```html:preview
<wa-alert variant="brand" open>
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
<wa-icon slot="icon" name="info-circle"></wa-icon>
<strong>This is super informative</strong><br />
You can tell by how pretty the alert is.
</wa-alert>
@@ -43,7 +44,7 @@ Set the `variant` attribute to change the alert's variant.
<br />
<wa-alert variant="success" open>
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
<wa-icon slot="icon" name="check2-circle"></wa-icon>
<strong>Your changes have been saved</strong><br />
You can safely exit the app now.
</wa-alert>
@@ -51,7 +52,7 @@ Set the `variant` attribute to change the alert's variant.
<br />
<wa-alert variant="neutral" open>
<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>
<wa-icon slot="icon" name="gear"></wa-icon>
<strong>Your settings have been updated</strong><br />
Settings will take effect on next login.
</wa-alert>
@@ -59,7 +60,7 @@ Set the `variant` attribute to change the alert's variant.
<br />
<wa-alert variant="warning" open>
<wa-icon slot="icon" name="triangle-exclamation" variant="regular"></wa-icon>
<wa-icon slot="icon" name="exclamation-triangle"></wa-icon>
<strong>Your session has ended</strong><br />
Please login again to continue.
</wa-alert>
@@ -67,7 +68,7 @@ Set the `variant` attribute to change the alert's variant.
<br />
<wa-alert variant="danger" open>
<wa-icon slot="icon" name="circle-exclamation" variant="regular"></wa-icon>
<wa-icon slot="icon" name="exclamation-octagon"></wa-icon>
<strong>Your account has been deleted</strong><br />
We're very sorry to see you go!
</wa-alert>
@@ -80,7 +81,7 @@ import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
const App = () => (
<>
<WaAlert variant="brand" open>
<WaIcon slot="icon" name="circle-info" variant="regular" />
<WaIcon slot="icon" name="info-circle" />
<strong>This is super informative</strong>
<br />
You can tell by how pretty the alert is.
@@ -89,7 +90,7 @@ const App = () => (
<br />
<WaAlert variant="success" open>
<WaIcon slot="icon" name="circle-check" variant="regular" />
<WaIcon slot="icon" name="check2-circle" />
<strong>Your changes have been saved</strong>
<br />
You can safely exit the app now.
@@ -98,7 +99,7 @@ const App = () => (
<br />
<WaAlert variant="neutral" open>
<WaIcon slot="icon" name="gear" variant="regular" />
<WaIcon slot="icon" name="gear" />
<strong>Your settings have been updated</strong>
<br />
Settings will take effect on next login.
@@ -107,7 +108,7 @@ const App = () => (
<br />
<WaAlert variant="warning" open>
<WaIcon slot="icon" name="triangle-exclamation" variant="regular" />
<WaIcon slot="icon" name="exclamation-triangle" />
<strong>Your session has ended</strong>
<br />
Please login again to continue.
@@ -116,7 +117,7 @@ const App = () => (
<br />
<WaAlert variant="danger" open>
<WaIcon slot="icon" name="circle-exclamation" variant="regular" />
<WaIcon slot="icon" name="exclamation-octagon" />
<strong>Your account has been deleted</strong>
<br />
We're very sorry to see you go!
@@ -131,7 +132,7 @@ Add the `closable` attribute to show a close button that will hide the alert.
```html:preview
<wa-alert variant="brand" open closable class="alert-closable">
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
<wa-icon slot="icon" name="info-circle"></wa-icon>
You can close this alert any time!
</wa-alert>
@@ -158,7 +159,7 @@ const App = () => {
return (
<WaAlert open={open} closable onWaAfterHide={handleHide}>
<WaIcon slot="icon" name="circle-info" variant="regular" />
<WaIcon slot="icon" name="info-circle" />
You can close this alert any time!
</WaAlert>
);
@@ -192,7 +193,7 @@ Set the `duration` attribute to automatically hide an alert after a period of ti
<wa-button variant="brand">Show Alert</wa-button>
<wa-alert variant="brand" duration="3000" closable>
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
<wa-icon slot="icon" name="info-circle"></wa-icon>
This alert will automatically hide itself after three seconds, unless you interact with it.
</wa-alert>
</div>
@@ -235,7 +236,7 @@ const App = () => {
</WaButton>
<WaAlert variant="brand" duration="3000" open={open} closable onWaAfterHide={() => setOpen(false)}>
<WaIcon slot="icon" name="circle-info" variant="regular" />
<WaIcon slot="icon" name="info-circle" />
This alert will automatically hide itself after three seconds, unless you interact with it.
</WaAlert>
</div>
@@ -261,31 +262,31 @@ You should always use the `closable` attribute so users can dismiss the notifica
<wa-button variant="danger">Danger</wa-button>
<wa-alert variant="brand" duration="3000" closable>
<wa-icon slot="icon" name="circle-info" variant="regular"></wa-icon>
<wa-icon slot="icon" name="info-circle"></wa-icon>
<strong>This is super informative</strong><br />
You can tell by how pretty the alert is.
</wa-alert>
<wa-alert variant="success" duration="3000" closable>
<wa-icon slot="icon" name="circle-check" variant="regular"></wa-icon>
<wa-icon slot="icon" name="check2-circle"></wa-icon>
<strong>Your changes have been saved</strong><br />
You can safely exit the app now.
</wa-alert>
<wa-alert variant="neutral" duration="3000" closable>
<wa-icon slot="icon" name="gear" variant="regular"></wa-icon>
<wa-icon slot="icon" name="gear"></wa-icon>
<strong>Your settings have been updated</strong><br />
Settings will take effect on next login.
</wa-alert>
<wa-alert variant="warning" duration="3000" closable>
<wa-icon slot="icon" name="triangle-exclamation" variant="regular"></wa-icon>
<wa-icon slot="icon" name="exclamation-triangle"></wa-icon>
<strong>Your session has ended</strong><br />
Please login again to continue.
</wa-alert>
<wa-alert variant="danger" duration="3000" closable>
<wa-icon slot="icon" name="circle-exclamation" variant="regular"></wa-icon>
<wa-icon slot="icon" name="exclamation-octagon"></wa-icon>
<strong>Your account has been deleted</strong><br />
We're very sorry to see you go!
</wa-alert>
@@ -343,35 +344,35 @@ const App = () => {
</WaButton>
<WaAlert ref={brand} variant="brand" duration="3000" closable>
<WaIcon slot="icon" name="circle-info" variant="regular" />
<WaIcon slot="icon" name="info-circle" />
<strong>This is super informative</strong>
<br />
You can tell by how pretty the alert is.
</WaAlert>
<WaAlert ref={success} variant="success" duration="3000" closable>
<WaIcon slot="icon" name="circle-check" variant="regular" />
<WaIcon slot="icon" name="check2-circle" />
<strong>Your changes have been saved</strong>
<br />
You can safely exit the app now.
</WaAlert>
<WaAlert ref={neutral} variant="neutral" duration="3000" closable>
<WaIcon slot="icon" name="gear" variant="regular" />
<WaIcon slot="icon" name="gear" />
<strong>Your settings have been updated</strong>
<br />
Settings will take effect on next login.
</WaAlert>
<WaAlert ref={warning} variant="warning" duration="3000" closable>
<WaIcon slot="icon" name="triangle-exclamation" variant="regular" />
<WaIcon slot="icon" name="exclamation-triangle" />
<strong>Your session has ended</strong>
<br />
Please login again to continue.
</WaAlert>
<WaAlert ref={danger} variant="danger" duration="3000" closable>
<WaIcon slot="icon" name="circle-exclamation" variant="regular" />
<WaIcon slot="icon" name="exclamation-octagon" />
<strong>Your account has been deleted</strong>
<br />
We're very sorry to see you go!
@@ -403,13 +404,13 @@ For convenience, you can create a utility that emits toast notifications with a
}
// Custom function to emit toast notifications
function notify(message, variant = 'brand', icon = 'circle-info', duration = 3000) {
function notify(message, variant = 'brand', icon = 'info-circle', duration = 3000) {
const alert = Object.assign(document.createElement('wa-alert'), {
variant,
closable: true,
duration: duration,
innerHTML: `
<wa-icon name="${icon}" variant="regular" slot="icon"></wa-icon>
<wa-icon name="${icon}" slot="icon"></wa-icon>
${escapeHtml(message)}
`
});

View File

@@ -1,7 +1,8 @@
---
title: Animated Image
description: A component for displaying animated GIFs and WEBPs that play and pause on interaction.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Animated Image
description: A component for displaying animated GIFs and WEBPs that play and pause on interaction.
layout: component
---
```html:preview
@@ -60,6 +61,8 @@ To set a custom size, apply a width and/or height to the host element.
</wa-animated-image>
```
{% raw %}
```jsx:react
import WaAnimatedImage from '@shoelace-style/shoelace/dist/react/animated-image';
@@ -72,6 +75,8 @@ const App = () => (
);
```
{% endraw %}
### Customizing the Control Box
You can change the appearance and location of the control box by targeting the `control-box` part in your styles.

View File

@@ -1,7 +1,8 @@
---
title: Animation
description: Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Animation
description: Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes.
layout: component
---
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.
@@ -19,7 +20,7 @@ To animate an element, wrap it in `<wa-animation>` and set an animation `name`.
display: inline-block;
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
margin: 1.5rem;
}
</style>
@@ -33,7 +34,7 @@ const css = `
display: inline-block;
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
margin: 1.5rem;
}
`;
@@ -79,8 +80,7 @@ This example demonstrates all of the baked-in animations and easings. Animations
<div class="controls">
<wa-select label="Animation" value="bounce"></wa-select>
<wa-select label="Easing" value="linear"></wa-select>
<wa-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1">
</wa-input>
<wa-input label="Playback Rate" type="number" min="0" max="2" step=".25" value="1"></wa-input>
</div>
</div>
@@ -120,7 +120,7 @@ This example demonstrates all of the baked-in animations and easings. Animations
.animation-sandbox .box {
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
}
.animation-sandbox .controls {
@@ -134,10 +134,6 @@ This example demonstrates all of the baked-in animations and easings. Animations
</style>
```
```jsx:react
```
### Using Intersection Observer
Use an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to control the animation when an element enters or exits the viewport. For example, scroll the box below in and out of your screen. The animation stops when the box exits the viewport and restarts each time it enters the viewport.
@@ -170,7 +166,7 @@ Use an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/
display: inline-block;
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
}
</style>
```
@@ -188,7 +184,7 @@ const css = `
display: inline-block;
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
}
`;
@@ -260,7 +256,7 @@ Supply your own [keyframe formats](https://developer.mozilla.org/en-US/docs/Web/
.animation-keyframes .box {
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
}
</style>
```
@@ -272,7 +268,7 @@ const css = `
.animation-keyframes .box {
width: 100px;
height: 100px;
background-color: var(--wa-color-brand-spot);
background-color: var(--wa-color-brand-fill-vivid);
}
`;

View File

@@ -1,7 +1,8 @@
---
title: Avatar
description: Avatars are used to represent a person or object.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Avatar
description: Avatars are used to represent a person or object.
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.
@@ -56,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.
```html:preview
<wa-avatar initials="WA" label="Avatar with initials: SL"></wa-avatar>
<wa-avatar initials="SL" label="Avatar with initials: SL"></wa-avatar>
```
```jsx:react
import WaAvatar from '@shoelace-style/shoelace/dist/react/avatar';
const App = () => <WaAvatar initials="WA" label="Avatar with initials: SL" />;
const App = () => <WaAvatar initials="SL" label="Avatar with initials: SL" />;
```
### Custom Icons
@@ -71,15 +72,15 @@ When no image or initials are set, an icon will be shown. The default avatar sho
```html:preview
<wa-avatar label="Avatar with an image icon">
<wa-icon slot="icon" name="image" variant="solid"></wa-icon>
<wa-icon slot="icon" name="image"></wa-icon>
</wa-avatar>
<wa-avatar label="Avatar with an archive icon">
<wa-icon slot="icon" name="archive" variant="solid"></wa-icon>
<wa-icon slot="icon" name="archive"></wa-icon>
</wa-avatar>
<wa-avatar label="Avatar with a briefcase icon">
<wa-icon slot="icon" name="briefcase" variant="solid"></wa-icon>
<wa-icon slot="icon" name="briefcase"></wa-icon>
</wa-avatar>
```

View File

@@ -1,7 +1,8 @@
---
title: Badge
description: Badges are used to draw attention and display statuses or counts.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Badge
description: Badges are used to draw attention and display statuses or counts.
layout: component
---
```html:preview
@@ -153,6 +154,8 @@ One of the most common use cases for badges is attaching them to buttons. To mak
</wa-button>
```
{% raw %}
```jsx:react
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -181,6 +184,8 @@ const App = () => (
);
```
{% endraw %}
### With Menu Items
When including badges in menu items, use the `suffix` slot to make sure they're aligned correctly.
@@ -193,6 +198,8 @@ When including badges in menu items, use the `suffix` slot to make sure they're
</wa-menu>
```
{% raw %}
```jsx:react
import WaBadge from '@shoelace-style/shoelace/dist/react/badge';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -220,3 +227,5 @@ const App = () => (
</WaMenu>
);
```
{% endraw %}

View File

@@ -1,13 +1,14 @@
---
title: Breadcrumb Item
description: Breadcrumb Items are used inside breadcrumbs to represent different links.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Breadcrumb Item
description: Breadcrumb Items are used inside breadcrumbs to represent different links.
layout: component
---
```html:preview
<wa-breadcrumb>
<wa-breadcrumb-item>
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="house"></wa-icon>
Home
</wa-breadcrumb-item>
<wa-breadcrumb-item>Clothing</wa-breadcrumb-item>

View File

@@ -1,7 +1,8 @@
---
title: Breadcrumb
description: Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Breadcrumb
description: Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy.
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.
@@ -72,7 +73,7 @@ Use the `separator` slot to change the separator that goes between breadcrumb it
```html:preview
<wa-breadcrumb>
<wa-icon slot="separator" name="angles-right" variant="solid"></wa-icon>
<wa-icon name="dot" slot="separator"></wa-icon>
<wa-breadcrumb-item>First</wa-breadcrumb-item>
<wa-breadcrumb-item>Second</wa-breadcrumb-item>
<wa-breadcrumb-item>Third</wa-breadcrumb-item>
@@ -81,7 +82,7 @@ Use the `separator` slot to change the separator that goes between breadcrumb it
<br />
<wa-breadcrumb>
<wa-icon slot="separator" name="arrow-right" variant="solid"></wa-icon>
<wa-icon name="arrow-right" slot="separator"></wa-icon>
<wa-breadcrumb-item>First</wa-breadcrumb-item>
<wa-breadcrumb-item>Second</wa-breadcrumb-item>
<wa-breadcrumb-item>Third</wa-breadcrumb-item>
@@ -105,7 +106,7 @@ import WaBreadcrumbItem from '@shoelace-style/shoelace/dist/react/breadcrumb-ite
const App = () => (
<>
<WaBreadcrumb>
<wa-icon slot="separator" name="angles-right" variant="solid" />
<wa-icon name="dot" slot="separator" />
<WaBreadcrumbItem>First</WaBreadcrumbItem>
<WaBreadcrumbItem>Second</WaBreadcrumbItem>
<WaBreadcrumbItem>Third</WaBreadcrumbItem>
@@ -114,7 +115,7 @@ const App = () => (
<br />
<WaBreadcrumb>
<wa-icon slot="separator" name="arrow-right" variant="solid" />
<wa-icon name="arrow-right" slot="separator" />
<WaBreadcrumbItem>First</WaBreadcrumbItem>
<WaBreadcrumbItem>Second</WaBreadcrumbItem>
<WaBreadcrumbItem>Third</WaBreadcrumbItem>
@@ -139,7 +140,7 @@ Use the `prefix` slot to add content before any breadcrumb item.
```html:preview
<wa-breadcrumb>
<wa-breadcrumb-item>
<wa-icon slot="prefix" name="house" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="house"></wa-icon>
Home
</wa-breadcrumb-item>
<wa-breadcrumb-item>Articles</wa-breadcrumb-item>
@@ -155,7 +156,7 @@ import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
const App = () => (
<WaBreadcrumb>
<WaBreadcrumbItem>
<WaIcon slot="prefix" name="house" variant="solid" />
<WaIcon slot="prefix" name="house" />
Home
</WaBreadcrumbItem>
<WaBreadcrumbItem>Articles</WaBreadcrumbItem>
@@ -174,7 +175,7 @@ Use the `suffix` slot to add content after any breadcrumb item.
<wa-breadcrumb-item>Policies</wa-breadcrumb-item>
<wa-breadcrumb-item>
Security
<wa-icon slot="suffix" name="shield" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="shield-lock"></wa-icon>
</wa-breadcrumb-item>
</wa-breadcrumb>
```
@@ -190,7 +191,7 @@ const App = () => (
<WaBreadcrumbItem>Policies</WaBreadcrumbItem>
<WaBreadcrumbItem>
Security
<WaIcon slot="suffix" name="shield" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="shield-lock"></WaIcon>
</WaBreadcrumbItem>
</WaBreadcrumb>
);
@@ -208,8 +209,8 @@ Dropdown menus can be placed in a prefix or suffix slot to provide additional op
<wa-breadcrumb-item>
Web Design
<wa-dropdown slot="suffix">
<wa-button slot="trigger" size="small" pill>
<wa-icon label="More options" name="ellipsis" variant="solid"></wa-icon>
<wa-button slot="trigger" size="small" circle>
<wa-icon label="More options" name="three-dots"></wa-icon>
</wa-button>
<wa-menu>
<wa-menu-item type="checkbox" checked>Web Design</wa-menu-item>
@@ -240,8 +241,8 @@ const App = () => (
<WaBreadcrumbItem>
Web Design
<WaDropdown slot="suffix">
<WaButton slot="trigger" size="small" pill>
<WaIcon label="More options" name="ellipsis"></WaIcon>
<WaButton slot="trigger" size="small" circle>
<WaIcon label="More options" name="three-dots"></WaIcon>
</WaButton>
<WaMenu>
<WaMenuItem type="checkbox" checked>

View File

@@ -1,7 +1,8 @@
---
title: Button Group
description: Button groups can be used to group related buttons into sections.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Button Group
description: Button groups can be used to group related buttons into sections.
layout: component
---
```html:preview
@@ -400,34 +401,34 @@ Create interactive toolbars with button groups.
<div class="button-group-toolbar">
<wa-button-group label="History">
<wa-tooltip content="Undo">
<wa-button><wa-icon name="undo" variant="solid" label="Undo"></wa-icon></wa-button>
<wa-button><wa-icon name="arrow-counterclockwise" label="Undo"></wa-icon></wa-button>
</wa-tooltip>
<wa-tooltip content="Redo">
<wa-button><wa-icon name="redo" variant="solid" label="Redo"></wa-icon></wa-button>
<wa-button><wa-icon name="arrow-clockwise" label="Redo"></wa-icon></wa-button>
</wa-tooltip>
</wa-button-group>
<wa-button-group label="Formatting">
<wa-tooltip content="Bold">
<wa-button><wa-icon name="bold" variant="solid" label="Bold"></wa-icon></wa-button>
<wa-button><wa-icon name="type-bold" label="Bold"></wa-icon></wa-button>
</wa-tooltip>
<wa-tooltip content="Italic">
<wa-button><wa-icon name="italic" variant="solid" label="Italic"></wa-icon></wa-button>
<wa-button><wa-icon name="type-italic" label="Italic"></wa-icon></wa-button>
</wa-tooltip>
<wa-tooltip content="Underline">
<wa-button><wa-icon name="underline" variant="solid" label="Underline"></wa-icon></wa-button>
<wa-button><wa-icon name="type-underline" label="Underline"></wa-icon></wa-button>
</wa-tooltip>
</wa-button-group>
<wa-button-group label="Alignment">
<wa-tooltip content="Align Left">
<wa-button><wa-icon name="align-left" variant="solid" label="Align Left"></wa-icon></wa-button>
<wa-button><wa-icon name="justify-left" label="Align Left"></wa-icon></wa-button>
</wa-tooltip>
<wa-tooltip content="Align Center">
<wa-button><wa-icon name="align-center" variant="solid" label="Align Center"></wa-icon></wa-button>
<wa-button><wa-icon name="justify" label="Align Center"></wa-icon></wa-button>
</wa-tooltip>
<wa-tooltip content="Align Right">
<wa-button><wa-icon name="align-right" variant="solid" label="Align Right"></wa-icon></wa-button>
<wa-button><wa-icon name="justify-right" label="Align Right"></wa-icon></wa-button>
</wa-tooltip>
</wa-button-group>
</div>
@@ -457,12 +458,12 @@ const App = () => (
<WaButtonGroup label="History">
<WaTooltip content="Undo">
<WaButton>
<WaIcon name="undo" variant="solid"></WaIcon>
<WaIcon name="arrow-counterclockwise"></WaIcon>
</WaButton>
</WaTooltip>
<WaTooltip content="Redo">
<WaButton>
<WaIcon name="redo" variant="solid"></WaIcon>
<WaIcon name="arrow-clockwise"></WaIcon>
</WaButton>
</WaTooltip>
</WaButtonGroup>
@@ -470,17 +471,17 @@ const App = () => (
<WaButtonGroup label="Formatting">
<WaTooltip content="Bold">
<WaButton>
<WaIcon name="bold" variant="solid"></WaIcon>
<WaIcon name="type-bold"></WaIcon>
</WaButton>
</WaTooltip>
<WaTooltip content="Italic">
<WaButton>
<WaIcon name="italic" variant="solid"></WaIcon>
<WaIcon name="type-italic"></WaIcon>
</WaButton>
</WaTooltip>
<WaTooltip content="Underline">
<WaButton>
<WaIcon name="underline" variant="solid"></WaIcon>
<WaIcon name="type-underline"></WaIcon>
</WaButton>
</WaTooltip>
</WaButtonGroup>
@@ -488,17 +489,17 @@ const App = () => (
<WaButtonGroup label="Alignment">
<WaTooltip content="Align Left">
<WaButton>
<WaIcon name="align-left" variant="solid"></WaIcon>
<WaIcon name="justify-left"></WaIcon>
</WaButton>
</WaTooltip>
<WaTooltip content="Align Center">
<WaButton>
<WaIcon name="align-center" variant="solid"></WaIcon>
<WaIcon name="justify"></WaIcon>
</WaButton>
</WaTooltip>
<WaTooltip content="Align Right">
<WaButton>
<WaIcon name="align-right" variant="solid"></WaIcon>
<WaIcon name="justify-right"></WaIcon>
</WaButton>
</WaTooltip>
</WaButtonGroup>

View File

@@ -1,7 +1,8 @@
---
title: Button
description: Buttons represent actions that are available to the user.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Button
description: Buttons represent actions that are available to the user.
layout: component
---
```html:preview
@@ -200,6 +201,8 @@ As expected, buttons can be given a custom width by setting the `width` attribut
<wa-button size="large" style="width: 100%;">Large</wa-button>
```
{% raw %}
```jsx:react
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -218,60 +221,62 @@ const App = () => (
);
```
{% endraw %}
### Prefix and Suffix Icons
Use the `prefix` and `suffix` slots to add icons.
```html:preview
<wa-button size="small">
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="gear"></wa-icon>
Settings
</wa-button>
<wa-button size="small">
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-counterclockwise"></wa-icon>
Refresh
</wa-button>
<wa-button size="small">
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="link-45deg"></wa-icon>
<wa-icon slot="suffix" name="box-arrow-up-right"></wa-icon>
Open
</wa-button>
<br /><br />
<wa-button>
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="gear"></wa-icon>
Settings
</wa-button>
<wa-button>
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-counterclockwise"></wa-icon>
Refresh
</wa-button>
<wa-button>
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="link-45deg"></wa-icon>
<wa-icon slot="suffix" name="box-arrow-up-right"></wa-icon>
Open
</wa-button>
<br /><br />
<wa-button size="large">
<wa-icon slot="prefix" name="gear" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="gear"></wa-icon>
Settings
</wa-button>
<wa-button size="large">
<wa-icon slot="suffix" name="undo" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-counterclockwise"></wa-icon>
Refresh
</wa-button>
<wa-button size="large">
<wa-icon slot="prefix" name="link" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="arrow-up-right-from-square" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="link-45deg"></wa-icon>
<wa-icon slot="suffix" name="box-arrow-up-right"></wa-icon>
Open
</wa-button>
```
@@ -283,18 +288,18 @@ import WaIcon from '@shoelace-style/shoelace/dist/react/icon';
const App = () => (
<>
<WaButton size="small">
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="gear"></WaIcon>
Settings
</WaButton>
<WaButton size="small">
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-counterclockwise"></WaIcon>
Refresh
</WaButton>
<WaButton size="small">
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="link-45deg"></WaIcon>
<WaIcon slot="suffix" name="box-arrow-up-right"></WaIcon>
Open
</WaButton>
@@ -302,18 +307,18 @@ const App = () => (
<br />
<WaButton>
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="gear"></WaIcon>
Settings
</WaButton>
<WaButton>
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-counterclockwise"></WaIcon>
Refresh
</WaButton>
<WaButton>
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="link-45deg"></WaIcon>
<WaIcon slot="suffix" name="box-arrow-up-right"></WaIcon>
Open
</WaButton>
@@ -321,18 +326,18 @@ const App = () => (
<br />
<WaButton size="large">
<WaIcon slot="prefix" name="gear" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="gear"></WaIcon>
Settings
</WaButton>
<WaButton size="large">
<WaIcon slot="suffix" name="undo" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-counterclockwise"></WaIcon>
Refresh
</WaButton>
<WaButton size="large">
<WaIcon slot="prefix" name="link" variant="solid"></WaIcon>
<WaIcon slot="suffix" name="arrow-up-right-from-square" variant="solid"></WaIcon>
<WaIcon slot="prefix" name="link-45deg"></WaIcon>
<WaIcon slot="suffix" name="box-arrow-up-right"></WaIcon>
Open
</WaButton>
</>
@@ -369,7 +374,7 @@ const App = () => (
### Loading
Use the `loading` attribute to make a button busy. The width will remain the same as before, preventing adjacent elements from moving around.
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
<wa-button variant="brand" loading>Brand</wa-button>
@@ -454,7 +459,7 @@ This example demonstrates how to style buttons using a custom class. This is the
wa-button.pink::part(base) {
border-radius: 6px;
border: solid 2px;
background: #ff1493;
background-color: #ff1493;
border-top-color: #ff7ac1;
border-left-color: #ff7ac1;
border-bottom-color: #ad005c;

View File

@@ -1,7 +1,8 @@
---
title: Card
description: Cards can be used to group related subjects in a container.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Card
description: Cards can be used to group related subjects in a container.
layout: component
---
```html:preview
@@ -132,7 +133,7 @@ Headers can be used to display titles and more.
<wa-card class="card-header">
<div slot="header">
Header Title
<wa-icon-button name="gear" variant="solid" label="Settings"></wa-icon-button>
<wa-icon-button name="gear" label="Settings"></wa-icon-button>
</div>
This card has a header. You can put all sorts of things in it!
@@ -188,7 +189,7 @@ const App = () => (
<WaCard className="card-header">
<div slot="header">
Header Title
<WaIconButton name="gear" variant="solid"></WaIconButton>
<WaIconButton name="gear"></WaIconButton>
</div>
This card has a header. You can put all sorts of things in it!
</WaCard>

View File

@@ -1,7 +1,8 @@
---
title: Carousel Item
description: A carousel item represent a slide within a carousel.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Carousel Item
description: A carousel item represent a slide within a carousel.
layout: component
---
```html:preview

View File

@@ -1,7 +1,8 @@
---
title: Carousel
description: Carousels display an arbitrary number of content slides along a horizontal or vertical axis.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Carousel
description: Carousels display an arbitrary number of content slides along a horizontal or vertical axis.
layout: component
---
```html:preview
@@ -526,6 +527,8 @@ The `slides-per-page` attribute makes it possible to display multiple slides at
</wa-carousel>
```
{% raw %}
```jsx:react
import WaCarousel from '@shoelace-style/shoelace/dist/react/carousel';
import WaCarouselItem from '@shoelace-style/shoelace/dist/react/carousel-item';
@@ -542,6 +545,8 @@ const App = () => (
);
```
{% endraw %}
### Adding and Removing Slides
The content of the carousel can be changed by adding or removing carousel items. The carousel will update itself automatically.
@@ -614,6 +619,8 @@ The content of the carousel can be changed by adding or removing carousel items.
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaCarousel from '@shoelace-style/shoelace/dist/react/carousel';
@@ -673,6 +680,8 @@ const App = () => {
};
```
{% endraw %}
### Vertical Scrolling
Setting the `orientation` attribute to `vertical` will render the carousel in a vertical layout. If the content of your slides vary in height, you will need to set amn explicit `height` or `max-height` on the carousel using CSS.
@@ -850,6 +859,8 @@ Use the `--aspect-ratio` custom property to customize the size of the carousel's
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaCarousel from '@shoelace-style/shoelace/dist/react/carousel';
@@ -915,6 +926,8 @@ const App = () => {
};
```
{% endraw %}
### Scroll Hint
Use the `--scroll-hint` custom property to add inline padding in horizontal carousels and block padding in vertical carousels. This will make the closest slides slightly visible, hinting that there are more items in the carousel.
@@ -954,6 +967,8 @@ Use the `--scroll-hint` custom property to add inline padding in horizontal caro
</wa-carousel>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaCarousel from '@shoelace-style/shoelace/dist/react/carousel';
@@ -999,6 +1014,8 @@ const App = () => (
);
```
{% endraw %}
### Gallery Example
The carousel has a robust API that makes it possible to extend and customize. This example syncs the active slide with a set of thumbnails, effectively creating a gallery-style carousel.

View File

@@ -1,7 +1,8 @@
---
title: Checkbox
description: Checkboxes allow the user to toggle an option on or off.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Checkbox
description: Checkboxes allow the user to toggle an option on or off.
layout: component
---
```html:preview
@@ -88,18 +89,6 @@ const App = () => (
);
```
### Help Text
Add descriptive help text to a switch with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html:preview
<wa-checkbox help-text="What should the user know about the checkbox?">Label</wa-checkbox>
```
````jsx:react
import WaCheckbox from '@shoelace-style/shoelace/dist/react/checkbox';
const App = () => <WaCheckbox help-text="What should the user know about the switch?">Label</WaCheckbox>;
### Custom Validity
Use the `setCustomValidity()` method to set a custom validation message. This will prevent the form from submitting and make the browser display the error message you provide. To clear the error, call this function with an empty string.
@@ -134,7 +123,9 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
});
});
</script>
````
```
{% raw %}
```jsx:react
import { useEffect, useRef } from 'react';
@@ -171,3 +162,5 @@ const App = () => {
);
};
```
{% endraw %}

View File

@@ -1,7 +1,8 @@
---
title: Color Picker
description: Color pickers allow the user to select a color.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Color Picker
description: Color pickers allow the user to select a color.
layout: component
---
```html:preview

View File

@@ -1,7 +1,8 @@
---
title: Copy Button
description: Copies data to the clipboard when the user clicks the button.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Copy Button
description: Copies data to the clipboard when the user clicks the button.
layout: component
---
```html:preview
@@ -50,9 +51,9 @@ Use the `copy-icon`, `success-icon`, and `error-icon` slots to customize the ico
```html:preview
<wa-copy-button value="Copied from a custom button">
<wa-icon slot="copy-icon" name="clipboard" variant="regular"></wa-icon>
<wa-icon slot="success-icon" name="thumbs-up" variant="solid"></wa-icon>
<wa-icon slot="error-icon" name="xmark" variant="solid"></wa-icon>
<wa-icon slot="copy-icon" name="clipboard"></wa-icon>
<wa-icon slot="success-icon" name="clipboard-check"></wa-icon>
<wa-icon slot="error-icon" name="clipboard-x"></wa-icon>
</wa-copy-button>
```
@@ -63,9 +64,9 @@ import { WaIcon } from '@shoelace-style/shoelace/dist/react/icon';
const App = () => (
<>
<WaCopyButton value="Copied from a custom button">
<WaIcon slot="copy-icon" name="clipboard" variant="regular" />
<WaIcon slot="success-icon" name="check" variant="solid" />
<WaIcon slot="error-icon" name="xmark" variant="solid" />
<WaIcon slot="copy-icon" name="clipboard" />
<WaIcon slot="success-icon" name="clipboard-check" />
<WaIcon slot="error-icon" name="clipboard-x" />
</WaCopyButton>
</>
);
@@ -178,9 +179,9 @@ You can customize the button to your liking with CSS.
```html:preview
<wa-copy-button value="I'm so stylish" class="custom-styles">
<wa-icon slot="copy-icon" name="clipboard"></wa-icon>
<wa-icon slot="success-icon" name="thumbs-up"></wa-icon>
<wa-icon slot="error-icon" name="thumbs-down"></wa-icon>
<wa-icon slot="copy-icon" name="asterisk"></wa-icon>
<wa-icon slot="success-icon" name="check-lg"></wa-icon>
<wa-icon slot="error-icon" name="x-lg"></wa-icon>
</wa-copy-button>
<style>

View File

@@ -1,7 +1,8 @@
---
title: Details
description: Details show a brief summary and expand to show additional content.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Details
description: Details show a brief summary and expand to show additional content.
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->
@@ -54,8 +55,8 @@ Use the `expand-icon` and `collapse-icon` slots to change the expand and collaps
```html:preview
<wa-details summary="Toggle Me" class="custom-icons">
<wa-icon name="square-plus" slot="expand-icon" variant="regular"></wa-icon>
<wa-icon name="square-minus" slot="collapse-icon" variant="regular"></wa-icon>
<wa-icon name="plus-square" slot="expand-icon"></wa-icon>
<wa-icon name="dash-square" slot="collapse-icon"></wa-icon>
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.
@@ -83,8 +84,8 @@ const css = `
const App = () => (
<>
<WaDetails summary="Toggle Me" class="custom-icon">
<WaIcon name="square-plus" slot="expand-icon" />
<WaIcon name="square-minus" slot="collapse-icon" />
<WaIcon name="plus-square" slot="expand-icon" />
<WaIcon name="dash-square" slot="collapse-icon" />
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.
@@ -121,9 +122,9 @@ Details are designed to function independently, but you can simulate a group or
const container = document.querySelector('.details-group-example');
// Close all other details when one is shown
container.addEventListener('wa-show', event => {
if (event.target.localName === 'wa-details') {
[...container.querySelectorAll('wa-details')].map(details => (details.open = event.target === details));
container.addEventListener('sl-show', event => {
if (event.target.localName === 'sl-details') {
[...container.querySelectorAll('sl-details')].map(details => (details.open = event.target === details));
}
});
</script>

View File

@@ -1,7 +1,8 @@
---
title: Dialog
description: 'Dialogs, sometimes called "modals", appear above the page and require the user''s immediate attention.'
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Dialog
description: 'Dialogs, sometimes called "modals", appear above the page and require the user''s immediate attention.'
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->
@@ -71,6 +72,8 @@ Use the `--width` custom property to set the dialog's width.
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -94,13 +97,15 @@ const App = () => {
};
```
{% endraw %}
### Scrolling
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
<wa-dialog label="Dialog" class="dialog-scrolling">
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-border); padding: 0 1rem;">
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-outline); padding: 0 1rem;">
<p>Scroll down and give it a try! 👇</p>
</div>
<wa-button slot="footer" variant="brand">Close</wa-button>
@@ -118,6 +123,8 @@ By design, a dialog's height will never exceed that of the viewport. As such, di
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -132,7 +139,7 @@ const App = () => {
<div
style={{
height: '150vh',
border: 'dashed 2px var(--wa-color-surface-border)',
border: 'dashed 2px var(--wa-color-surface-outline)',
padding: '0 1rem'
}}
>
@@ -150,13 +157,15 @@ const App = () => {
};
```
{% endraw %}
### Header Actions
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
<wa-dialog label="Dialog" class="dialog-header-actions">
<wa-icon-button class="new-window" slot="header-actions" name="arrow-up-right-from-square" variant="solid"></wa-icon-button>
<wa-icon-button class="new-window" slot="header-actions" name="box-arrow-up-right"></wa-icon-button>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<wa-button slot="footer" variant="brand">Close</wa-button>
</wa-dialog>
@@ -190,7 +199,7 @@ const App = () => {
<WaIconButton
class="new-window"
slot="header-actions"
name="arrow-up-right-from-square"
name="box-arrow-up-right"
onClick={() => window.open(location.href)}
/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

View File

@@ -1,7 +1,8 @@
---
title: Divider
description: Dividers are used to visually separate or group elements.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Divider
description: Dividers are used to visually separate or group elements.
layout: component
---
```html:preview
@@ -24,12 +25,16 @@ Use the `--width` custom property to change the width of the divider.
<wa-divider style="--width: 4px;"></wa-divider>
```
{% raw %}
```jsx:react
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
const App = () => <WaDivider style={{ '--width': '4px' }} />;
```
{% endraw %}
### Color
Use the `--color` custom property to change the color of the divider.
@@ -38,12 +43,16 @@ Use the `--color` custom property to change the color of the divider.
<wa-divider style="--color: tomato;"></wa-divider>
```
{% raw %}
```jsx:react
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
const App = () => <WaDivider style={{ '--color': 'tomato' }} />;
```
{% endraw %}
### Spacing
Use the `--spacing` custom property to change the amount of space between the divider and it's neighboring elements.
@@ -56,6 +65,22 @@ Use the `--spacing` custom property to change the amount of space between the di
</div>
```
{% raw %}
```jsx:react
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
const App = () => (
<>
Above
<WaDivider style={{ '--spacing': '2rem' }} />
Below
</>
);
```
{% endraw %}
### Vertical
Add the `vertical` attribute to draw the divider in a vertical orientation. The divider will span the full height of its container. Vertical dividers work especially well inside of a flex container.
@@ -70,6 +95,8 @@ Add the `vertical` attribute to draw the divider in a vertical orientation. The
</div>
```
{% raw %}
```jsx:react
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
@@ -90,6 +117,8 @@ const App = () => (
);
```
{% endraw %}
### Menu Dividers
Use dividers in [menus](/components/menu) to visually group menu items.
@@ -106,6 +135,8 @@ Use dividers in [menus](/components/menu) to visually group menu items.
</wa-menu>
```
{% raw %}
```jsx:react
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
@@ -123,3 +154,5 @@ const App = () => (
</WaMenu>
);
```
{% endraw %}

View File

@@ -1,7 +1,8 @@
---
title: Drawer
description: Drawers slide in from a container to expose additional options and information.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Drawer
description: Drawers slide in from a container to expose additional options and information.
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->
@@ -192,7 +193,7 @@ Unlike normal drawers, contained drawers are not modal. This means they do not s
```html:preview
<div
style="position: relative; border: solid 2px var(--wa-color-surface-border); height: 300px; padding: 1rem; margin-bottom: 1rem;"
style="position: relative; border: solid 2px var(--wa-color-surface-outline); 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.
@@ -214,6 +215,8 @@ Unlike normal drawers, contained drawers are not modal. This means they do not s
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -227,7 +230,7 @@ const App = () => {
<div
style={{
position: 'relative',
border: 'solid 2px var(--wa-color-surface-border)',
border: 'solid 2px var(--wa-color-surface-outline)',
height: '300px',
padding: '1rem',
marginBottom: '1rem'
@@ -256,6 +259,8 @@ const App = () => {
};
```
{% endraw %}
### Custom Size
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`.
@@ -278,6 +283,8 @@ Use the `--size` custom property to set the drawer's size. This will be applied
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -301,13 +308,15 @@ const App = () => {
};
```
{% endraw %}
### Scrolling
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
<wa-drawer label="Drawer" class="drawer-scrolling">
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-border); padding: 0 1rem;">
<div style="height: 150vh; border: dashed 2px var(--wa-color-surface-outline); padding: 0 1rem;">
<p>Scroll down and give it a try! 👇</p>
</div>
<wa-button slot="footer" variant="brand">Close</wa-button>
@@ -325,6 +334,8 @@ By design, a drawer's height will never exceed 100% of its container. As such, d
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -339,7 +350,7 @@ const App = () => {
<div
style={{
height: '150vh',
border: 'dashed 2px var(--wa-color-surface-border)',
border: 'dashed 2px var(--wa-color-surface-outline)',
padding: '0 1rem'
}}
>
@@ -356,13 +367,15 @@ const App = () => {
};
```
{% endraw %}
### Header Actions
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
<wa-drawer label="Drawer" class="drawer-header-actions">
<wa-icon-button class="new-window" slot="header-actions" name="arrow-up-right-from-square" variant="solid"></wa-icon-button>
<wa-icon-button class="new-window" slot="header-actions" name="box-arrow-up-right"></wa-icon-button>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<wa-button slot="footer" variant="brand">Close</wa-button>
</wa-drawer>
@@ -393,7 +406,7 @@ const App = () => {
return (
<>
<WaDrawer label="Drawer" open={open} onWaAfterHide={() => setOpen(false)}>
<WaIconButton slot="header-actions" name="arrow-up-right-from-square" onClick={() => window.open(location.href)} />
<WaIconButton slot="header-actions" name="box-arrow-up-right" onClick={() => window.open(location.href)} />
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<WaButton slot="footer" variant="brand" onClick={() => setOpen(false)}>
Close

View File

@@ -1,7 +1,8 @@
---
title: Dropdown
description: 'Dropdowns expose additional content that "drops down" in a panel.'
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Dropdown
description: 'Dropdowns expose additional content that "drops down" in a panel.'
layout: component
---
Dropdowns consist of a trigger and a panel. By default, activating the trigger will expose the panel and interacting outside of the panel will close it.
@@ -21,11 +22,11 @@ Dropdowns are designed to work well with [menus](/components/menu) to provide a
<wa-divider></wa-divider>
<wa-menu-item>
Prefix
<wa-icon slot="prefix" name="gift" variant="solid"></wa-icon>
<wa-icon slot="prefix" name="gift"></wa-icon>
</wa-menu-item>
<wa-menu-item>
Suffix Icon
<wa-icon slot="suffix" name="heart" variant="solid"></wa-icon>
<wa-icon slot="suffix" name="heart"></wa-icon>
</wa-menu-item>
</wa-menu>
</wa-dropdown>
@@ -354,7 +355,7 @@ import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
const css = `
.dropdown-hoist {
border: solid 2px var(--wa-color-surface-border);
border: solid 2px var(--wa-color-surface-outline);
padding: var(--wa-space-m);
overflow: hidden;
}
@@ -395,7 +396,7 @@ const App = () => (
);
```
:::caution
:::warning
As a UX best practice, avoid using more than one level of submenu when possible.
:::
@@ -427,7 +428,7 @@ Dropdown panels will be clipped if they're inside a container that has `overflow
<style>
.dropdown-hoist {
position: relative;
border: solid 2px var(--wa-color-surface-border);
border: solid 2px var(--wa-color-surface-outline);
padding: var(--wa-space-m);
overflow: hidden;
}
@@ -443,7 +444,7 @@ import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';
const css = `
.dropdown-hoist {
border: solid 2px var(--wa-color-surface-border);
border: solid 2px var(--wa-color-surface-outline);
padding: var(--wa-space-m);
overflow: hidden;
}

View File

@@ -1,7 +1,8 @@
---
title: Format Bytes
description: Formats a number as a human readable bytes value.
layout: ../../../layouts/ComponentLayout.astro
meta:
title: Format Bytes
description: Formats a number as a human readable bytes value.
layout: component
---
```html:preview
@@ -19,6 +20,8 @@ layout: ../../../layouts/ComponentLayout.astro
</script>
```
{% raw %}
```jsx:react
import { useState } from 'react';
import WaButton from '@shoelace-style/shoelace/dist/react/button';
@@ -45,6 +48,8 @@ const App = () => {
};
```
{% endraw %}
## Examples
### Formatting Bytes

Some files were not shown because too many files have changed in this diff Show More