Git Product home page Git Product logo

uigradients's Introduction

UIGradients Logo

CircleCI npm npm GitHub

💾 Installation

npm install --save uigradients

or

yarn add uigradients

📚 Docs

Components

Utilities

🏗 Usage Examples

Linear Gradient Component

// Import the component...
import { Gradient } from 'uigradients';

// Now, use it!
class App extends Component {
    // If no gradient preset is provided,
    // a random preset will be used.
    return (
      <Gradient preset="cherry">
        <h1>This will draw a div with a cherry gradient, like the one you're looking at right now.</h1>
      </Gradient>
    );
}
cherry is only one of the many presets provided by uigradients

A complete list of the gradient presets can be previewed here. You can use your own preset library via GradientProvider

Radial Gradient Component

import { Gradient } from 'uigradients';

class App extends Component {
    return (
      // Add a "type" attribute on your component and
      // set it to "radial" for a radial gradient!
      // NOTE: If a "type" attribute is not on
      // your component, the gradient type will
      // default to linear
      <Gradient preset="aubergine" type="radial">
        <h1>Wow, a radial gradient!</h1>
      </Gradient>
    );
}

Gradient Generator

import { generator } from 'uigradients';

generator({preset: 'intuitive_purple'});

/* The function above returns:
background-color: ,#DA22FF,;
background-image: -webkit-linear-gradient(
  left,
  ,#DA22FF,,
  ,#9733EE,);
background-image: linear-gradient(
  to left,
  ,#DA22FF,,
  ,#9733EE,);
*/

💅 Styled Components

Use the Generator in styled-components

import { generator } from 'uigradients';
import styled from 'styled-components';

const Pre = styled.pre`
  ${generator({preset: 'electric_violet'})}
  border-radius: 4px;
  display: block;
`;

And render the component

This is what an electric_violet pre looks like!

Or, you can override other properties on the Gradient component

import { Gradient } from 'uigradients';
import styled from 'styled-components';

const Header = styled(Gradient)`
  min-height: 300px;
  text-align: center;
  width: 100%;
`;

And render the component

Awesome!

Or, you can generate a radial gradient

import { generator } from 'uigradients';
import styled from 'styled-components';

const RadialComponent = styled.div`
  ${generator({gradient: 'electric_violet', type: 'radial'})}
`;

And render the component

Radial gradient

📜 License

This package is released under the MIT License

sponsored by syntra.io

uigradients's People

Contributors

aritheelk avatar matthamil avatar rozzzly avatar sapegin avatar

Stargazers

 avatar Robiul H. avatar Dzhake avatar N V S Pavan Kalyan avatar  avatar Tenvi avatar Shivam Agrawal avatar Max Protsenko avatar Trey Perry avatar Fabio Franzini avatar Akyla Aquino avatar Mianta McKnight avatar Chris Hansen avatar Hamed Al Hashmi avatar Chris Messina avatar Noah Hendlish avatar Jake Schaffer avatar Dani Goldberg avatar John Marczak avatar Alexander Rose avatar Jonathan Herman avatar Bohdan avatar max avatar Pooria Soltani avatar Danniel Condez avatar Naga durga Prasad E avatar Thyatdora Ny avatar Gustavo avatar Cihan Uygur avatar Nitin Khanna avatar António Lopes avatar David J. Rudolph avatar Phonedolly avatar Joey avatar  avatar Nathan Hutchision avatar Michael Filipenko avatar Josh Meads avatar Melinda Jones avatar  avatar Sergio avatar Sven Hohlfeld avatar  avatar  avatar Sandra Boez avatar Eric Cheung avatar Stephen Peters avatar Cody Averett avatar JimZer avatar John McLem Adan avatar Zeus avatar  avatar Summy avatar Matthew Elphick avatar Ben Parnell avatar Richard Lopes avatar Peter W avatar Ivan Istomin avatar  avatar Quang Van avatar Taylor Goolsby avatar Jigz avatar Thibault You avatar Burak Ömer Yuksel avatar Jakub Sarnowski avatar Feraidoon Mehri avatar улик avatar Dmytro Meleshko avatar Jimmy Nordbeck avatar Roman O avatar Derek Reynolds avatar Justin Cuaresma avatar Joe Kent avatar Simon Collins avatar Tiago S. P. Rodrigues avatar Ajit Bohra avatar Mads Obel avatar  avatar Kamil Zaleski avatar Keith Gonzalez avatar Ahmed Elsakaan avatar Michael S avatar Victor avatar Alessio Delmonti avatar Brian Yang avatar Javier Bermúdez Lobo avatar Lobito avatar Arthur Denner avatar Rick Wong avatar Michele Bertoli avatar Shu Uesugi avatar Anton Petrov avatar Alexey Elizarov avatar Anton St. avatar Steve J Calamia avatar Gerardo Palazuelos-Guerrero avatar Julio Canares avatar Zhang Xiaohui avatar  avatar Alexey Neyasov avatar

Watchers

Richard Hess avatar James Cloos avatar  avatar Nancy Jiang avatar  avatar

uigradients's Issues

[Feature Proposal] Support for radial gradients

Do you think it would be a good idea to include support for radial gradients?

Instead of

generator({gradient: 'intuitive_purple'});

Support could be added for

generator({radial-gradient: 'intuitive_purple'});

I'd like to work on this and submit a PR if you think that UIGradients could benefit from this feature.

Bundle Size

Great library!

Wanted to discuss bundle size.
raw: 285.28kb
gzipped: 26.56kb
This is quite large.

Looking at the source, it appears styled-components and react are listed as dependencies. Listing them as peerDependencies would be a quick win (and making a note in the docs that these need to be in the project as peers).

Otherwise, I have not looked into what is causing such a large bundle size, but perhaps bundling to allow the importing of only portions of the codebase needed (like rxjs and lodash do) would be helpful here.

Externalize the gradient list [easy for new contributors]

Currently, the gradient list is stored inside the gradients.js file.

This leaves much to be desired, and should really be externalized. Preferably in either a JSON or YAML format. This file should then be loaded inside the gradients.js file and exported in the file's defaults.

If you're new to open source, this is a great introductory issue to solve. It's straight forward and fairly simple to implement.

Failed to compile

./node_modules/uigradients/dist/uigradients.mjs
Can't import the named export 'createContext' from non EcmaScript module (only default export is available)

Please update your package asap. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.