csstyle

MOVED TO https://github.com/csstyle/csstyle a modern approach for crafting beautifully maintainable stylesheets

  • 所有者: geddski/csstyle
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

csstyle

csstyle

Clean, simple, for styling the web.

Check out the docs and examples on csstyle.io

You can use csstyle with either Sass or postcss.

Getting Started

  1. Setup your project with either Sass or Postcss. If you're using Sass make sure you have the latest stable SASS (3.4).

  2. Add id="csstyle" to your html or body element. This is necessary so that components with their
    parts and options can nest indefinitely yet always be overridden by tweaks.

  3. Download csstyle from npm:

    npm install csstyle --save
    

    or from bower:

    bower install csstyle --save
    
  4. If you're using Sass, import into your stylesheets:

@import 'csstyle';

If you're using postcss, add csstyle as a plugin:

postcss([require('postcss-nested'), require('csstyle')]);

Be sure to include postcss-nested and csstyle in that order.

Now you're set and can start creating components with options & parts, adding in tweaks as needed. Enjoy!

Customizing Styling Conventions

csstyle lets you change the style conventions to whatever suits your style.

Default Symbols

  • options: \--
  • parts: __
  • tweaks: \+
  • rootId: csstyle

With SASS

Override the defaults using SASS variables.

  • options: $csstyle-option-symbol
  • parts: $csstyle-part-symbol
  • tweaks: $csstyle-tweak-symbol
  • rootId: $csstyle-root-id

Example:

  $csstyle-part-symbol: '\\/';
  $csstyle-root-id: 'app';

With Postcss

Override the defaults by calling the cssytle function with an options object.

  • options: optionSymbol
  • parts: partSymbol
  • tweaks: tweakSymbol
  • rootId: rootId

Example:

  require('../csstyle')({optionSymbol: '\\-', partSymbol: '\\/', rootId: 'app'})

IMPORTANT NOTE All characters besides _ need to be escaped! However, if you are using dashes, only the first one needs to be escaped. Use two backslashes to properly escape. For example to use a forward slash to separate parts, set $csstyle-part-symbol to \\/. The generated CSS classes will then be escaped with a single backslash.

FAQ

Can I use this with Libsass?

Yes. Libsass version 3.2.0 or greater fully supports csstyle.

How do parts react to component states like hover?

In Sass you can append a & to a selector or pseudo-selector to have it applied to the parent context. So for example to have a part react when the component gets hovered:

@include component(capacitor){
  background: red;
  
  @include part(flux){
    background: orange;
  }
  
  &:hover & {
    @include part(flux){
      background: blue;
    }
  }
}

License

MIT

主要指標

概覽
名稱與所有者geddski/csstyle
主編程語言CSS
編程語言CSS (語言數: 3)
平台
許可證Other
所有者活动
創建於2014-08-11 07:03:57
推送於2020-07-15 19:36:15
最后一次提交2016-12-21 00:19:41
發布數8
最新版本名稱v1.5.0 (發布於 2015-06-12 15:55:06)
第一版名稱1.0.1 (發布於 )
用户参与
星數848
關注者數28
派生數34
提交數105
已啟用問題?
問題數51
打開的問題數19
拉請求數8
打開的拉請求數2
關閉的拉請求數10
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?