Skip to content

Commit

Permalink
setup a dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Agney committed Mar 1, 2020
1 parent a56c4c7 commit f515d2b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 14 deletions.
6 changes: 6 additions & 0 deletions example/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>React Playground example</title>
<style>
body {
background: #212121;
color: #fff;
}
</style>
</head>

<body>
Expand Down
3 changes: 1 addition & 2 deletions example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ render(app, document.getElementById('app'));
initialSnippet={snippet}
defaultEditorTab="javascript"
defaultResultTab="console"
transformJs
presets={["react"]}
mode="dark"
/>
</Fragment>
);
Expand Down
1 change: 1 addition & 0 deletions playground/src/Result/ErrorDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Container = styled.div`
position: absolute;
width: 100%;
bottom: 0;
box-sizing: border-box;
`;

interface IProps {
Expand Down
2 changes: 2 additions & 0 deletions playground/src/TabStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const StyledTabs = styled(Tabs)`
export const StyledTabList = styled(TabList)`
border-bottom: ${props => props.theme.tabs.tabHeader.borderBottom};
padding: 0 0.8em;
background-color: ${props => props.theme.tabs.tabHeader.panelBackground || 'transparent'};
`;

export const StyledTab = styled(Tab)`
Expand All @@ -25,6 +26,7 @@ export const StyledTab = styled(Tab)`
padding: 0.8em 0.5em;
margin: 0 0.2em;
cursor: pointer;
color: ${props => props.theme.tabs.tabHeader.color};
&[data-selected] {
border-bottom: ${props => props.theme.tabs.selectedTab.borderBottom};
Expand Down
72 changes: 60 additions & 12 deletions playground/src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,61 @@
import { DefaultTheme } from "styled-components";
import { merge } from "lodash-es";

const lightModeColors = {
container: {
borderColor: "rgba(0, 0, 0, 0.3)",
}
},
error: {
background: "#e74c3c",
color: "#ffffff",
},
console: {
background: "rgba(0, 0, 0, 1)",
},
divider: {
background: "#202020",
},
editor: {
backgroundColor: `#000000`,
color: `#ffffff`,
},
tabs: {
tabHeader: {
background: 'transparent',
color: `#000000`,
borderBottom: `0.1em solid rgba(0, 0, 0, 0.1)`,
},
},
}

const darkModeColors = {
container: {
borderColor: "#ffffff",
}
borderColor: "rgba(255, 255, 255, 0.4)",
},
error: {
background: "#e74c3c",
color: "#ffffff",
},
console: {
background: "rgba(0, 0, 0, 1)",
},
divider: {
background: "rgba(255, 255, 255, 0.5)",
},
editor: {
backgroundColor: `#000000`,
color: `#ffffff`,
},
tabs: {
tabHeader: {
background: `rgba(1, 21, 21, 0.8)`,
panelBackground: `rgb(1, 21, 21)`,
color: `#ffffff`,
borderBottom: `0.1em solid rgba(255, 255, 255, 0.4)`,
},
selectedTab: {
borderBottom: "0.2em solid rgb(255, 255, 255)",
},
},
}

export const theme = {
Expand All @@ -20,31 +65,34 @@ export const theme = {
minWidth: "20em",
},
error: {
background: "#e74c3c",
color: "#ffffff",
background: "",
color: "",
},
console: {
background: "rgba(0, 0, 0, 1)",
},
divider: {
width: 2,
background: "#202020",
background: "",
},
editor: {
fontFamily: `Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace`,
backgroundColor: `#000000`,
color: `#ffffff`,
backgroundColor: ``,
color: ``,
},
tabs: {
tabHeader: {
borderBottom: "0.1em solid rgba(0, 0, 0, 0.1)",
background: `transparent`,
borderBottom: "",
panelBackground: "",
background: "",
color: '',
},
tabPanel: {
phoneHeight: "10em",
},
selectedTab: {
borderBottom: "0.1em solid rgb(0, 0, 0)",
background: '',
borderBottom: "0.2em solid rgb(0, 0, 0)",
},
},
};
Expand Down

0 comments on commit f515d2b

Please sign in to comment.