diff --git a/docs/_includes/base.njk b/docs/_includes/base.njk index 8662da1ab..b21d537df 100644 --- a/docs/_includes/base.njk +++ b/docs/_includes/base.njk @@ -6,7 +6,7 @@ - + diff --git a/docs/_includes/head.njk b/docs/_includes/head.njk index 3235daf7d..1121fd1d8 100644 --- a/docs/_includes/head.njk +++ b/docs/_includes/head.njk @@ -28,6 +28,7 @@ {# Web Awesome #} + {# Preset Theme #} {% if not forceTheme %} @@ -44,6 +45,7 @@ if (localStorage.presetTheme) { link.after(newLink); } + {% endif %} diff --git a/docs/_includes/preset-theme-selector.njk b/docs/_includes/preset-theme-selector.njk index 5959ffc5e..2b57b1389 100644 --- a/docs/_includes/preset-theme-selector.njk +++ b/docs/_includes/preset-theme-selector.njk @@ -1,14 +1,9 @@ {# Preset theme selector #} - Default - Classic - Awesome - Active - Brutalist - Glassy - Mellow - Tailspin - Playful - Premium + {% for theme in collections.theme | sort %} + + {{ theme.data.title }} + + {% endfor %} diff --git a/docs/_includes/sidebar.njk b/docs/_includes/sidebar.njk index b5e5d570e..1e99e57e8 100644 --- a/docs/_includes/sidebar.njk +++ b/docs/_includes/sidebar.njk @@ -3,7 +3,6 @@ {% for tag, title in { + 'themes': 'Themes', 'components': 'Components', 'native': 'Native Styles', 'utilities': 'Style Utilities', diff --git a/docs/_includes/status.njk b/docs/_includes/status.njk index d91b9cee6..3ba32a88f 100644 --- a/docs/_includes/status.njk +++ b/docs/_includes/status.njk @@ -1,25 +1,25 @@ {% if since -%} Since {{ since }} -{%- endif %} +{% endif -%} -{% if status -%} +{%- if status %} {%- if status == "wip" %} Work In Progress - {%- elif status == "experimental" -%} + {%- elif status == "experimental" %} Experimental - {%- elif status == "stable" -%} + {%- elif status == "stable" %} Stable {%- else %} {{ status}} - {%- endif %} + {%- endif -%} {%- endif %} -{% if isPro -%} +{%- if isPro %} PRO -{%- endif %} +{%- endif -%} diff --git a/docs/_includes/theme-showcase.njk b/docs/_includes/theme-showcase.njk new file mode 100644 index 000000000..d0b72966c --- /dev/null +++ b/docs/_includes/theme-showcase.njk @@ -0,0 +1,144 @@ + diff --git a/docs/_layouts/theme.njk b/docs/_layouts/theme.njk new file mode 100644 index 000000000..570ed4e4b --- /dev/null +++ b/docs/_layouts/theme.njk @@ -0,0 +1,85 @@ +{% set hasSidebar = true %} +{% set hasOutline = true %} +{# {% set forceTheme = page.fileSlug %} #} + +{% extends '../_includes/base.njk' %} + +{% block header %} + +{% endblock %} + +{% block afterContent %} +{% markdown %} +## How to use this theme + +You can import this theme from the Web Awesome CDN. + + +In HTML +In CSS + + +Simply add the following code to the `` of your page: +```html + +``` + + + +Simply add the following code at the top of your CSS file: +```css +@import url('{% cdnUrl 'styles/themes/' + page.fileSlug + '.css' %}'); +``` + + + +## Dark mode + +To activate the dark color scheme of the theme on any element and its contents, apply the class `wa-dark` to it. +This means you can use different color schemes throughout the page. +Here, we use the default theme with a dark sidebar: + +```html + + + + + + + + + + + +``` + +You can apply the class to the `` element on your page to activate the dark color scheme for the entire page. + +```html + + + + + + + + + +``` +### Detecting Color Scheme Preference + +Web Awesome's themes have both light and dark styles built in. +However, Web Awesome doesn't try to auto-detect the user's light/dark mode preference. +This should be done at the application level. +As a best practice, to provide a dark theme in your app, you should: + +- Check for [`prefers-color-scheme`](https://stackoverflow.com/a/57795495/567486) and use its value by default +- Allow the user to override the setting in your app +- Remember the user's preference and restore it on subsequent logins + +Web Awesome avoids using the `prefers-color-scheme` media query because not all apps support dark mode, and it would break things for the ones that don't. + +{% endmarkdown %} +{% endblock %} diff --git a/docs/_utils/filters.js b/docs/_utils/filters.js index 171081a63..5f672881a 100644 --- a/docs/_utils/filters.js +++ b/docs/_utils/filters.js @@ -167,6 +167,9 @@ export function sort(arr, by = { 'data.order': 1, 'data.title': '' }) { * @returns { Object. } An object with keys for each tag, and an array of items for each tag. */ export function groupByTags(collection, tags) { + if (!collection) { + console.error(`Empty collection passed to groupByTags() to group by ${JSON.stringify(tags)}`); + } if (!tags) { // Default to grouping by union of all tags tags = Array.from(new Set(collection.flatMap(item => item.data.tags))); diff --git a/docs/assets/scripts/preset-theme-picker.js b/docs/assets/scripts/preset-theme-picker.js new file mode 100644 index 000000000..b51cfeb9d --- /dev/null +++ b/docs/assets/scripts/preset-theme-picker.js @@ -0,0 +1,64 @@ +import { domChange, nextFrame, ThemeAspect } from './theme-picker.js'; + +const presetTheme = new ThemeAspect({ + defaultValue: 'default', + key: 'presetTheme', + picker: 'wa-select.preset-theme-selector', + + applyChange() { + const oldStylesheets = [...document.querySelectorAll('#theme-stylesheet')]; + const oldStylesheet = oldStylesheets.pop(); + + if (oldStylesheets.length > 0) { + // Remove all but the last one + for (let stylesheet of oldStylesheets) { + stylesheet.remove(); + } + } + + const href = `/dist/styles/themes/${this.value}.css`; + + if (!oldStylesheet || oldStylesheet.getAttribute('href') !== href) { + const newStylesheet = document.createElement('link'); + Object.assign(newStylesheet, { href, id: 'theme-stylesheet', rel: 'preload', as: 'style' }); + oldStylesheet.after(newStylesheet); + + newStylesheet.addEventListener( + 'load', + e => { + domChange( + async instant => { + // Swap stylesheets + newStylesheet.rel = 'stylesheet'; + + if (instant) { + // If no VT, delay by 1 frame to make it smoother + await nextFrame(); + } + + oldStylesheet.remove(); + }, + { behavior: 'smooth' }, + ); + }, + { once: true }, + ); + } + }, +}); + +/** + * Without this, there's a flash of the incorrect preset theme. + */ +function updateSelectionBeforeTurboLoad(e) { + const newElement = e.detail.newBody || e.detail.newFrame || e.detail.newStream; + if (newElement) { + presetTheme.syncUI(newElement); + } +} + +['turbo:before-render', 'turbo:before-stream-render', 'turbo:before-frame-render'].forEach(eventName => { + document.addEventListener(eventName, updateSelectionBeforeTurboLoad); +}); + +window.presetTheme = presetTheme; diff --git a/docs/assets/scripts/sync-iframe-height.js b/docs/assets/scripts/sync-iframe-height.js new file mode 100644 index 000000000..1e74f0266 --- /dev/null +++ b/docs/assets/scripts/sync-iframe-height.js @@ -0,0 +1,37 @@ +/** + * Sync iframe height with its content page (for same-origin iframes) + * NOT CURRENTLY USED ANYWHERE + */ +for (let iframe of document.querySelectorAll('iframe')) { + if (iframe.contentDocument) { + // Already loaded + syncIframeHeight(iframe); + } + + iframe.onload = () => { + console.log('iframe loaded'); + if (iframe.contentDocument) { + // Same origin + iframe.contentWindow.iframe = iframe; + syncIframeHeight(iframe); + const resizeObserver = new ResizeObserver(entries => { + for (let entry of entries) { + if (entry.target === iframe.contentDocument.body) { + syncIframeHeight(iframe); + } + } + }); + + resizeObserver.observe(iframe.contentDocument.body); + window.addEventListener('turbo:render', syncIframeHeight(iframe)); + } + }; +} + +function syncIframeHeight(iframe) { + iframe.style.height = '0px'; + + requestAnimationFrame(() => { + iframe.style.height = iframe.contentDocument.body.scrollHeight + 'px'; + }); +} diff --git a/docs/assets/scripts/theme-picker.js b/docs/assets/scripts/theme-picker.js index 85ec091fc..c5c1b8368 100644 --- a/docs/assets/scripts/theme-picker.js +++ b/docs/assets/scripts/theme-picker.js @@ -10,7 +10,7 @@ export function domChange(fn, { behavior = 'smooth' } = {}) { } } -function nextFrame() { +export function nextFrame() { return new Promise(resolve => requestAnimationFrame(resolve)); } @@ -75,55 +75,6 @@ export class ThemeAspect { } } -const presetTheme = new ThemeAspect({ - defaultValue: 'default', - key: 'presetTheme', - picker: 'wa-select.preset-theme-selector', - - applyChange() { - const oldStylesheets = [...document.querySelectorAll('#theme-stylesheet')]; - const oldStylesheet = oldStylesheets.pop(); - - if (oldStylesheets.length > 0) { - // Remove all but the last one - for (let stylesheet of oldStylesheets) { - stylesheet.remove(); - } - } - - const href = `/dist/styles/themes/${this.value}.css`; - - if (!oldStylesheet || oldStylesheet.getAttribute('href') !== href) { - const newStylesheet = document.createElement('link'); - Object.assign(newStylesheet, { href, id: 'theme-stylesheet', rel: 'preload', as: 'style' }); - oldStylesheet.after(newStylesheet); - - newStylesheet.addEventListener( - 'load', - e => { - domChange( - async instant => { - // Swap stylesheets - newStylesheet.rel = 'stylesheet'; - - if (instant) { - // If no VT, delay by 1 frame to make it smoother - await nextFrame(); - } - - oldStylesheet.remove(); - }, - { behavior: 'smooth' }, - ); - }, - { once: true }, - ); - - nextFrame().then(_ => updateThemeNameAndDescription()); - } - }, -}); - const colorScheme = new ThemeAspect({ defaultValue: 'auto', key: 'colorScheme', @@ -152,23 +103,6 @@ const colorScheme = new ThemeAspect({ // Update the color scheme when the preference changes window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => colorScheme.set()); -/** - * Without this, there's a flash of the incorrect preset theme. - */ -function updateSelectionBeforeTurboLoad(e) { - const newElement = e.detail.newBody || e.detail.newFrame || e.detail.newStream; - if (newElement) { - presetTheme.syncUI(newElement); - colorScheme.syncUI(newElement); - } -} - -['turbo:before-render', 'turbo:before-stream-render', 'turbo:before-frame-render'].forEach(eventName => { - document.addEventListener(eventName, updateSelectionBeforeTurboLoad); -}); - -document.addEventListener('turbo:render', updateThemeNameAndDescription); - // Toggle color scheme with backslash document.addEventListener('keydown', event => { if ( @@ -179,22 +113,3 @@ document.addEventListener('keydown', event => { colorScheme.set(theming.colorScheme.resolvedValue === 'dark' ? 'light' : 'dark'); } }); - -// Temp hack for theme switcher -function updateThemeNameAndDescription() { - let selectedOption = document.querySelector(`.preset-theme-selector wa-option[value="${presetTheme.value}"]`); - - if (selectedOption) { - let title = selectedOption.textContent; - let description = selectedOption.dataset.description; - for (let element of document.querySelectorAll('[data-theme-name]')) { - element.textContent = title; - } - for (let element of document.querySelectorAll('[data-theme-description]')) { - element.textContent = description; - } - } -} -updateThemeNameAndDescription(); - -window.presetTheme = presetTheme; diff --git a/docs/assets/styles/docs.css b/docs/assets/styles/docs.css index fbacdc16a..c68026859 100644 --- a/docs/assets/styles/docs.css +++ b/docs/assets/styles/docs.css @@ -455,3 +455,20 @@ wa-page > main:has(> .index-grid) { padding: var(--wa-space-3xl); } } + +.layout-theme { + wa-page > main { + max-width: 140ch; + + .max-line-length { + max-width: 80ch; + } + } + + iframe { + width: 100%; + min-height: 16lh; + height: 65vh; + max-height: 21lh; + } +} diff --git a/docs/docs/components/page.md b/docs/docs/components/page.md index 2cbf41976..f23f0b893 100644 --- a/docs/docs/components/page.md +++ b/docs/docs/components/page.md @@ -1,7 +1,7 @@ --- title: Page description: Pages offer an easy way to scaffold entire page layouts using minimal markup. -tags: [organization, layout] +tags: [pro, organization, layout] isPro: true order: 0 # icon: page diff --git a/docs/docs/customizing.md b/docs/docs/customizing.md index 78c0e336c..95782eac9 100644 --- a/docs/docs/customizing.md +++ b/docs/docs/customizing.md @@ -15,7 +15,7 @@ Because these custom properties live at the page level, they're prefixed with `- To customize a theme, simply override any of these custom properties in your own stylesheet by scoping your styles to `:root`, `:host`, and, if needed, the class for the specific theme you want to override. Here's an example that changes the default brand color (blue) to violet in the light theme using existing [literal colors](/docs/theming/color/#literal-colors). ```css -:root, +:where(:root), :host, .wa-theme-default { /* Changes the brand color to violet across the library */ diff --git a/docs/docs/themes/active.md b/docs/docs/themes/active.md new file mode 100644 index 000000000..bf8d99fde --- /dev/null +++ b/docs/docs/themes/active.md @@ -0,0 +1,6 @@ +--- +title: Active +description: Energetic and tactile, always in motion. +isPro: true +tags: pro +--- diff --git a/docs/docs/themes/awesome.md b/docs/docs/themes/awesome.md new file mode 100644 index 000000000..019d31a48 --- /dev/null +++ b/docs/docs/themes/awesome.md @@ -0,0 +1,5 @@ +--- +title: Awesome +description: Punchy and vibrant, the rockstar of themes. +order: 0.2 +--- diff --git a/docs/docs/themes/brutalist.md b/docs/docs/themes/brutalist.md new file mode 100644 index 000000000..a38b4382d --- /dev/null +++ b/docs/docs/themes/brutalist.md @@ -0,0 +1,6 @@ +--- +title: Brutalist +description: Sharp, square, and unapologetically bold. +isPro: true +tags: pro +--- diff --git a/docs/docs/themes/classic.md b/docs/docs/themes/classic.md new file mode 100644 index 000000000..6cbd4e397 --- /dev/null +++ b/docs/docs/themes/classic.md @@ -0,0 +1,5 @@ +--- +title: Classic +description: Timeless elegance that never goes out of style. +order: 0.1 +--- diff --git a/docs/docs/themes/creating.md b/docs/docs/themes/creating.md new file mode 100644 index 000000000..a64c0d836 --- /dev/null +++ b/docs/docs/themes/creating.md @@ -0,0 +1,59 @@ +--- +title: Creating Themes +layout: page-outline +order: 999 +override:tags: [themes] +--- + +There are two ways to create themes. +The easiest way is to customize the default theme. +The advanced way is to create a new theme from scratch. +Which method you choose depends on your project's requirements and the amount of effort you're willing to invest. + +## Customizing a Built-in Theme + +Overriding the default theme is the easiest way to customize Web Awesome. +You can do this by importing the default theme as-is, then creating a separate stylesheet that overrides [the theming API](/docs/customizing#design-tokens) and adds [component styles](/docs/customizing#css-parts) to your liking. You must import your theme _after_ the default theme. + +If you're customizing the default light styles, scope your styles to the following selectors. + +```css +:where(:root), +:host, +.wa-theme-default, +.wa-light { + /* your custom styles here */ +} +``` + +If you're customizing the default dark styles, scope your styles to the following selectors. + +```css +.wa-dark, +:is(:host-context(.wa-dark)) { + /* your custom styles here */ +} +``` + +By customizing a built-in theme, you'll maintain a smaller stylesheet containing only your changes. Contrast this to [creating a new theme](#creating-a-new-theme), where you need to explicitly define every custom property required by the library. This approach is more "future-proof," as new design tokens that emerge in subsequent versions of Web Awesome will be accounted for by built-in themes. + +While this approach is easier to maintain, the drawback is that your theme can't be activated independently — it's tied to the built-in theme you're extending. + +## Creating a New Theme + +Creating a new theme is more of an undertaking than [customizing an existing one](#customizing-a-built-in-theme). At a minimum, you must implement all of the required custom properties. The easiest way to do this is by "forking" a built-in theme and modifying it from there. + +Start by changing the selector to match your theme's name. Assuming your new theme is called "Purple Power", your theme should be scoped like this. + +```css +:where(:root), +:host, +.wa-theme-purple-power, +.wa-light { + /* your custom styles here */ +} +``` + +By creating a new theme, you won't be relying on a built-in theme as a foundation. Because of this, you can activate it independently as an alternative to the default theme. This is the recommended approach if you're looking to open source your theme for others to use. + +You will, however, need to maintain your theme more carefully, as new versions of Web Awesome change the theming API in ways that your theme won't have accounted for. It's recommended that you clearly specify which version(s) of Web Awesome your theme is designed to work with and keep it up to date as new versions of Web Awesome are released. diff --git a/docs/docs/themes/default.md b/docs/docs/themes/default.md new file mode 100644 index 000000000..ad302846b --- /dev/null +++ b/docs/docs/themes/default.md @@ -0,0 +1,5 @@ +--- +title: Default +description: Your trusty companion, like a perfectly broken-in pair of jeans. +order: 0 +--- diff --git a/docs/docs/themes/demo.njk b/docs/docs/themes/demo.njk new file mode 100644 index 000000000..ee54aa408 --- /dev/null +++ b/docs/docs/themes/demo.njk @@ -0,0 +1,40 @@ +--- +layout: blank +pagination: + data: collections.theme + size: 1 + alias: theme +permalink: '/docs/themes/{{ theme.fileSlug }}/demo.html' +eleventyExcludeFromCollections: true +override:tags: [] +eleventyComputed: + forceTheme: "{{ theme.fileSlug }}" +--- + + + + + + +{% set content %} +
+ {% include 'breadcrumbs.njk' %} +

{{ theme.data.title }}

+

{% include 'status.njk' %}

+

{{ theme.data.description | inlineMarkdown | safe }}

+
+{% include 'theme-showcase.njk' %} +{% endset %} + + + + + diff --git a/docs/docs/themes/glassy.md b/docs/docs/themes/glassy.md new file mode 100644 index 000000000..a008d30a8 --- /dev/null +++ b/docs/docs/themes/glassy.md @@ -0,0 +1,7 @@ +--- +title: Glassy +description: Smooth, sleek, and reflective. +isPro: true +tags: pro +noAlpha: true +--- diff --git a/docs/docs/themes/index.md b/docs/docs/themes/index.md deleted file mode 100644 index ad711c47f..000000000 --- a/docs/docs/themes/index.md +++ /dev/null @@ -1,328 +0,0 @@ ---- -title: Themes -description: Everything you need to know about theming Web Awesome. -layout: page-outline ---- - - - -
-
-

-

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
- -Themes are collections of pre-defined CSS custom properties that thread through every Web Awesome component and pattern. - -Web Awesome Free includes these pre-made themes: -- **Default** (`default.css`) for a clean look that prioritizes accessibility and performance -- **Classic** (`classic.css`) for the look and feel of Shoelace with more accessible color pairings -- **Awesome** (`awesome.css`) for the familiar, vibrant styles from your friends at Font Awesome - -Even more themes are available with Web Awesome Pro: -- **Active** (`active.css`) -- **Brutalist** (`brutalist.css`) -- **Mellow** (`mellow.css`) -- **Tailspin** (`tailspin.css`) - -To get started right away, include the following in your project, replacing `default.css` at the end with your preferred pre-made theme: -```html - -``` - - -## What's a Theme? - -Themes are a collection of standardized [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) that cover a range of styles from colors to transitions. We use these custom properties throughout Web Awesome components for a cohesive look and feel. Our [Theming pages](/docs/theming/) document these styles so that you can use them freely throughout your project and customize them as needed. - -Themes are scoped to unique classes, such as `wa-theme-default` or `wa-theme-classic`. Scoping to unique classes allows you to import multiple themes and use them interchangeably without collisions. - -Each theme may also include both light and dark color schemes with the classes `wa-light` and `wa-dark`. -You can use these classes to apply a specific color scheme to an entire page or just a section. -In pre-made themes, we use a light color scheme by default. - - -Additionally, styles may be scope to the `:root` selector to be activated automatically. -For pre-made themes, *all* custom properties are scoped to `:where(:root)`, the theme class, and `wa-light`. - -:::info -We use `:where(:root)` to give these styles 0 [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) so that they can be easily overridden. If you plan on using multiple themes in your project, we recommend doing the same for your custom themes. -::: - -Finally, we scope themes to `:host` and `:host-context()` to ensure the styles are applied to the shadow roots of custom elements. - -For example, the default theme is set up like this: - -```css -:where(:root), -:host, -.wa-theme-default, -.wa-light { - /* all CSS custom properties for color, typography, space, etc. */ -} - -.wa-dark, -:host-context(.wa-dark) { - /* subset of CSS custom properties for a dark color scheme */ -} -``` - -## Using Themes - -You can import pre-made themes from the Web Awesome CDN. Simply add the following code to the `` of your page to import the **default** theme: - -```html - -``` - -Or the **Classic** theme: - -```html - -``` - -Or any of our Pro themes, like **Brutalist**: - -```html - -``` - - To activate the dark color scheme of any theme, apply the class `wa-dark` to the `` element on your page, like this example for the default theme: -```html - - - - - - - - - -``` - -Because themes are scoped to specific classes, you can use different color schemes or even different themes throughout the page. Here, we use the default theme with a dark sidebar: - -```html - - - - - - - - - - - -``` - -## Creating Themes - -There are two ways to create themes. The easiest way is to customize the default theme. The advanced way is to create a new theme from scratch. Which method you choose depends on your project's requirements and the amount of effort you're willing to invest. - -### Customizing a Built-in Theme - -Overriding the default theme is the easiest way to customize Web Awesome. You can do this by importing the default theme as-is, then creating a separate stylesheet that overrides [the theming API](/docs/customizing#design-tokens) and adds [component styles](/docs/customizing#css-parts) to your liking. You must import your theme _after_ the default theme. - -If you're customizing the default light styles, scope your styles to the following selectors. - -```css -:root, -:host, -.wa-theme-default, -.wa-light { - /* your custom styles here */ -} -``` - -If you're customizing the default dark styles, scope your styles to the following selectors. - -```css -.wa-dark, -:is(:host-context(.wa-dark)) { - /* your custom styles here */ -} -``` - -By customizing a built-in theme, you'll maintain a smaller stylesheet containing only your changes. Contrast this to [creating a new theme](#creating-a-new-theme), where you need to explicitly define every custom property required by the library. This approach is more "future-proof," as new design tokens that emerge in subsequent versions of Web Awesome will be accounted for by built-in themes. - -While this approach is easier to maintain, the drawback is that your theme can't be activated independently — it's tied to the built-in theme you're extending. - -### Creating a New Theme - -Creating a new theme is more of an undertaking than [customizing an existing one](#customizing-a-built-in-theme). At a minimum, you must implement all of the required custom properties. The easiest way to do this is by "forking" a built-in theme and modifying it from there. - -Start by changing the selector to match your theme's name. Assuming your new theme is called "Purple Power", your theme should be scoped like this. - -```css -:root, -:host, -.wa-theme-purple-power, -.wa-light { - /* your custom styles here */ -} -``` - -By creating a new theme, you won't be relying on a built-in theme as a foundation. Because of this, you can activate it independently as an alternative to the default theme. This is the recommended approach if you're looking to open source your theme for others to use. - -You will, however, need to maintain your theme more carefully, as new versions of Web Awesome change the theming API in ways that your theme won't have accounted for. It's recommended that you clearly specify which version(s) of Web Awesome your theme is designed to work with and keep it up to date as new versions of Web Awesome are released. - -## Detecting Color Scheme Preference - -Web Awesome's default theme has both light and dark styles built in. However, Web Awesome doesn't try to auto-detect the user's light/dark mode preference. This should be done at the application level. As a best practice, to provide a dark theme in your app, you should: - -- Check for [`prefers-color-scheme`](https://stackoverflow.com/a/57795495/567486) and use its value by default -- Allow the user to override the setting in your app -- Remember the user's preference and restore it on subsequent logins - -Web Awesome avoids using the `prefers-color-scheme` media query because not all apps support dark mode, and it would break things for the ones that don't. -
diff --git a/docs/docs/themes/index.njk b/docs/docs/themes/index.njk new file mode 100644 index 000000000..16c3323f2 --- /dev/null +++ b/docs/docs/themes/index.njk @@ -0,0 +1,55 @@ +--- +title: Themes +description: Themes are collections of pre-defined CSS custom properties that thread through every Web Awesome component and pattern. +layout: overview +override:tags: [] +forTag: theme +categories: + other: Free + pro: Pro +--- + +
+{% markdown %} + +## What's a Theme? + +Themes are a collection of standardized [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) that cover a range of styles from colors to transitions. We use these custom properties throughout Web Awesome components for a cohesive look and feel. Our [Theming pages](/docs/theming/) document these styles so that you can use them freely throughout your project and customize them as needed. + +Themes are scoped to unique classes, such as `wa-theme-default` or `wa-theme-classic`. +Scoping to unique classes allows you to import multiple themes and use them interchangeably without collisions. +Please note that if you import multiple themes, the last one will be the default that will apply if no class is used. + +Each theme may also include both light and dark color schemes with the classes `wa-light` and `wa-dark`. +You can use these classes to apply a specific color scheme to an entire page or just a section. +In pre-made themes, we use a light color scheme by default. + + +Additionally, styles may be scoped to the `:root` selector to be activated automatically. +For pre-made themes, *all* custom properties are scoped to `:root`, the theme class, and `wa-light`. + +Finally, we scope themes to `:host` and `:host-context()` to ensure the styles are applied to the shadow roots of custom elements. + +For example, the default theme is set up like this: + +```css +:where(:root), +:host, +.wa-theme-default, +.wa-light { + /* all CSS custom properties for color, typography, space, etc. */ +} + +.wa-dark, +:host-context(.wa-dark) { + /* subset of CSS custom properties for a dark color scheme */ +} +``` + +## Using Themes + +You can import pre-made themes from the Web Awesome CDN. +Refer to each theme’s page for copyable code snippets. + +{% endmarkdown %} +
diff --git a/docs/docs/themes/mellow.md b/docs/docs/themes/mellow.md new file mode 100644 index 000000000..ebd2fb8af --- /dev/null +++ b/docs/docs/themes/mellow.md @@ -0,0 +1,6 @@ +--- +title: Mellow +description: Soft and soothing, like a lazy Sunday morning. +isPro: true +tags: pro +--- diff --git a/docs/docs/themes/playful.md b/docs/docs/themes/playful.md new file mode 100644 index 000000000..007bfa2b2 --- /dev/null +++ b/docs/docs/themes/playful.md @@ -0,0 +1,7 @@ +--- +title: Playful +description: Fun, colorful, and full of personality. +isPro: true +tags: pro +noAlpha: true +--- diff --git a/docs/docs/themes/premium.md b/docs/docs/themes/premium.md new file mode 100644 index 000000000..6f41c59af --- /dev/null +++ b/docs/docs/themes/premium.md @@ -0,0 +1,7 @@ +--- +title: Premium +description: The ultimate in sophistication and style. +isPro: true +tags: pro +noAlpha: true +--- diff --git a/docs/docs/themes/showcase.css b/docs/docs/themes/showcase.css index 3248dc119..1e7c7478b 100644 --- a/docs/docs/themes/showcase.css +++ b/docs/docs/themes/showcase.css @@ -1,26 +1,40 @@ -wa-page > main { - max-width: 140ch; +html { + background: transparent; +} - .max-line-length { - max-width: 80ch; - } +html, +body, +.theme-showcase { + height: 100vh; + overflow: hidden; } .theme-showcase { - container: showcase / inline-size; - background-color: var(--wa-color-surface-lowered); border-radius: var(--wa-border-radius-l); - min-height: 16lh; - height: 65vh; - max-height: 21lh; padding: var(--wa-space-xl); + box-sizing: border-box; overflow: hidden; - margin-block-end: var(--wa-space-xl); - &.wa-flank { - --content-percentage: 60%; - --flank-size: 25ch; + @media (width < 500px) { + flex-flow: column; + } + + header { + min-width: min(25ch, 100vw); + align-self: center; + + h1 { + margin-bottom: var(--wa-space-2xs); + } + + wa-breadcrumb-item:not(:first-of-type, :last-of-type) { + display: none; + } + + p:empty { + display: none; + } } } @@ -40,54 +54,37 @@ wa-page > main { margin-block-end: var(--wa-space-xl); } } -} -@supports not (zoom: 1) { - .showcase-examples { + @supports not (zoom: 1) { column-count: 1; - } - @container showcase (width > 750px) { - .showcase-examples { + @media (width > 750px) { column-count: 2; } - } - @container showcase (width > 950px) { - .showcase-examples { + @media (width > 950px) { column-count: 3; } } -} -@supports (zoom: 1) { - .showcase-examples { + @supports (zoom: 1) { column-count: 1; zoom: 40%; - } - @container showcase (width > 350px) { - .showcase-examples { + @media (width > 350px) { column-count: 2; } - } - @container showcase (width > 450px) { - .showcase-examples { + @media (width > 450px) { zoom: 55%; } - } - @container showcase (width > 750px) { - .showcase-examples { + @media (width > 750px) { zoom: 70%; } - } - @container showcase (width > 950px) { - .showcase-examples { + @media (width > 950px) { column-count: 3; - zoom: 70%; } } } diff --git a/docs/docs/themes/tailspin.md b/docs/docs/themes/tailspin.md new file mode 100644 index 000000000..10ae2984f --- /dev/null +++ b/docs/docs/themes/tailspin.md @@ -0,0 +1,6 @@ +--- +title: Tailspin +description: Like a bird in flight, guiding you from there to here. +isPro: true +tags: pro +--- diff --git a/docs/docs/themes/themes.json b/docs/docs/themes/themes.json new file mode 100644 index 000000000..484a809ee --- /dev/null +++ b/docs/docs/themes/themes.json @@ -0,0 +1,4 @@ +{ + "layout": "theme.njk", + "tags": ["themes", "theme"] +}