stylus / nib

Stylus mixins, utilities, components, and gradient image generation
http://stylus.github.io/nib
MIT License
1.91k stars 249 forks source link

Featurerequest / Idea: chaining of classes and ids #232

Closed ryrun closed 10 years ago

ryrun commented 10 years ago

Descendant selectors are slow. I use stylus mainly with the indent syntax and produce css with many descendant selectors. What about chaining of classnames and combine styles of chained classes and ids?

Example:

.menu
    padding: 0
    margin: 0
    _item
         font-size: 12px
        color: red

.text
    color: #ccc
    __link
         text-decoration: none
         &:hover
             text-decoration: underline

Generated CSS:

.menu{
    padding:0;
    margin:0
}
.menu_item{
    font-size:12px;
    color:red
}

.text{
    color:#ccc
}
.text_link{
    color:#ccc;
    text-decoration:none
}
.text_link:hover{
    color:#ccc;
    text-decoration:underline
}

_ = combine previous class or id __ = combine previous class or id and copy styles

What do you think about it?

ryrun commented 10 years ago

Ah sorry, wrong github :)