From e360b57762e0fd8e101eabfaf934a64ce9da6efa Mon Sep 17 00:00:00 2001 From: Atila Fassina Date: Thu, 19 Dec 2024 17:40:47 +0100 Subject: [PATCH 1/2] add copy to clipboard button to code snippet --- docs/src/components/clipboard-button.tsx | 36 ++++++++++++++++++++ docs/src/components/code-snippet.tsx | 15 ++++---- docs/src/components/icons/clipboard-icon.tsx | 17 +++++++++ 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 docs/src/components/clipboard-button.tsx create mode 100644 docs/src/components/icons/clipboard-icon.tsx diff --git a/docs/src/components/clipboard-button.tsx b/docs/src/components/clipboard-button.tsx new file mode 100644 index 000000000..37912fa72 --- /dev/null +++ b/docs/src/components/clipboard-button.tsx @@ -0,0 +1,36 @@ +import { createSignal, Show } from "solid-js"; +import { ClipboardIcon } from "./icons/clipboard-icon"; + +interface CopyToClipboardProps { + class?: string; + manager: string; + command: string; +} + +export function CopyToClipboard(props: CopyToClipboardProps) { + const copyText = () => `${props.manager} ${props.command}`; + + const [isCopied, setIsCopied] = createSignal(false); + + const copyToClipboard = async () => { + try { + await navigator.clipboard.writeText(copyText()); + setIsCopied(true); + setTimeout(() => setIsCopied(false), 2000); // Reset after 2 seconds + } catch (err) { + console.error("Failed to copy text: ", err); + } + }; + + return ( + + ); +} diff --git a/docs/src/components/code-snippet.tsx b/docs/src/components/code-snippet.tsx index b2d8880e7..173f2e4eb 100644 --- a/docs/src/components/code-snippet.tsx +++ b/docs/src/components/code-snippet.tsx @@ -1,9 +1,6 @@ import { Tabs } from "@kobalte/core/tabs"; import { createResource, Suspense } from "solid-js"; -// import { YarnIcon } from "./icons/yarn-icon"; -// import { NpmIcon } from "./icons/npm-icon"; -// import { PnpmIcon } from "./icons/pnpm-icon"; - +import { CopyToClipboard } from "./clipboard-button"; const getSolidStartVersion = async () => { "use server"; @@ -66,7 +63,7 @@ export function CodeSnippet() { ); } -function TabContent(props: { manager: string, command: string }) { +function TabContent(props: { manager: string; command: string }) { return ( ); } diff --git a/docs/src/components/icons/clipboard-icon.tsx b/docs/src/components/icons/clipboard-icon.tsx new file mode 100644 index 000000000..3c97556de --- /dev/null +++ b/docs/src/components/icons/clipboard-icon.tsx @@ -0,0 +1,17 @@ +export function ClipboardIcon(props: { class?: string }) { + return ( + + + + + ); +} From d867bb22a0637a8be13480844321707b5ebdeb5a Mon Sep 17 00:00:00 2001 From: Atila Fassina Date: Sun, 5 Jan 2025 10:17:35 +0100 Subject: [PATCH 2/2] docs: run typecheck, but skip if changes only in landing page --- .github/workflows/typecheck.yml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index 00b540423..82204a264 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -8,20 +8,31 @@ on: - release-* tags-ignore: - v* - paths-ignore: - - "docs/**" - - "docs.root.tsx" - - "components/**" - - "**/README.md" - pull_request: - paths-ignore: - - "docs/**" - - "**/*.md" jobs: + filter-changes: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.changes.outputs.landing_page }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get changed files + id: changes + uses: dorny/paths-filter@v2 + with: + filters: | + landing_page: + - 'docs/**' + - "docs.root.tsx" + - "components/**" + - "**/README.md" typecheck: name: "👀 Typecheck" - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.changed_files != 0) + needs: filter-changes + if: needs.filter-changes.outputs.should_skip != 'true' runs-on: ubuntu-latest