@smashgg/gg-components
A Component Pattern Library for GG-Web
Last updated 14 days ago by pelham .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @smashgg/gg-components 
SYNC missed versions from official npm registry.

Description

gg-components is a Component / Pattern Library. Visualized by http://storybook.smash.gg/

Getting Started

  1. Clone the Repo: git clone git@github.com:smashgg/gg-components.git.
  2. Open the Directory: cd gg-components.
  3. Run the Setup: npm run setup.
  4. Open localhost:8080.
  5. Get Component-ing!

Devloping in storybook

  1. Run: npm run storybook.
  2. Open localhost:6006.
  3. Get Component-ing!

Running / Writing Tests

  1. Run: npm run tdd.
  2. Write moar tests!

Making a new Component

  1. Create a ComponentName.spec.js file in the same directory as the component you are testing (e.g. MyFoo/MyFoo.jsx, MyFoo/MyFoo.spec.js). Your first test could assert that the component returns the element you expect it to when render is called, for example:
describe('GettingStarted', () => {
	test('is a span element', () => {
		const wrapper = shallow(<GettingStarted />);

		expect(wrapper.type()).toEqual('span');
	});
});
  1. Create a ComponentName directory in the src/components directory. This directory should have at least 2 files: index.jsx and ComponentName.jsx. index.jsx just imports and exports ./ComponentName.jsx.

Example Component

  1. Continue adding Tests into your test spec. It's best practice to write failing tests that resolve themselves while you continue writing your new component.

  2. Once your component is nearing a completed state, it's time to export the component to Storybook. To prepare your component to be exported, you currently need to add the component to src/index.js. It's probably time for you to read the docs of https://github.com/smashgg/gg-storybook!

Building the Distribution for Storybook / Elsewhere

  1. Run: npm run prepublish (Webpack builds all required vendor dlls and our code with npm run dll && npm run build).
  2. Read up on npm publish here and npm version here.
  3. When ready to publish a new version run: npm run publish:patch it will auto bump to a new version and publish the package and create a new commit with the same information. Don't forget to push the version commit so we track the new publish

styleName Vs. className

React CSS Modules automates loading of CSS Modules using the styleName property. The easiest way to think about the difference between StyleName and ClassName is the below example:

<div className='global-css' styleName='local-module'></div>

The convention for React CSS Modules is that styleName is for Interoperable CSS (CSS Modules) and className is for CSS.

Example:

/* JSX */
import React from 'react';
import './index.css';

function Apple() {
  return (
    <div
      className="fa fa-apple"
      styleName="apple"
    />
  );
}

export default Apple;
/* CSS */
.apple {
  color: #f00;
}

Result:

<div className="fa fa-apple src-components-Apple-___index__apple___2KF4L"></div>

