Skip to content

Latest commit

 

History

History
55 lines (50 loc) · 1.28 KB

README.md

File metadata and controls

55 lines (50 loc) · 1.28 KB

Stylish

A Swift CSS DSL library, based on swift-css.

let css = Stylesheet {            
    All {
        Background("#222")
    }
    Element(.div) {
        Color(.white)
        TextAlign(.left)
        Element(.p) {
            FontWeight(.bold)
        }
        Child {
            Element(.span) {
                BackgroundColor(.gray)
            }
        }
    }
    Element(.input) {
        Pseudo(.focus) {
            BackgroundColor(.red)
        }
        Attribute("type", .matches("text")) {
            FontSize(14.px)
        }
    }
    Media("only screen and (max-width: 600px)") {
        Id("custom-identifier") {
            Background("#222")
            Color(.cyan)
        }
        Class("custom-class") {
            Background("#333")
            Color(.aliceBlue)
        }
        Selector("ul > li > a") {
            Background("black")
            Color(.red)
                .important()
        }
        .pseudo(.hover)
    }
}
    
print(css.render())

Credits & references