polished css,GitHub - styled-components/polished: A lightweight toolset for writing styles in JavaSc...

344b8d6e23fb09dbe74a0fc41eeadbe8.png

A lightweight toolset for writing styles in JavaScript. ✨

badge.svg?branch=main

68747470733a2f2f636f6465636f762e696f2f67682f7374796c65642d636f6d706f6e656e74732f706f6c69736865642f6272616e63682f6d61696e2f67726170682f62616467652e737667

68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f706f6c69736865642e737667

npm install --save polished

# or if you're using yarn

yarn add polished

Want to write styles in JavaScript, but also want Sass-style helper functions and mixins? Need a consistent color palette throughout your app? ✨ polished is for you!

Make your app look great without stress

Cross framework compatible: No matter if you're using styled-components, emotion, jss, aphrodite, radium, or plain inline styles, as long as you're writing your styles in JavaScript you can use polished!

Switching from a pre-processor to styles in JS made easy

Docs

See the full documentation at polished.js.org!

Usage

✨ polished modules are meant to be used as stand-alone imports. You should avoid importing the entire library directly:

import { clearFix, animation } from 'polished'

import * as polished from 'polished

import polished from 'polished'

When ✨ polished modules are imported properly, tree shaking in webpack and Rollup can be leveraged to reduce your bundle size.

Browser Support

All Evergreen Browsers + IE11

As of v3.6.X we support >0.5%, not dead, ie >= 11, not op_mini all for all our builds.

Flow Type Definitions

✨ polished has first-class Flow support with zero configuration to assist you in finding type errors while using our modules.

Ignore ✨ polished source

Flow frequently updates and it is possible that the version you are running may cause you to run into errors coming from the polished package in your node_modules directory. You can add the following lines to your .flowconfig to ignore polished in those cases:

[ignore]

.*/node_modules/polished/.*

TypeScript Definitions

✨ polished has TypeScript definitions to allow the library to be used in any TypeScript project. You will need to set moduleResolution to node in your tsconfig.json in order to use ✨ polished with TypeScript.

Babel plugin

You can optionally also use babel-plugin-polished to compile the static function calls out and remove the (already tiny) runtime performance impact of using ✨ polished.

Object Spread Properties

In the documentation you will see examples using object spread properties. ({ ...other }) To enable this syntax in your project add the transform-object-rest-spread plugin (or the stage-3 preset to enable all stage three features) to your Babel configuration.

Why?

When writing styles in JavaScript, many people need Sass-style helper functions to be productive. ✨ polished brings them to you in a nice, lightweight package tailor-made for styles in JavaScript.

The main difference with Sass is that it's written in a functional style and all color functions are curried. This means you can compose them together into your own reusable helpers with a compose function of your choice:

import { compose } from 'ramda' // Replace with any compose() function of your choice

import { lighten, desaturate } from 'polished'

// Create tone() helper

const tone = compose(lighten(0.1), desaturate(0.1))

Why not package-xyz?

First of all, we didn't find another library that had everything we needed, and we don't care about installing a dozen packages separately.

Specifically most other packages that provide color functions do so in an object-oriented style, often with a fluent API that's very different from the Sass-style helpers. This means people that aren't very familiar with JavaScript might shy away from using them.

✨ polished was made as a standard library for everybody, no matter if they know JS inside out or not.

Compatibility

✨ polished is compatible with any library that accepts styles as JS objects. This includes, but is by far not limited to, styled-components, radium, aphrodite, glamor, glamorous, jss and many more!

No matter if you're using inline styles or CSS-in-JS, polished is for you.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f706f6c69736865642f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365

Backers

Thank you to all our backers! 🙏 [Become a backer]

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f706f6c69736865642f6261636b6572732e7376673f77696474683d383930

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f706f6c69736865642f73706f6e736f722f302f6176617461722e737667

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f706f6c69736865642f73706f6e736f722f312f6176617461722e737667

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f706f6c69736865642f73706f6e736f722f322f6176617461722e737667

9e5f9397325906680eb5f3ff042a293a.png

1b8aa5e92296a23892333dfa4ee98914.png

ff3bc7f429a1ce5080b2b49188a70a7e.png

82a85058f3cf414ef9ce619e7252227c.png

97f8b2297001cdbcbc950b9bf370f49b.png

dd98d1b79074da0db46af90448c10561.png

f68a1ff4882e21b33ddbbab30311eff2.png

License

Copyright © 2016-2021 Brian Hough, Maximilian Stoiber, & Nik Graf. Licensed under the MIT License, see LICENSE.md for more information!

2749d2cab413974036965401af426e68.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值