Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@convoy/dapper

Package Overview
Dependencies
Maintainers
17
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@convoy/dapper

Styling library

  • 1.0.37
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by250%
Maintainers
17
Weekly downloads
 
Created
Source

Dapper

Getting Started

npm install @convoy/dapper

Basic usage

import StyleSheet from '@convoy/dapper';

const STYLES = StyleSheet.createSimple({
  root: {
    display: 'flex',
    backgroundColor: '#BBB',
    padding: 8,
    width: '200px',
  },
});

export default class Button extends React.Component<Props, State> {
  render(): JSX.Element {
    return (
      <div className={STYLES.root} />
    );
  }
}

Prop or state based styling

import StyleSheet from '@convoy/dapper';

export interface Props {
  large?: boolean;
  ghost?: boolean;
  className?: string;
}

export interface State {
  hovered: boolean;
}

export type ModeState = { props: Props, state: State };

const STYLES = StyleSheet.create({
  root: {
    display: 'flex',
    backgroundColor: '#BBB',
    padding: 8,
    margin: {
      $large: 10,
      $ghost: 5,
    },
    ':hover': {
      backgroundColor: '#555',
      $ghost: {
        backgroundColor: '#000045',
      },
    },
    '@media (max-width: 800px)': {
      width: '100px',
    },
    $ghost: {
      backgroundColor: 'white',
      '@media (max-width: 800px)': {
        backgroundColor: '#DDD',
      },
      $large: {
        border: '1px solid #000',
      },
    },
    $large: {
      padding: '16px',
      fontSize: '20px',
    },
    $hovered: {
      borderRight: '1px solid #000',
    },
  },
  text: {
    display: 'inline-block',
  },
});

const MODES = {
  large: ({ props }: ModeState) => !!props.large,
  hovered: ({ state }: ModeState) => state.hovered,
  ghost: ({ props }: ModeState) => !!props.ghost,
};

export default class Button extends React.Component<Props, State> {
  state = {
    hovered: false,
  };

  styles = StyleSheet.compute(STYLES, MODES, { props: this.props, state: this.state });

  componentWillUpdate(props: Props, state: State) {
    this.styles = StyleSheet.compute(STYLES, MODES, { props, state });
  }

  render(): JSX.Element {
    return (
      <div
        className={classnames(this.styles.root, this.props.className)}
        onMouseEnter={this._onMouseEnter}
        onMouseLeave={this._onMouseLeave}
      >
        {this._renderText()}
      </div>
    );
  }

  _renderText() {
    return (
      <span className={this.styles.text}>
        Button
      </span>
    );
  }

  _onMouseEnter = () => {
    this.setState({hovered: true});
  }

  _onMouseLeave = () => {
    this.setState({hovered: false});
  }
}

keyframes

import StyleSheet from '@convoy/dapper';

const fadeOut = StyleSheet.keyframes({
  '0%': {
    opacity: 0,
  },
  '100%': {
    opacity: 1,
  },
});

const STYLES = StyleSheet.create({
  root: {
    animation: `5s ${fadeOut} linear`,
  },
});

renderStatic

StyleSheet.renderStatic({
  'html, body': {
    backgroundColor: '#CCFFFF',
    '@media (max-width: 800px)': {
      backgroundColor: '#FFCCFF',
    },
  },
});

configure

StyleSheet.configure({
  node: document.querySelector('#stylesheet'),
  classNamePrefix: 'app-',
  friendlyClassNames: false,
})

Contributing

  1. Switch to the right node: nvm install
  2. Install the dependencies: npm install
  3. Watch for changes: npm start

FAQs

Package last updated on 22 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc