5.4.0 • Published 2 years ago

@smashgg/gg-components v5.4.0

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

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

5.4.0

2 years ago

5.3.3

2 years ago

5.3.2

2 years ago

5.3.1

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.3.0

5 years ago

5.1.0

5 years ago

5.0.2

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.4.3

5 years ago

4.4.2

5 years ago

4.4.0

5 years ago

4.3.2

5 years ago

4.3.1

5 years ago

4.2.4

5 years ago

4.3.0

6 years ago

4.2.2

6 years ago

4.2.1

6 years ago

4.2.0

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.2.0

6 years ago

3.1.4

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.4

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.17

6 years ago

1.5.16

6 years ago

1.5.15

6 years ago

1.5.14

6 years ago

1.5.13

6 years ago

1.5.12

6 years ago

1.5.11

6 years ago

1.5.10

6 years ago

1.5.9

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.19.0

6 years ago

0.18.1

6 years ago

0.18.0

6 years ago

0.17.8

6 years ago

0.17.7

6 years ago

0.17.6

6 years ago

0.17.5

6 years ago

0.17.4

6 years ago

0.17.3

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.18

6 years ago

0.16.17

6 years ago

0.16.16

6 years ago

0.16.15

6 years ago

0.16.14

7 years ago

0.16.13

7 years ago

0.16.12

7 years ago

0.16.11

7 years ago

0.16.10

7 years ago

0.16.9

7 years ago

0.16.8

7 years ago

0.16.7

7 years ago

0.16.6

7 years ago

0.16.5

7 years ago

0.16.4

7 years ago

0.16.3

7 years ago

0.16.2

7 years ago

0.16.1

7 years ago

0.16.0

7 years ago

0.15.2

7 years ago

0.15.1

7 years ago

0.15.0

7 years ago

0.14.1

7 years ago

0.14.0

7 years ago

0.12.5

7 years ago

0.12.4

7 years ago

0.12.3

7 years ago

0.12.2

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.5

7 years ago

0.11.4

7 years ago

0.11.3

7 years ago

0.11.2

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.4

7 years ago

0.10.2

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.7

7 years ago

0.6.6

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.2

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.34

7 years ago

0.1.33

7 years ago

0.1.32

7 years ago

0.1.31

7 years ago

0.1.30

7 years ago

0.1.29

7 years ago

0.1.28

7 years ago

0.1.27

7 years ago

0.1.26

7 years ago

0.1.25

7 years ago

0.1.23

7 years ago

0.1.22

7 years ago

0.1.21

7 years ago

0.1.20

7 years ago

0.1.19

7 years ago

0.1.18

7 years ago

0.1.17

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.66

7 years ago

0.0.65

7 years ago

0.0.64

7 years ago

0.0.63

7 years ago

0.0.62

7 years ago

0.0.61

7 years ago

0.0.60

7 years ago

0.0.59

7 years ago

0.0.58

7 years ago

0.0.57

7 years ago

0.0.56

7 years ago

0.0.55

7 years ago

0.0.54

7 years ago

0.0.53

7 years ago

0.0.52

7 years ago

0.0.51

7 years ago

0.0.50

7 years ago

0.0.49

7 years ago

0.0.48

7 years ago

0.0.47

7 years ago

0.0.46

7 years ago

0.0.45

7 years ago

0.0.43

7 years ago

0.0.42

7 years ago

0.0.41

7 years ago

0.0.40

7 years ago

0.0.39

7 years ago

0.0.38

7 years ago

0.0.37

7 years ago

0.0.36

8 years ago

0.0.35

8 years ago

0.0.34

8 years ago

0.0.33

8 years ago

0.0.32

8 years ago

0.0.31

8 years ago

0.0.30

8 years ago

0.0.29

8 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago