Skip to content

Commit

Permalink
Implemented Icons and a Dark Mode toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
frewes committed Aug 18, 2020
1 parent 5708821 commit 546e6a2
Show file tree
Hide file tree
Showing 19 changed files with 5,640 additions and 21 deletions.
1,769 changes: 1,767 additions & 2 deletions lib/index.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.es.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion lib/index.es.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.es.min.js.map

Large diffs are not rendered by default.

1,775 changes: 1,773 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.min.js.map

Large diffs are not rendered by default.

1,781 changes: 1,775 additions & 6 deletions lib/index.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.umd.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion lib/index.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.umd.min.js.map

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "westreact",
"name": "reaction-time",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
Expand Down Expand Up @@ -31,6 +31,7 @@
"@babel/preset-react": "^7.10.4",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@rollup/plugin-json": "^4.1.0",
"@testing-library/react": "^10.4.7",
"babel-loader": "^8.1.0",
"babel-plugin-emotion": "^10.0.33",
Expand Down
7 changes: 7 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import resolve from "rollup-plugin-node-resolve";
import external from "rollup-plugin-peer-deps-external";
import { uglify } from "rollup-plugin-uglify";
import { terser } from "rollup-plugin-terser";
import json from "@rollup/plugin-json";

import packageJSON from "./package.json";
const input = "./src/index.js";
Expand All @@ -19,6 +20,7 @@ export default [
sourcemap: true,
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand All @@ -35,6 +37,7 @@ export default [
sourcemap: true,
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand All @@ -59,6 +62,7 @@ export default [
},
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand All @@ -81,6 +85,7 @@ export default [
sourcemap: true,
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand All @@ -100,6 +105,7 @@ export default [
sourcemap: true,
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand All @@ -117,6 +123,7 @@ export default [
sourcemap: true,
},
plugins: [
json(),
babel({
exclude: "node_modules/**",
}),
Expand Down
31 changes: 31 additions & 0 deletions src/components/DarkMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { Component } from "react";
import { getCurrentTheme, setTheme } from "airspeed";
import Icon from "../components/Icon";
/**
* Button for switching between light mode and dark mode
*/
export default class DarkMode extends Component {
constructor(props) {
super(props);
this.state = { theme: getCurrentTheme() };

this.toggleTheme = this.toggleTheme.bind(this);
}
toggleTheme() {
var newTh = this.state.theme === "light" ? "dark" : "light";
setTheme(newTh);
this.setState({ theme: newTh });
}

render() {
return (
<button className="button-darkmode" onClick={this.toggleTheme}>
{this.state.theme === "light" ? (
<Icon icon="moon" />
) : (
<Icon icon="sun" />
)}
</button>
);
}
}
20 changes: 20 additions & 0 deletions src/components/Icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Component } from "react";
import icons from "../resources/icons.json";

export default class Icon extends Component {
getIcon(cls) {
if (!cls) return "";
var name = cls.replace("-", "_");
if (icons[name]) return icons[name];
else return "";
}

render() {
return (
<div
className={`wrapper-icon ${this.props.className}`}
dangerouslySetInnerHTML={{ __html: this.getIcon(this.props.icon) }}
/>
);
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as Button } from "components/Button";
export { default as DarkMode } from "components/DarkMode";
export { default as Alert } from "components/Alert";
export { default as Badge } from "components/Badge";
export { default as TextInput } from "components/form/TextInput";
Expand Down
Loading

0 comments on commit 546e6a2

Please sign in to comment.