Skip to content

Commit

Permalink
Add experimental Dark Theme with funny toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
anagstef committed Jul 4, 2019
1 parent a1337c4 commit 9edde64
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 100 deletions.
23 changes: 21 additions & 2 deletions src/components/header.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
header{
background: #4d8dff;
background: var(--header-color);
margin-bottom: 1.45rem;
}

header .header-container{
margin: 0 auto;
max-width: 960px;
padding: 1.45rem 1.0875rem;
color: white;
color: var(--header-font-color);
display: flex;
justify-content: space-between;
}

header .header-title-logo{
display: flex;
}

header button {
height: 100%;
width: auto;
font-size: 14px;
line-height: normal;
border-radius: 50%;
background-color: #fff;
font-weight: 500;
}

header button:focus {
outline: none;
}

header h1{
Expand Down
53 changes: 32 additions & 21 deletions src/components/header.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import './header.css';
import IonicLogo from '../images/ionic-icon.png';

const Header = ({ siteTitle, siteSubtitle }) => (
<header>
<div className="header-container">
<img src={IonicLogo} className="ionic-logo" alt="ionic logo" />
<div className="header-title-text">
<h1>{siteTitle}</h1>
<h5>{siteSubtitle}</h5>
</div>
</div>
</header>
);
class Header extends React.Component {
constructor(props) {
super(props);
this.toggleDarkTheme = this.toggleDarkTheme.bind(this);
}

Header.propTypes = {
siteTitle: PropTypes.string,
siteSubtitle: PropTypes.string,
};
toggleDarkTheme() {
const { toggleDarkTheme, darkTheme } = this.props;
toggleDarkTheme(!darkTheme);
}

Header.defaultProps = {
siteTitle: '',
siteSubtitle: '',
};
render() {
const { siteTitle, siteSubtitle } = this.props;
return (
<header>
<div className="header-container">
<div className="header-title-logo">
<img src={IonicLogo} className="ionic-logo" alt="ionic logo" />
<div className="header-title-text">
<h1>{siteTitle}</h1>
<h5>{siteSubtitle}</h5>
</div>
</div>
<button type="button" onClick={this.toggleDarkTheme}>?</button>
</div>
</header>
);
}
}

export default Header;
export default connect(
({ darkTheme }) => ({ darkTheme }),
dispatch => ({ toggleDarkTheme: value => dispatch({ type: 'DARK_THEME', data: value }) }),
)(Header);
38 changes: 35 additions & 3 deletions src/components/layout.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
:root {
--searchbar-bg-color: #f0f0f0;
--searchbar-text-color: rgba(0, 0, 0, 0.5);
--font-color: rgba(0, 0, 0, 0.8);
--bg-color: #fff;
--header-color: #4d8dff;
--header-font-color: #fff;
--ionic-link-icon-color: rgba(0, 0, 0, 0.2);
--ionic-link-icon-color-hover: rgb(77, 141, 255, 0.6);
--table-border-bottom-color: rgba(0, 0, 0, 0.15);
--variable-highlight-color: rgba(212, 212, 212, 0.2);
--variable-highlight-color-hover: rgba(77,166,255, 0.2);
}

.dark-theme {
--searchbar-bg-color: rgba(240, 240, 240, 0.1);
--searchbar-text-color: rgba(255, 255, 255, 0.7);
--font-color: #fff;
--bg-color: rgba(40, 44, 53, 1);
--header-color: var(--bg-color);
--header-font-color: #fff;
--ionic-link-icon-color: rgba(255, 255, 255, 0.5);
--ionic-link-icon-color-hover: rgba(77, 141, 255, 1);
--table-border-bottom-color: rgba(255, 255, 255, 0.15);
--variable-highlight-color: rgba(212, 212, 212, 0.1);
--variable-highlight-color-hover: rgba(77,166,255, 0.8);
}

html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
Expand All @@ -8,6 +36,8 @@ body {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: var(--bg-color);
color: var(--font-color);
}
article,
aside,
Expand Down Expand Up @@ -199,7 +229,7 @@ html {
box-sizing: inherit;
}
body {
color: hsla(0, 0%, 0%, 0.8);
color: var(--font-color);
font-weight: normal;
word-wrap: break-word;
font-kerning: normal;
Expand Down Expand Up @@ -623,8 +653,10 @@ pre tt:after {
left: 0;
width: 20px;
height: 20px;
opacity: 0.8;
background: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-49 141 512 512'%3E%3Cpath d='M79 641.8c0 5.7.8 8.9 4 10.5 2.4 1.6 6.4 0 10.5-4.1l235.1-236.7c4-4.1 6.4-8.9 6.4-14.6s-2.4-10.5-6.4-14.6L93.5 145.7c-4-4.1-7.2-5.7-10.5-4.1-2.4.8-4 4.9-4 10.5'/%3E%3C/svg%3E") center / contain no-repeat;
mask-repeat: no-repeat;
mask-position: center;
background-color: var(--font-color);
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-49 141 512 512'%3E%3Cpath d='M79 641.8c0 5.7.8 8.9 4 10.5 2.4 1.6 6.4 0 10.5-4.1l235.1-236.7c4-4.1 6.4-8.9 6.4-14.6s-2.4-10.5-6.4-14.6L93.5 145.7c-4-4.1-7.2-5.7-10.5-4.1-2.4.8-4 4.9-4 10.5'/%3E%3C/svg%3E");
}

.heart-icon{
Expand Down
66 changes: 0 additions & 66 deletions src/components/list-item.css

This file was deleted.

68 changes: 68 additions & 0 deletions src/components/list-item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.list-item {
width: 100%;
margin-bottom: 50px;
}

.list-item-title{
display: flex;
flex-direction: row;
justify-content: space-between;

span {
position: absolute;
right: 0;
width: 32px;
height: 32px;
background-color: var(--ionic-link-icon-color);
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M256 161.2c-52.3 0-94.8 42.5-94.8 94.8s42.5 94.8 94.8 94.8 94.8-42.5 94.8-94.8-42.5-94.8-94.8-94.8z'/%3E%3Ccircle cx='392.1' cy='126.4' r='43.2'/%3E%3Cpath d='M445.3 169.8l-1.8-4-2.9 3.3c-7.1 8-16.1 14.2-26.1 17.9l-2.8 1 1.1 2.7c8.6 20.7 13 42.7 13 65.2 0 93.7-76.2 169.9-169.9 169.9S86.1 349.7 86.1 256 162.3 86.1 256 86.1c25.4 0 49.9 5.5 72.8 16.4l2.7 1.3 1.2-2.7c4.2-9.8 10.8-18.5 19.2-25.2l3.4-2.7-3.9-2C321.6 55.8 289.5 48 256 48 141.3 48 48 141.3 48 256s93.3 208 208 208 208-93.3 208-208c0-30-6.3-59-18.7-86.2z'/%3E%3C/svg%3E");
}

span:hover {
background-color: var(--ionic-link-icon-color-hover);
}

a {
text-decoration: none;
position: relative;
}
}

.table-row{
border-bottom: solid 1px var(--table-border-bottom-color);
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
min-height: 50px;
}

.row-name,
.row-desc {
width: 45%;
padding-top: 10px;
padding-bottom: 10px;
}

.row-name span{
background: var(--variable-highlight-color);
font-weight: 500;
}

.row-name span:hover{
background: var(--variable-highlight-color-hover);
cursor: pointer;
}

.row-name span::after{
content: '';
position: absolute;
margin-left: 10px;
margin-top: 5px;
width: 16px;
height: 16px;
mask-position: center;
mask-repeat: no-repeat;
background-color: var(--font-color);
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg baseProfile='tiny' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M15.979 7.62H1.021a.4.4 0 0 0-.4.4v14.959a.4.4 0 0 0 .4.4H15.98a.4.4 0 0 0 .4-.4V8.021a.402.402 0 0 0-.401-.401zm-.399 14.959H1.42V8.421h14.16v14.158z'/%3E%3Cpath d='M22.979.62H8.021a.4.4 0 0 0-.4.4v4.959a.4.4 0 1 0 .8 0V1.421H22.58v14.158h-4.559a.4.4 0 0 0 0 .8h4.959a.4.4 0 0 0 .4-.4V1.021a.402.402 0 0 0-.401-.401z'/%3E%3C/svg%3E");
opacity: 0.7;
}
12 changes: 7 additions & 5 deletions src/components/searchbar.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
.search{
margin-top: 20px;
margin-bottom: 20px;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
.searchbar-container{
position: relative;
width: 100%;
background-color: #f0f0f0;
background-color: var(--searchbar-bg-color);
border-radius: 99px;
margin-bottom: 10px;
}
Expand All @@ -19,8 +17,10 @@
top: 0;
bottom: 0;
width: 20px;
background: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1000'%3E%3Cpath d='M932.8 850l-201-201c56.4-67.6 90.3-154.5 90.3-249.5C822.2 184.2 647.9 10 432.7 10 217.4 10 43.2 184.2 43.2 399.5 43.2 614.7 217.4 789 432.7 789c61.1 0 119-14.1 170.5-39.1 3 4.7 6.6 9.1 10.7 13.2l203 203c32 32 84 32 116 0 31.9-32.1 31.9-84.1-.1-116.1zM125.2 399.5C125.2 229.7 262.9 92 432.7 92s307.5 137.7 307.5 307.5S602.4 707 432.7 707c-169.8 0-307.5-137.7-307.5-307.5z'/%3E%3C/svg%3E") center / contain no-repeat;
opacity: 0.5;
background-color: var(--searchbar-text-color);
mask-repeat: no-repeat;
mask-position: center;
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1000'%3E%3Cpath d='M932.8 850l-201-201c56.4-67.6 90.3-154.5 90.3-249.5C822.2 184.2 647.9 10 432.7 10 217.4 10 43.2 184.2 43.2 399.5 43.2 614.7 217.4 789 432.7 789c61.1 0 119-14.1 170.5-39.1 3 4.7 6.6 9.1 10.7 13.2l203 203c32 32 84 32 116 0 31.9-32.1 31.9-84.1-.1-116.1zM125.2 399.5C125.2 229.7 262.9 92 432.7 92s307.5 137.7 307.5 307.5S602.4 707 432.7 707c-169.8 0-307.5-137.7-307.5-307.5z'/%3E%3C/svg%3E");
}

.searchbar-container input{
Expand All @@ -29,6 +29,7 @@
border-style: none;
height: 50px;
padding-left: 50px;
color: var(--searchbar-text-color);
}

.searchbar-container input:focus{
Expand All @@ -37,6 +38,7 @@

.searchbar-container input::placeholder{
font-style: italic;
color: var(--searchbar-text-color);
}

.checkboxes{
Expand Down
14 changes: 11 additions & 3 deletions src/state/createStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ const reducer = (state, action) => {
const newState = Object.assign({}, state, {
search: action.data,
});
// localStorage.setItem('state', JSON.stringify(newState));
return newState;
}
if (action.type === 'DARK_THEME') {
const body = document.body.classList;

if (action.data) body.add('dark-theme');
else body.remove('dark-theme');

const newState = Object.assign({}, state, {
darkTheme: action.data,
});
return newState;
}
return state;
};

// const initialState = JSON.parse(localStorage.getItem('state')) || { };

const createStore = () => reduxCreateStore(reducer, { });
export default createStore;

0 comments on commit 9edde64

Please sign in to comment.