Skip to content

Commit a92c34d

Browse files
committed
match styles to open in chatgpt dropdown
1 parent 84161db commit a92c34d

File tree

2 files changed

+69
-10
lines changed

2 files changed

+69
-10
lines changed

src/theme/EditThisPage/index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7-
import React from "react";
7+
import React, { useEffect, useState } from "react";
88
import Translate from "@docusaurus/Translate";
99
import { ThemeClassNames } from "@docusaurus/theme-common";
1010
import ReportIcon from "../../../static/images/report.svg";
@@ -17,6 +17,25 @@ export default function EditThisPage({ editUrl }) {
1717
typeof window !== "undefined"
1818
? url.substring(url.lastIndexOf("/") + 1)
1919
: "";
20+
const [isDarkTheme, setIsDarkTheme] = useState(false);
21+
22+
// Check for dark theme
23+
useEffect(() => {
24+
const checkTheme = () => {
25+
setIsDarkTheme(document.documentElement.getAttribute('data-theme') === 'dark');
26+
};
27+
28+
checkTheme();
29+
30+
// Listen for theme changes
31+
const observer = new MutationObserver(checkTheme);
32+
observer.observe(document.documentElement, {
33+
attributes: true,
34+
attributeFilter: ['data-theme']
35+
});
36+
37+
return () => observer.disconnect();
38+
}, []);
2039

2140
return (
2241
<div className={styles.githubLinksWrapper}>
@@ -42,7 +61,7 @@ export default function EditThisPage({ editUrl }) {
4261
target="_blank"
4362
rel="noreferrer noopener"
4463
className={ThemeClassNames.common.editThisPage}
45-
style={{ textAlign: "right", textDecoration: "none" }}
64+
style={{ textDecoration: "none" }}
4665
>
4766
<div className={styles.iconTextWrapper}>
4867
<ReportIcon className={styles.icon} />

src/theme/EditThisPage/styles.module.css

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,71 @@
99
width: 18px;
1010
height: 18px;
1111
margin-right: 7px;
12-
fill:#6DD2D2
12+
fill: var(--ifm-color-gray-800, #444950);
13+
transition: fill 0.2s ease;
1314
}
1415

1516
.iconTextWrapper {
1617
display: flex;
1718
align-items: center;
18-
border: 2px solid #6DD2D2;
19-
padding: 8px;
19+
border: 1px solid var(--ifm-color-gray-400, #cfd3d9);
20+
padding: 0.45rem 0.5rem;
2021
border-radius: 8px;
22+
font-size: 1rem;
23+
font-weight: 500;
24+
color: var(--ifm-color-gray-800, #444950);
25+
background-color: transparent;
26+
transition: all 0.2s ease;
2127
}
28+
2229
.iconTextWrapper:hover {
23-
color: #ffffff;
24-
background-color: #6DD2D2;
25-
fill:#ffffff;
30+
background-color: var(--ifm-color-gray-100, #f5f6f7);
31+
border-color: var(--ifm-color-gray-500, #a8acb3);
2632
cursor: pointer;
2733
}
34+
35+
.iconTextWrapper:active {
36+
transform: translateY(1px);
37+
}
38+
39+
.iconTextWrapper:focus {
40+
box-shadow: 0 0 0 2px var(--ifm-color-gray-300, #dadde1);
41+
outline: none;
42+
}
43+
2844
.iconTextWrapper:hover .icon {
29-
fill:#ffffff;
45+
fill: var(--ifm-color-gray-800, #444950);
3046
}
3147

3248
.githubLinksWrapper {
33-
display:flex;
49+
display: flex;
3450
gap: 10px;
3551
}
3652

53+
/* Dark mode styles */
54+
html[data-theme='dark'] .iconTextWrapper {
55+
color: var(--ifm-color-gray-300, #dadde1);
56+
border-color: var(--ifm-color-gray-600, #606770);
57+
background-color: transparent;
58+
}
59+
60+
html[data-theme='dark'] .icon {
61+
fill: var(--ifm-color-gray-300, #dadde1);
62+
}
63+
64+
html[data-theme='dark'] .iconTextWrapper:hover {
65+
background-color: var(--ifm-color-gray-800, #444950);
66+
border-color: var(--ifm-color-gray-500, #a8acb3);
67+
}
68+
69+
html[data-theme='dark'] .iconTextWrapper:focus {
70+
box-shadow: 0 0 0 2px var(--ifm-color-gray-700, #606770);
71+
}
72+
73+
html[data-theme='dark'] .iconTextWrapper:hover .icon {
74+
fill: var(--ifm-color-gray-300, #dadde1);
75+
}
76+
3777
@media (max-width: 500px) {
3878
.githubLinksWrapper {
3979
flex-direction: column;

0 commit comments

Comments
 (0)