diff --git a/docs/assets/plugins/code-block/code-block.js b/docs/assets/plugins/code-block/code-block.js index 0918f7165..2c8cc3a84 100644 --- a/docs/assets/plugins/code-block/code-block.js +++ b/docs/assets/plugins/code-block/code-block.js @@ -146,8 +146,6 @@
- ${hasReact ? ` ${htmlButton} ${reactButton} ` : ''} - + ${hasReact ? ` ${htmlButton} ${reactButton} ` : ''} + ${!code.classList.contains('no-codepen') ? codePenButton : ''}
@@ -232,36 +232,45 @@ // Toggle source mode document.addEventListener('click', event => { - const button = event.target.closest('button'); + const button = event.target.closest('.code-block__button'); + const codeBlock = button?.closest('.code-block'); if (button?.classList.contains('code-block__button--html')) { + // Show HTML setFlavor('html'); + toggleSource(codeBlock, true); } else if (button?.classList.contains('code-block__button--react')) { + // Show React setFlavor('react'); + toggleSource(codeBlock, true); + } else if (button?.classList.contains('code-block__toggle')) { + // Toggle source + toggleSource(codeBlock); } else { return; } // Update flavor buttons - [...document.querySelectorAll('.code-block')].forEach(codeBlock => { - codeBlock - .querySelector('.code-block__button--html') - ?.classList.toggle('code-block__button--selected', flavor === 'html'); - codeBlock - .querySelector('.code-block__button--react') - ?.classList.toggle('code-block__button--selected', flavor === 'react'); + [...document.querySelectorAll('.code-block')].forEach(cb => { + cb.querySelector('.code-block__button--html')?.classList.toggle( + 'code-block__button--selected', + flavor === 'html' + ); + cb.querySelector('.code-block__button--react')?.classList.toggle( + 'code-block__button--selected', + flavor === 'react' + ); }); }); - // Expand and collapse code blocks - document.addEventListener('click', event => { - const toggle = event.target.closest('.code-block__toggle'); + function toggleSource(codeBlock, force) { + const toggle = codeBlock.querySelector('.code-block__toggle'); + if (toggle) { - const codeBlock = event.target.closest('.code-block'); - codeBlock.classList.toggle('code-block--expanded'); + codeBlock.classList.toggle('code-block--expanded', force === undefined ? undefined : force); event.target.setAttribute('aria-expanded', codeBlock.classList.contains('code-block--expanded')); } - }); + } // Show pulse when copying document.addEventListener('click', event => { diff --git a/docs/assets/plugins/metadata/metadata.js b/docs/assets/plugins/metadata/metadata.js index 0dfbd3932..12baaf2cb 100644 --- a/docs/assets/plugins/metadata/metadata.js +++ b/docs/assets/plugins/metadata/metadata.js @@ -434,7 +434,7 @@ To import this component from [the CDN](https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace) using a script tag: \`\`\`html - + \`\`\` @@ -442,14 +442,14 @@ To import this component from [the CDN](https://www.jsdelivr.com/package/npm/@shoelace-style/shoelace) using a JavaScript import: \`\`\`js - import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${metadata.package.version}/${component.path}'; + import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@${metadata.package.version}/dist/${component.path}'; \`\`\` \n To import this component using [a bundler](/getting-started/installation#bundling): \`\`\`js - import '@shoelace-style/shoelace/${component.path}'; + import '@shoelace-style/shoelace/dist/${component.path}'; \`\`\` diff --git a/docs/assets/styles/docs.css b/docs/assets/styles/docs.css index c553cbbb8..a33e3dd42 100644 --- a/docs/assets/styles/docs.css +++ b/docs/assets/styles/docs.css @@ -490,6 +490,7 @@ kbd, .markdown-section p.tip code, .markdown-section p.warn code { background-color: var(--sl-color-neutral-100); + white-space: nowrap; } /* Sponsorship callouts */ diff --git a/docs/components/popup.md b/docs/components/popup.md index 5122dac12..54755865d 100644 --- a/docs/components/popup.md +++ b/docs/components/popup.md @@ -6,6 +6,8 @@ This component's name is inspired by [``](https://github.com/MicrosoftEdg Popup doesn't provide any styles — just positioning! The popup's preferred placement, distance, and skidding (offset) can be configured using attributes. An arrow that points to the anchor can be shown and customized to your liking. Additional positioning options are available and described in more detail below. +!> Popup is a low-level utility built specifically for positioning elements. Do not mistake it for a [tooltip](/components/tooltip) or similar because _it does not facilitate an accessible experience!_ Almost every correct usage of `` will involve building other components. It should rarely, if ever, occur in your own HTML. + ```html preview