diff --git a/docs/.eleventy.js b/docs/.eleventy.js index e530813f2f..a75af71d70 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -134,6 +134,35 @@ module.exports = function(eleventyConfig) { return output; }); + // Copy button shortcode + eleventyConfig.addLiquidShortcode("copybutton", function(name) { + var checkmarkIcon = Icons["Checkmark"]; + var copyIcon = Icons["Copy"]; + var tooltipId = "tooltip-" + (name || Math.floor(Math.random() * 1000)); + + var output = ''; + output += '' + output += '
'; + + return output; + }); + // Version shortcode eleventyConfig.addLiquidShortcode("version", function() { return {version}.version; diff --git a/docs/assets/js/controllers/clipboard.ts b/docs/assets/js/controllers/clipboard.ts new file mode 100644 index 0000000000..421884c645 --- /dev/null +++ b/docs/assets/js/controllers/clipboard.ts @@ -0,0 +1,32 @@ +(function(){ + var application = Stimulus.Application.start(); + application.register("clipboard", class extends Stimulus.Controller { + static targets = ["source"]; + sourceTarget!: HTMLElement; + + connect() { + super.connect(); + }; + + copy() { + const text = this.sourceTarget.innerText; + navigator.clipboard.writeText(text); + this.handleVisible(); + } + + private handleVisible() { + const { scope } = this.targets; + + const hideElements = scope.findAllElements('[data-hide-on-copy]'); + const showElements = scope.findAllElements('[data-show-on-copy]'); + + hideElements.map(el => el.classList.add("d-none")); + showElements.map(el => el.classList.remove("d-none")); + + setTimeout(function () { + hideElements.map(el => el.classList.remove("d-none")); + showElements.map(el => el.classList.add("d-none")); + }, 3000); + } + }); +})(); \ No newline at end of file diff --git a/docs/assets/less/stacks-documentation.less b/docs/assets/less/stacks-documentation.less index acff8723dd..638a9ad550 100644 --- a/docs/assets/less/stacks-documentation.less +++ b/docs/assets/less/stacks-documentation.less @@ -255,7 +255,8 @@ box-shadow: none; }); - > pre.s-code-block { + > pre.s-code-block, + > .stacks-clipboard-content pre.s-code-block { border-radius: @br-md @br-md 0 0; border: 1px solid var(--bc-medium); max-height: 24rem; diff --git a/docs/product/components/cards.html b/docs/product/components/cards.html index f58ffdd769..d16b65ef13 100644 --- a/docs/product/components/cards.html +++ b/docs/product/components/cards.html @@ -9,6 +9,9 @@The base card styling applies a border and padding to the card.
Cards can be any size and it’s ok to increase the body text size for larger cards.
Applying a .bs-*
class adds a box shadow to a card. Useful when giving users the impression they can interact with the card.
The .s-card
class can be applied to an <a>
tag for instances where a whole card should link somewhere. If possible, linked cards should visually indication that they’re interactive (ex. including an .s-btn
or .s-link
somewhere).
A :hover
style for border color is automatically added to all linked cards. For linked cards with a box shadow (.bs-*
), adding a .h:bs-*
class will apply a hover style to the box shadow as well. Increasing the .bs-
size by a factor of one is usually best.
…
{% endhighlight %} + +