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

rts-react-components

v0.1.31

Published

A library of React component primitives for use in company projects and experiments.

Downloads

5

Readme

@rtslabs/react-components

A library of React component primitives for use in company projects and experiments.

Local Development

Link the local repository using your package manager

machine/repos/rts-react-components $ yarn link

machine/repos/new-react-project $ yarn link @rtslabs/react-components

Installation

Add the following to your package.json

"@rtslabs/react-components": "git+ssh://[email protected]/rtslabs/rts-react-components.git#development",

Component Structuring

Components have been organized as individual modules to allow for future initiatives like separate packaing, tests, documentation, and distribution.

Component Structure

- carousel
  - src (component modules)
    - Carousel.js
    - CarouselSlide.js
    - CarouselControls.js
  - index.js (exports necessary components from ./src)
  - stories.js (storybook stories)
  - styles.js (component base styles)

Components

Accordion
Breadcrumbs
Button
Card
Chart
Checkbox
DevAlert
Dropdown
Icon
Input
Layout
Link
Navbar
Sidebar
Table
Tabs
Tooltip

Writing Component Stories

Basic Story Example

import React from 'react';
import { storiesOf } from '@storybook/react';

import { Button } from 'components/button';

// first argument to storiesOf controls the navigation text in Storybook's sidebar
const stories = storiesOf('Button', module);

// first argument to add controls the text in the subnavigation
stories.add('default', () => (
  <Button>Submit</Button>
));

Theme Structuring

@TODO update once project theme is updated to reflect the theme @chrism has been building for Centivo.

API

create(type, styles)

built on top of styled from react-emotion—used for building primitives and extending existing components. Styles passed to create will be merged with the base styles provided by this library.

ThemeProvider(Component)

Directly exported from emotion-theming for convenience. Passes theme directly to children via context. Can be used as the root component or anywhere within the component tree. Overriding works as expected—theme properties from parent ThemeProvider will be overriden by properties from nested ThemeProviders.

Overriding Styles

Using the theme prop

import DangerButton from '<project_component_root>/buttons/Danger';

const Wrapper = (props) => (
  <DangerButton
    theme={{
      backgroundColor: props.active ? 'green' : 'grey'
    }}
  />
);

export default Wrapper;

Presentational Components

import create, { Button } from '@rtslabs/react-components';

import theme from '<project_theme_location>';

const styles = {
  backgroundColor: theme.colors.roles.background,
  padding: theme.buttons.padding,

  ':hover': {
    backgroundColor: theme.colors.states.hover
  }
};

const DangerButton = create(Button, styles);

DangerButton.propTypes = { ... };
DangerButton.defaultProps = { ... };

export default DangerButton;

Class Components

import React, { Component } from 'react';
import create, { Button } from '@rtslabs/react-components';

import styles from '<project_component_root>/buttons/danger';

const DangerButtonBase = create(Button, styles);

class DangerButton extends Component {
  state = {
    clicked: false
  };

  onClick = () => this.setState({ clicked: true });

  render() {
    return (
      <DangerButtonBase onClick={this.onClick} {...this.props}>
        {this.props.children}
      </DangerButtonBase>
    );
  }
}

export default DangerButton;