0.0.11 • Published 4 years ago

get-active-classes v0.0.11

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

getActiveClasses Build Status

Javascript conditional class utility

Installation

yarn add get-active-classes

Usage

// React functional component
import { getActiveClasses } from "get-active-classes";

const MenuItemFocus = ({
  orientation,
  forceActive,
  withTransition,
  className
}) => (
  <div
    className={getActiveClasses("menuItemFocus", className, {
      "menuItemFocus--vertical": orientation === "vertical",
      "menuItemFocus--horizontal": orientation === "horizontal",
      "menuItemFocus--active": forceActive,
      "menuItemFocus--withTransition": withTransition
    })}
  ></div>
);

So if the component had the props of

<MenuItemFocus
  orientation="vertical"
  forceActive={true}
  withTransition={false}
  className="widthFull"
/>

the resulting HTML will be

<div
  class="menuItemFocus widthFull menuItemFocus--vertical menuItemFocus--active"
></div>

Find detailed write up of the motivation behind this utility on my blog.

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago