Skip to content

Commit

Permalink
feat: support dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Aug 18, 2021
1 parent 3715ba6 commit 40d96a4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/swr-devtools-extensions/src/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
html {
height: 100%;
background-color: white;
@media (prefers-color-scheme: dark) {
background-color: rgb(39, 40, 34);
}
}
body, div#app {
height: 100%;
Expand Down
3 changes: 2 additions & 1 deletion packages/swr-devtools/src/components/CacheData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CacheDataView = ({ data }: Props) => {

const AsyncReactJson = ({ data }: Props) => {
const ReactJson = lazy(() => import("react-json-view"));
return <ReactJson src={data} />;
return <ReactJson src={data} theme="monokai" />;
};

const ErrorText = styled.p`
Expand All @@ -51,6 +51,7 @@ const ErrorText = styled.p`
const Title = styled.h3`
margin: 0;
padding: 1rem 0.5rem;
color: var(--swr-devtools-text-color);
`;

const TimestampText = styled.span`
Expand Down
7 changes: 6 additions & 1 deletion packages/swr-devtools/src/components/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Panel = ({
))}
</CacheItems>
</PanelItem>
<hr />
<Hr />
<PanelItem>{currentData && <CacheData data={currentData} />}</PanelItem>
</PanelWrapper>
);
Expand Down Expand Up @@ -89,6 +89,11 @@ const CacheItemButton = styled.button`
height: 100%;
border: none;
background: transparent;
color: var(--swr-devtools-text-color);
cursor: pointer;
text-align: left;
`;

const Hr = styled.hr`
border-color: var(--swr-devtools-border-color);
`;
13 changes: 13 additions & 0 deletions packages/swr-devtools/src/components/SWRDevTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type ItemKey = {

const GlobalStyle = createGlobalStyle`
html {
--swr-devtools-text-color: #000;
--swr-devtools-bg-color: #FFF;
--swr-devtools-hover-bg-color: #f7f5f4;
--swr-devtools-border-color: #CCC;
Expand All @@ -40,6 +41,17 @@ const GlobalStyle = createGlobalStyle`
--swr-devtools-tag-text-color: #FFF;
--swr-devtools-error-text-color: red;
@media (prefers-color-scheme: dark) {
--swr-devtools-text-color: #FFF;
--swr-devtools-bg-color: rgb(39, 40, 34);
--swr-devtools-hover-bg-color: #6d6a66;
--swr-devtools-border-color: #555454;
--swr-devtools-selected-bg-color: #524f4d;
--swr-devtools-selected-border-color: #bbb;
--swr-devtools-tag-bg-color: #FFF;
--swr-devtools-tag-text-color: #464242;
--swr-devtools-error-text-color: red;
}
}
`;

Expand Down Expand Up @@ -88,6 +100,7 @@ const Header = styled.header`
display: flex;
/* TODO: stop using the fixed size */
height: 36px;
color: var(--swr-devtools-text-color);
`;

const HeaderTitle = styled.h3`
Expand Down
1 change: 1 addition & 0 deletions packages/swr-devtools/src/components/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const TabButton = styled.button.attrs({ type: "button" })<{
props.isSelected
? "var(--swr-devtools-selected-bg-color)"
: "var(--swr-devtools-bg-color)"};
color: var(--swr-devtools-text-color);
cursor: pointer;
&:hover {
background-color: ${(props) =>
Expand Down

0 comments on commit 40d96a4

Please sign in to comment.