Skip to content

Commit

Permalink
docs: fix sampe
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Aug 30, 2024
1 parent ef2ff28 commit 4533052
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
});
}

const surface = document.getElementById('theme-link-demo');
const card = surface.querySelector('rh-card');
const surface = document.querySelector('rh-surface');

surface.addEventListener('change', function(event) {
const next = event.target.checked ? 'darkest' : 'lightest';
Expand Down
9 changes: 6 additions & 3 deletions lib/11ty/preview-page-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ const capitalize = x =>
const isRef = x =>
x?.original?.$value?.startsWith?.('{') ?? false;

const derefValue = x =>
`rh-${x.replace(/[{}]/g, '').split('.').join('-')}`;

const deref = x =>
`rh-${x.original.$value.replace(/[{}]/g, '').split('.').join('-')}`;
derefValue(x.original.$value);

/** Returns a string with common indent stripped from each line. Useful for templating HTML */
function dedent(str) {
Expand Down Expand Up @@ -176,8 +179,8 @@ export async function PreviewPagePlugin(eleventyConfig: UserConfig) {
<tr id="${token.name}" class="${path.join(' ')} theme" data-name="${name}">
<td class="sample theme-token">
<div class="values">
<samp style="background-color: var(--${token.name}-on-light);"></samp>
<samp style="background-color: var(--${token.name}-on-dark);"></samp>
<samp style="background-color: var(--${derefValue(token.original.$value.at(0))});"></samp>
<samp style="background-color: var(--${derefValue(token.original.$value.at(1))});"></samp>
</div>
</td>
<td class="token name">
Expand Down

0 comments on commit 4533052

Please sign in to comment.