All Projects → scalajs-css → core

scalajs-css / core

Licence: Apache-2.0 license
ScalaJS CSS library

Programming Languages

scala
5932 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to core

Hacktober-Fest-2021
📜This repository is created to welcome all the open source enthusiasts to get introduced to beginner friendly projects they could work with in the festive season of HacktoberFest 2021🎇🙌.
Stars: ✭ 23 (-4.17%)
Mutual labels:  css3
SIAKAD-PT
Sistem Informasi Akademik Perguruan Tinggi with Framework CodeIgniter
Stars: ✭ 53 (+120.83%)
Mutual labels:  css3
Web-Development-Path-And-Resources
Will Add a path and some resources in this repo for web D for my first year students
Stars: ✭ 46 (+91.67%)
Mutual labels:  css3
QRCode-generator
Easily create your QR Code with this application.
Stars: ✭ 31 (+29.17%)
Mutual labels:  css3
hovercraft-slides
🍪 A template for new Hovercraft presentation projects (impress.js slides in reStructuredText)
Stars: ✭ 12 (-50%)
Mutual labels:  css3
The-HTML-and-CSS-Workshop
A New, Interactive Approach to Learning HTML and CSS
Stars: ✭ 65 (+170.83%)
Mutual labels:  css3
boss-lite
Boss Lite - React Redux Material Admin Template
Stars: ✭ 148 (+516.67%)
Mutual labels:  css3
HelpingHand
A Donation Website With Razorpay Payment Gateway Integration. Tech Stack Used- HTML, CSS, JavaScript.
Stars: ✭ 25 (+4.17%)
Mutual labels:  css3
BabyBrowser
A Small Web Browser Built in Python
Stars: ✭ 21 (-12.5%)
Mutual labels:  css3
css3-animation-generator
chrome plugin css3 animation generator
Stars: ✭ 93 (+287.5%)
Mutual labels:  css3
javascript-book-reading
「前端书籍精读笔记系列」,整理的前端书籍清单阅读笔记
Stars: ✭ 58 (+141.67%)
Mutual labels:  css3
css-loader
This is a library having a collection of different types of CSS loaders, spinners
Stars: ✭ 414 (+1625%)
Mutual labels:  css3
science-fiction-magazines-blog
Blog template (concept) is inspired by stylish science fiction magazines of the 80-90s.
Stars: ✭ 24 (+0%)
Mutual labels:  css3
MemoryGame
🎮🕹😁 Rick And Morty Memory Game
Stars: ✭ 188 (+683.33%)
Mutual labels:  css3
30diasDeCSS
Desafio criar 30 mini projetos utilizando HTML e CSS em 30 dias, participe também!
Stars: ✭ 38 (+58.33%)
Mutual labels:  css3
youphonic
an online musical machine interface for building and sharing soundscapes and musical compositions
Stars: ✭ 28 (+16.67%)
Mutual labels:  css3
react-theme
Production ready Wordpress theme built with React, Redux, Redux-Thunk, Intl, React Router v4, etc... and packaged by Webpack 2. Enjoy!
Stars: ✭ 14 (-41.67%)
Mutual labels:  css3
js-to-do
A Simple To Do Web App using just JavaScript.
Stars: ✭ 22 (-8.33%)
Mutual labels:  css3
static-website
🖥 New Vue/Nuxt website for cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 47 (+95.83%)
Mutual labels:  css3
css3-loading
20种常见的css3 Loading动画
Stars: ✭ 22 (-8.33%)
Mutual labels:  css3

ScalaJS-CSS

Features :

  • Type Safe CSS
  • Compile Time Generated
  • Built for Component Age
  • Extensible via Plugins
// build.sbt
resolvers += Resolver.bintrayRepo("scalajs-css", "maven")
libraryDependencies += "scalajs-css" %%% "core" % "replaceThisWithLatestVersionNumberFromReleaseTags"

Docs

