0.1.7 • Published 6 years ago

react-bem-components-ts v0.1.7

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

React BEM Components

Super simple components to create BEM styled component.

Components

React BEM comes with multiple built in components

  • Wrapper
  • Title
  • Text
  • Button
  • Link
  • Image

Usage

Each component has named props to aid in building your desired BEM structure

import React, { Component } from 'react'
import { Wrapper, Title, Text, Button } from 'react-bem-components';

class MyBEMComponent extends Component {

    clickHandler(e) {
        console.log('clicked');
    }

    render() {

        const block = 'my-component';

        render (
            //the first element should use the block as its element. All children use it as the block
            <Wrapper element={block}>
                <Title block={block}>Cool Title</Title>
                <Text block={block} modifier={'large'}>Some large text</Text>
                <Button onClick={this.clickHandler.bind(this)} block={block} modifier={'wide'} modifiers={['outline', 'wave-hover']}>Click me</Button>
            </Wrapper>
        );
    }
}

/**
rendering this component outputs:

<div class="my-component my-component--default">
    <h2 class="my-component__title title title--default">Cool Title</h2>
    <p class="my-component__text text text--large">Some large text</p>
    <button class="my-component__btn btn btn--wide btn--outline btn--wave-hover">Click me</button>
</div>

*/

Props

Each BEM props comes with the same basic prop types:

const propTypes = {
    // the element tag e.g. div, h1, p, etc
    tag: PropTypes.string,
    block: PropTypes.string,
    element: PropTypes.string.isRequired,
    modifier: PropTypes.string,
    // for elements with multiple modifiers required
    modifiers: PropTypes.arrayOf(PropTypes.string),
    // any non bem related classes
    extraClasses: PropTypes.string,
    id: PropTypes.string,
    // data-attributes
    attributes: PropTypes.object
};
0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago