Compare commits

..

3 Commits

Author SHA1 Message Date
Lea Verou
4a7fd7964f Update callout.css 2024-12-11 17:35:01 -05:00
Lea Verou
5a683300b2 Convert viewport-demo and callout styles 2024-12-11 16:56:49 -05:00
Lea Verou
20321f84d9 Start integrating esbuild-plugin-lit-css 2024-12-11 16:56:01 -05:00
502 changed files with 15156 additions and 12075 deletions

10
.eslintignore Normal file
View File

@@ -0,0 +1,10 @@
.cache
docs/dist
docs/search.json
docs/**/*.min.js
dist
examples
node_modules
src/react
scripts

213
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,213 @@
/* eslint-env node */
module.exports = {
plugins: [
'@typescript-eslint',
'wc',
'lit',
'lit-a11y',
'chai-expect',
'chai-friendly',
'import',
'sort-imports-es6-autofix'
],
extends: [
'eslint:recommended',
'plugin:wc/recommended',
'plugin:wc/best-practice',
'plugin:lit/recommended',
'plugin:lit-a11y/recommended'
],
env: {
es2021: true,
browser: true
},
parserOptions: {
sourceType: 'module'
},
overrides: [
{
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname
},
files: ['*.ts'],
rules: {
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'no-console': 'warn',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'warn',
'no-implied-eval': 'off',
'no-invalid-this': 'off',
'no-shadow': 'off',
'no-throw-literal': 'off',
'no-unused-expressions': 'off',
'lit-a11y/no-autofocus': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false
}
],
'@typescript-eslint/consistent-type-assertions': [
'warn',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never'
}
],
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/unified-signatures': 'warn',
'@typescript-eslint/array-type': 'warn',
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
'@typescript-eslint/member-delimiter-style': 'warn',
'@typescript-eslint/method-signature-style': 'warn',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/strict-boolean-expressions': 'off'
}
},
{
files: ['**/*.cjs'],
env: {
node: true
}
},
{
extends: ['plugin:chai-expect/recommended', 'plugin:chai-friendly/recommended'],
files: ['*.test.ts'],
rules: {
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unused-expressions': 'off'
}
}
],
rules: {
'no-template-curly-in-string': 'error',
'array-callback-return': 'error',
'comma-dangle': 'off',
'consistent-return': 'error',
curly: 'off',
'default-param-last': 'error',
eqeqeq: 'error',
'lit-a11y/click-events-have-key-events': 'off',
'no-constructor-return': 'error',
'no-empty-function': 'warn',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-floating-decimal': 'error',
'no-implicit-coercion': 'off',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'off',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-return-assign': 'warn',
'no-script-url': 'error',
'no-self-compare': 'warn',
'no-sequences': 'warn',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'error',
'no-unused-expressions': 'warn',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-return': 'warn',
'prefer-promise-reject-errors': 'error',
radix: 'off',
'require-await': 'error',
'wrap-iife': ['warn', 'inside'],
'no-shadow': 'error',
'no-array-constructor': 'error',
'no-bitwise': 'error',
'no-multi-assign': 'warn',
'no-new-object': 'error',
'no-useless-computed-key': 'warn',
'no-useless-rename': 'warn',
'no-var': 'error',
'prefer-const': 'warn',
'prefer-numeric-literals': 'warn',
'prefer-object-spread': 'warn',
'prefer-rest-params': 'warn',
'prefer-spread': 'warn',
'prefer-template': 'off',
'no-else-return': 'off',
'func-names': ['warn', 'never'],
'one-var': ['warn', 'never'],
'operator-assignment': 'warn',
'prefer-arrow-callback': 'warn',
'no-restricted-imports': [
'warn',
{
paths: [
{
name: '.',
message: 'Usage of local index imports is not allowed.'
},
{
name: './index',
message: 'Import from the source file instead.'
}
]
}
],
'import/extensions': [
'error',
'always',
{
ignorePackages: true,
pattern: {
js: 'always',
ts: 'never'
}
}
],
'import/no-duplicates': 'warn',
'sort-imports-es6-autofix/sort-imports-es6': [
2,
{
ignoreCase: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
}
],
'wc/guard-super-call': 'off'
}
};

View File

@@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run prettier
run: npm run prettier && npm run lint
- name: Build
run: npm run build
- name: Install Playwright

View File

@@ -27,7 +27,7 @@ jobs:
run: npm ci
# Just lint here too. Save some GH Action minutes and not need to use "depends_on" or anything.
- name: Lint
run: npm run prettier
run: npm run prettier && npm run lint
- name: Build
run: npm run build

View File

@@ -3,6 +3,7 @@
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bierner.lit-html",
"bashmish.es6-string-css",
"streetsidesoftware.code-spell-checker"
]
}

View File

@@ -39,7 +39,6 @@
"crutchcorn",
"csspart",
"cssproperty",
"cssstate",
"datetime",
"describedby",
"Docsify",
@@ -47,7 +46,6 @@
"dropdowns",
"easings",
"ecommerce",
"endfor",
"endraw",
"endregion",
"enterkeyhint",
@@ -105,7 +103,6 @@
"metaframeworks",
"middlewares",
"minlength",
"minmax",
"monospace",
"mousedown",
"mousemove",
@@ -158,19 +155,16 @@
"smartquotes",
"spacebar",
"stylesheet",
"svgs",
"Tabbable",
"tabindex",
"tabler",
"tablist",
"tabpanel",
"tbody",
"templating",
"tera",
"testid",
"textareas",
"textfield",
"thead",
"Themer",
"tinycolor",
"transitionend",

View File

@@ -2,8 +2,8 @@ import { customElementJetBrainsPlugin } from 'custom-element-jet-brains-integrat
import { customElementVsCodePlugin } from 'custom-element-vs-code-integration';
// import { customElementVuejsPlugin } from 'custom-element-vuejs-integration';
import { parse } from 'comment-parser';
import fs from 'fs';
import { pascalCase } from 'pascal-case';
import fs from 'fs';
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const { name, description, version, author, homepage, license } = packageData;
@@ -28,7 +28,7 @@ export default {
name: 'wa-package-data',
packageLinkPhase({ customElementsManifest }) {
customElementsManifest.package = { name, description, version, author, homepage, license };
},
}
},
// Parse custom jsDoc tags
@@ -83,13 +83,13 @@ export default {
classDoc[t.tag].push({
name: t.name,
description: t.description,
type: t.type || undefined,
type: t.type || undefined
});
}
});
}
}
},
}
},
{
@@ -109,7 +109,7 @@ export default {
}
}
}
},
}
},
{
@@ -127,7 +127,7 @@ export default {
//
const terms = [
{ from: /^src\//, to: '' }, // Strip the src/ prefix
{ from: /\.(t|j)sx?$/, to: '.js' }, // Convert .ts to .js
{ from: /\.(t|j)sx?$/, to: '.js' } // Convert .ts to .js
];
mod.path = replace(mod.path, terms);
@@ -146,7 +146,7 @@ export default {
}
}
});
},
}
},
// Generate custom VS Code data
@@ -156,9 +156,9 @@ export default {
referencesTemplate: (_, tag) => [
{
name: 'Documentation',
url: `https://webawesome.com/docs/components/${tag.replace('wa-', '')}`,
},
],
url: `https://webawesome.com/docs/components/${tag.replace('wa-', '')}`
}
]
}),
customElementJetBrainsPlugin({
@@ -168,10 +168,10 @@ export default {
referencesTemplate: (_, tag) => {
return {
name: 'Documentation',
url: `https://webawesome.com/docs/components/${tag.replace('wa-', '')}`,
url: `https://webawesome.com/docs/components/${tag.replace('wa-', '')}`
};
},
}),
}
})
//
// TODO - figure out why this broke when events were updated
@@ -181,5 +181,5 @@ export default {
// fileName: 'index.d.ts',
// componentTypePath: (_, tag) => `../../components/${tag.replace('wa-', '')}/${tag.replace('wa-', '')}.js`
// })
],
]
};

View File

@@ -1,24 +1,24 @@
import { parse } from 'path';
import { markdown } from './_utils/markdown.js';
import { anchorHeadingsPlugin } from './_utils/anchor-headings.js';
import { codeExamplesPlugin } from './_utils/code-examples.js';
import { copyCodePlugin } from './_utils/copy-code.js';
import { removeDataAlphaElements } from './_utils/remove-data-alpha-elements.js';
import { currentLink } from './_utils/current-link.js';
import { highlightCodePlugin } from './_utils/highlight-code.js';
import { markdown } from './_utils/markdown.js';
import { removeDataAlphaElements } from './_utils/remove-data-alpha-elements.js';
// import { formatCodePlugin } from './_utils/format-code.js';
import litPlugin from '@lit-labs/eleventy-plugin-lit';
import { readFile } from 'fs/promises';
import componentList from './_data/componentList.js';
import * as filters from './_utils/filters.js';
import { outlinePlugin } from './_utils/outline.js';
import { replaceTextPlugin } from './_utils/replace-text.js';
import { searchPlugin } from './_utils/search.js';
import { readFile } from 'fs/promises';
import { outlinePlugin } from './_utils/outline.js';
import componentList from './_data/componentList.js';
import litPlugin from '@lit-labs/eleventy-plugin-lit';
import process from 'process';
const packageData = JSON.parse(await readFile('./package.json', 'utf-8'));
const isAlpha = process.argv.includes('--alpha');
const isDev = process.argv.includes('--develop');
// const isDeveloping = process.argv.includes('--develop');
export default function (eleventyConfig) {
// NOTE - alpha setting removes certain pages
@@ -38,19 +38,14 @@ export default function (eleventyConfig) {
// Template filters - {{ content | filter }}
eleventyConfig.addFilter('inlineMarkdown', content => markdown.renderInline(content || ''));
eleventyConfig.addFilter('markdown', content => markdown.render(content || ''));
for (let name in filters) {
eleventyConfig.addFilter(name, filters[name]);
}
eleventyConfig.addFilter('sort', (arr, key = 'data.title') => {
key = key.split('.');
return arr.sort((a, b) => {
let aVal = key.reduce((obj, i) => obj?.[i], a);
let bVal = key.reduce((obj, i) => obj?.[i], b);
return aVal.localeCompare(bVal);
});
eleventyConfig.addFilter('stripExtension', string => parse(string).name);
eleventyConfig.addFilter('stripPrefix', content => content.replace(/^wa-/, ''));
eleventyConfig.addFilter('trimPipes', content => {
// Trims whitespace and pipes from the start and end of a string. Useful for CEM types, which can be pipe-delimited.
// With Prettier 3, this means a leading pipe will exist be present when the line wraps.
return typeof content === 'string' ? content.replace(/^(\s|\|)/g, '').replace(/(\s|\|)$/g, '') : content;
});
eleventyConfig.addFilter('keys', obj => Object.keys(obj));
// Shortcodes - {% shortCode arg1, arg2 %}
eleventyConfig.addShortcode('cdnUrl', location => {
@@ -76,8 +71,8 @@ export default function (eleventyConfig) {
selector: 'h2, h3',
ifEmpty: doc => {
doc.querySelector('#outline')?.remove();
},
}),
}
})
);
// Add current link classes
@@ -98,58 +93,54 @@ export default function (eleventyConfig) {
// Replace [issue:1234] with a link to the issue on GitHub
{
replace: /\[pr:([0-9]+)\]/gs,
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/pull/$1">#$1</a>',
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/pull/$1">#$1</a>'
},
// Replace [pr:1234] with a link to the pull request on GitHub
{
replace: /\[issue:([0-9]+)\]/gs,
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/issues/$1">#$1</a>',
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/issues/$1">#$1</a>'
},
// Replace [discuss:1234] with a link to the discussion on GitHub
{
replace: /\[discuss:([0-9]+)\]/gs,
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/discussions/$1">#$1</a>',
},
]),
replaceWith: '<a href="https://github.com/shoelace-style/webawesome/discussions/$1">#$1</a>'
}
])
);
// SSR plugin
if (!isDev) {
//
// Problematic components in SSR land:
// - animation (breaks on navigation + ssr with Turbo)
// - mutation-observer (why SSR this?)
// - resize-observer (why SSR this?)
// - tooltip (why SSR this?)
//
const omittedModules = [];
const componentModules = componentList
.filter(component => !omittedModules.includes(component.tagName.split(/wa-/)[1]))
.map(component => {
const name = component.tagName.split(/wa-/)[1];
return `./dist/components/${name}/${name}.js`;
});
const omittedModules = [];
eleventyConfig.addPlugin(litPlugin, {
mode: 'worker',
componentModules,
// problematic components:
// animation (breaks on navigation + ssr with Turbo)
// mutation-observer (why SSR this?)
// resize-observer (why SSR this?)
// tooltip (why SSR this?)
const componentModules = componentList
// .filter(component => !omittedModules.includes(component.tagName.split(/wa-/)[1]))
.map(component => {
const name = component.tagName.split(/wa-/)[1];
return `./dist/components/${name}/${name}.js`;
});
}
eleventyConfig.addPlugin(litPlugin, {
mode: 'worker',
componentModules
});
// Build the search index
eleventyConfig.addPlugin(
searchPlugin({
filename: '',
selectorsToIgnore: ['code.example'],
getContent: doc => doc.querySelector('#content')?.textContent ?? '',
}),
getContent: doc => doc.querySelector('#content')?.textContent ?? ''
})
);
// Production-only plugins
//
// TODO - disabled because it takes about a minute to run now
//
// if (!isDev) {
// if (!isDeveloping) {
// // Run Prettier on each file (prod only because it can be slow)
// eleventyConfig.addPlugin(formatCodePlugin());
// }
@@ -158,8 +149,8 @@ export default function (eleventyConfig) {
markdownTemplateEngine: 'njk',
dir: {
includes: '_includes',
layouts: '_layouts',
layouts: '_layouts'
},
templateFormats: ['njk', 'md'],
templateFormats: ['njk', 'md']
};
}

View File

@@ -1,9 +1,9 @@
/**
* @module components Fetches components from custom-elements.json and exposes them in a saner format.
*/
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { readFileSync } from 'fs';
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -36,7 +36,7 @@ const components = manifest.modules.flatMap(module => {
slug: declaration.tagName.replace(/^wa-/, ''),
methods,
attributes,
properties,
properties
};
});
});

View File

@@ -6,7 +6,7 @@ const by = {
event: {},
method: {},
cssPart: {},
cssProperty: {},
cssProperty: {}
};
function getAll(component, type) {

View File

@@ -22,10 +22,10 @@
{# Web Awesome #}
<script type="module" src="/dist/webawesome.loader.js"></script>
<link rel="stylesheet" id="theme-stylesheet" href="/dist/styles/themes/default.css" />
<link rel="stylesheet" href="/dist/styles/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/styles/color/standard.css" />
<link rel="stylesheet" href="/dist/styles/forms.css" />
<link rel="stylesheet" id="theme-stylesheet" href="/dist/themes/default.css" />
<link rel="stylesheet" href="/dist/themes/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/themes/color_standard.css" />
<link rel="stylesheet" href="/dist/themes/forms.css" />
{# Docs styles #}
<link rel="stylesheet" href="/assets/styles/docs.css" />
@@ -43,7 +43,7 @@
<wa-page>
<header slot="header">
{# Nav toggle #}
<wa-button appearance="plain" data-toggle-nav>
<wa-button variant="text" data-toggle-nav>
<wa-icon name="bars" label="Toggle navigation"></wa-icon>
</wa-button>

View File

@@ -31,10 +31,11 @@
{# Web Awesome #}
<script type="module" src="/dist/webawesome.ssr-loader.js"></script>
<link rel="stylesheet" id="theme-stylesheet" href="/dist/styles/themes/default.css" />
<link rel="stylesheet" href="/dist/styles/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/styles/utilities.css" />
<link rel="stylesheet" href="/dist/styles/forms.css" />
<link rel="stylesheet" id="theme-stylesheet" href="/dist/themes/default.css" />
<link rel="stylesheet" href="/dist/themes/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/themes/layout.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/themes/utilities.css" />
<link rel="stylesheet" href="/dist/themes/forms.css" />
{# Docs styles #}
<link rel="stylesheet" href="/assets/styles/docs.css" />
@@ -62,7 +63,7 @@
const newStylesheet = document.createElement("link")
let preset = getPresetTheme()
newStylesheet.href = `/dist/styles/themes/${preset}.css`
newStylesheet.href = `/dist/themes/${preset}.css`
newStylesheet.rel = "preload"
newStylesheet.as = "style"
@@ -89,7 +90,7 @@
{# Logo #}
<div id="docs-branding">
{# Nav toggle #}
<wa-button appearance="plain" size="small" data-toggle-nav>
<wa-button appearance="text" size="small" data-toggle-nav>
<wa-icon name="bars" label="Toggle navigation"></wa-icon>
</wa-button>
@@ -98,7 +99,7 @@
<span class="only-mobile">{% include "logo-simple.njk" %}</span>
</a>
<small id="version-number" class="only-desktop">{{ package.version }}</small>
<wa-badge variant="warning" appearance="filled" class="only-desktop">Alpha</wa-badge>
<wa-badge variant="warning" class="only-desktop">Alpha</wa-badge>
</div>
<div id="docs-toolbar">
@@ -149,17 +150,6 @@
</details>
</nav>
{% set breadcrumbs = page.url | breadcrumbs %}
{% if breadcrumbs.length > 0 %}
<wa-breadcrumb id="docs-breadcrumbs">
{% for crumb in breadcrumbs %}
<wa-breadcrumb-item href="{{ crumb.url }}">{{ crumb.title }}</wa-breadcrumb-item>
{% endfor %}
<wa-breadcrumb-item>{# Current page #}</wa-breadcrumb-item>
</wa-breadcrumb>
{% else %}
{% endif %}
{% block beforeContent %}{% endblock %}
{% block content %}

View File

@@ -1,6 +1,6 @@
{# Color scheme selector #}
<wa-dropdown id="color-scheme-selector">
<wa-button slot="trigger" appearance="filled" size="small" pill caret title="Press \ to toggle">
<wa-button slot="trigger" appearance="tinted" size="small" pill caret title="Press \ to toggle">
<wa-icon class="only-light" slot="prefix" name="sun" variant="regular"></wa-icon>
<wa-icon class="only-dark" slot="prefix" name="moon" variant="regular"></wa-icon>
<span class="only-light">Light</span>

View File

@@ -16,11 +16,7 @@
</div>
</fieldset>
<wa-viewport-demo viewport="1000">
<iframe srcdoc="" id="page_slots_iframe"></iframe>
<iframe srcdoc="" id="page_slots_iframe" data-turbo="false" data-turbo-temporary></iframe>
</wa-viewport-demo>
</div>
<script type="module">
const cacheBust = new Date().toString()
import(`/assets/examples/page-demo/demo.js?${cacheBust}`)
</script>
<script type=module src="/assets/examples/page-demo/demo.js"></script>

View File

@@ -1,6 +1,6 @@
{# Preset theme selector #}
<wa-dropdown id="preset-theme-selector">
<wa-button slot="trigger" appearance="filled" size="small" pill caret>
<wa-button slot="trigger" appearance="tinted" size="small" pill caret>
<wa-icon slot="prefix" name="paintbrush" variant="regular"></wa-icon>
<span id="preset-theme-selector__text">Default</span>
</wa-button>

View File

@@ -6,7 +6,7 @@
<wa-input
id="site-search-input"
type="search"
appearance="filled"
filled
size="large"
clearable
placeholder="Search"

View File

@@ -20,50 +20,216 @@
</ul>
{# Components #}
<wa-details{{ ' open' if '/components/' in page.url }}>
<h2 slot=summary>
<a href="/docs/components/" title="Overview">Components
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for component in collections.component | sort %}
{% if not component.data.parent and not (isAlpha and component.data.isAlpha) %}
<li>
<a href="/docs/components/{{ component.fileSlug }}">{{ component.data.title }}</a>
{% if components[component.fileSlug].status == 'experimental' %}<wa-icon name="flask"></wa-icon>{% endif %}
{% if component.data.isPro %}<wa-badge class="pro">PRO</wa-badge>{% endif %}
<ul>
{% for child in collections.component | sort %}
{% if child.data.parent == component.fileSlug and not (isAlpha and child.data.isAlpha) %}
<li>
<a href="/docs/components/{{ child.fileSlug }}">{{ child.data.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</wa-details>
<wa-details{{ ' open' if '/natives/' in page.url }}>
<h2 slot=summary>
<a href="/docs/natives/" title="Overview">Natives
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for page in collections.natives | sort %}
<li>
<a href="/docs/natives/{{ page.fileSlug }}">{{ page.data.title }}</a>
</li>
{% endfor %}
</ul>
</wa-details>
<h2>
<a href="/docs/components/" title="Overview">Components
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
<li>
<a href="/docs/components/animated-image">Animated Image</a>
</li>
<li>
<a href="/docs/components/animation">Animation</a>
</li>
<li>
<a href="/docs/components/avatar">Avatar</a>
</li>
<li>
<a href="/docs/components/badge">Badge</a>
</li>
<li>
<a href="/docs/components/breadcrumb">Breadcrumb</a>
<ul>
<li>
<a href="/docs/components/breadcrumb-item">Breadcrumb Item</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/button">Button</a>
</li>
<li>
<a href="/docs/components/button-group">Button Group</a>
</li>
<li>
<a href="/docs/components/callout">Callout</a>
</li>
<li>
<a href="/docs/components/card">Card</a>
</li>
<li>
<a href="/docs/components/carousel">Carousel</a>
<ul>
<li>
<a href="/docs/components/carousel-item">Carousel Item</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/checkbox">Checkbox</a>
</li>
{% if not isAlpha %}
<li>
<a href="/docs/components/code-demo">Code Demo</a>
</li>
{% endif %}
<li>
<a href="/docs/components/color-picker">Color Picker</a>
</li>
<li>
<a href="/docs/components/copy-button">Copy Button</a>
</li>
<li>
<a href="/docs/components/details">Details</a>
</li>
<li>
<a href="/docs/components/dialog">Dialog</a>
</li>
<li>
<a href="/docs/components/divider">Divider</a>
</li>
<li>
<a href="/docs/components/drawer">Drawer</a>
</li>
<li>
<a href="/docs/components/dropdown">Dropdown</a>
</li>
<li>
<a href="/docs/components/format-bytes">Format Bytes</a>
</li>
<li>
<a href="/docs/components/format-date">Format Date</a>
</li>
<li>
<a href="/docs/components/format-number">Format Number</a>
</li>
<li>
<a href="/docs/components/icon">Icon</a>
</li>
<li>
<a href="/docs/components/icon-button">Icon Button</a>
</li>
<li>
<a href="/docs/components/image-comparer">Image Comparer</a>
</li>
<li>
<a href="/docs/components/include">Include</a>
</li>
<li>
<a href="/docs/components/input">Input</a>
</li>
<li>
<a href="/docs/components/menu">Menu</a>
<ul>
<li>
<a href="/docs/components/menu-item">Menu Item</a>
</li>
<li>
<a href="/docs/components/menu-label">Menu Label</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/mutation-observer">Mutation Observer</a>
</li>
<li>
<a href="/docs/components/page">Page</a>
<wa-icon name="flask"></wa-icon>
<wa-badge class="pro">PRO</wa-badge>
</li>
<li>
<a href="/docs/components/popup">Popup</a>
</li>
<li>
<a href="/docs/components/progress-bar">Progress Bar</a>
</li>
<li>
<a href="/docs/components/progress-ring">Progress Ring</a>
</li>
<li>
<a href="/docs/components/qr-code">QR Code</a>
</li>
<li>
<a href="/docs/components/radio-group">Radio Group</a>
<ul>
<li>
<a href="/docs/components/radio">Radio</a>
</li>
<li>
<a href="/docs/components/radio-button">Radio Button</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/range">Range</a>
</li>
<li>
<a href="/docs/components/rating">Rating</a>
</li>
<li>
<a href="/docs/components/relative-time">Relative Time</a>
</li>
<li>
<a href="/docs/components/resize-observer">Resize Observer</a>
</li>
<li>
<a href="/docs/components/select">Select</a>
<ul>
<li>
<a href="/docs/components/option">Option</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/skeleton">Skeleton</a>
</li>
<li>
<a href="/docs/components/spinner">Spinner</a>
</li>
<li>
<a href="/docs/components/split-panel">Split Panel</a>
</li>
<li>
<a href="/docs/components/switch">Switch</a>
</li>
<li>
<a href="/docs/components/tab-group">Tab Group</a>
<ul>
<li>
<a href="/docs/components/tab">Tab</a>
</li>
<li>
<a href="/docs/components/tab-panel">Tab Panel</a>
</li>
</ul>
</li>
<li>
<a href="/docs/components/tag">Tag</a>
</li>
<li>
<a href="/docs/components/textarea">Textarea</a>
</li>
<li>
<a href="/docs/components/tooltip">Tooltip</a>
</li>
<li>
<a href="/docs/components/tree">Tree</a>
<ul>
<li>
<a href="/docs/components/tree-item">Tree Item</a>
</li>
</ul>
</li>
{% if not isAlpha %}
<li>
<a href="/docs/components/viewport-demo">Viewport Demo</a>
</li>
{% endif %}
<li>
<a href="/docs/components/visually-hidden">Visually Hidden</a>
</li>
</ul>
{# Layout #}
{% if not isAlpha %}

View File

@@ -21,9 +21,10 @@
{# Web Awesome #}
<script type="module" src="/dist/webawesome.ssr-loader.js"></script>
<link rel="stylesheet" id="theme-stylesheet" />
<link rel="stylesheet" href="/dist/styles/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/styles/utilities.css" />
<link rel="stylesheet" href="/dist/styles/forms.css" />
<link rel="stylesheet" href="/dist/themes/applied.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/themes/layout.css" />
<link id="color-stylesheet" rel="stylesheet" href="/dist/themes/utilities.css" />
<link rel="stylesheet" href="/dist/themes/forms.css" />
{# Set the theme to prevent flashing #}
<script>
@@ -46,7 +47,7 @@
const stylesheet = document.getElementById("theme-stylesheet")
let preset = getPresetTheme()
stylesheet.href = `/dist/styles/themes/${preset}.css`
stylesheet.href = `/dist/themes/${preset}.css`
document.documentElement.classList.toggle(
`wa-theme-${preset}-dark`,

View File

@@ -9,7 +9,7 @@
{% block beforeContent %}
<h1 class="title">{{ title }}</h1>
<div class="component-info">
<code class="tag">&lt;{{ component.tagName }}&gt;</code>
<code class="component-tag">&lt;{{ component.tagName }}&gt;</code>
<wa-badge variant="neutral">Since {{ component.since }}</wa-badge>
<wa-badge
{% if component.status == 'stable' %}variant="brand"{% endif %}
@@ -17,19 +17,14 @@
>
{{ component.status }}
</wa-badge>
{% if isPro %}<wa-badge class="pro">PRO</wa-badge>{% endif %}
{# TODO - add a pro flag for pro components #}
{% if component.tagName == 'wa-page' %}
<wa-badge class="pro">PRO</wa-badge>
{% endif %}
</div>
<p class="summary">
<p class="component-summary">
{{ component.summary | inlineMarkdown | safe }}
</p>
{% if natives %}
<wa-callout variant="success">
<wa-icon slot="icon" name="lightbulb" variant="regular"></wa-icon>
Just want the styles?
Check out <a href="/docs/natives/{{ natives }}/">{{ ('/docs/natives/' + natives + '/') | getTitleFromUrl }} natives</a>!
</wa-callout>
{% endif %}
{% endblock %}
{# Content #}
@@ -42,7 +37,6 @@
{# Slots #}
{% if component.slots.length %}
<h2>Slots</h2>
<p>Learn more about <a href="/docs/usage/#slots">using slots</a>.</p>
<div class="table-scroll">
<table class="component-table">
@@ -73,7 +67,6 @@
{# Properties #}
{% if component.properties.length %}
<h2>Attributes & Properties</h2>
<p>Learn more about <a href="/docs/usage/#attributes-and-properties">attributes and properties</a>.</p>
<div class="table-scroll">
<table class="component-table">
@@ -120,8 +113,6 @@
{# Methods #}
{% if component.methods.length %}
<h2>Methods</h2>
<p>Learn more about <a href="/docs/usage/#methods">methods</a>.</p>
<div class="table-scroll">
<table class="component-table">
<thead>
@@ -152,10 +143,34 @@
</div>
{% endif %}
{# States #}
{% if component.states.length %}
<h2>States</h2>
<div class="table-scroll">
<table class="component-table">
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
<th class="table-selector">CSS selector</th>
</tr>
</thead>
<tbody>
{% for state in component.states %}
<tr>
<td class="table-name"><code>{{ state.name }}</code></td>
<td class="table-description">{{ state.description | inlineMarkdown | safe }}</td>
<td class="table-selector"><code>[data-state-{{ state.name }}]</code></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# Events #}
{% if component.events.length %}
<h2>Events</h2>
<p>Learn more about <a href="/docs/usage/#events">events</a>.</p>
<div class="table-scroll">
<table class="component-table">
@@ -182,7 +197,6 @@
{# Custom Properties #}
{% if component.cssProperties.length %}
<h2>CSS custom properties</h2>
<p>Learn more about <a href="/docs/customizing/#custom-properties">CSS custom properties</a>.</p>
<div class="table-scroll">
<table class="component-table">
@@ -211,37 +225,9 @@
</div>
{% endif %}
{# Custom States #}
{% if component.cssStates.length %}
<h2>Custom States</h2>
<p>Learn more about <a href="/docs/customizing/#custom-states">custom states</a>.</p>
<div class="table-scroll">
<table class="component-table">
<thead>
<tr>
<th class="table-name">Name</th>
<th class="table-description">Description</th>
<th class="table-selector">CSS selector</th>
</tr>
</thead>
<tbody>
{% for state in component.cssStates %}
<tr>
<td class="table-name"><code>{{ state.name }}</code></td>
<td class="table-description">{{ state.description | inlineMarkdown | safe }}</td>
<td class="table-selector"><code>:state({{ state.name }})</code></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# CSS Parts #}
{% if component.cssParts.length %}
<h2>CSS parts</h2>
<p>Learn more about <a href="/docs/customizing/#css-parts">CSS parts</a>.</p>
<div class="table-scroll">
<table class="component-table">
@@ -267,7 +253,7 @@
{% if component.dependencies.length %}
<h2>Dependencies</h2>
<p>
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.
This component automatically imports the following elements. Subdependencies, if any exist, will also be included in this list.
</p>
<ul class="dependency-list">

View File

@@ -1,55 +0,0 @@
{% set hasSidebar = true %}
{% set hasOutline = true %}
{% extends '../_includes/base.njk' %}
{# Component header #}
{% block beforeContent %}
<h1 class="title">{{ title }}</h1>
<div class="component-info">
{% for tag, url in elements %}
<code class="tag"><a href="{{ url }}">{{ tag }}</a></code>
{% endfor %}
{% if since %}<wa-badge variant="neutral">Since {{ since }}</wa-badge>{% endif %}
{% if status %}
<wa-badge
{% if status == 'stable' %}variant="brand"{% endif %}
{% if status == 'experimental' %}variant="warning"{% endif %}
>
{{ status }}
</wa-badge>
{% endif %}
{% if isPro %}
<wa-badge class="pro">PRO</wa-badge>
{% endif %}
</div>
{% if description -%}
<p class="summary">{{ description | inlineMarkdown | safe }}</p>
{%- endif %}
{% if component %}
<wa-callout variant="success">
<wa-icon slot="icon" name="lightbulb" variant="regular"></wa-icon>
Want to do more?
Check out the {% for name in (component | toArray) -%}
{{ ' and ' if loop.last and not loop.first }}<a href="/docs/components/{{ name }}"><code>&lt;wa-{{ name }}&gt;</code></a>{{ ', ' if not loop.last }}
{%- endfor %} component{{ 's' if (component | isArray) }}</a>!
</wa-callout>
{% endif %}
{% endblock %}
{# Content #}
{% block content %}
{{ content | safe }}
{% endblock %}
{# Component API #}
{% block afterContent %}
{# Slots #}
{% if css_file %}
<h2>Using these styles</h2>
<p>If you want to use these styles without using the entirety of Web Awesome Natives, you can include the following CSS files:</p>
{% endif %}
{% endblock %}

View File

@@ -1,11 +1,11 @@
import { parse } from 'node-html-parser';
import slugify from 'slugify';
import { v4 as uuid } from 'uuid';
import slugify from 'slugify';
function createId(text) {
let slug = slugify(String(text), {
remove: /[^\w|\s]/g,
lower: true,
lower: true
});
// ids must start with a letter
@@ -24,7 +24,7 @@ export function anchorHeadingsPlugin(options = {}) {
container: 'body',
headingSelector: 'h2, h3, h4, h5, h6',
anchorLabel: 'Jump to heading',
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -53,7 +53,7 @@ const templates = {
attributes = {
open,
include: `link[rel=stylesheet][href^='/dist/']`,
...attributes,
...attributes
};
const attributesString = Object.entries(attributes)
@@ -93,7 +93,7 @@ const templates = {
${pre.outerHTML}
</wa-code-demo>
`;
},
}
};
/**
@@ -107,13 +107,13 @@ export function codeExamplesPlugin(eleventyConfig, options = {}) {
outputPathIndex === 1 && // is first
code.textContent.length < 500
); // is short
},
}
};
options = { ...defaultOptions, ...options };
const stats = {
inputPaths: {},
outputPaths: {},
outputPaths: {}
};
eleventyConfig.addTransform('code-examples', function (content) {
@@ -144,7 +144,7 @@ export function codeExamplesPlugin(eleventyConfig, options = {}) {
edit: true,
buttons: true,
new: true, // comment this line to default back to the old demos
attributes: {},
attributes: {}
};
for (const prop of ['new', 'open', 'buttons', 'edit']) {
@@ -174,7 +174,7 @@ export function codeExamplesPlugin(eleventyConfig, options = {}) {
localOptions.open = localOptions.defaultOpen(code, {
pre,
inputPathIndex: stats.inputPaths[inputPath],
outputPathIndex: stats.outputPaths[outputPath],
outputPathIndex: stats.outputPaths[outputPath]
});
}
}

View File

@@ -6,7 +6,7 @@ import { parse } from 'node-html-parser';
export function copyCodePlugin(options = {}) {
options = {
container: 'body',
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -28,7 +28,7 @@ export function currentLink(options = {}) {
options = {
container: 'body',
className: 'current',
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -1,79 +0,0 @@
import { parse } from 'path';
export function stripExtension(string) {
return parse(string).name;
}
export function stripPrefix(content) {
return content.replace(/^wa-/, '');
}
// Trims whitespace and pipes from the start and end of a string. Useful for CEM types, which can be pipe-delimited.
// With Prettier 3, this means a leading pipe will exist be present when the line wraps.
export function trimPipes(content) {
return typeof content === 'string' ? content.replace(/^(\s|\|)/g, '').replace(/(\s|\|)$/g, '') : content;
}
export function keys(obj) {
return Object.keys(obj);
}
export function log(firstArg, ...rest) {
console.log(firstArg, ...rest);
return firstArg;
}
function getCollection(name) {
// From https://github.com/11ty/eleventy/blob/d3d24ccddb804e6e14773501d8c4e07e2c4b9c2b/src/Filters/GetLocaleCollectionItem.js#L39-L43
return this.collections?.[name] || this.ctx?.collections?.[name] || this.context?.environments?.collections?.[name];
}
export function getCollectionItemFromUrl(url, collection) {
collection ??= getCollection.call(this, 'all') || [];
return collection.find(item => item.url === url);
}
export function getTitleFromUrl(url, collection) {
const item = getCollectionItemFromUrl.call(this, url, collection);
return item?.data.title || '';
}
export function breadcrumbs(url, { withCurrent = false } = {}) {
const parts = url.split('/').filter(Boolean);
const ret = [];
while (parts.length) {
let partialUrl = '/' + parts.join('/') + '/';
let item = getCollectionItemFromUrl.call(this, partialUrl);
if (item && (partialUrl !== url || withCurrent)) {
let title = item.data.title;
if (title) {
ret.unshift({ url: partialUrl, title });
}
}
parts.pop();
if (item?.data.parent) {
let parentURL = item.data.parent;
if (!item.data.parent.startsWith('/')) {
// Parent is in the same directory
parts.push(item.data.parent);
parentURL = '/' + parts.join('/') + '/';
}
let parentBreadcrumbs = breadcrumbs.call(this, parentURL, { withCurrent: true });
return [...parentBreadcrumbs, ...ret];
}
}
return ret;
}
export function isArray(value) {
return Array.isArray(value);
}
export function toArray(value) {
return isArray(value) ? value : [value];
}

View File

@@ -11,7 +11,7 @@ import defaultOptions from '../../prettier.config.js';
export async function formatCode(string, options) {
return await format(string, {
...defaultOptions,
...options,
...options
});
}
@@ -21,7 +21,7 @@ export async function formatCode(string, options) {
export function formatCodePlugin(options = {}) {
options = {
parser: 'html',
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -1,8 +1,8 @@
/* eslint sort-imports-es6-autofix/sort-imports-es6: 0 */
import { parse } from 'node-html-parser';
import Prism from 'prismjs';
import PrismLoader from 'prismjs/components/index.js';
import 'prismjs/plugins/custom-class/prism-custom-class.js';
import PrismLoader from 'prismjs/components/index.js';
PrismLoader('diff');
PrismLoader.silent = true;
@@ -40,7 +40,7 @@ export function highlightCode(code, language = 'plain') {
export function highlightCodePlugin(options = {}) {
options = {
container: 'body',
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -14,7 +14,7 @@ export const markdown = MarkdownIt({
breaks: false,
langPrefix: 'language-',
linkify: false,
typographer: false,
typographer: false
});
markdown.use(markdownItIns);
@@ -34,7 +34,7 @@ markdown.use(markdownItMark);
`;
}
return '</div></div>\n';
},
}
});
});
@@ -44,7 +44,7 @@ markdown.use(markdownItContainer, 'aside', {
return `<aside>`;
}
return '</aside>\n';
},
}
});
markdown.use(markdownItContainer, 'details', {
@@ -55,9 +55,9 @@ markdown.use(markdownItContainer, 'details', {
return `<details>\n<summary><span>${markdown.utils.escapeHtml(m[1])}</span></summary>\n`;
}
return '</details>\n';
},
}
});
markdown.use(markdownItAttrs, {
allowedAttributes: [],
allowedAttributes: []
});

View File

@@ -15,7 +15,7 @@ export function outlinePlugin(options = {}) {
target: '.outline',
selector: 'h2,h3',
ifEmpty: () => null,
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -6,7 +6,7 @@ import { parse } from 'node-html-parser';
export function removeDataAlphaElements(options = {}) {
options = {
isAlpha: false,
...options,
...options
};
return function (eleventyConfig) {

View File

@@ -1,8 +1,8 @@
/* eslint-disable no-invalid-this */
import { mkdir, writeFile } from 'fs/promises';
import lunr from 'lunr';
import { parse } from 'node-html-parser';
import { dirname, join } from 'path';
import { mkdir, writeFile } from 'fs/promises';
import { parse } from 'node-html-parser';
import lunr from 'lunr';
function collapseWhitespace(string) {
return string.replace(/\s+/g, ' ');
@@ -19,7 +19,7 @@ export function searchPlugin(options = {}) {
getDescription: doc => doc.querySelector('meta[name="description"]')?.getAttribute('content') ?? '',
getHeadings: doc => [...doc.querySelectorAll('h1, h2, h3, h4, h5, h6')].map(heading => heading.textContent ?? ''),
getContent: doc => doc.querySelector('body')?.textContent ?? '',
...options,
...options
};
return function (eleventyConfig) {
@@ -32,8 +32,8 @@ export function searchPlugin(options = {}) {
noscript: false,
style: false,
pre: false,
code: false,
},
code: false
}
});
// Remove content that shouldn't be searchable to reduce the index size
@@ -46,7 +46,7 @@ export function searchPlugin(options = {}) {
description: collapseWhitespace(options.getDescription(doc)),
headings: options.getHeadings(doc).map(collapseWhitespace),
content: collapseWhitespace(options.getContent(doc)),
url: this.page.url === '/' ? '/' : this.page.url.replace(/\/$/, ''),
url: this.page.url === '/' ? '/' : this.page.url.replace(/\/$/, '')
});
return content;

View File

@@ -1,6 +1,5 @@
await customElements.whenDefined('wa-checkbox');
let container = document.getElementById('page_slots_demo');
let fieldset = container.querySelector('fieldset');
let iframe = container.querySelector('iframe');
let stylesheets = Array.from(document.querySelectorAll("link[rel=stylesheet][href^='/dist/']"))
@@ -11,7 +10,7 @@ let includes = `${stylesheets}
<link rel="stylesheet" href="/assets/examples/page-demo/page.css">`;
function render() {
let slots = Array.from(fieldset.querySelectorAll('wa-checkbox[name=slot]:state(checked)'));
let slots = Array.from(fieldset.querySelectorAll('wa-checkbox[name=slot]:is([data-wa-checked])'));
let slotsHTML = slots
.map(slot => {
let name = slot.getAttribute('value');
@@ -41,3 +40,11 @@ function render() {
}
fieldset?.addEventListener('input', render);
render();
//
// TODO - fix Turbo caching. When this is removed, visiting the <wa-page> docs via Turbo will cause the <iframe srcdoc>
// to not render. Even with this, there are console errors when leaving the page.
//
// NOTE - the iframe already has `data-turbo="false"` and `data-turbo-temporary` on it.
//
document.body.setAttribute('data-turbo', 'false');

View File

@@ -13,7 +13,7 @@ const matchers = {
regexp(textContent, query) {
query.lastIndex = 0;
return query.test(textContent);
},
}
};
matchers.iregexp = matchers.regexp; // i is baked into the query

View File

@@ -18,9 +18,10 @@ document.addEventListener('click', event => {
const cdnUrl = document.documentElement.dataset.cdnUrl;
const html =
`<script type="module" src="${cdnUrl}webawesome.loader.js"></script>\n` +
`<link rel="stylesheet" href="${cdnUrl}styles/themes/default.css">\n` +
`<link rel="stylesheet" href="${cdnUrl}styles/applied.css">\n` +
`<link rel="stylesheet" href="${cdnUrl}styles/utilities.css">\n\n` +
`<link rel="stylesheet" href="${cdnUrl}themes/default.css">\n` +
`<link rel="stylesheet" href="${cdnUrl}themes/applied.css">\n` +
`<link rel="stylesheet" href="${cdnUrl}themes/layout.css">\n` +
`<link rel="stylesheet" href="${cdnUrl}themes/utilities.css">\n\n` +
`${code.textContent}`;
const css = 'html > body {\n font: 16px sans-serif;\n padding: 2rem;\n}';
const js = '';
@@ -43,7 +44,7 @@ document.addEventListener('click', event => {
js_pre_processor: 'none',
html,
css,
js,
js
};
const input = document.createElement('input');

View File

@@ -79,8 +79,8 @@
diffViewer.appendChild(
createDiff({
serverHTML,
clientHTML,
}),
clientHTML
})
);
});
}
@@ -88,7 +88,7 @@
function createDiff({ serverHTML, clientHTML }) {
const diff = diffLines(serverHTML, clientHTML, {
ignoreWhitespace: false,
newLineIsToken: true,
newLineIsToken: true
});
const fragment = document.createDocumentFragment();
for (var i = 0; i < diff.length; i++) {

View File

@@ -9,9 +9,9 @@
const stylesheet = document.getElementById('theme-stylesheet');
const newStylesheet = Object.assign(document.createElement('link'), {
href: `/dist/styles/themes/${presetTheme}.css`,
href: `/dist/themes/${presetTheme}.css`,
rel: 'preload',
as: 'style',
as: 'style'
});
newStylesheet.addEventListener(
@@ -23,7 +23,7 @@
stylesheet.remove();
});
},
{ once: true },
{ once: true }
);
document.head.append(newStylesheet);

View File

@@ -1,14 +1,13 @@
// Smooth links
document.addEventListener('click', event => {
const link = event.target.closest('a');
const id = (link?.hash ?? '').substr(1);
if (!link || link.getAttribute('data-smooth-link') === 'off') {
return;
}
const id = (link.hash ?? '').substr(1);
// Only handle smooth scroll if there's a hash and the link points to the current page
if (id && link.pathname === window.location.pathname) {
if (id) {
const target = document.getElementById(id);
const headerHeight = document.querySelector('wa-page > header').clientHeight;
@@ -16,7 +15,7 @@ document.addEventListener('click', event => {
event.preventDefault();
window.scroll({
top: target.offsetTop - headerHeight,
behavior: 'smooth',
behavior: 'smooth'
});
history.pushState(undefined, undefined, `#${id}`);
}

View File

@@ -9,7 +9,7 @@ const icons = {
component: 'puzzle-piece',
document: 'file',
home: 'house',
theme: 'palette',
theme: 'palette'
};
let searchTimeout;
@@ -18,7 +18,7 @@ function getElements() {
return {
dialog: document.getElementById('site-search'),
input: document.getElementById('site-search-input'),
results: document.getElementById('site-search-listbox'),
results: document.getElementById('site-search-listbox')
};
}

View File

@@ -9,7 +9,7 @@ function saveScrollPosition() {
if (element.id) {
positions[element.id] = {
top: element.scrollTop,
left: element.scrollLeft,
left: element.scrollLeft
};
} else {
console.warn(`Can't save scroll position for elements without an id.`, el);

View File

@@ -25,11 +25,11 @@ wa-page::part(header) {
border-bottom: var(--wa-border-style) var(--wa-panel-border-width) var(--wa-color-neutral-border-quiet);
}
wa-page::part(body) {
wa-page::part(drawer__body) {
padding-top: 0px;
}
wa-page::part(header-actions) {
wa-page::part(drawer__header-actions) {
align-self: center;
}
@@ -46,7 +46,7 @@ wa-page > header {
}
wa-button[data-toggle-nav] {
--text-color: currentColor;
--label-color: currentColor;
font-size: 1rem;
margin-inline-start: -0.875rem;
margin-inline-end: 0;
@@ -76,6 +76,8 @@ wa-page > header {
margin-block-start: var(--wa-space-2xs);
}
#version-number + wa-badge {
--background-color: var(--wa-color-warning-fill-quiet);
--content-color: var(--wa-color-warning-on-quiet);
font-size: var(--wa-font-size-2xs);
text-transform: uppercase;
}
@@ -95,26 +97,9 @@ wa-page > header {
font-size: var(--wa-font-size-m);
margin: 0;
}
h2:not(:first-child),
wa-details:not(:first-child) {
h2:not(:first-child) {
margin-block-start: var(--wa-space-xs);
}
wa-details {
border: none;
background: none;
}
wa-details::part(header) {
padding: 0;
}
wa-details::part(content) {
padding-inline: 0;
padding-block-end: 0;
}
ul {
border-inline-start: var(--wa-border-width-s) solid var(--wa-color-surface-border);
font-size: var(--wa-font-size-s);
@@ -122,30 +107,21 @@ wa-page > header {
margin: 0;
padding-inline-start: var(--wa-space-m);
}
ul ul {
margin-block-start: var(--wa-space-m);
}
ul:empty {
display: none;
}
li {
list-style: none;
+ li {
margin-block-start: var(--wa-space-m);
}
}
li + li {
margin-block-start: var(--wa-space-m);
}
li a {
color: var(--wa-color-text-normal);
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
li a:hover {
text-decoration: underline;
}
li wa-badge::part(base) {
@@ -479,7 +455,6 @@ wa-page > main:has(> .index-grid) {
.table-scroll {
overflow-x: auto;
margin-block-end: var(--wa-flow-spacing);
}
/** mobile */

View File

@@ -23,7 +23,7 @@
.hero wa-button[variant='brand'] {
--background: var(--wa-color-neutral-fill-quiet);
--text-color: var(--wa-color-neutral-on-normal);
--label-color: var(--wa-color-neutral-on-normal);
}
.project-header {

View File

@@ -1,7 +1,7 @@
---
title: Animated Image
description: A component for displaying animated GIFs and WEBPs that play and pause on interaction.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Animation
description: Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes.
tags: component
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.
@@ -196,4 +196,4 @@ Animations won't play until you apply the `play` attribute. You can omit it init
animation.play = true;
});
</script>
```
```

View File

@@ -1,7 +1,7 @@
---
title: Avatar
description: Avatars are used to represent a person or object.
tags: component
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.
@@ -97,7 +97,7 @@ You can group avatars with a few lines of CSS.
margin-left: calc(-1 * var(--wa-space-m));
}
.avatar-group wa-avatar {
.avatar-group wa-avatar::part(base) {
border: solid 2px var(--wa-color-surface-default);
}
</style>

View File

@@ -1,7 +1,7 @@
---
title: Badge
description: Badges are used to draw attention and display statuses or counts.
tags: component
layout: component
---
```html {.example}
@@ -22,48 +22,6 @@ Set the `variant` attribute to change the badge's variant.
<wa-badge variant="danger">Danger</wa-badge>
```
### Appearance
Use the `appearance` attribute to change the badge's visual appearance.
```html {.example}
<div style="margin-block-end: 1rem;">
<wa-badge appearance="accent outlined" variant="neutral">A+O</wa-badge>
<wa-badge appearance="accent" variant="neutral">Accent</wa-badge>
<wa-badge appearance="filled outlined" variant="neutral">F+O</wa-badge>
<wa-badge appearance="filled" variant="neutral">Filled</wa-badge>
<wa-badge appearance="outlined" variant="neutral">Outlined</wa-badge>
</div>
<div style="margin-block-end: 1rem;">
<wa-badge appearance="accent outlined" variant="brand">A+O</wa-badge>
<wa-badge appearance="accent" variant="brand">Accent</wa-badge>
<wa-badge appearance="filled outlined" variant="brand">F+O</wa-badge>
<wa-badge appearance="filled" variant="brand">Filled</wa-badge>
<wa-badge appearance="outlined" variant="brand">Outlined</wa-badge>
</div>
<div style="margin-block-end: 1rem;">
<wa-badge appearance="accent outlined" variant="success">A+O</wa-badge>
<wa-badge appearance="accent" variant="success">Accent</wa-badge>
<wa-badge appearance="filled outlined" variant="success">F+O</wa-badge>
<wa-badge appearance="filled" variant="success">Filled</wa-badge>
<wa-badge appearance="outlined" variant="success">Outlined</wa-badge>
</div>
<div style="margin-block-end: 1rem;">
<wa-badge appearance="accent outlined" variant="warning">A+O</wa-badge>
<wa-badge appearance="accent" variant="warning">Accent</wa-badge>
<wa-badge appearance="filled outlined" variant="warning">F+O</wa-badge>
<wa-badge appearance="filled" variant="warning">Filled</wa-badge>
<wa-badge appearance="outlined" variant="warning">Outlined</wa-badge>
</div>
<div>
<wa-badge appearance="accent outlined" variant="danger">A+O</wa-badge>
<wa-badge appearance="accent" variant="danger">Accent</wa-badge>
<wa-badge appearance="filled outlined" variant="danger">F+O</wa-badge>
<wa-badge appearance="filled" variant="danger">Filled</wa-badge>
<wa-badge appearance="outlined" variant="danger">Outlined</wa-badge>
</div>
```
### Pill Badges
Use the `pill` attribute to give badges rounded edges.

View File

@@ -1,8 +1,7 @@
---
title: Breadcrumb Item
description: Breadcrumb Items are used inside breadcrumbs to represent different links.
tags: component
parent: breadcrumb
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Breadcrumb
description: Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy.
tags: component
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.
@@ -135,7 +135,7 @@ Dropdown menus can be placed in the default slot to provide additional options.
<wa-breadcrumb-item>Homepage</wa-breadcrumb-item>
<wa-breadcrumb-item>
<wa-dropdown>
<wa-button slot="trigger" size="small" appearance="filled" pill>
<wa-button slot="trigger" size="small" appearance="tinted" pill>
<wa-icon label="More options" name="ellipsis" variant="solid"></wa-icon>
</wa-button>
<wa-menu>
@@ -160,7 +160,7 @@ Alternatively, you can place dropdown menus in a prefix or suffix slot.
<wa-breadcrumb-item>
Web Design
<wa-dropdown slot="suffix">
<wa-button slot="trigger" size="small" appearance="filled" pill>
<wa-button slot="trigger" size="small" appearance="tinted" pill>
<wa-icon label="More options" name="ellipsis" variant="solid"></wa-icon>
</wa-button>
<wa-menu>

View File

@@ -1,7 +1,7 @@
---
title: Button Group
description: Button groups can be used to group related buttons into sections.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,8 +1,7 @@
---
title: Button
description: Buttons represent actions that are available to the user.
tags: component
natives: button
layout: component
---
```html {.example}
@@ -29,34 +28,34 @@ Use the `appearance` attribute to change the button's visual appearance.
```html {.example}
<div style="margin-block-end: 1rem;">
<wa-button appearance="accent" variant="neutral">Accent</wa-button>
<wa-button appearance="filled" variant="neutral">Filled</wa-button>
<wa-button appearance="tinted" variant="neutral">Tinted</wa-button>
<wa-button appearance="outlined" variant="neutral">Outlined</wa-button>
<wa-button appearance="plain" variant="neutral">Text</wa-button>
<wa-button appearance="text" variant="neutral">Text</wa-button>
</div>
<div style="margin-block-end: 1rem;">
<wa-button appearance="accent" variant="brand">Accent</wa-button>
<wa-button appearance="filled" variant="brand">Filled</wa-button>
<wa-button appearance="tinted" variant="brand">Tinted</wa-button>
<wa-button appearance="outlined" variant="brand">Outlined</wa-button>
<wa-button appearance="plain" variant="brand">Text</wa-button>
<wa-button appearance="text" variant="brand">Text</wa-button>
</div>
<div style="margin-block-end: 1rem;">
<wa-button appearance="accent" variant="success">Accent</wa-button>
<wa-button appearance="filled" variant="success">Filled</wa-button>
<wa-button appearance="tinted" variant="success">Tinted</wa-button>
<wa-button appearance="outlined" variant="success">Outlined</wa-button>
<wa-button appearance="plain" variant="success">Text</wa-button>
<wa-button appearance="text" variant="success">Text</wa-button>
</div>
<div style="margin-block-end: 1rem;">
<wa-button appearance="accent" variant="warning">Accent</wa-button>
<wa-button appearance="filled" variant="warning">Filled</wa-button>
<wa-button appearance="tinted" variant="warning">Tinted</wa-button>
<wa-button appearance="outlined" variant="warning">Outlined</wa-button>
<wa-button appearance="plain" variant="warning">Text</wa-button>
<wa-button appearance="text" variant="warning">Text</wa-button>
</div>
<div>
<wa-button appearance="accent" variant="danger">Accent</wa-button>
<wa-button appearance="filled" variant="danger">Filled</wa-button>
<wa-button appearance="tinted" variant="danger">Tinted</wa-button>
<wa-button appearance="outlined" variant="danger">Outlined</wa-button>
<wa-button appearance="plain" variant="danger">Text</wa-button>
<wa-button appearance="text" variant="danger">Text</wa-button>
</div>
```
@@ -92,7 +91,7 @@ It's often helpful to have a button that works like a link. This is possible by
### Setting a Custom Width
As expected, buttons can be given a custom width by setting the `width` CSS property. This is useful for making buttons span the full width of their container on smaller screens.
As expected, buttons can be given a custom width by setting the `width` attribute. This is useful for making buttons span the full width of their container on smaller screens.
```html {.example}
<wa-button size="small" style="width: 100%; margin-bottom: 1rem;">Small</wa-button>

View File

@@ -1,7 +1,7 @@
---
title: Callout
description: Callouts are used to display important messages inline.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Card
description: Cards can be used to group related subjects in a container.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,8 +1,7 @@
---
title: Carousel Item
description: A carousel item represent a slide within a carousel.
tags: component
parent: carousel
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Carousel
description: Carousels display an arbitrary number of content slides along a horizontal or vertical axis.
tags: component
layout: component
---
```html {.example}
@@ -534,12 +534,12 @@ The carousel has a robust API that makes it possible to extend and customize. Th
</wa-carousel>
<div class="thumbnails">
<div class="scroller">
<img alt="Thumbnail by 1" class="image active" src="https://images.unsplash.com/photo-1426604966848-d7adac402bff?q=10" />
<img alt="Thumbnail by 2" class="image" src="https://images.unsplash.com/photo-1473448912268-2022ce9509d8?q=10" />
<img alt="Thumbnail by 3" class="image" src="https://images.unsplash.com/photo-1499002238440-d264edd596ec?q=10" />
<img alt="Thumbnail by 4" class="image" src="https://images.unsplash.com/photo-1475113548554-5a36f1f523d6?q=10" />
<img alt="Thumbnail by 5" class="image" src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?q=10" />
<div class="thumbnails__scroller">
<img alt="Thumbnail by 1" class="thumbnails__image active" src="https://images.unsplash.com/photo-1426604966848-d7adac402bff?q=10" />
<img alt="Thumbnail by 2" class="thumbnails__image" src="https://images.unsplash.com/photo-1473448912268-2022ce9509d8?q=10" />
<img alt="Thumbnail by 3" class="thumbnails__image" src="https://images.unsplash.com/photo-1499002238440-d264edd596ec?q=10" />
<img alt="Thumbnail by 4" class="thumbnails__image" src="https://images.unsplash.com/photo-1475113548554-5a36f1f523d6?q=10" />
<img alt="Thumbnail by 5" class="thumbnails__image" src="https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?q=10" />
</div>
</div>
@@ -553,7 +553,7 @@ The carousel has a robust API that makes it possible to extend and customize. Th
justify-content: center;
}
.scroller {
.thumbnails__scroller {
display: flex;
gap: var(--wa-space-s);
overflow-x: auto;
@@ -562,11 +562,11 @@ The carousel has a robust API that makes it possible to extend and customize. Th
scroll-padding: var(--wa-space-s);
}
.scroller::-webkit-scrollbar {
.thumbnails__scroller::-webkit-scrollbar {
display: none;
}
.image {
.thumbnails__image {
width: 64px;
height: 64px;
object-fit: cover;
@@ -578,7 +578,7 @@ The carousel has a robust API that makes it possible to extend and customize. Th
cursor: pointer;
}
.image.active {
.thumbnails__image.active {
opacity: 1;
}
</style>
@@ -586,13 +586,13 @@ The carousel has a robust API that makes it possible to extend and customize. Th
<script>
{
const carousel = document.querySelector('.carousel-thumbnails');
const scroller = document.querySelector('.scroller');
const thumbnails = document.querySelectorAll('.image');
const scroller = document.querySelector('.thumbnails__scroller');
const thumbnails = document.querySelectorAll('.thumbnails__image');
scroller.addEventListener('click', e => {
const target = e.target;
if (target.matches('.image')) {
if (target.matches('.thumbnails__image')) {
const index = [...thumbnails].indexOf(target);
carousel.goToSlide(index);
}

View File

@@ -1,7 +1,7 @@
---
title: Checkbox
description: Checkboxes allow the user to toggle an option on or off.
tags: component
layout: component
---
```html {.example}
@@ -50,12 +50,12 @@ Use the `size` attribute to change a checkbox's size.
<wa-checkbox size="large">Large</wa-checkbox>
```
### Hint
### Help Text
Add descriptive hint to a switch with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
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 {.example}
<wa-checkbox hint="What should the user know about the checkbox?">Label</wa-checkbox>
<wa-checkbox help-text="What should the user know about the checkbox?">Label</wa-checkbox>
```
### Custom Validity
@@ -92,4 +92,4 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
});
});
</script>
```
```

View File

@@ -1,8 +1,7 @@
---
title: Code Demo
description: Code demos can be used to render code examples as inline live demos.
tags: component
noAlpha: true
layout: component
---
```html {.example}
@@ -82,7 +81,7 @@ There are certain types of elements that are handled specially:
This is useful for including resources in your demo that you don't want rendered outside the demo.
The following example shows both methods.
It includes all stylesheets on this page whose URLs start with `/dist/styles/themes/`,
It includes all stylesheets on this page whose URLs start with `/dist/themes/`,
plus any other elements with the class `.demo-import`, plus a CSS file with the class `wa-code-demo-include`:
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Color Picker
description: Color pickers allow the user to select a color.
tags: component
layout: component
---
```html {.example}
@@ -75,10 +75,10 @@ The color picker can be rendered as disabled.
<wa-color-picker disabled label="Select a color"></wa-color-picker>
```
### Hint
### Help Text
Add descriptive hint to a color picker with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
Add descriptive help text to a color picker with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html {.example}
<wa-color-picker label="Select a color" hint="Choose a color with appropate contrast!"></wa-color-picker>
```
<wa-color-picker label="Select a color" help-text="Choose a color with appropate contrast!"></wa-color-picker>
```

View File

@@ -1,3 +0,0 @@
{
"layout": "component.njk"
}

View File

@@ -1,7 +1,7 @@
---
title: Copy Button
description: Copies data to the clipboard when the user clicks the button.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,8 +1,7 @@
---
title: Details
description: Details show a brief summary and expand to show additional content.
tags: component
natives: details
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->
@@ -18,7 +17,7 @@ natives: details
### Disabled
Use the `disabled` attribute to prevent the details from expanding.
Use the `disable` attribute to prevent the details from expanding.
```html {.example}
<wa-details summary="Disabled" disabled>
@@ -29,7 +28,7 @@ Use the `disabled` attribute to prevent the details from expanding.
### Customizing the Summary Icon
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `icon` part as shown below.
Use the `expand-icon` and `collapse-icon` slots to change the expand and collapse icons, respectively. To disable the animation, override the `rotate` property on the `summary-icon` part as shown below.
```html {.example}
<wa-details summary="Toggle Me" class="custom-icons">
@@ -41,41 +40,13 @@ Use the `expand-icon` and `collapse-icon` slots to change the expand and collaps
</wa-details>
<style>
/* Disable the expand/collapse animation */
wa-details.custom-icons::part(icon) {
wa-details.custom-icons::part(summary-icon) {
/* Disable the expand/collapse animation */
rotate: none;
}
</style>
```
### HTML in summary
To use HTML in the summary, use the `summary` slot.
Links and other interactive elements will still retain their behavior:
```html {.example}
<wa-details>
<span slot="summary">
Some text
<a href="https://webawesome.com" target="_blank">a link</a>
more text
</span>
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.
</wa-details>
```
### Right-to-Left languages
The details component automatically adapts to right-to-left languages:
```html {.example}
<wa-details summary="تبديلني" lang="ar" dir="rtl">
استخدام طريقة لوريم إيبسوم لأنها تعطي توزيعاَ طبيعياَ -إلى حد ما- للأحرف عوضاً عن
</wa-details>
```
### Grouping Details
Details are designed to function independently, but you can simulate a group or "accordion" where only one is shown at a time by listening for the `wa-show` event.

View File

@@ -1,14 +1,13 @@
---
title: Dialog
description: 'Dialogs, sometimes called "modals", appear above the page and require the user''s immediate attention.'
tags: component
natives: dialog
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->
```html {.example}
<wa-dialog label="Dialog" with-header with-footer id="dialog-overview">
<wa-dialog label="Dialog" with-header with-footer class="dialog-overview">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<wa-button slot="footer" variant="brand" data-dialog="close">Close</wa-button>
</wa-dialog>
@@ -16,7 +15,7 @@ natives: dialog
<wa-button>Open Dialog</wa-button>
<script>
const dialog = document.querySelector('#dialog-overview');
const dialog = document.querySelector('.dialog-overview');
const openButton = dialog.nextElementSibling;
openButton.addEventListener('click', () => dialog.open = true);
@@ -86,10 +85,10 @@ You can add the special `data-dialog="close"` attribute to a button inside the d
### Custom Width
Just use the CSS `width` property to set the dialog's width.
Use the `--width` custom property to set the dialog's width.
```html {.example}
<wa-dialog label="Dialog" with-header with-footer class="dialog-width" style="width: 50vw;">
<wa-dialog label="Dialog" with-header with-footer class="dialog-width" style="--width: 50vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<wa-button slot="footer" variant="brand" data-dialog="close">Close</wa-button>
</wa-dialog>
@@ -220,4 +219,4 @@ To give focus to a specific element when the dialog opens, use the `autofocus` a
openButton.addEventListener('click', () => dialog.open = true);
</script>
```
```

View File

@@ -1,7 +1,7 @@
---
title: Divider
description: Dividers are used to visually separate or group elements.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Drawer
description: Drawers slide in from a container to expose additional options and information.
tags: component
layout: component
---
<!-- cspell:dictionaries lorem-ipsum -->

View File

@@ -1,7 +1,7 @@
---
title: Dropdown
description: 'Dropdowns expose additional content that "drops down" in a panel.'
tags: component
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.

View File

@@ -1,7 +1,7 @@
---
title: Format Bytes
description: Formats a number as a human readable bytes value.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Format Date
description: Formats a date/time using the specified locale and options.
tags: component
layout: component
---
Localization is handled by the browser's [`Intl.DateTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat). No language packs are required.

View File

@@ -1,7 +1,7 @@
---
title: Format Number
description: Formats a number using the specified locale and options.
tags: component
layout: component
---
Localization is handled by the browser's [`Intl.NumberFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat). No language packs are required.

View File

@@ -1,7 +1,7 @@
---
title: Icon Button
description: Icons buttons are simple, icon-only buttons that can be used for actions and in toolbars.
tags: component
layout: component
---
For a full list of icons that come bundled with Web Awesome, refer to the [icon component](/docs/components/icon).

View File

@@ -1,7 +1,7 @@
---
title: Icon
description: Icons are symbols that can be used to represent various options within an application.
tags: component
layout: component
---
Web Awesome comes bundled with over 2,000 free icons courtesy of [Font Awesome](https://fontawesome.com/). These icons are part of the `default` icon library. Font Awesome Pro users can unlock additional icon families. Or, if you prefer, you can register your own [custom icon library](#icon-library).
@@ -146,7 +146,7 @@ Icons in this library are licensed under the [MIT License](https://github.com/tw
resolver: (name, family) => {
const suffix = family === 'filled' ? '-fill' : '';
return `https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/${name}${suffix}.svg`
}
}
});
</script>
```
@@ -517,7 +517,7 @@ For example, this will change the default icon library to use [Bootstrap Icons](
resolver: (name, family) => {
const suffix = family === 'filled' ? '-fill' : '';
return `https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/${name}${suffix}.svg`
}
}
});
</script>
```

View File

@@ -1,7 +1,7 @@
---
title: Image Comparer
description: Compare visual differences between similar photos with a sliding panel.
tags: component
layout: component
---
For best results, use images that share the same dimensions. The slider can be controlled by dragging or pressing the left and right arrow keys. (Tip: press shift + arrows to move the slider in larger intervals, or home + end to jump to the beginning or end.)

View File

@@ -1,7 +1,7 @@
---
title: Include
description: Includes give you the power to embed external HTML files into the page.
tags: component
layout: component
---
Included files are asynchronously requested using `window.fetch()`. Requests are cached, so the same file can be included multiple times, but only one request will be made.

View File

@@ -4,13 +4,17 @@ description: Browse the library of customizable, framework-friendly web componen
layout: page-outline
---
<style>
wa-card#drawer-card::part(header) {
--spacing: 0;
justify-content: flex-end;
overflow: hidden;
}
</style>
<p class="index-summary">Components are the essential building blocks to create intuitive, cohesive experiences. Browse the library of customizable, framework-friendly web components included in Web Awesome.</p>
<div id="component-filter">
<wa-input type="search" placeholder="Search components" clearable autofocus></wa-input>
</div>
<div id="component-grid" class="index-grid">
<div class="index-grid">
<h2 class="index-category">Actions</h2>
<a href="/docs/components/button">
<wa-card with-header>
@@ -110,7 +114,7 @@ layout: page-outline
<span class="page-name">Skeleton</span>
</wa-card>
</a>
<a href="/docs/components/spinner" data-keywords="loader">
<a href="/docs/components/spinner">
<wa-card with-header>
<div slot="header">
{% include "svgs/spinner.njk" %}
@@ -194,7 +198,7 @@ layout: page-outline
<span class="page-name">Color Picker</span>
</wa-card>
</a>
<a href="/docs/components/input" data-keywords="textfield text field">
<a href="/docs/components/input">
<wa-card with-header>
<div slot="header">
{% include "svgs/input.njk" %}
@@ -234,7 +238,7 @@ layout: page-outline
<span class="page-name">Select</span>
</wa-card>
</a>
<a href="/docs/components/switch" data-keywords="toggle">
<a href="/docs/components/switch">
<wa-card with-header>
<div slot="header">
{% include "svgs/switch.njk" %}
@@ -294,7 +298,7 @@ layout: page-outline
<span class="page-name">Details</span>
</wa-card>
</a>
<a href="/docs/components/dialog" data-keywords="modal">
<a href="/docs/components/dialog">
<wa-card with-header>
<div slot="header">
{% include "svgs/dialog.njk" %}
@@ -416,77 +420,4 @@ layout: page-outline
<span class="page-name">Visually Hidden</span>
</wa-card>
</a>
</div>
<div id="component-filter-empty" hidden>
No results
</div>
<script type="module">
const container = document.getElementById('component-filter');
const empty = document.getElementById('component-filter-empty');
const grid = document.getElementById('component-grid');
const input = container.querySelector('wa-input');
function updateResults() {
const filter = input.value.toLowerCase().trim();
// Hide headings while filtering
grid.querySelectorAll('h2').forEach(heading => {
heading.hidden = filter === '' ? false : true;
});
// Show matching components
grid.querySelectorAll('a').forEach(link => {
const content = link.textContent.toLowerCase();
const keywords = link.getAttribute('data-keywords') || '';
const isMatch = filter === '' || (content + keywords).includes(filter);
link.classList.toggle('hidden', !isMatch);
});
// Show empty state when there's a search filter and no results
if (filter !== '' && grid.querySelector('a:not(.hidden)') === null) {
empty.hidden = false;
} else {
empty.hidden = true;
}
}
input.addEventListener('wa-input', updateResults);
</script>
<style>
wa-card#drawer-card::part(header) {
--spacing: 0;
justify-content: flex-end;
overflow: hidden;
}
#component-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: var(--wa-space-m);
margin-block-start: var(--wa-space-2xl);
> a {
position: static;
visibility: visible;
&.hidden {
display: block;
position: absolute;
visibility: hidden;
}
}
}
#component-filter-empty {
border: dashed var(--wa-border-width-m) var(--wa-color-neutral-border-quiet);
border-radius: var(--wa-border-radius-m);
font-size: var(--wa-font-size-l);
color: var(--wa-color-text-quiet);
text-align: center;
padding-block: var(--wa-space-2xl);
margin-block-start: 0
}
</style>
</div>

View File

@@ -1,8 +1,7 @@
---
title: Input
description: Inputs collect data from the user.
tags: component
natives: input
layout: component
---
```html {.example}
@@ -23,12 +22,12 @@ Use the `label` attribute to give the input an accessible label. For labels that
<wa-input label="What is your name?"></wa-input>
```
### Hint
### Help Text
Add descriptive hint to an input with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
Add descriptive help text to an input with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html {.example}
<wa-input label="Nickname" hint="What would you like people to call you?"></wa-input>
<wa-input label="Nickname" help-text="What would you like people to call you?"></wa-input>
```
### Placeholders
@@ -55,12 +54,12 @@ Add the `password-toggle` attribute to add a toggle button that will show the pa
<wa-input type="password" placeholder="Password Toggle" password-toggle></wa-input>
```
### Appearance
### Filled Inputs
Use the `appearance` attribute to change the input's visual appearance.
Add the `filled` attribute to draw a filled input.
```html {.example}
<wa-input placeholder="Type something" appearance="filled"></wa-input>
<wa-input placeholder="Type something" filled></wa-input>
```
### Disabled
@@ -133,9 +132,9 @@ Use the `prefix` and `suffix` slots to add icons.
Use [CSS parts](#css-parts) to customize the way form controls are drawn. This example uses CSS grid to position the label to the left of the control, but the possible orientations are nearly endless. The same technique works for inputs, textareas, radio groups, and similar form controls.
```html {.example}
<wa-input class="label-on-left" label="Name" hint="Enter your name"></wa-input>
<wa-input class="label-on-left" label="Email" type="email" hint="Enter your email"></wa-input>
<wa-textarea class="label-on-left" label="Bio" hint="Tell us something about yourself"></wa-textarea>
<wa-input class="label-on-left" label="Name" help-text="Enter your name"></wa-input>
<wa-input class="label-on-left" label="Email" type="email" help-text="Enter your email"></wa-input>
<wa-textarea class="label-on-left" label="Bio" help-text="Tell us something about yourself"></wa-textarea>
<style>
.label-on-left {
@@ -158,8 +157,8 @@ Use [CSS parts](#css-parts) to customize the way form controls are drawn. This e
text-align: right;
}
.label-on-left::part(hint) {
.label-on-left::part(form-control-help-text) {
grid-column-start: 2;
}
</style>
```
```

View File

@@ -1,8 +1,7 @@
---
title: Menu Item
description: Menu items provide options for the user to pick from in a menu.
tags: component
parent: menu
layout: component
---
```html {.example}

View File

@@ -1,8 +1,7 @@
---
title: Menu Label
description: Menu labels are used to describe a group of menu items.
tags: component
parent: menu
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Menu
description: Menus provide a list of options for the user to choose from.
tags: component
layout: component
---
You can use [menu items](/docs/components/menu-item), [menu labels](/docs/components/menu-label), and [dividers](/docs/components/divider) to compose a menu. Menus support keyboard interactions, including type-to-select an option.

View File

@@ -1,7 +1,7 @@
---
title: Mutation Observer
description: The Mutation Observer component offers a thin, declarative interface to the MutationObserver API.
tags: component
layout: component
---
The mutation observer will report changes to the content it wraps through the `wa-mutation` event. When emitted, a collection of [MutationRecord](https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord) objects will be attached to `event.detail` that contains information about how it changed.

View File

@@ -1,8 +1,7 @@
---
title: Option
description: Options define the selectable items within various form controls such as select.
tags: component
parent: select
layout: component
---
```html {.example}

View File

@@ -9,7 +9,9 @@ layout: blank
--menu-width: 15rem;
--aside-width: 15rem;
}
wa-page[view='desktop'] [data-toggle-nav] {
display: none;
}
wa-page[view='mobile'] {
--menu-width: auto;
--aside-width: auto;
@@ -233,4 +235,4 @@ layout: blank
<a href="#">Youth Audubon Camps</a>
</div>
</footer>
</wa-page>
</wa-page>

View File

@@ -305,7 +305,9 @@ layout: blank
--wa-tooltip-arrow-size: 0;
background-color: var(--wa-color-surface-lowered);
}
wa-page[view='desktop'] [data-toggle-nav] {
display: none;
}
wa-page[view='mobile'] {
--menu-width: auto;
}
@@ -396,4 +398,4 @@ layout: blank
font-size: 3rem;
padding: 1.5rem;
}
</style>
</style>

View File

@@ -1,7 +1,7 @@
---
title: Page
description: Pages offer an easy way to scaffold entire page layouts using minimal markup.
tags: component
layout: component
isPro: true
---
@@ -103,11 +103,11 @@ It can be opened using a button with `[data-toggle-nav]` that appears in the `su
<a href="#conservation">Conservation</a>
</nav>
<nav slot="navigation-footer">
<a href="#" class="wa-flank">
<a href="#" class="wa-flank" style="--flank-size: 1.25em;">
<wa-icon name="camera"></wa-icon>
<span>Photo Gallery</span>
</a>
<a href="#" class="wa-flank">
<a href="#" class="wa-flank" style="--flank-size: 1.25em;">
<wa-icon name="map-location-dot"></wa-icon>
<span>Interactive Range Map</span>
</a>
@@ -227,26 +227,18 @@ It can be opened using a button with `[data-toggle-nav]` that appears in the `su
--menu-width: 15rem;
--aside-width: 15rem;
}
wa-page[view='desktop'] {
[data-toggle-nav] {
display: none;
}
[slot*='navigation'] {
border-inline-end: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
wa-page[view='desktop'] [data-toggle-nav] {
display: none;
}
wa-page[view='mobile'] {
--menu-width: auto;
--aside-width: auto;
[slot='aside'],
#brand-name,
#search {
display: none;
}
}
wa-page[view='mobile'] [slot='aside'],
wa-page[view='mobile'] #brand-name,
wa-page[view='mobile'] #search {
display: none;
}
[slot='banner'] {
--wa-color-text-link: var(--wa-color-neutral-on-loud);
background-color: var(--wa-color-neutral-fill-loud);
@@ -265,16 +257,15 @@ It can be opened using a button with `[data-toggle-nav]` that appears in the `su
[slot='navigation-header'] {
border-block-end: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
wa-page[view='desktop'] [slot*='navigation'] {
border-inline-end: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
[slot*='navigation'] a {
--wa-color-text-link: var(--wa-color-text-normal);
}
[slot='navigation-footer'] {
border-block-start: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
[slot='navigation-footer'] .wa-flank {
--flank-size: 1.25em;
}
[slot='main-header'],
main,
[slot='main-footer'] {
@@ -290,11 +281,6 @@ It can be opened using a button with `[data-toggle-nav]` that appears in the `su
font-size: var(--wa-font-size-s);
}
</style>
<script>
const sectionAnchors = document.querySelectorAll("[slot*='navigation'] a[href*='#']");
sectionAnchors.forEach((sectionAnchor) => sectionAnchor.setAttribute("data-drawer", "close"));
</script>
```
### Media
@@ -608,22 +594,18 @@ A sample media app page using `header`, `navigation-header`, `main-header`, and
--wa-tooltip-arrow-size: 0;
background-color: var(--wa-color-surface-lowered);
}
wa-page[view='desktop'] {
:is([data-toggle-nav], #search-nav-drawer) {
display: none;
}
wa-page[view='desktop'] :is([data-toggle-nav], #search-nav-drawer) {
display: none;
}
wa-page[view='mobile'] {
--menu-width: auto;
#search-header {
display: none;
}
[slot*='main'], main {
padding: var(--wa-space-xl);
}
}
wa-page[view='mobile'] #search-header {
display: none;
}
wa-page[view='mobile'] :is([slot*='main'], main) {
padding: var(--wa-space-xl);
}
wa-page,
[slot='header'],
wa-page[view='desktop'] [slot*='navigation'] {
@@ -643,41 +625,37 @@ A sample media app page using `header`, `navigation-header`, `main-header`, and
padding-block-end: 0 !important;
padding-block-start: var(--wa-space-3xl);
}
[slot='navigation'] {
a {
--wa-color-text-link: var(--wa-color-text-normal);
--wa-link-decoration-default: none;
--wa-link-decoration-hover: none;
--flank-size: 2rem;
font-weight: var(--wa-font-weight-action);
gap: 0.5rem;
}
ul {
list-style: none;
margin: 0;
a {
border-radius: var(--wa-border-radius-s);
padding: var(--wa-space-xs);
&:hover {
background-color: color-mix(in oklab, var(--wa-color-surface-default), var(--wa-color-brand-fill-quiet));
}
}
}
wa-icon {
align-items: center;
aspect-ratio: 1;
color: var(--wa-color-brand-fill-loud);
display: flex;
height: var(--flank-size);
justify-content: center;
}
#recent wa-icon {
border-radius: var(--wa-border-radius-xs);
}
[slot='navigation'] a {
--wa-color-text-link: var(--wa-color-text-normal);
--wa-link-decoration-default: none;
--wa-link-decoration-hover: none;
--flank-size: 2rem;
font-weight: var(--wa-font-weight-action);
gap: 0.5rem;
}
[slot='navigation'] ul {
list-style: none;
margin: 0;
}
[slot='navigation'] ul a {
border-radius: var(--wa-border-radius-s);
padding: var(--wa-space-xs);
}
[slot='navigation'] ul a:hover,
main ol li:hover {
background-color: color-mix(in oklab, var(--wa-color-surface-default), var(--wa-color-brand-fill-quiet));
}
[slot='navigation'] wa-icon {
align-items: center;
aspect-ratio: 1;
color: var(--wa-color-brand-fill-loud);
display: flex;
height: var(--flank-size);
justify-content: center;
}
[slot='navigation'] #recent wa-icon {
border-radius: var(--wa-border-radius-xs);
}
[slot='main-header'] {
border-block-start: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
border-inline: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
@@ -689,18 +667,12 @@ A sample media app page using `header`, `navigation-header`, `main-header`, and
}
main ol li {
padding: var(--wa-space-m);
&:hover {
background-color: color-mix(in oklab, var(--wa-color-surface-default), var(--wa-color-brand-fill-quiet));
}
&:not(:first-child) {
border-block-start: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
.wa-flank {
--flank-size: 2rem;
}
}
main ol li .wa-flank {
--flank-size: 2rem;
}
main ol li:not(:first-child) {
border-block-start: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
}
main,
[slot='main-footer'] {
@@ -726,11 +698,6 @@ A sample media app page using `header`, `navigation-header`, `main-header`, and
max-inline-size: 30ch;
}
</style>
<script>
const sectionAnchors = document.querySelectorAll("[slot*='navigation'] a[href*='#']");
sectionAnchors.forEach((sectionAnchor) => sectionAnchor.setAttribute("data-drawer", "close"));
</script>
```
@@ -794,29 +761,11 @@ You can override the default display and flex properties for each slot with your
#### Responsive Navigation
When you use the `navigation` slot, your slotted content automatically collapses into a drawer on smaller screens.
The breakpoint at which this occurs is `768px` by default, but you can change it using the `mobile-breakpoint` attribute,
which takes either a number or a [CSS length](https://developer.mozilla.org/en-US/docs/Web/CSS/length).
The breakpoint at which this occurs is `768px` by default, but you can change it using the `mobile-breakpoint` attribute.
```html
<wa-page mobile-breakpoint="600"> ... </wa-page>
```
```html {.example viewport}
<wa-page mobile-breakpoint="50ch">
<div slot=navigation>Nav</div>
<header slot=header>
<div style="width: 50ch; background: gold">Im 50ch wide</div>
</header>
</wa-page>
<style>
html,
body {
min-height: 100%;
height: 100%;
padding: 0;
margin: 0;
}
</style>
```
By default, a "hamburger" button appears in the `header` slot to toggle the navigation menu on smaller screens.
You can customize what this looks like by slotting your own button in the `toggle-navigation` slot,
@@ -860,10 +809,9 @@ You can use a similar approach for `--aside-width` to hide the `aside` slot on s
```css
wa-page[view='mobile'] {
--aside-width: auto;
[slot='aside'] {
display: none;
}
}
wa-page[view='mobile'] [slot='aside'] {
display: none;
}
```

View File

@@ -1,7 +1,7 @@
---
title: Popup
description: 'Popup is a utility that lets you declaratively anchor "popup" containers to another element.'
tags: component
layout: component
---
This component's name is inspired by [`<popup>`](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/Popup/explainer.md). It uses [Floating UI](https://floating-ui.com/) under the hood to provide a well-tested, lightweight, and fully declarative positioning utility for tooltips, dropdowns, and more.

View File

@@ -1,7 +1,7 @@
---
title: Progress Bar
description: Progress bars are used to show the status of an ongoing operation.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Progress Ring
description: Progress rings are used to show the progress of a determinate operation in a circular fashion.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: QR Code
description: Generates a QR code and renders it using the Canvas API.
tags: component
layout: component
---
QR codes are useful for providing small pieces of information to users who can quickly scan them with a smartphone. Most smartphones have built-in QR code scanners, so simply pointing the camera at a QR code will decode it and allow the user to visit a website, dial a phone number, read a message, etc.

View File

@@ -1,8 +1,7 @@
---
title: Radio Button
description: Radios buttons allow the user to select a single option from a group using a button-like control.
tags: component
parent: radio-group
layout: component
---
Radio buttons are designed to be used with [radio groups](/docs/components/radio-group). When a radio button has focus, the arrow keys can be used to change the selected option just like standard radio controls.

View File

@@ -1,7 +1,7 @@
---
title: Radio Group
description: Radio groups are used to group multiple radios or radio buttons so they function as a single form control.
tags: component
layout: component
---
```html {.example}
@@ -14,12 +14,12 @@ tags: component
## Examples
### Hint
### Help Text
Add descriptive hint to a radio group with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
Add descriptive help text to a radio group with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html {.example}
<wa-radio-group label="Select an option" hint="Choose the most appropriate option." name="a" value="1">
<wa-radio-group label="Select an option" help-text="Choose the most appropriate option." name="a" value="1">
<wa-radio value="1">Option 1</wa-radio>
<wa-radio value="2">Option 2</wa-radio>
<wa-radio value="3">Option 3</wa-radio>
@@ -31,7 +31,7 @@ Add descriptive hint to a radio group with the `hint` attribute. For hints that
[Radio buttons](/docs/components/radio-button) offer an alternate way to display radio controls. In this case, an internal [button group](/docs/components/button-group) is used to group the buttons into a single, cohesive control.
```html {.example}
<wa-radio-group label="Select an option" hint="Select an option that makes you proud." name="a" value="1">
<wa-radio-group label="Select an option" help-text="Select an option that makes you proud." name="a" value="1">
<wa-radio-button value="1">Option 1</wa-radio-button>
<wa-radio-button value="2">Option 2</wa-radio-button>
<wa-radio-button value="3">Option 3</wa-radio-button>
@@ -137,4 +137,4 @@ Use the `setCustomValidity()` method to set a custom validation message. This wi
alert('All fields are valid!');
});
</script>
```
```

View File

@@ -1,8 +1,7 @@
---
title: Radio
description: Radios allow the user to select a single option from a group.
tags: component
parent: radio-group
layout: component
---
Radios are designed to be used with [radio groups](/docs/components/radio-group).

View File

@@ -1,7 +1,7 @@
---
title: Range
description: Ranges allow the user to select a single value within a given range using a slider.
tags: component
layout: component
---
```html {.example}
@@ -22,12 +22,12 @@ Use the `label` attribute to give the range an accessible label. For labels that
<wa-range label="Volume" min="0" max="100"></wa-range>
```
### Hint
### Help Text
Add descriptive hint to a range with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
Add descriptive help text to a range with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html {.example}
<wa-range label="Volume" hint="Controls the volume of the current song." min="0" max="100"></wa-range>
<wa-range label="Volume" help-text="Controls the volume of the current song." min="0" max="100"></wa-range>
```
### Min, Max, and Step

View File

@@ -1,7 +1,7 @@
---
title: Rating
description: Ratings give users a way to quickly view and provide feedback.
tags: component
layout: component
---
```html {.example}
@@ -138,4 +138,4 @@ You can also use the `getSymbol` property to render different icons based on val
return `<wa-icon name="${icons[value - 1]}"></wa-icon>`;
};
</script>
```
```

View File

@@ -1,7 +1,7 @@
---
title: Relative Time
description: Outputs a localized time phrase relative to the current date and time.
tags: component
layout: component
---
Localization is handled by the browser's [`Intl.RelativeTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat). No language packs are required.

View File

@@ -1,7 +1,7 @@
---
title: Resize Observer
description: The Resize Observer component offers a thin, declarative interface to the ResizeObserver API.
tags: component
layout: component
---
The resize observer will report changes to the dimensions of the elements it wraps through the `wa-resize` event. When emitted, a collection of [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) objects will be attached to `event.detail` that contains the target element and information about its dimensions.

View File

@@ -1,8 +1,7 @@
---
title: Select
description: Selects allow you to choose items from a menu of predefined options.
tags: component
natives: input
layout: component
---
```html {.example}
@@ -34,12 +33,12 @@ Use the `label` attribute to give the select an accessible label. For labels tha
</wa-select>
```
### Hint
### Help Text
Add descriptive hint to a select with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
Add descriptive help text to a select with the `help-text` attribute. For help texts that contain HTML, use the `help-text` slot instead.
```html {.example}
<wa-select label="Experience" hint="Please tell us your skill level.">
<wa-select label="Experience" help-text="Please tell us your skill level.">
<wa-option value="1">Novice</wa-option>
<wa-option value="2">Intermediate</wa-option>
<wa-option value="3">Advanced</wa-option>
@@ -70,12 +69,12 @@ Use the `clearable` attribute to make the control clearable. The clear button on
</wa-select>
```
### Appearance
### Filled Selects
Use the `appearance` attribute to change the select's visual appearance.
Add the `filled` attribute to draw a filled select.
```html {.example}
<wa-select appearance="filled">
<wa-select filled>
<wa-option value="option-1">Option 1</wa-option>
<wa-option value="option-2">Option 2</wa-option>
<wa-option value="option-3">Option 3</wa-option>
@@ -413,4 +412,4 @@ This can be hard to conceptualize, so heres a fairly large example showing how l
container.addEventListener("click", addFooOption)
container.addEventListener("submit", handleLazySubmit)
</script>
```
```

View File

@@ -1,7 +1,7 @@
---
title: Skeleton
description: Skeletons are used to provide a visual representation of where content will eventually be drawn.
tags: component
layout: component
---
These are simple containers for scaffolding layouts that mimic what users will see when content has finished loading. This prevents large areas of empty space during asynchronous operations.

View File

@@ -1,7 +1,7 @@
---
title: Spinner
description: Spinners are used to show the progress of an indeterminate operation.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Split Panel
description: Split panels display two adjacent panels, allowing the user to reposition them.
tags: component
layout: component
---
```html {.example}

View File

@@ -1,7 +1,7 @@
---
title: Switch
description: Switches allow the user to toggle an option on or off.
tags: component
layout: component
---
```html {.example}
@@ -42,12 +42,12 @@ Use the `size` attribute to change a switch's size.
<wa-switch size="large">Large</wa-switch>
```
### Hint
### Help Text
Add descriptive hint to a switch with the `hint` attribute. For hints that contain HTML, use the `hint` slot instead.
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 {.example}
<wa-switch hint="What should the user know about the switch?">Label</wa-switch>
<wa-switch help-text="What should the user know about the switch?">Label</wa-switch>
```
### Custom Styles

View File

@@ -1,7 +1,7 @@
---
title: Tab Group
description: Tab groups organize content into a container that shows one section at a time.
tags: component
layout: component
---
Tab groups make use of [tabs](/docs/components/tab) and [tab panels](/docs/components/tab-panel). Each panel should have a name that's unique within the tab group, and tabs should have a `panel` attribute that points to the respective panel's name.
@@ -125,7 +125,7 @@ You can make a tab closable by adding a close button next to the tab and inside
const closableTab = tabGroup.querySelectorAll('wa-tab')[1];
const closeButton = tabGroup.querySelector('wa-icon-button');
const restoreButton = tabGroup.nextElementSibling.nextElementSibling;
// Remove the tab when the close button is clicked
closeButton.addEventListener('click', () => {
closableTab.remove();

View File

@@ -1,8 +1,7 @@
---
title: Tab Panel
description: Tab panels are used inside tab groups to display tabbed content.
tags: component
parent: tab-group
layout: component
---
```html {.example}

View File

@@ -1,10 +1,9 @@
---
title: Tab
description: Tabs are used inside tab groups to represent and activate tab panels.
tags: component
parent: tab-group
layout: component
---
:::info
Additional demonstrations can be found in the [tab group examples](/docs/components/tab-group).
:::
:::

View File

@@ -1,7 +1,7 @@
---
title: Tag
description: Tags are used as labels to organize things or to indicate a selection.
tags: component
layout: component
---
```html {.example}

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