This module will let you seamlessly integrate functional css and comes with a dark and light theme.
npm install functional-css
import 'functional-css'
require('functional-css')
@import '~functional-css'
<link href="./node_modules/functional-css/dist/index.min.css" rel="stylesheet" media="all" >
require('functional-css/dist/index.min.css')
...
export class App extends React.Component {
constructor(props) {
super(props)
this.state = { theme: 'dark' }
}
switchTheme() {
this.setState(state => ({theme: state.theme === 'dark' ? 'light' : 'dark'}))
}
render() {
return <div className={`${this.state.theme}`}>
<i className="ion-ios-color-palette"
onClick={this.switchTheme.bind(this)} />
</div>
}
}
Add css to .angular-cli.json
under apps > styles
{
....
"apps": [{
...
"styles": [
...
"../node_modules/functional-css/dist/index.min.css",
],
}],
}
To use color theme add the theme's name to host element
import { Component, HostBinding } from '@angular/core';
@Component({
selector: 'app-root',
template: `
...
<i class="ion-ios-color-palette pointer" (click)="switchTheme()"></i>
`
})
export class AppComponent {
@HostBinding('class') theme = 'dark';
switchTheme() {
this.theme = this.theme === 'dark' ? 'light' : 'dark';
}
}
// core functional-css classes
import 'functional-css/dist/core.min.css'
// light and dark themes
import 'functional-css/dist/theme.min.css'
// light theme
import 'functional-css/dist/light-theme.min.css'
// dark theme
import 'functional-css/dist/dark-theme.min.css'
This module comes with the two color themes dark
and light
. Define the color name as a class on the body
tag, then use colors as defined under Colors Classes
You can define colors themes on your own as below. Colors are defined in pairs. The second color is the contrast color to the first.
@import '~functional-css/src/mixins'
.name-of-the-theme {
@include addColor(primary, #2C3336, #d7e3ea);
@include addColor(primary-s1, #162029, #abb4bd);
@include addColor(primary-s2, #3C4549, #d3dce0);
@include addColor(primary-s3, #58656d, #d3dce0);
@include addColor(secondary, #fafafa, #4b585f);
@include addColor(secondary-s1, #ecf0f3, #4b585f);
@include addColor(secondary-s2, #58656d, #ecf0f3);
@include addColor(accent, #ffae27, #424242);
@include addColor(white, #fff, #000);
@include addColor(black, #000, #fff);
@include addColor(error, #D02A2B, #fff);
@include addColor(success, #29D185, #fff);
@include addColor(warning, #ffae27, #424242);
@include addColor(divider, #263138);
}
- Colors Classes
- Available Colors
- Transparent Colors
- Border Radius
- Border Style
- Outline Style
- Border Width
- Outline
- Flexbox
- Font Weight
- Opacity
- Image
- Shadow
- Text
- Margin
- Margin Bottom
- Margin Left
- Margin Right
- Margin Top
- Margin Horizontal
- Margin Vertical
- Padding
- Padding Bottom
- Padding Left
- Padding Right
- Padding Top
- Padding Horizontal
- Padding Vertical
- Font Size
- Left
- Top
- Right
- Bottom
- Stroke Width
- Line Height
- Height
- Max Height
- Min Height
- Width
- Max Width
- Min Width
- Utils
- Overflow
- Vertical Align
- Transition
Contributions are very welcome! Just send a pull request. Feel free to contact me or checkout my GitHub page.
Rinto Jose (rintoj)
Follow me: GitHub | Facebook | Twitter | Google+ | Youtube
The MIT License (MIT)
Copyright (c) 2017 Rinto Jose (rintoj)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.