Best Practices

  1. Write your tests first!
  2. Use EMs / % for your measurements! No Pixels!
  3. Use :root variables as often as you can!
  4. D.R.Y! (Don't repeat yourself!)
  5. Prefer Functions over Stateless Components over React.createClass!
  6. Love ES6!

PostCSS Gotchas (for those used to SASS)

Math on :root variables is kinda tricky.

This does not work:

$margins : var(--spacing--sm);
.foo {
	margin: -$margins 0 $margins -$margins;
}

Works:

$margins : var(--spacing--sm);
.foo {
	margin: calc($margins * -1) 0 $margins calc($margins * -1);
}

Further Reading

webpack

post-css

css-modules

babel

babel-plugin-react-css-modules

Current Tags

  • 2.0.11                                ...           latest (14 days ago)

227 Versions

  • 2.0.11                                ...           14 days ago
  • 2.0.10                                ...           a month ago
  • 2.0.9                                ...           a month ago
  • 2.0.8                                ...           2 months ago
  • 2.0.6                                ...           2 months ago
  • 2.0.5                                ...           2 months ago
  • 2.0.4                                ...           3 months ago
  • 2.0.3                                ...           4 months ago
  • 2.0.2                                ...           4 months ago
  • 2.0.1                                ...           4 months ago
  • 2.0.0                                ...           4 months ago
  • 1.8.3                                ...           5 months ago
  • 1.8.2                                ...           5 months ago
  • 1.8.1                                ...           5 months ago
  • 1.8.0                                ...           5 months ago
  • 1.7.3                                ...           5 months ago
  • 1.7.2                                ...           5 months ago
  • 1.7.1                                ...           5 months ago
  • 1.7.0                                ...           5 months ago
  • 1.6.4                                ...           5 months ago
  • 1.6.3                                ...           6 months ago
  • 1.6.2                                ...           6 months ago
  • 1.6.1                                ...           6 months ago
  • 1.6.0                                ...           6 months ago
  • 1.5.17                                ...           6 months ago
  • 1.5.16                                ...           6 months ago
  • 1.5.15                                ...           6 months ago
  • 1.5.14                                ...           6 months ago
  • 1.5.13                                ...           6 months ago
  • 1.5.12                                ...           6 months ago
  • 1.5.11                                ...           6 months ago
  • 1.5.10                                ...           6 months ago
  • 1.5.9                                ...           6 months ago
  • 1.5.8                                ...           6 months ago
  • 1.5.7                                ...           6 months ago
  • 1.5.6                                ...           6 months ago
  • 1.5.5                                ...           6 months ago
  • 1.5.4                                ...           6 months ago
  • 1.5.3                                ...           6 months ago
  • 1.5.2                                ...           7 months ago
  • 1.5.1                                ...           7 months ago
  • 1.5.0                                ...           7 months ago
  • 1.4.3                                ...           7 months ago
  • 1.4.2                                ...           7 months ago
  • 1.3.0                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.5                                ...           7 months ago
  • 1.1.4                                ...           7 months ago
  • 1.1.1                                ...           7 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.0                                ...           7 months ago
  • 0.19.0                                ...           7 months ago
  • 0.18.1                                ...           7 months ago
  • 0.18.0                                ...           7 months ago
  • 0.17.8                                ...           8 months ago
  • 0.17.7                                ...           8 months ago
  • 0.17.6                                ...           8 months ago
  • 0.17.5                                ...           8 months ago
  • 0.17.4                                ...           8 months ago
  • 0.17.3                                ...           8 months ago
  • 0.17.1                                ...           9 months ago
  • 0.17.0                                ...           9 months ago
  • 0.16.18                                ...           9 months ago
  • 0.16.17                                ...           9 months ago
  • 0.16.16                                ...           9 months ago
  • 0.16.15                                ...           9 months ago
  • 0.16.14                                ...           9 months ago
  • 0.16.13                                ...           9 months ago
  • 0.16.12                                ...           9 months ago
  • 0.16.11                                ...           9 months ago
  • 0.16.10                                ...           9 months ago
  • 0.16.9                                ...           10 months ago
  • 0.16.8                                ...           10 months ago
  • 0.16.7                                ...           10 months ago
  • 0.16.6                                ...           10 months ago
  • 0.16.5                                ...           10 months ago
  • 0.16.4                                ...           10 months ago
  • 0.16.2                                ...           10 months ago
  • 0.16.3                                ...           10 months ago
  • 0.16.1                                ...           10 months ago
  • 0.16.0                                ...           10 months ago
  • 0.15.2                                ...           10 months ago
  • 0.15.1                                ...           10 months ago
  • 0.15.0                                ...           10 months ago
  • 0.14.1                                ...           10 months ago
  • 0.14.0                                ...           10 months ago
  • 0.12.5                                ...           10 months ago
  • 0.12.4                                ...           10 months ago
  • 0.12.3                                ...           10 months ago
  • 0.12.2                                ...           10 months ago
  • 0.12.1                                ...           10 months ago
  • 0.12.0                                ...           10 months ago
  • 0.11.5                                ...           10 months ago
  • 0.11.4                                ...           10 months ago
  • 0.11.3                                ...           10 months ago
  • 0.11.2                                ...           10 months ago
  • 0.11.1                                ...           10 months ago
  • 0.11.0                                ...           10 months ago
  • 0.10.4                                ...           a year ago
  • 0.10.2                                ...           a year ago
  • 0.10.0                                ...           a year ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.8.4                                ...           a year ago
  • 0.8.3                                ...           a year ago
  • 0.8.2                                ...           a year ago
  • 0.8.1                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.7                                ...           a year ago
  • 0.6.6                                ...           a year ago
  • 0.6.5                                ...           a year ago
  • 0.6.4                                ...           a year ago
  • 0.6.2                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.4.7                                ...           a year ago
  • 0.4.6                                ...           a year ago
  • 0.4.5                                ...           a year ago
  • 0.4.4                                ...           a year ago
  • 0.4.3                                ...           a year ago
  • 0.4.2                                ...           a year ago
  • 0.4.1                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.3                                ...           a year ago
  • 0.3.2                                ...           a year ago
  • 0.3.0                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.34                                ...           a year ago
  • 0.1.33                                ...           a year ago
  • 0.1.32                                ...           a year ago
  • 0.1.31                                ...           a year ago
  • 0.1.30                                ...           a year ago
  • 0.1.29                                ...           a year ago
  • 0.1.28                                ...           a year ago
  • 0.1.27                                ...           a year ago
  • 0.1.26                                ...           a year ago
  • 0.1.25                                ...           a year ago
  • 0.1.23                                ...           a year ago
  • 0.1.22                                ...           a year ago
  • 0.1.21                                ...           a year ago
  • 0.1.20                                ...           a year ago
  • 0.1.19                                ...           a year ago
  • 0.1.18                                ...           a year ago
  • 0.1.17                                ...           a year ago
  • 0.1.16                                ...           a year ago
  • 0.1.15                                ...           a year ago
  • 0.1.14                                ...           a year ago
  • 0.1.13                                ...           a year ago
  • 0.1.12                                ...           a year ago
  • 0.1.10                                ...           a year ago
  • 0.1.9                                ...           a year ago
  • 0.1.8                                ...           a year ago
  • 0.1.7                                ...           a year ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
  • 0.0.66                                ...           2 years ago
  • 0.0.65                                ...           2 years ago
  • 0.0.64                                ...           2 years ago
  • 0.0.63                                ...           2 years ago
  • 0.0.62                                ...           2 years ago
  • 0.0.61                                ...           2 years ago
  • 0.0.60                                ...           2 years ago
  • 0.0.59                                ...           2 years ago
  • 0.0.58                                ...           2 years ago
  • 0.0.57                                ...           2 years ago
  • 0.0.56                                ...           2 years ago
  • 0.0.55                                ...           2 years ago
  • 0.0.54                                ...           2 years ago
  • 0.0.53                                ...           2 years ago
  • 0.0.52                                ...           2 years ago
  • 0.0.51                                ...           2 years ago
  • 0.0.50                                ...           2 years ago
  • 0.0.49                                ...           2 years ago
  • 0.0.48                                ...           2 years ago
  • 0.0.47                                ...           2 years ago
  • 0.0.46                                ...           2 years ago
  • 0.0.45                                ...           2 years ago
  • 0.0.43                                ...           2 years ago
  • 0.0.42                                ...           2 years ago
  • 0.0.41                                ...           2 years ago
  • 0.0.40                                ...           2 years ago
  • 0.0.39                                ...           2 years ago
  • 0.0.38                                ...           2 years ago
  • 0.0.37                                ...           2 years ago
  • 0.0.36                                ...           2 years ago
  • 0.0.35                                ...           2 years ago
  • 0.0.34                                ...           2 years ago
  • 0.0.33                                ...           2 years ago
  • 0.0.32                                ...           2 years ago
  • 0.0.31                                ...           2 years ago
  • 0.0.30                                ...           2 years ago
  • 0.0.29                                ...           2 years ago
  • 0.0.28                                ...           2 years ago
  • 0.0.27                                ...           2 years ago
  • 0.0.26                                ...           2 years ago
  • 0.0.25                                ...           2 years ago
  • 0.0.24                                ...           2 years ago
  • 0.0.23                                ...           2 years ago
  • 0.0.22                                ...           2 years ago
  • 0.0.21                                ...           2 years ago
  • 0.0.20                                ...           2 years ago
  • 0.0.19                                ...           2 years ago
  • 0.0.18                                ...           2 years ago
  • 0.0.17                                ...           2 years ago
  • 0.0.16                                ...           2 years ago
  • 0.0.15                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           2 years ago
  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 83
Last Day 0
Last Week 55
Last Month 937
Dependencies (6)
Dev Dependencies (69)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |