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

adonis

v0.9.0

Published

The best of aphrodite and styled-components combined

Downloads

747

Readme

:muscle: Adonis: Aphrodite's lover

Adonis combines the best of Aphrodite and styled-components: Named DOM elements, stylable via object literals with support for inheritance, overriding and theming while staying lightweight (28 KB / 7.6 KB gzipped)

Installation

  npm install --save adonis

API

import React, { Component } from 'react'
import adonis from 'adonis'

class App extends Component {
  render () {
    return (<div>
      <Section red>
        This is red.
      </Section>
      <Section hover>
        This turns red on hover.
      </Section>
      <Section small>
        This turns red when the browser is less than 600px wide.
      </Section>
      <Section blue small>
        This is blue and turns red when the browser is less than 600px wide.
      </Section>
    </div>)
  }
}

const Section = adonis.div({
  width: '500px',
  height: '100px',
  textAlign: 'center',
  marginBottom: '20px'
}, {
  red: {
    backgroundColor: 'red'
  },
  blue: {
    backgroundColor: 'blue'
  },
  hover: {
    ':hover': {
      backgroundColor: 'red'
    }
  },
  small: {
    '@media (max-width: 600px)': {
      backgroundColor: 'red'
    }
  }
})

Creating an Adonis Component

Adonis components can be created from DOM elements, React Components or other Adonis Components:

  // A styled `div` tag:
  const Title = adonis.div({
    fontSize: '24px'
  })

  // Overriding `Title`'s styles
  const SubTitle = adonis(Title)({
    fontSize: '15px',
    fontStyle: 'italic'
  })

  // Overriding styles of a React component
  class Button extends React.Component({
    render () {
      // You need to pass the `styles` prop in order to override this component's styles
      return <ButtonContainer styles={this.props.styles} />
    }
  })

  const ButtonContainer = adonis.div({
    padding: '5px 10px'
  })

  // Primary button will have `padding: 5px 10px` as well as `background: blue`
  const PrimaryButton = adonis(Button)({
    background: 'blue'
  })

Variations and flags

Adonis adds support for element variations that can be toggled using properties passed to the element:

const Button = adonis.div(
  // Base styles
  {
    width: '100px',
    height: '50px',
    background: 'grey'
  },
  // Variation styles
  {
    primary: {
      background: 'blue'
    }
  }
)

<Button /> // This would be styled with `background: grey`
<Button primary /> // This would be styled with `background: blue`

Re-usable base styles

You can specify "base" styles that can be re-used in any other component:

const primaryBackgroundColor = adonis.css({
  backgroundColor: 'blue'
})

const Button = adonis(primaryBackgroundColor).button({
  color: 'white'
})

Theming

Similarly to styled-components, you can wrap your React application in a ThemeProvider and pass a theme object.

import { Component } from 'react'
import adonis, { ThemeProvider } from 'adonis'
import AppComponent from './app-component'

const theme = {
  buttonBackgroundColor: 'grey'
}

ReactDOM.render(<ThemeProvider theme={theme}>
  <AppComponent />
</ThemeProvider>, appContainerElement)

You need to make sure that your topmost component is wrapped in withTheme(), so that all child components are receiving the theme:

import { Component } from 'react'
import adonis, { withTheme } from 'adonis'

class AppComponent extends Component {
  render () {
    return <Button />
  }
}

const Button = adonis.div({
  background: 'grey'
})

export default withTheme(AppComponent)

Instead of specifying values inside your style object literals, you can now also pass functions with a theme argument:

const Button = adonis.div({
  background: theme => theme.buttonBackgroundColor
})

Or, if you're using your theme a lot, you can pass a function returning a whole object:

const Button = adonis.div(theme => {
  return {
    background: theme.buttonBackgroundColor,
    borderWidth: theme.buttonBorderWidth,
    borderRadius: theme.buttonBorderRadius,
    color: theme.textColor,
  }
})

License (MIT)

Copyright (c) 2016 [PhotoEditorSDK.com] (www.photoeditorsdk.com/?utm_source=Github&utm_medium=Side_Projects&utm_content=Adonis&utm_term=HTML5) / 9elements GmbH / Sascha Gehlich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.