All Projects → imgly → adonis

imgly / adonis

Licence: other
Adonis ❤️ Aphrodite

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to adonis

flair
a lean, component-centric style system for React components
Stars: ✭ 19 (-56.82%)
Mutual labels:  css-in-js, theming
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+16095.45%)
Mutual labels:  css-in-js, theming
Styled Theming
Create themes for your app using styled-components
Stars: ✭ 1,067 (+2325%)
Mutual labels:  css-in-js, theming
Aphrodite
Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
Stars: ✭ 5,257 (+11847.73%)
Mutual labels:  css-in-js, aphrodite
tsstyled
A small, fast, and simple CSS-in-JS solution for React.
Stars: ✭ 52 (+18.18%)
Mutual labels:  css-in-js, theming
siimple
The minimal and themeable CSS toolkit for flat and clean designs
Stars: ✭ 525 (+1093.18%)
Mutual labels:  css-in-js
elegant-react-ssr
Server-side rendering with create-react-app, React Router v4, Helmet, Redux, and Thunk boilerplate, without ejecting CRA
Stars: ✭ 16 (-63.64%)
Mutual labels:  css-in-js
Holi
Holi is a lightweight Jetpack Compose library of colors, gradients and cool utility functions for all your palette needs!
Stars: ✭ 160 (+263.64%)
Mutual labels:  theming
benefit
✨ Utility CSS-in-JS library that provides a set of low-level, configurable, ready-to-use styles
Stars: ✭ 51 (+15.91%)
Mutual labels:  css-in-js
Aris
Aris - A fast and powerful tool to write HTML in JS easily. Includes syntax highlighting, templates, SVG, CSS autofixing, debugger support and more...
Stars: ✭ 61 (+38.64%)
Mutual labels:  css-in-js
visage
Visage design system
Stars: ✭ 12 (-72.73%)
Mutual labels:  css-in-js
react-koa-universal
a boilerplate react graphql apollo css-in-js buzzword koa ssr pwa wasm throwaway app 🚮
Stars: ✭ 12 (-72.73%)
Mutual labels:  css-in-js
boss-lite
Boss Lite - React Redux Material Admin Template
Stars: ✭ 148 (+236.36%)
Mutual labels:  css-in-js
Theming-Android
Examples and tips on how to support multiple themes within your app
Stars: ✭ 40 (-9.09%)
Mutual labels:  theming
generator-nitro
Your frontend? Fuel it with Nitro! Develop your frontend with a proven but flexible Node.js app, even in a large team.
Stars: ✭ 65 (+47.73%)
Mutual labels:  theming
system-ui.com
Standards for creating consistent, interoperable user interfaces
Stars: ✭ 64 (+45.45%)
Mutual labels:  css-in-js
css-render
Generating CSS using JS with considerable flexibility and extensibility, at both server side and client side.
Stars: ✭ 137 (+211.36%)
Mutual labels:  css-in-js
theme-change
Change CSS theme with toggle, buttons or select using CSS custom properties and localStorage
Stars: ✭ 283 (+543.18%)
Mutual labels:  theming
mediocre-pictures
Helping you take mediocre pictures, hands-free. 📷🙆🏻🙅🏾💁🏼📸
Stars: ✭ 16 (-63.64%)
Mutual labels:  css-in-js
React-Crypto-Exchange
React Crypto exchange
Stars: ✭ 35 (-20.45%)
Mutual labels:  aphrodite

💪 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 / 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.

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