mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
update brand color too
This commit is contained in:
@@ -30,6 +30,7 @@ layout: page
|
||||
data-description="{{ theme.description }}"
|
||||
data-title="{{ theme.name }}"
|
||||
data-palette="{{ theme.palette.filename | stripExtension}}"
|
||||
data-brand="{{ theme.colorBrand.color }}"
|
||||
{% if theme.isPro %}data-is-pro{% endif %}
|
||||
>
|
||||
{{ theme.name }}
|
||||
@@ -44,6 +45,7 @@ layout: page
|
||||
data-description="{{ theme.description }}"
|
||||
data-title="{{ theme.name }}"
|
||||
data-palette="{{ theme.palette.filename | stripExtension}}"
|
||||
data-brand="{{ theme.colorBrand.color }}"
|
||||
{% if theme.isPro %}data-is-pro{% endif %}
|
||||
>
|
||||
{{ theme.name }}
|
||||
@@ -88,7 +90,7 @@ layout: page
|
||||
<p>
|
||||
To import this theme, apply the following classes to the <code><html></code> element and import the theme's stylesheet.
|
||||
</p>
|
||||
<pre><code class="language-html"><html class="wa-theme-{{ theme.filename | stripExtension }} wa-palette-{{ theme.palette.filename | stripExtension }}">
|
||||
<pre><code class="language-html"><html class="wa-theme-{{ theme.filename | stripExtension }} wa-palette-{{ theme.palette.filename | stripExtension }} wa-brand-{{ theme.colorBrand.color}}">
|
||||
...
|
||||
<link rel="stylesheet" href="{% cdnUrl %}styles/themes/{{ theme.filename }}" /></code></pre>
|
||||
</div>
|
||||
@@ -107,24 +109,25 @@ layout: page
|
||||
const freeBadge = document.querySelector('[data-free-badge]');
|
||||
const proBadge = document.querySelector('[data-pro-badge]');
|
||||
|
||||
function updateFrames(selectedValue, title, description, isPro, palette) {
|
||||
function updateFrames(selectedValue, title, description, isPro, palette, brand) {
|
||||
// Update theme classes on both frames
|
||||
[afterFrame, beforeFrame].forEach(frame => {
|
||||
if (frame.contentDocument) {
|
||||
const html = frame.contentDocument.documentElement;
|
||||
if (!html) return;
|
||||
|
||||
// Remove all existing wa-theme-* and wa-palette-* classes
|
||||
// Remove all existing wa-theme-*, wa-palette-*, and wa-brand-* classes
|
||||
[...html.classList].forEach(className => {
|
||||
if (className.startsWith('wa-theme-') || className.startsWith('wa-palette-')) {
|
||||
if (className.startsWith('wa-theme-') || className.startsWith('wa-palette-') || className.startsWith('wa-brand-')) {
|
||||
html.classList.remove(className);
|
||||
}
|
||||
});
|
||||
|
||||
// Add new theme and palette class
|
||||
// Add new theme, palette, and brand classes
|
||||
if (selectedValue !== 'default') {
|
||||
html.classList.add(`wa-theme-${selectedValue}`);
|
||||
html.classList.add(`wa-palette-${palette}`);
|
||||
html.classList.add(`wa-brand-${brand}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -153,8 +156,9 @@ layout: page
|
||||
const title = defaultRadio.getAttribute('data-title');
|
||||
const description = defaultRadio.getAttribute('data-description');
|
||||
const palette = defaultRadio.getAttribute('data-palette');
|
||||
const brand = defaultRadio.getAttribute('data-brand');
|
||||
const isPro = defaultRadio.hasAttribute('data-is-pro');
|
||||
updateFrames('default', title, description, isPro, palette);
|
||||
updateFrames('default', title, description, isPro, palette, brand);
|
||||
}
|
||||
|
||||
// Listen for radio changes
|
||||
@@ -163,9 +167,10 @@ layout: page
|
||||
const title = selectedRadio.getAttribute('data-title');
|
||||
const description = selectedRadio.getAttribute('data-description');
|
||||
const palette = selectedRadio.getAttribute('data-palette');
|
||||
const brand = selectedRadio.getAttribute('data-brand');
|
||||
const isPro = selectedRadio.hasAttribute('data-is-pro');
|
||||
doViewTransition(() => {
|
||||
updateFrames(selectedRadio.value, title, description, isPro, palette);
|
||||
updateFrames(selectedRadio.value, title, description, isPro, palette, brand);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user