Skip to content

Commit 532cd24

Browse files
add dark mode support
1 parent 2f164dd commit 532cd24

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/components/copyMarkdownButton.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
4343
setCopied(true);
4444
setTimeout(() => setCopied(false), 2000);
4545
} catch (err) {
46-
console.error('Failed to copy markdown to clipboard:', err);
4746
setError(true);
4847
setTimeout(() => setError(false), 3000);
4948
} finally {
@@ -92,25 +91,25 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
9291
};
9392
};
9493

95-
const buttonClass = "inline-flex items-center h-full text-gray-700 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-gray-50 active:bg-gray-100 focus:bg-gray-50 outline-none";
96-
const dropdownItemClass = "flex items-center gap-3 w-full p-2 px-3 text-left bg-transparent rounded-md transition-colors hover:bg-gray-100 font-sans text-gray-900";
97-
const iconContainerClass = "flex items-center justify-center w-7 h-7 bg-gray-100 rounded shrink-0";
94+
const buttonClass = "inline-flex items-center h-full text-gray-700 dark:text-[var(--foreground)] bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-[var(--gray-a4)] active:bg-gray-100 dark:active:bg-[var(--gray-5)] focus:bg-gray-50 dark:focus:bg-[var(--gray-a4)] outline-none";
95+
const dropdownItemClass = "flex items-center gap-3 w-full p-2 px-3 text-left bg-transparent rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-[var(--gray-a4)] font-sans text-gray-900 dark:text-[var(--foreground)]";
96+
const iconContainerClass = "flex items-center justify-center w-7 h-7 bg-gray-100 dark:bg-[var(--gray-a4)] rounded shrink-0";
9897

9998
return (
10099
<Fragment>
101100
<div className="relative inline-block" ref={buttonRef}>
102-
<div className="inline-flex items-center h-9 border border-gray-200 rounded-full overflow-hidden bg-white">
101+
<div className="inline-flex items-center h-9 border border-gray-200 dark:border-[var(--gray-6)] rounded-full overflow-hidden bg-white dark:bg-[var(--gray-2)]">
103102
<button
104103
onClick={copyMarkdownToClipboard}
105-
className={`${buttonClass} gap-2 px-3.5 text-sm font-medium disabled:opacity-50 ${error ? 'text-red-600' : ''}`}
104+
className={`${buttonClass} gap-2 px-3.5 text-sm font-medium disabled:opacity-50`}
106105
style={{borderRadius: '9999px 0 0 9999px'}}
107106
disabled={isLoading}
108107
>
109108
<Clipboard size={16} />
110109
<span>{error ? 'Failed to copy' : copied ? 'Copied!' : 'Copy page'}</span>
111110
</button>
112111

113-
<div className="w-px h-full bg-gray-200" />
112+
<div className="w-px h-full bg-gray-200 dark:bg-[var(--gray-6)]" />
114113

115114
<button
116115
onClick={handleDropdownToggle}
@@ -130,8 +129,8 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
130129
{isMounted && isOpen && createPortal(
131130
<div
132131
ref={dropdownRef}
133-
className="fixed w-80 bg-white rounded-xl shadow-lg overflow-hidden z-[9999]"
134-
style={{...getDropdownPosition(), border: '1px solid #d1d5db'}}
132+
className="fixed w-80 bg-white dark:bg-[var(--gray-2)] rounded-xl shadow-lg overflow-hidden z-[9999] border border-gray-300 dark:border-[var(--gray-6)]"
133+
style={{...getDropdownPosition()}}
135134
>
136135
<div className="p-1">
137136
<button
@@ -143,10 +142,10 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
143142
<Clipboard size={14} />
144143
</div>
145144
<div className="flex-1">
146-
<div className={`font-medium text-sm leading-5 ${error ? 'text-red-600' : 'text-gray-900'}`}>
145+
<div className={`font-medium text-sm leading-5`}>
147146
{error ? 'Failed to copy' : 'Copy page'}
148147
</div>
149-
<div className="text-xs text-gray-500 leading-4">
148+
<div className="text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]">
150149
{error ? 'Network error - please try again' : 'Copy page as Markdown for LLMs'}
151150
</div>
152151
</div>
@@ -163,8 +162,8 @@ export function CopyMarkdownButton({pathname}: CopyMarkdownButtonProps) {
163162
<Markdown width={14} height={14} />
164163
</div>
165164
<div className="flex-1">
166-
<div className="font-medium text-gray-900 text-sm leading-5">View as Markdown</div>
167-
<div className="text-xs text-gray-500 leading-4">View this page as plain text</div>
165+
<div className="font-medium text-sm leading-5 text-gray-900 dark:text-[var(--foreground)]">View as Markdown</div>
166+
<div className="text-xs leading-4 text-gray-500 dark:text-[var(--foreground-secondary)]">View this page as plain text</div>
168167
</div>
169168
</Link>
170169
</div>

0 commit comments

Comments
 (0)