npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slup/theming

v0.5.1

Published

Theming utility for the slup framework

Downloads

4

Readme

This package contains the Theming, a Utility Component which is part of a bigger ecosystem called Slup and also contains many useful features such as a reproduction of the styled-components library and some handy functions to modify colors.

Description

From Google's Material Design guidelines:

Installation

This package can be installed with NPM

npm install --save @slup/theming

Usage

All material design colors are available in this package We provide by default lightTheme(default one) and a darkTheme option.

import { ThemeProvider, lightTheme } from '@slup/theming'

<ThemeProvider theme={lightTheme}>
  <Application />
</ThemeProvider>

Available properties

| Props | Type | Default | Documentation | |------------- |:-------------:|:-------------:|------: | | theme | object | {} | Link|

Property: 'theme'

With this property you can set a custom theme or you can import our preset themes: lightTheme or darkTheme. The default theme can be seen on the component demons of our other packages.

import {
  ThemeProvider,
  black,
  white,
  cyan,
  pink
} from '@slup/theming'

const customTheme = {
  text: black,
  background: white,
  primary: cyan[300],
  secondary: pink[500]
}

const App = () =>
  <ThemeProvider theme={customTheme}>
    <YourApp />
  </ThemeProvider>

Styling

We've made a reproduction of the styled-components library since we had some problems with compatibility but we also wanted a faster and lighter way of styling our components. The syntax is almost identical to styled-components so if you want to see all the features that we offer you can take a look at their site.

import Inferno from 'inferno'
import styled, { keyframes } from '@slup/theming'

const Rotate = keyframes`
  0%,
  100% {
    transform: scale(0)
  }

  50% {
    transform: scale(1)
  }
`

const Bubble = styled.div`
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, .5);
  border-radius: 50%;
  animation: ${Rotate} 2s infinite forwards;
  animation-delay: ${props => props.second
    ? -1
    : 0
  }s;
`

const Container = styled.section`
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
`

render(
  <Container>
    <Bubble />
    <Bubble second />
  </Container>,
  document.body.firstChild
)

Modifying colors

We have created some useful functions that help us doing modifying colors:

  • rgba()
  • shade()

Rgba

rgba() makes an rgba color by taking normal rgb values or an hex color: The first parameter is the hex or the rgb color, the second one is the alpha value.

import styled, { rgba } from '@slup/theming'

const Title = styled.h1`
  color: ${rgba('#fff', 0.87)};
  background: ${rgba(52, 37, 137, 0.3)};
`

Shade

shade() is a function that combines two other functions called lighten() and darken() in Sass.

So shade() lightens the color if the first parameter is positive and it darkens it if it is negative: The first parameter is the amount of lightness/darkness you want to add, the second one is a string representing the hex or the rgb color.

import styled, { shade } from '@slup/theming'

const Box = styled.div`
  background: ${shade(-1, '#fff')};          // Returns pure black
  color: ${shade(0.3, 'rgb(66, 134, 244)')}; // Returns rgb(212,227,252)
`