Skip to content

Commit 653417f

Browse files
committed
feat(copy-markdown): ✨ use content-secondary for icon and label color
1 parent cb29b03 commit 653417f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

packages/docusaurus-plugin-copy-markdown/src/client/copy-markdown-button.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ const CONTAINER_ATTR = "data-copy-markdown-button";
1818

1919
const COPY_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`;
2020

21-
// Default outline + icon color. Uses Infima's emphasis-300 in a Docusaurus
22-
// context and falls back to its light-mode value when the variable is absent.
21+
// Outline (border) color. Uses Infima's emphasis-300 in a Docusaurus context
22+
// and falls back to its light-mode value when the variable is absent.
2323
const OUTLINE_COLOR = "var(--ifm-color-emphasis-300, #dadde1)";
2424

25+
// Icon + label text color. Uses Infima's secondary content color, with a
26+
// fallback to its light-mode value for non-Docusaurus contexts.
27+
const CONTENT_COLOR = "var(--ifm-color-content-secondary, #525860)";
28+
2529
type PluginGlobalData = CopyMarkdownGlobalData;
2630

2731
function getPluginData(): PluginGlobalData | undefined {
@@ -98,13 +102,13 @@ function ensureBaseStylesInjected(): void {
98102
border: 1px solid ${OUTLINE_COLOR};
99103
border-radius: 6px;
100104
background: transparent;
101-
color: inherit;
105+
color: ${CONTENT_COLOR};
102106
cursor: pointer;
103107
transition: opacity 0.15s ease, background-color 0.15s ease;
104108
white-space: nowrap;
105109
}
106110
.copy-markdown-button__icon {
107-
color: ${OUTLINE_COLOR};
111+
color: ${CONTENT_COLOR};
108112
}
109113
.copy-markdown-button:hover {
110114
background-color: rgba(0, 0, 0, 0.04);
@@ -147,7 +151,7 @@ function createCopyButton(
147151
borderRadius: "6px",
148152
borderStyle: "solid",
149153
borderWidth: "1px",
150-
color: "inherit",
154+
color: CONTENT_COLOR,
151155
cursor: "pointer",
152156
display: "inline-flex",
153157
fontSize: "0.875rem",
@@ -161,7 +165,7 @@ function createCopyButton(
161165
const icon = document.createElement("span");
162166
icon.className = "copy-markdown-button__icon";
163167
icon.innerHTML = COPY_ICON_SVG;
164-
icon.style.color = OUTLINE_COLOR;
168+
icon.style.color = CONTENT_COLOR;
165169
icon.style.display = "inline-flex";
166170
icon.style.flexShrink = "0";
167171

0 commit comments

Comments
 (0)