Skip to content

website : Add copy to clipboard and language banner for code snippets#4393

Open
HeythisisSud wants to merge 1 commit into
kubeflow:masterfrom
HeythisisSud:master
Open

website : Add copy to clipboard and language banner for code snippets#4393
HeythisisSud wants to merge 1 commit into
kubeflow:masterfrom
HeythisisSud:master

Conversation

@HeythisisSud

@HeythisisSud HeythisisSud commented Jun 9, 2026

Copy link
Copy Markdown

Description of Changes

What was changed:

assets/js/click-to-copy.js — Rewrote the existing (disabled) copy-to-clipboard script with a new, dependency-free implementation that:

Injects a header bar (.c2c-header) at the top of each .highlight code block containing a language label (e.g. "Terminal", "YAML", "Python") and a copy icon button.
Automatically wraps any bare pre tag elements in a .highlight container so all code blocks render consistently.
Uses the modern navigator.clipboard API with a legacy execCommand fallback for broader browser support.
Switches the button to a checkmark icon with a "Copied!" tooltip on success, reverting after 2 seconds.
assets/scss/_styles_project.scss — Added styles for the copy button feature:

Converts .td-content .highlight to a flex column so the header sits above the pre tag block.
Styles the .c2c-header bar with a language badge on the left and copy button on the right.
Full light and dark theme support using @at-root [data-theme="light/dark"] to correctly target the site's theme attribute.
Resets browser default styles (appearance: none; background: none) to prevent unstyled grey button rendering.
Includes a smooth floating tooltip and keyboard accessibility (focus-visible outline).
layouts/partials/scripts.html — Enabled the click-to-copy script, which was previously gated behind a hardcoded false condition.

Design decisions:

The copy button is placed in a dedicated header bar above the code, so it never overlaps or obscures code text.
Button opacity and hover states follow the existing Kubeflow brand color (#4279f4).
Success state uses green (#10b981 light / #34d399 dark) consistent with standard UX conventions.
No external dependencies added (no Popper.js, no extra libraries).

Related Issues

Closes: #4327 #4328 #4210

Screenshot 2026-06-10 020249

Signed-off-by: Sudhanshu <sudhanshumani94@gmail.com>
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign johnugeorge for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot added the area/website AREA: Website Styles/Hosting/Serving label Jun 9, 2026
@google-oss-prow

Copy link
Copy Markdown

Hi @HeythisisSud. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🚫 This command cannot be processed. Only organization members or owners can use the commands.

@Arhell Arhell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ok-to-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/website AREA: Website Styles/Hosting/Serving ok-to-test size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature(Website): copy to clickboard button.

2 participants