-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/pytorch/test-infra?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
6 changed files
with
151 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
:root { | ||
--announcement-border-color: black; | ||
--announcement-bg-color: #daedf4; | ||
} | ||
|
||
.announcementBanner { | ||
border: 1px solid black; | ||
border: 1px solid var(--announcement-border-color); | ||
border-radius: 5px; | ||
background-color: #daedf4; | ||
background-color: var(--announcement-bg-color); | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
margin-top: 10px; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
:root { | ||
--announcement-border-color: white; | ||
--announcement-bg-color: #2b2b2b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
import { useState, useEffect } from "react"; | ||
import styles from "./AnnouncementBanner.module.css"; | ||
|
||
function AnnouncementBanner() { | ||
return null; | ||
const [isDarkMode, setIsDarkMode] = useState(false); | ||
|
||
useEffect(() => { | ||
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)"); | ||
setIsDarkMode(darkModeMediaQuery.matches); | ||
|
||
const handleChange = (e: MediaQueryListEvent) => { | ||
setIsDarkMode(e.matches); | ||
}; | ||
|
||
darkModeMediaQuery.addEventListener("change", handleChange); | ||
|
||
return () => { | ||
darkModeMediaQuery.removeEventListener("change", handleChange); | ||
}; | ||
}, []); | ||
|
||
const toggleDarkMode = () => { | ||
setIsDarkMode((prevMode) => !prevMode); | ||
}; | ||
|
||
return ( | ||
<div className={styles.announcementBanner}> | ||
<button onClick={toggleDarkMode}> | ||
{isDarkMode ? "Switch to Light Mode" : "Switch to Dark Mode"} | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default AnnouncementBanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters