All Projects → winston0410 → glory

winston0410 / glory

Licence: MIT License
The world fastest framework agonistic CSS-in-JS library. Available in any frontend framework you use, like React, Vue and Svelte.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to glory

morfeo
Morfeo is a tool to build design systems based on a theme. It helps you to follow a design language and write consistent UIs, whatever it is the framework of your choice. It's easy to use and, with the browser extension, your theme and your components are automatically documented.
Stars: ✭ 30 (+50%)
Mutual labels:  css-in-js, framework-agnostic
satchel
The little bag of CSS-in-JS superpowers
Stars: ✭ 14 (-30%)
Mutual labels:  css-in-js
mugiwara
fast minimal CSS-in-JS created to reduce size of CSS injected
Stars: ✭ 11 (-45%)
Mutual labels:  css-in-js
react-awesome-reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 564 (+2720%)
Mutual labels:  css-in-js
csstips
CSS Tips to help beginners using CSS in TS / JS
Stars: ✭ 50 (+150%)
Mutual labels:  css-in-js
veel
Base react styling components using fela with a design system
Stars: ✭ 26 (+30%)
Mutual labels:  css-in-js
flair
a lean, component-centric style system for React components
Stars: ✭ 19 (-5%)
Mutual labels:  css-in-js
react-native-css-in-js-benchmarks
CSS in JS Benchmarks for React Native
Stars: ✭ 46 (+130%)
Mutual labels:  css-in-js
styled-jsx-plugin-sass
Plugin to add Sass support to styled-jsx.
Stars: ✭ 20 (+0%)
Mutual labels:  css-in-js
styletron-connect
A high-level interface to styletron, similar to react-redux's connect
Stars: ✭ 17 (-15%)
Mutual labels:  css-in-js
styled-components-docs-zh
💅 styled-components 中文文档翻译 🏇持续施工中
Stars: ✭ 160 (+700%)
Mutual labels:  css-in-js
adonis
Adonis ❤️ Aphrodite
Stars: ✭ 44 (+120%)
Mutual labels:  css-in-js
permissionary
Tiny and framework-agnostic role-based permission management using composition over inheritance
Stars: ✭ 19 (-5%)
Mutual labels:  framework-agnostic
bredon
A modern CSS value compiler in JavaScript
Stars: ✭ 39 (+95%)
Mutual labels:  css-in-js
stylelint-processor-glamorous
💄 Lint glamorous and related css-in-js with stylelint
Stars: ✭ 18 (-10%)
Mutual labels:  css-in-js
watson-personality-insights-php
Framework Agnostic Watson Personality Insights Client
Stars: ✭ 13 (-35%)
Mutual labels:  framework-agnostic
fence
🔰 Framework-agnostic package who provides powerful ACL abilities to JavaScript
Stars: ✭ 64 (+220%)
Mutual labels:  framework-agnostic
smoothie
A deliciously scalable and adaptable stylesheet methodology 🍹
Stars: ✭ 27 (+35%)
Mutual labels:  css-in-js
namecase
This package allows you to convert names into the correct case where possible.
Stars: ✭ 70 (+250%)
Mutual labels:  framework-agnostic
zaftig
~2kB css in js: z`display flex` // .zjsdkk43-1
Stars: ✭ 15 (-25%)
Mutual labels:  css-in-js

Glory

🚀🚀🚀 The world fastest framework agonistic CSS-in-JS library.

File size Test Coverage Codacy Badge Known Vulnerabilities Build Status

Out run big-name popular CSS-in-JS libraries like Styled-component, Emotion, Styletron and Fela but with identical or even better supports.

Don't you believe me? Check out the benchmark here.

You can also try the sandboxes to try using Glory with different frameworks

Features

  • Lightweight and modular. Only weights 1.8kb (minified and gzipped) for the minimum viable setup.

  • 🔥 Blazing fast.

  • 🌏 Framework agonistic.

  • Well-tested.

  • 🚑 Provide optional prefixer plugin.

  • 👷 Provide optional Web Worker plugin support(experimental).

  • 🎨 Provide optional theming plugin.

  • 💅 Support nesting, keyframes and media-queries.

  • 🚧 Isomorphic. Support SSR/SSG server side render style rehydration. Unnecessary re-render is avoided.

Installation

Npm:

npm install glory

Yarn:

yarn add glory

Sponsors

Support this package by becoming our sponsor.

Tecky Academy Logo

Getting started

See our quick start guide for more details.

import { create } from 'glory'
import prefixer from 'glory/prefixer'
import hydration from 'glory/hydration'
import virtual from 'glory/virtual'

const glory = create({
	//Config renderer here
})

//Use plugin to upgrade the default renderer

//Select your preferred styling interface
virtual(glory)
//Add support for auto-prefixing if needed
prefixer(glory)
//Add style hydration supports, if you will render styling beforehand in server
hydration(glory)

const style = {
	color: 'red',
	paddingTop: '100px',
	'@media screen': {
		//supports media queries
		color: 'red'
	},
	':hover': {
		//supports pesudo-classes and selectors
		backgroundColor: 'blue'
	}
}

const className = glory.virtual(style)
//return 'a b c d' as class name for maximum performance

//Insert .a{color:red;}.b{padding-top:100px;}@media screen{.c{color:red;}}.d:hover{background-color:blue;} as styling

Example

Live demo (Code Sandbox)

Source code

Made in Hong Kong

This library is made by Hong Kongers.

Benchmarks

You can test the benchmark in your computer by cloning this repo and cd benchmarks. You can find all benchmarking commands in that package.json there.

Without prefixer, virtual()

$ node -r esm renderStyle/css.spec.js
nano-css("^5.3.1"), rule() x 121,604 ops/sec ±20.27% (64 runs sampled)
nano-css("^5.3.1"), virtual() x 395,781 ops/sec ±0.38% (92 runs sampled)
emotion("^11.1.3") x 381,874 ops/sec ±0.32% (98 runs sampled)
styletron("^1.4.6") x 816,730 ops/sec ±0.31% (97 runs sampled)
fela("^11.5.2") x 1,352,522 ops/sec ±1.11% (93 runs sampled)
glory, rule() x 324,168 ops/sec ±49.39% (56 runs sampled)
glory, virtual() x 1,357,795 ops/sec ±0.63% (94 runs sampled)
Fastest is glory, virtual(),fela("^11.5.2")

With prefixer, virtual()

$ node -r esm renderStyle/css-prefixed.spec.js
nano-css("^5.3.1"), rule() x 79,994 ops/sec ±16.18% (70 runs sampled)
nano-css("^5.3.1"), virtual() x 174,209 ops/sec ±1.19% (85 runs sampled)
emotion("^11.1.3") x 252,219 ops/sec ±1.64% (90 runs sampled)
goober("^2.0.21") x 98,742 ops/sec ±2.60% (57 runs sampled)
fela("^11.5.2") x 437,485 ops/sec ±3.97% (82 runs sampled)
styletron("^1.4.6") x 394,933 ops/sec ±1.32% (90 runs sampled)
glory, rule() x 249,918 ops/sec ±4.25% (57 runs sampled)
glory, virtual() x 1,002,094 ops/sec ±5.58% (72 runs sampled)
Fastest is glory, virtual()

With prefixer, jsx()

$ node -r esm renderStyle/css-jsx.spec.js
styled component x 39,671 ops/sec ±1.29% (90 runs sampled)
emotion, styled() x 645,268 ops/sec ±1.29% (90 runs sampled)
goober x 1,085,717 ops/sec ±0.43% (95 runs sampled)
glory, jsx() x 1,107,726 ops/sec ±0.58% (96 runs sample
d)
Fastest is glory, jsx()

Difference between nano-css and glory

This library is a fork of nano-css, with the following difference:

  • renderer.put() is no longer the default.

  • rendere.pfx is default to ''.

  • hydration() add-on can handle hydration for basic rules, at-rules and keyframes.

  • Handle values in array without needing array add-on.

Known issues

Module not found due to Typescript absolute import

create-react-app uses Typescript and absolute import is enabled by default.

If you are using Typescript, which may support absolute import based on compiler setting. If you have enabled absolute import, importing module like glory/virtual will make Typescript think that it is importing a file from <baseUrl>/glory/virtual, instead of searching node_modules for you.

To solve this, you have to update tsconfig.json to give the correct path to Typescript.

https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping

Contribution

To contribute in this project, you need to do the followings:

  • Fork this repo and then clone your fork into your computer.

  • Contribute in your fork, commit and push to your fork.

  • Create a pull request in this repo.

After your code had been reviewed, accepted and merged into this repo, you contribution will be shown in this repo.

Roadmap

You can check our development roadmap here

Inspirations

nano-css

This library is developed based on the good work of nano-css. This library would not be possible without their awesome test code.

TailwindCSS and Styletron

These two libraries have enlightened me with the potential of atomic css.

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