├── .npmignore
├── .eslintignore
├── .travis.yml
├── src
├── index.ts
├── __tests__
│ ├── index.spec.ts
│ ├── __snapshots__
│ │ ├── enhance.spec.tsx.snap
│ │ └── Panel.spec.tsx.snap
│ ├── enhance.spec.tsx
│ └── Panel.spec.tsx
├── consts.ts
├── config.ts
├── enhance.tsx
├── styles.ts
├── Panel.tsx
└── Panel.md
├── styleguide
├── setup.ts
├── jss.js
├── Intro.md
└── styles.css
├── test
└── jestsetup.ts
├── .eslintrc
├── .gitignore
├── .editorconfig
├── tsconfig.json
├── styleguide.config.js
├── Readme.md
└── package.json
/.npmignore:
--------------------------------------------------------------------------------
1 | __tests__/
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | styleguide/setup.ts
3 | styleguide-build/
4 | lib/
5 | coverage/*
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - node_modules
5 | node_js:
6 | - 6
7 | - 8
8 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { Panel } from './Panel';
2 | export default Panel;
3 | export { default as spaceman } from './enhance';
4 |
--------------------------------------------------------------------------------
/styleguide/setup.ts:
--------------------------------------------------------------------------------
1 | const spaceman = require('../src/enhance.tsx').default;
2 |
3 | (global as any).spaceman = spaceman;
4 |
--------------------------------------------------------------------------------
/styleguide/jss.js:
--------------------------------------------------------------------------------
1 | const jss = require('jss').default;
2 | const preset = require('jss-preset-default').default;
3 |
4 | jss.setup(preset());
5 |
6 | module.exports = jss;
7 |
--------------------------------------------------------------------------------
/test/jestsetup.ts:
--------------------------------------------------------------------------------
1 | import { configure } from 'enzyme';
2 | import * as Adapter from 'enzyme-adapter-react-16';
3 |
4 | // React 16 Enzyme adapter
5 | configure({ adapter: new Adapter() });
6 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tamia/react",
3 | "parser": "typescript-eslint-parser",
4 | "rules": {
5 | "no-undef": 0,
6 | "no-unused-vars": 0,
7 | "no-useless-constructor": 0
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | styleguide-build/
3 | .DS_Store
4 | Thumbs.db
5 | .idea/
6 | .vscode/
7 | *.sublime-project
8 | *.sublime-workspace
9 | *.log
10 | .eslintcache
11 | Changelog.md
12 | lib/
13 | coverage/
14 |
--------------------------------------------------------------------------------
/src/__tests__/index.spec.ts:
--------------------------------------------------------------------------------
1 | import Panel, { spaceman } from '../index';
2 |
3 | describe('API', () => {
4 | it('should export an API', () => {
5 | expect(Panel).toEqual(expect.any(Function));
6 | expect(spaceman).toEqual(expect.any(Function));
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/src/consts.ts:
--------------------------------------------------------------------------------
1 | export type Size = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
2 |
3 | export const Sizes: { [index: string]: number | undefined } = {
4 | none: undefined,
5 | xs: 2,
6 | s: 4,
7 | m: 8,
8 | l: 16,
9 | xl: 32,
10 | xxl: 64,
11 | xxxl: 128,
12 | };
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 |
3 | [*]
4 | indent_style = tab
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.{json,yml,md,babelrc,eslintrc,remarkrc}]
11 | indent_style = space
12 | indent_size = 2
13 |
--------------------------------------------------------------------------------
/styleguide/Intro.md:
--------------------------------------------------------------------------------
1 | # React Spaceman
2 |
3 | React component to manage whitespace.
4 |
5 | *Inspired by Nathan Curtis’ article [Space in Design Systems](https://medium.com/eightshapes-llc/space-in-design-systems-188bcbae0d62).*
6 |
7 | ### Installation
8 |
9 | ```bash
10 | npm install --save-dev react-spaceman
11 | ```
12 |
--------------------------------------------------------------------------------
/src/config.ts:
--------------------------------------------------------------------------------
1 | export interface ISizeItem {
2 | size: string,
3 | value: number,
4 | }
5 |
6 | export const Sizes: ISizeItem[] = [
7 | { size: 'xxs', value: 2 },
8 | { size: 'xs', value: 4 },
9 | { size: 's', value: 8 },
10 | { size: 'm', value: 16 },
11 | { size: 'l', value: 32 },
12 | { size: 'xl', value: 64 },
13 | { size: 'xxl', value: 128 },
14 | ];
15 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "moduleResolution": "node",
6 | "jsx": "react",
7 | "strict": true,
8 | "experimentalDecorators": true,
9 | "emitDecoratorMetadata": true,
10 | "noUnusedLocals": true,
11 | "pretty": true,
12 | "lib": [
13 | "dom",
14 | "esnext"
15 | ],
16 | "declaration": true
17 | },
18 | "include": [
19 | "src/**/*"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/styleguide.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { createConfig, css, typescript } = require('webpack-blocks');
3 | module.exports = {
4 | sections: [
5 | {
6 | content: path.join(__dirname, 'styleguide/Intro.md'),
7 | },
8 | {
9 | components: 'src/[A-Z]*.tsx',
10 | },
11 | ],
12 | propsParser: require('react-docgen-typescript').parse,
13 | require: [
14 | path.join(__dirname, 'styleguide/styles.css'),
15 | path.join(__dirname, 'styleguide/setup.ts'),
16 | ],
17 | context: {
18 | jss: path.join(__dirname, 'styleguide/jss.js'),
19 | },
20 | webpackConfig: createConfig([css(), typescript()]),
21 | getComponentPathLine: componentName => `import Panel from 'react-spaceman';`,
22 | showUsage: true,
23 | showSidebar: false,
24 | styleguideDir: path.join(__dirname, 'styleguide-build'),
25 | };
26 |
--------------------------------------------------------------------------------
/src/__tests__/__snapshots__/enhance.spec.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`enhance returned function should accept Spaceman props 1`] = `
4 |