From 21be8825cd5a8f4d3c1b1dee685ba24c5d84ccde Mon Sep 17 00:00:00 2001 From: Arnaud Freismuth Date: Fri, 23 Aug 2024 14:17:37 +0200 Subject: [PATCH] Copy codes raw --- package-lock.json | 4 ++-- package.json | 2 +- part/code.pug | 2 ++ src/documentation/atom/button/_button.scss | 11 +++++++++++ src/documentation/scripts/tikui.js | 4 ++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1ab33ce..31ba15c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tikuidoc-tikui", - "version": "7.0.1", + "version": "8.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tikuidoc-tikui", - "version": "7.0.1", + "version": "8.0.0", "license": "MIT", "devDependencies": { "@fontsource/montserrat": "5.0.19", diff --git a/package.json b/package.json index 5e7c70a..0dbc96a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tikuidoc-tikui", - "version": "7.0.1", + "version": "8.0.0", "description": "Tikui documentation", "main": "tikuidoc.json", "files": [ diff --git a/part/code.pug b/part/code.pug index aa57c38..9f6b236 100644 --- a/part/code.pug +++ b/part/code.pug @@ -2,6 +2,8 @@ .tikui-line-section--column pre.doc-code-example code.code.language-html !{htmlCode} + button.tikui-button.-small(onclick='copyCode(this)' data-code=htmlRaw) Copy .tikui-line-section--column pre.doc-code-example code.code.language-pug !{pugCode} + button.tikui-button.-small(onclick='copyCode(this)' data-code=pugRaw) Copy diff --git a/src/documentation/atom/button/_button.scss b/src/documentation/atom/button/_button.scss index f4868e0..78337ee 100644 --- a/src/documentation/atom/button/_button.scss +++ b/src/documentation/atom/button/_button.scss @@ -2,9 +2,13 @@ $tikui-button-border-width: 1px !default; $tikui-button-padding: 19px !default; +$tikui-button-padding-small: 9px !default; $tikui-button-min-width: 176px !default; +$tikui-button-min-width-small: 80px !default; $tikui-button-line-height: 20px !default; +$tikui-button-line-height-small: 16px !default; $tikui-button-font-size: 16px !default; +$tikui-button-font-size-small: 12px !default; $tikui-button-radius: 30px !default; $tikui-button-font-family: $tikui-font-family-main !default; $tikui-button-color-background: $tikui-color-secondary !default; @@ -56,4 +60,11 @@ $tikui-button-secondary-hover-color-background: $tikui-button-color-background ! background-color: $tikui-button-secondary-hover-color-background; } } + + &.-small { + padding: $tikui-button-padding-small; + min-width: $tikui-button-min-width-small; + line-height: $tikui-button-line-height-small; + font-size: $tikui-button-font-size-small; + } } diff --git a/src/documentation/scripts/tikui.js b/src/documentation/scripts/tikui.js index 66c9a8f..deec213 100644 --- a/src/documentation/scripts/tikui.js +++ b/src/documentation/scripts/tikui.js @@ -62,3 +62,7 @@ const tikuiScripts = () => { }; document.addEventListener('DOMContentLoaded', tikuiScripts, false); + +const copyCode = async (element) => { + await navigator.clipboard.writeText(element.dataset['code']); +};