Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/theme/EditThisPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import React, { useEffect, useState } from "react";
import Translate from "@docusaurus/Translate";
import { ThemeClassNames } from "@docusaurus/theme-common";
import ReportIcon from "../../../static/images/report.svg";
Expand All @@ -17,6 +17,25 @@ export default function EditThisPage({ editUrl }) {
typeof window !== "undefined"
? url.substring(url.lastIndexOf("/") + 1)
: "";
const [isDarkTheme, setIsDarkTheme] = useState(false);

// Check for dark theme
useEffect(() => {
const checkTheme = () => {
setIsDarkTheme(document.documentElement.getAttribute('data-theme') === 'dark');
};

checkTheme();

// Listen for theme changes
const observer = new MutationObserver(checkTheme);
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-theme']
});

return () => observer.disconnect();
}, []);

return (
<div className={styles.githubLinksWrapper}>
Expand All @@ -42,7 +61,7 @@ export default function EditThisPage({ editUrl }) {
target="_blank"
rel="noreferrer noopener"
className={ThemeClassNames.common.editThisPage}
style={{ textAlign: "right", textDecoration: "none" }}
style={{ textDecoration: "none" }}
>
<div className={styles.iconTextWrapper}>
<ReportIcon className={styles.icon} />
Expand Down
56 changes: 48 additions & 8 deletions src/theme/EditThisPage/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,71 @@
width: 18px;
height: 18px;
margin-right: 7px;
fill:#6DD2D2
fill: var(--ifm-color-gray-800, #444950);
transition: fill 0.2s ease;
}

.iconTextWrapper {
display: flex;
align-items: center;
border: 2px solid #6DD2D2;
padding: 8px;
border: 1px solid var(--ifm-color-gray-400, #cfd3d9);
padding: 0.45rem 0.5rem;
border-radius: 8px;
font-size: 1rem;
font-weight: 500;
color: var(--ifm-color-gray-800, #444950);
background-color: transparent;
transition: all 0.2s ease;
}

.iconTextWrapper:hover {
color: #ffffff;
background-color: #6DD2D2;
fill:#ffffff;
background-color: var(--ifm-color-gray-100, #f5f6f7);
border-color: var(--ifm-color-gray-500, #a8acb3);
cursor: pointer;
}

.iconTextWrapper:active {
transform: translateY(1px);
}

.iconTextWrapper:focus {
box-shadow: 0 0 0 2px var(--ifm-color-gray-300, #dadde1);
outline: none;
}

.iconTextWrapper:hover .icon {
fill:#ffffff;
fill: var(--ifm-color-gray-800, #444950);
}

.githubLinksWrapper {
display:flex;
display: flex;
gap: 10px;
}

/* Dark mode styles */
html[data-theme='dark'] .iconTextWrapper {
color: var(--ifm-color-gray-300, #dadde1);
border-color: var(--ifm-color-gray-600, #606770);
background-color: transparent;
}

html[data-theme='dark'] .icon {
fill: var(--ifm-color-gray-300, #dadde1);
}

html[data-theme='dark'] .iconTextWrapper:hover {
background-color: var(--ifm-color-gray-800, #444950);
border-color: var(--ifm-color-gray-500, #a8acb3);
}

html[data-theme='dark'] .iconTextWrapper:focus {
box-shadow: 0 0 0 2px var(--ifm-color-gray-700, #606770);
}

html[data-theme='dark'] .iconTextWrapper:hover .icon {
fill: var(--ifm-color-gray-300, #dadde1);
}

@media (max-width: 500px) {
.githubLinksWrapper {
flex-direction: column;
Expand Down
Loading