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

@simpozio/aha-button

v1.0.1

Published

Package for aha-button component

Downloads

6

Readme

Aha Button Component

React component for aha-button.

Installation

npm i @simpozio/aha-button

Usage

Basic

import {useState} from 'react';
import {AhaButton} from '@simpozio/aha-button';

const Component = () => {
  const [loading, setLoading] = useState(false);
  const onButtonHover = (event) => {/* */}
  const onButtonFocus = (event) => {/* */}
  const onButtonBlur = (event) => {/* */}
  const onButtonClick = (event) => setLoading(true)

  return (
    <AhaButton
      pending={loading}
      onHover={onButtonHover}
      onFocus={onButtonFocus}
      onBlur={onButtonBlur}
      onClick={onButtonClick}
    />
  )
}

Styling

Theming

import {useContext} from 'react';
import {AhaButton} from '@simpozio/aha-button';
import {ThemeContext} from 'styled-components`;

const defaultTheme = {
  FONT: {
    SIZE: {
      XS: '1rem',
      S: '1.2rem',
      M: '1.6rem'
    },
    FAMILY: {
      BASE: '"Helvetica", sans-serif'
    },
    WEIGHT: {
      BASE: 600
    },
    SPACING: {
      M: '0.1em'
    }
  },
  COLOR: {
    PRIMARY: 'purple',
    INVERT: '#fff'
  },
  BACKGROUND: {
    INVERT: 'purple'
  },
  TRANSITION: {
    TIMING: {
      EASE_OUT_QUAD: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)'
    },
    DURATION: {
      BASE: '0.3s'
    }
  },
  MEDIA: {
    SM: 768,
    MD: 1024
  }
};

const Component = () => {
  const currentTheme = useContext(ThemeContext);

  const onButtonHover = (event) => {/* */}
  const onButtonFocus = (event) => {/* */}
  const onButtonBlur = (event) => {/* */}
  const onButtonClick = (event) => {/* */}

  return (
    <AhaButton theme={currentTheme || defaultTheme}>Submit</AhaButton>
  )
}

Styled Component

Default styling with styled components

import styled from 'styled-components';
import Color from 'color'
import {AhaButton} from '@simpozio/aha-button';

const StyledAhaButton = styled(AhaButton)`
  color: #fff;
  background: #43a047;
  border: 0.2em solid #43a047 !important;
  padding: 0 1.6em;
  height: 3em;
  line-height: 2.8em;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: border-color linear 0.2s, background-color linear 0.2s,
    color linear 0.2s;

  svg {
    opacity: 0 !important;
  }

  &:hover,
  &:focus,
  &:active {
    color: rgba(255, 255, 255, 0.9);
    background-color: ${Color('#43a047')
      .alpha(0.9)
      .string()};
    border-color: transparent !important;
  }

  &:disabled {
    color: ${Color('#fff')
      .alpha(0.6)
      .string()};
    border-color: transparent !important;
    background: ${Color('#43a047')
      .alpha(0.6)
      .string()};
  }
`;

const Component = () => {
  const onButtonHover = (event) => {/* */}
  const onButtonFocus = (event) => {/* */}
  const onButtonBlur = (event) => {/* */}
  const onButtonClick = (event) => {/* */}

  return (
    <StyledAhaButton>Submit</StyledAhaButton>
  )
}

CSS Mixin

In this method you can access all inner props of Aha Button

import {css} from 'styled-components';
import {AhaButton} from '@simpozio/aha-button';

const customCss = css(
({Spin, outlined, pending, theme}) => css`
  color: ${theme.COLOR.PRIMARY};
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;

  ${Spin} rect {
    stroke: #607d8b;
    fill: ${outlined ? 'none' : '#607D8B'};
  }

  &:hover,
  &:focus,
  &:active {
    color: #607d8b;
  }

  &:disabled {
    color: ${Color(outlined ? theme.COLOR.PRIMARY : theme.COLOR.INVERT)
      .alpha(0.6)
      .string()};

    ${Spin} rect {
      stroke: transparent;

      ${pending &&
        css`
          stroke: #607d8b;
        `}
    }
  }
`
);

const Component = () => {
  const onButtonHover = (event) => {/* */}
  const onButtonFocus = (event) => {/* */}
  const onButtonBlur = (event) => {/* */}
  const onButtonClick = (event) => {/* */}

  return (
    <AhaButton styles={customStyles}>Submit</AhaButton>
  )
}

Props

Button accepts standard HTML-attributes:

  • className: string
  • type: 'submit' | 'button' | 'reset'
  • disabled: boolean
  • onFocus: function
  • onBlur: function
  • onClick: function

Additional props:

  • outlined: boolean - set outlined style of button
  • pending: boolean - set pending state of button
  • icon: JSX.Element - icon component, if you pass icon prop - all children will be ignored!
  • theme: object - object with theme props
  • styles: CSSProp - custom styles in format of interpolated styled components string
  • onHover: function - implemetation of onmouseenter callback

Development

Look simpozio-frontend-common library