A multi-headed component library for React.
Note: This is a work in progress. It is not yet ready for production use. When it is, this message will be removed and version 1 will be released on NPM.
Note: Hydra is not yet published to NPM. You can install it directly from GitHub using yarn: yarn add xplato/hydra
or npm: npm install xplato/hydra
.
yarn add @xplato/hydra
or
npm install @xplato/hydra
import { Button, Switch } from '@xplato/hydra';
const App = () => (
<div>
<Button>Click Me</Button>
<Switch label={(on) => on ? "On" : "Off"} />
</div>
);
I know it's not exactly conventional, but the documentation for each component is in the component's file. You can find them easily in the packages/react/components
directory. The props
of every component are documented in the [Component]Props
interface just above the component itself. They are always structured the same way and written as simply as possible. Plus, it's a good idea to see how they work under-the-hood.
In Hydra, components are separate from their styles. This allows us to use the same components in different contexts, and to use the same styles in different contexts. Hydra is not a headless component library, but a multi-headed one (thus the name).
Hydra is built with customization in mind. There are a number of ways to customize Hydra. They range from one-off customizations on a per-component basis to full-on custom builds.
TBD
Although the styles are all global, Hydra's component styles are scoped, so there are really only a few top-level classes (like .hydra-button
). This fact has a few implications, discussed in the customization methods below.
Styling
- Most components accept a
className
prop, which is merged with the default classname. This allows you to modify things without overwriting the default styles. - The components that accept
className
also accept analtClass
prop, which will override the default class. This is useful if you want to completely replace the default styles. - Most components implicitly inherit from
React.HTMLAttributes
, which includes things likestyle
by default. If you choose to do so, you can style them this way. I don't recommend this for many reasons.
yarn start:react
- Start watching thereact
packageyarn build:react
- Build thereact
package (compiles todist/
)yarn start:styles
- Start watching thestyles
packageyarn build:styles
- Build thestyles
package (compiles todist/hydra.css
)
dist/
is committed so that this package can be installed directly from GitHub.react/
andstyles/
are separate packages so that they can be published independently and used interchangeably.