Skip to content

Commit 326e6cf

Browse files
committed
feat(copy-markdown): ✨ use emphasis-300 for button outline and icon
1 parent cf48248 commit 326e6cf

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ 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.
23+
const OUTLINE_COLOR = "var(--ifm-color-emphasis-300, #dadde1)";
24+
2125
type PluginGlobalData = CopyMarkdownGlobalData;
2226

2327
function getPluginData(): PluginGlobalData | undefined {
@@ -91,14 +95,17 @@ function ensureBaseStylesInjected(): void {
9195
padding: 0.375rem 0.75rem;
9296
font-size: 0.875rem;
9397
line-height: 1.25;
94-
border: 1px solid currentColor;
98+
border: 1px solid ${OUTLINE_COLOR};
9599
border-radius: 6px;
96100
background: transparent;
97101
color: inherit;
98102
cursor: pointer;
99103
transition: opacity 0.15s ease, background-color 0.15s ease;
100104
white-space: nowrap;
101105
}
106+
.copy-markdown-button__icon {
107+
color: ${OUTLINE_COLOR};
108+
}
102109
.copy-markdown-button:hover {
103110
background-color: rgba(0, 0, 0, 0.04);
104111
}
@@ -136,7 +143,7 @@ function createCopyButton(
136143
Object.assign(button.style, {
137144
alignItems: "center",
138145
background: "transparent",
139-
border: "1px solid currentColor",
146+
border: `1px solid ${OUTLINE_COLOR}`,
140147
borderRadius: "6px",
141148
color: "inherit",
142149
cursor: "pointer",
@@ -152,6 +159,7 @@ function createCopyButton(
152159
const icon = document.createElement("span");
153160
icon.className = "copy-markdown-button__icon";
154161
icon.innerHTML = COPY_ICON_SVG;
162+
icon.style.color = OUTLINE_COLOR;
155163
icon.style.display = "inline-flex";
156164
icon.style.flexShrink = "0";
157165

0 commit comments

Comments
 (0)