GithubHelp home page GithubHelp logo

oaki / functional-css-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rintoj/functional-css

0.0 1.0 0.0 3.72 MB

Lets you seamlessly integrate functional css.

JavaScript 8.59% CSS 32.42% TypeScript 58.99%

functional-css-1's Introduction

Functional CSS

This module will let you seamlessly integrate functional css and comes with a dark and light theme.

Install

npm install functional-css

Usage

Webpack with JS ES6 / TypeScript

import 'functional-css'

Webpack with ES5

require('functional-css')

With CSS/SCSS

@import '~functional-css'

Without Bundle

 <link href="./node_modules/functional-css/dist/index.min.css" rel="stylesheet" media="all" >

Integrate with React

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>
  }
}

Integrate with Angular

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';
  }
}

Import what's required

// 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'

Create Your Own Color Theme

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);
}

Styles

Contributing

Contributions are very welcome! Just send a pull request. Feel free to contact me or checkout my GitHub page.

Author

Rinto Jose (rintoj)

Hope this module is helpful to you. Checkout my other projects and articles. Enjoy coding!

Follow me: GitHub | Facebook | Twitter | Google+ | Youtube

Versions

Check CHANGELOG

License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.