Kitten is a components library based on Sass and React. It provides mixins to create flexible components based on your own brand elements (colors, fonts, typographic scale, etc.).
It is an npm module coupled with a Rails engine that provides an integrated styleguide. It should eventually be separated into two different repositories.
- Ruby 2.2.4
- Bundler (
gem install bundler) - Node ~> 6.0
You can choose to use the npm module only or with the Rails engine.
npm install kitten-components --save-devAdd this line to your application's Gemfile:
# Style guide
gem 'kitten'And these routes to your routes.rb:
mount Kitten::Engine, at: '/kitten' if Rails.env.development?You can then run bundle and restart your server.
kitten is designed to serve assets with Webpack
through React on Rails.
For more detailed instructions, see Rails webpack configuration.
Import kitten and the components your want to use in your application:
@import 'kitten';
@include k-Button;You can define your own font families, typography settings and colors by overriding the
the $k-fonts, $k-typography and $k-colors options. Check out the
default config
for an example.
You can render React components directly in your js bundle:
const yourLoanSimulatorProps = {}
ReactDOM.render(
React.createElement(LoanSimulator, yourLoanSimulatorProps),
document.getElementById('loan-simulator')
)Or, use React on
Rails
view helper in your .erb file:
<%= react_component('LoanSimulator', props: your_loan_simulator_props) %>Kitten provides a styleguide interface through a Rails engine. You can run see it in your browser by downloading kitten and launching the dummy app or by installing the style guide in your Rails app.
The engine provides some configuration options that can be defined in
config/initializers/kitten.rb:
- webpack_output_bundle: This option is used to pass an output bundle name
for hot reloading. By default, it is set to
application-bundle.
Example configuration:
Kitten.configure do |config|
config.webpack_output_bundle = 'your-custom-bundle'
endCheck out the guidelines to start creating new components!
$ bin/kitten installTo launch the style guide on the dummy app:
$ bin/kitten startThen visit http://localhost:3000
To stop the style guide on the dummy app:
$ bin/kitten stopTo check wether the dummy app is running or not:
$ bin/kitten statusTo tail the dummy app logs in real time:
$ bin/kitten logHit Ctrl+C to stop the tail.
To share the dummy app with production settings (to share via ngrok for example), you can compile the assets and serve a production server:
$ bin/rake staging:assets:precompile
$ REACT_ON_RAILS_ENV= rails s -b 0.0.0.0To cleanup installed modules:
bin/kitten cleanup$ yarn stylelint$ bundle exec rakeWe use SassDoc to generate documentation from our components comments.
Generate the documentation:
$ bundle exec rake sassdoc
# OR
$ yarn sassdocThe documentation is accessible on development environment: /kitten/sassdoc.
To launch the JS tests:
$ bin/kitten test
# OR
$ bin/kitten test {PATH}/{FILE}.test.jsCheck out the guidelines to know how to test kitten.
To contribute code:
-
Create a pull request on GitHub with a clear title in English.
-
Tag it with the right labels:
Needs reviews,Needs testingorWork in progress. -
Don't forget to update the
CHANGELOG.mdunder the[unreleased]section with the following syntax:- Breaking change: a breaking change. - Feature: a new feature. - Fix: a fix. -
Update the
KARL_CHANGELOG.mdunder the [unreleased] section if you added some updates to the styleguide.
To merge code into master:
- Make sure the code has been reviewed by someone.
- Make sure it has been tested.
- Merge using
Squash and mergeon GitHub. - Delete the branch.
To build an on disk static file mirror:
$ bin/kitten buildstatic- files are located in build/
If this is your first release, start by saving your npm credentials in
your ~/.npmrc by calling:
$ yarn login- Pull
master - Update the
CHANGELOG.mdfile:- Update the version following the Semantic Versioning.
- Add a new
[unreleased]section. - Check that each merged PR from the last release has an entry.
- Update the
KARL_CHANGELOG.mdfile:- Update the version with the version of the library.
- Add a new
[unreleased]section.
- Update the version in
lib/kitten/version.rb. - Update the version in
package.json.
Run this command:
$ bundle exec rake kitten_releaseOnly for KissKissBankBank collaborators
Update
our private project kanban:
move cards that are released from done column to released column.
