-
Notifications
You must be signed in to change notification settings - Fork 2
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 #46 from typecode/issue-15
#15 - Custom color config & handling
- Loading branch information
Showing
14 changed files
with
256 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
colors: { | ||
flyoutBg: 'rgb(32, 31, 32)', | ||
menuItemIcon: 'rgb(255, 255, 255)', | ||
menuItemHover: 'rgb(0, 174, 239)', | ||
menuItemActive: 'rgb(0, 156, 215)' | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// jshint strict: false | ||
|
||
/** | ||
* Styles - | ||
* Handle the creation and embedding of custom styles. | ||
* @access protected | ||
* @module modules/Styles | ||
*/ | ||
|
||
import Module from '../core/Module'; | ||
|
||
const Styles = Module({ | ||
name: 'Styles', | ||
|
||
props: { | ||
stylesheet: null, | ||
}, | ||
|
||
handlers: { | ||
events: { | ||
'app:destroy': 'destroy' | ||
} | ||
}, | ||
|
||
methods: { | ||
setup () { | ||
this.createStylesheet(); | ||
}, | ||
|
||
init () { | ||
const { mediator } = this; | ||
const config = mediator.get('config:styles'); | ||
let stylesheetContent = this.stylesTemplate(config); | ||
|
||
this.appendStylesheet(); | ||
this.updateStylesheet(stylesheetContent); | ||
}, | ||
|
||
stylesTemplate (config) { | ||
return ` | ||
.typester-toolbar .typester-menu-item, | ||
.typester-input-form input[type=text], | ||
.typester-link-display a, | ||
.typester-input-form button { | ||
color: ${config.colors.menuItemIcon}; | ||
} | ||
.typester-toolbar .typester-menu-item svg, | ||
.typester-link-display .typester-link-edit svg, | ||
.typester-input-form button svg { | ||
fill: ${config.colors.menuItemIcon}; | ||
} | ||
.typester-input-form button svg { | ||
stroke: ${config.colors.menuItemIcon}; | ||
} | ||
.typester-toolbar .typester-menu-item:hover, | ||
.typester-link-display .typester-link-edit:hover | ||
.typester-input-form button:hover { | ||
background: ${config.colors.menuItemHover}; | ||
} | ||
.typester-toolbar .typester-menu-item.s--active { | ||
background: ${config.colors.menuItemActive}; | ||
} | ||
.typester-flyout .typester-flyout-content { | ||
background: ${config.colors.flyoutBg}; | ||
} | ||
.typester-flyout.place-above .typester-flyout-arrow { | ||
border-top-color: ${config.colors.flyoutBg}; | ||
} | ||
.typester-flyout.place-below .typester-flyout-arrow { | ||
border-bottom-color: ${config.colors.flyoutBg}; | ||
} | ||
`; | ||
}, | ||
|
||
createStylesheet () { | ||
this.stylesheet = document.createElement('style'); | ||
}, | ||
|
||
appendStylesheet () { | ||
document.head.appendChild(this.stylesheet); | ||
}, | ||
|
||
updateStylesheet (stylesheetContent) { | ||
this.stylesheet.textContent = stylesheetContent; | ||
}, | ||
|
||
removeStylesheet () { | ||
document.head.removeChild(this.stylesheet); | ||
}, | ||
|
||
destroy () { | ||
this.removeStylesheet(); | ||
} | ||
} | ||
}); | ||
|
||
export default Styles; |
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.