mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-21 20:55:50 +02:00
Docs: fix missing "Copy to clipboard" tooltips when <Example>
was used, not just <Code>
(#41582)
Co-authored-by: Julien Déramond <juderamond@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2acf59d89b
commit
6d3345b24c
@@ -33,9 +33,14 @@ interface Props {
|
||||
* This takes precedence over the `code` prop.
|
||||
*/
|
||||
filePath?: string
|
||||
/**
|
||||
* Defines if the `<Code>` component is nested inside an `<Example>` component or not.
|
||||
* @default false
|
||||
*/
|
||||
nestedInExample?: boolean
|
||||
}
|
||||
|
||||
const { class: className, code, containerClass, fileMatch, filePath, lang } = Astro.props
|
||||
const { class: className, code, containerClass, fileMatch, filePath, lang, nestedInExample = false } = Astro.props
|
||||
|
||||
let codeToDisplay = filePath
|
||||
? fs.readFileSync(path.join(process.cwd(), filePath), 'utf8')
|
||||
@@ -130,11 +135,15 @@ if (filePath && fileMatch && codeToDisplay) {
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class:list={['bd-code-snippet', containerClass]}>
|
||||
<div class:list={[{ 'bd-code-snippet': !nestedInExample }, containerClass]}>
|
||||
{
|
||||
Astro.slots.has('pre') ? (
|
||||
nestedInExample
|
||||
? (<></>)
|
||||
: Astro.slots.has('pre')
|
||||
? (
|
||||
<slot name="pre" />
|
||||
) : (
|
||||
)
|
||||
: (
|
||||
<div class="bd-clipboard">
|
||||
<button type="button" class="btn-clipboard">
|
||||
<svg class="bi" role="img" aria-label="Copy">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
import { replacePlaceholdersInHtml } from '@libs/placeholder'
|
||||
import { Prism } from '@astrojs/prism'
|
||||
import Code from '@components/shortcodes/Code.astro'
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
@@ -96,9 +96,7 @@ const simplifiedMarkup = markup
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div class="highlight">
|
||||
<Prism code={simplifiedMarkup} lang={lang} />
|
||||
</div>
|
||||
<Code code={simplifiedMarkup} lang={lang} nestedInExample={true} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user