All Projects â†’ raphamorim â†’ mugiwara

raphamorim / mugiwara

Licence: MIT license
fast minimal CSS-in-JS created to reduce size of CSS injected

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mugiwara

Css In Js
Autocomplete React Native / JS Styles and converting plain CSS to JS styles
Stars: ✭ 192 (+1645.45%)
Mutual labels:  styled-components, css-in-js
Awesome Styled Components
A curated list of awesome styled-components resources 💅
Stars: ✭ 2,869 (+25981.82%)
Mutual labels:  styled-components, css-in-js
Styled Components Vs Emotion
a short doc comparing the popular CSS-in-JS libraries styled-components and emotion
Stars: ✭ 204 (+1754.55%)
Mutual labels:  styled-components, css-in-js
Filbert Js
A lightweight(~1kb) css-in-js framework
Stars: ✭ 167 (+1418.18%)
Mutual labels:  styled-components, css-in-js
tsstyled
A small, fast, and simple CSS-in-JS solution for React.
Stars: ✭ 52 (+372.73%)
Mutual labels:  styled-components, css-in-js
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+18800%)
Mutual labels:  styled-components, css-in-js
Styled Ppx
Typed styled components in Reason, OCaml and ReScript
Stars: ✭ 236 (+2045.45%)
Mutual labels:  styled-components, css-in-js
Next Dark Mode
🌑 Enable dark mode for Next.js apps
Stars: ✭ 133 (+1109.09%)
Mutual labels:  styled-components, css-in-js
tailed
Tailed is a tiny lib to add styled-components syntax like, with suport to conditional classes.
Stars: ✭ 79 (+618.18%)
Mutual labels:  styled-components, css-in-js
Arc
React starter kit based on Atomic Design
Stars: ✭ 2,780 (+25172.73%)
Mutual labels:  styled-components, css-in-js
Gatsby Theme Superstylin
💅 A Gatsby Theme with styled-components
Stars: ✭ 165 (+1400%)
Mutual labels:  styled-components, css-in-js
Styled-Responsive-Media-Queries
Responsive Media Queries for Emotion styled or styled-components — Standard size from Chrome DevTools.
Stars: ✭ 33 (+200%)
Mutual labels:  styled-components, css-in-js
Styled Bootstrap
💅ðŸŧ A styled-component implementation of Bootstrap
Stars: ✭ 154 (+1300%)
Mutual labels:  styled-components, css-in-js
Styled Theme
Extensible theming system for styled-components 💅
Stars: ✭ 183 (+1563.64%)
Mutual labels:  styled-components, css-in-js
Goober
ðŸĨœ goober, a less than 1KB 🎉 css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+20963.64%)
Mutual labels:  styled-components, css-in-js
Styled Email Components
💌 styled-components for emails
Stars: ✭ 231 (+2000%)
Mutual labels:  styled-components, css-in-js
Scoped Style
A tiny css in js library 🚀
Stars: ✭ 129 (+1072.73%)
Mutual labels:  styled-components, css-in-js
React Next Boilerplate
🚀 A basis for reducing the configuration of your projects with nextJS, best development practices and popular libraries in the developer community.
Stars: ✭ 129 (+1072.73%)
Mutual labels:  styled-components, css-in-js
Styled Props
Simple lib that allows you to set styled props in your styled-components without stress.
Stars: ✭ 247 (+2145.45%)
Mutual labels:  styled-components, css-in-js
linaria-styled
Zero-runtime CSS in JS library for building React components
Stars: ✭ 17 (+54.55%)
Mutual labels:  styled-components, css-in-js

Mugiwara

éšĶわらåļ―子

Mugiwara is a fast minimal CSS-in-JS created to reduce size of CSS injected

Mugiwara uses similar Virtual CSS concept to reduce bundle however using a preemption algorithm behind, called as Chain CSS. On 1.2KB (gzipped).

CircleCI branch NPM Version

Status: Under development.

Benchmark

cxs x 31,955 ops/sec Âą5.10% (85 runs sampled)
fela x 29,790 ops/sec Âą0.93% (85 runs sampled)
mugiwara x 33,806 ops/sec Âą0.96% (86 runs sampled)
glamor x 25,009 ops/sec Âą1.34% (85 runs sampled)
Fastest is mugiwara
âœĻ  Done in 27.38s.

Principles:

  • Transform declarations in Shallow way

Browsers read selectors from right to left. The deeper the selectors are, the longer it takes for the browser to render and re-render the elements those selectors are applied to. For complex DOMs that reflow often, short selectors can also cut down on jank.

Good to read: Efficiently Rendering CSS

  • Prehemption

Feature not available yet, soon more details.

  • Remove redundances

Good to read: Remove Unused CSS to Reduce the Size of your Stylesheets

How Chain CSS works?

Algorithm still in development, here's a preview of first step:

Element A -> {color: 'blue', padding: '10px', fontFamily: 'Helvetica'}
Element B -> {color: 'red', borderRight: '1px solid #333'}
Element C -> {padding: 10, fontFamily: 'Helvetica'}

Result:

.A { 
  color: blue 
}
.A, .C { 
  padding: '10px', 
  fontFamily: 'Helvetica' 
}
.B { 
  border-right: '1px solid #333' 
}

Installing

yarn add mugiwara

Using it

Example with ReactJS:

import React from 'react'
import { render } from 'react-dom'
import { createClass, createStyles } from 'mugiwara'

const className = createClass({
  padding: 32,
  backgroundColor: 'green'
})

const Box = (props) => <div {...props} className={className} />

createStyles()

render(Box, document.querySelector('#root'))

Also valid API (still in draft):

const className = createClass(`
  position: 'abolute',
  padding: 32px,
  backgroundColor: 'green'

  & div {
    width: 100px;
  }
`)

Example with ReactJS Server side-render:

import React from 'react'
import ReactDOMServer from 'react-dom/server'
import { shallowStyles } from 'mugiwara'
import App from './App'

const renderedApp = ReactDOMServer.renderToString(<App />)
const staticPage = `
<html>
  <style>${shallowStyles()}</style>
  ${renderedApp}
</html>
`

console.log(staticPage)
/*
<html>
  <style>.app{position:absolute;display:flex;margin:0 auto;}.heading{font-family:Helvetica, arial;}</style>
  <div class="app" data-reactroot=""><div class="heading">MyApp</div></div>
</html>
*/

1.x ROADMAP

  • Support pseudo-selectors
  • Support to prefix
  • Check similar properties (e.g: #FFF, white) and keep one
  • Support MediaQueries
  • Support Server Side Renderer
  • Cache features
  • Support React Native Style (using native-css)

Reference

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].