Define StyleSheet

  object styles extends CSSStyleSheet {

    import dsl._
    import scalajscss.units._

    val container =
      style(backgroundColor := "red",
            display.flex,
            width := 100.%%,
            zIndex := 100,
            textUnderlinePosition.`under left`,
            transformStyle.preserve3d)

    val container2 = style(display.flex, flexDirection.columnReverse)

    val container4 =
      style(backgroundColor := "blue")

    // prefix with other class names
    val container3 =
      styleExtend(container)(color.red)

    // style suffix (pseudo classes , pseudo elements , random child element)
    styleSuffix(container, PseudoClasses.nthChild(46))(
      backgroundColor := "yellow")

    styleSuffix(container, PseudoClasses.hover)(backgroundColor := "red")

    styleSuffix(container, PseudoElements.after)(
      content := "\"Look at this orange box.\"",
      backgroundColor := "orange")

    styleSuffix(container2, " " + Tags.li)(color.green)

    //media queries
    media("(max-width: 1024px)")(
      styleVariant(container)(backgroundColor := "yellow"))

    // key frames
    keyframes("identifier1")(
      keyframeBlock("from")(top := "0"),
      keyframeBlock("to")(top := 100.px)
    )

    //global styles
    styleGlobal(Tags.body)(backgroundColor := "white")
    styleGlobal(Tags.a)(color := "purple")

  }

Generated CSS

.packagename-styles-container {
background-color: red;
display: flex;
width: 100%;
z-index: 100;
text-underline-position: under left;
transform-style: preserve-3d;
}
.packagename-styles-container2 {
display: flex;
flex-direction: column-reverse;
}
.packagename-styles-container4 {
background-color: blue;
}
.scalajscss-ScalaJSCSSTest-styles-container3 {
color: red;
}
.packagename-styles-container:nth-child(46) {
background-color: yellow;
}
.packagename-styles-container:hover {
background-color: red;
}
.packagename-styles-container::after {
content: "Look at this orange box.";
background-color: orange;
}
.packagename-styles-container2 li {
color: green;
}
@media (max-width: 1024px) {
.packagename-styles-container {
background-color: yellow;
}
}
@keyframes identifier1 {
from {
top: 0;
}
to {
top: 100px;
}
}
body {
background-color: white;
}
a {
color: purple;
}

Add to Document

// add single sheet 
CSSStyleSheetRegistry.addToDocument(styles)

// add multiple sheets
CSSStyleSheetRegistry.addToDocument(styles,styles2,style3)

Note: Once StyleSheet(styles) added to document, adding it again and again has no effect

Remove from Document

// remove single sheet 
CSSStyleSheetRegistry.removeFromDocument(styles)

// remove multiple sheets
CSSStyleSheetRegistry.removeFromDocument(styles,styles2,style3)

Note: If you want to add removed styleSheet later at some point, make sure you used CSSStyleSheetRegistry.addToDocumentAndKeepCSSInMemory(..) while adding

StyleSheet Order

Let say you're building re usable component library and you have no control over which component is going to be used by end user. but your library depends on order of styles added to document(example : Button should be registered after BaseButton ,etc)

CSSStyleSheetRegistry.setOrder(BaseButton.styles,Button.styles)

Plugins

Use plugins to enhance raw css (example : autoprefixer,.. etc)

CSSStyleSheetRegistry.setPlugins(AutoPrefixer(),..)

ClassName Shrink

By default class names emitted with packagename prefix

Example :

package org.domain.components

object styles extends CSSStyleSheet {
 
  val container = style(display.flex)
}
 
}

println(s"ClassName : ${styles.container}")// prints ClassName: org-domain-components-styles-container

For example in react apps we put all styles inside components package and we can make sure that inside components package each className will be unique, and we can easily omit org-domain-components- from our class names, to achieve this set macro setting via scalacOptions in build.sbt

scalacOptions ++= Seq(
   ....,
  "-Xmacro-settings:classNameShrink=components"
)

Community

If you have any questions regarding scalajs-css ,open a thread here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].