-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from decentraland/feat/themes-addon
feat: themes addon
- Loading branch information
Showing
65 changed files
with
284 additions
and
236 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
const React = require('react') | ||
const { Checkbox } = require('semantic-ui-react') | ||
|
||
function addStyle(id, css) { | ||
removeStyle('switch-theme') | ||
const head = document.head || document.getElementsByTagName('head')[0] | ||
const style = document.createElement('style') | ||
|
||
style.id = id | ||
style.type = 'text/css' | ||
|
||
if (style.styleSheet) { | ||
// This is required for IE8 and below. | ||
style.styleSheet.cssText = css | ||
} else { | ||
style.appendChild(document.createTextNode(css)) | ||
} | ||
|
||
head.appendChild(style) | ||
} | ||
|
||
function removeStyle(id) { | ||
const element = document.getElementById(id) | ||
if (element) { | ||
element.remove() | ||
} | ||
} | ||
|
||
class SwitchTheme extends React.PureComponent { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
checked: !!this.props.isChecked() | ||
} | ||
this.toggleStyle(this.state.checked) | ||
} | ||
|
||
toggleStyle(toggle) { | ||
if (toggle) { | ||
addStyle('switch-theme', this.props.themeA) | ||
} else { | ||
addStyle('switch-theme', this.props.themeB) | ||
} | ||
} | ||
|
||
handleClick() { | ||
const toggle = !this.props.isChecked() | ||
this.toggleStyle(toggle) | ||
this.props.onChange(toggle) | ||
this.setState({ checked: toggle }) | ||
} | ||
|
||
render() { | ||
return React.createElement( | ||
'div', | ||
{ | ||
style: { | ||
zIndex: 1000, | ||
position: 'fixed' | ||
}, | ||
onClick: this.handleClick.bind(this) | ||
}, | ||
React.createElement( | ||
Checkbox, | ||
{ | ||
style: { margin: 20 }, | ||
label: 'Dark theme', | ||
slider: true, | ||
checked: this.state.checked | ||
}, | ||
null | ||
) | ||
) | ||
} | ||
} | ||
|
||
export default (themeA, themeB, isChecked, onChange) => storyFn => { | ||
return [ | ||
React.createElement( | ||
SwitchTheme, | ||
{ | ||
themeA: themeA, | ||
themeB: themeB, | ||
isChecked: isChecked, | ||
onChange: onChange | ||
}, | ||
null | ||
), | ||
storyFn() | ||
] | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.dcl.address { | ||
color: var(--text); | ||
} |
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,6 @@ | ||
.ui.header { | ||
font-family: var(--font-print); | ||
color: var(--text); | ||
} | ||
|
||
.ui.header.sub + .ui.header { | ||
|
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
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
Oops, something went wrong.