Skip to content

Commit

Permalink
Implemented align items feature
Browse files Browse the repository at this point in the history
* Fixed bettercodehub config and excluded yml files from prettier task

* Added keywords to the package config

* Added snapshot tests for index modules and added a test config

* Updated yarn.lock file

* Improved tslint config and added tslint-sonarts

* Removed vendor prefixes and fully trust on styled-components doing its job right

* Implemented align items feature
  • Loading branch information
rstaib authored Apr 18, 2018
1 parent 16c35fa commit 2e3fb92
Show file tree
Hide file tree
Showing 47 changed files with 555 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .bettercodehub.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
component_depth: 2;
component_depth: 2
1 change: 1 addition & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"coverageReporters": ["cobertura", "lcov"],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"setupTestFrameworkScriptFile": "./test.config.ts",
"snapshotSerializers": ["enzyme-to-json/serializer"],
"testRegex": ".*?\\.(spec|test)\\.(jsx?|tsx?)$",
"testResultsProcessor": "jest-junit",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-rasta",
"version": "0.3.0",
"version": "1.0.0",
"description": "The most powerful and flexible grid system for React",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand All @@ -11,12 +11,13 @@
},
"author": "ChilliCream",
"license": "MIT",
"keywords": ["grid", "layout", "css", "flexbox"],
"scripts": {
"build": "yarn prettier && yarn lint && yarn test:coverage && tsc",
"build-storybook": "build-storybook",
"cover": "coveralls < coverage/lcov.info",
"lint": "tslint -c tslint.json 'src/**/*.ts*'",
"prettier": "prettier \"./*.+(js|json|md|yml)\" \"./src/**/*.*\" --write",
"prettier": "prettier \"./*.+(js|json|md)\" \"./src/**/*.*\" --write",
"storybook": "start-storybook -p 6006",
"test": "jest --config jest.config.json",
"test:coverage": "jest --coverage --config jest.config.json"
Expand Down Expand Up @@ -54,6 +55,7 @@
"ts-jest": "^22.0.1",
"tslint": "^5.9.1",
"tslint-react": "^3.3.3",
"tslint-sonarts": "^1.6.0",
"typescript": "^2.8.1"
},
"dependencies": {}
Expand Down
14 changes: 14 additions & 0 deletions src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`index should verify the API shape 1`] = `
Object {
"BreakpointMap": Object {},
"BreakpointValue": Object {},
"BreakpointValues": Object {},
"Column": [Function],
"Container": [Function],
"Row": [Function],
"Theme": Object {},
"ThemeProvider": [Function],
}
`;
8 changes: 1 addition & 7 deletions src/column/Column.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Module mocks must mocked before importing modules
jest.mock("../utils/bootstrap", () => jest.fn());

import "jest-styled-components";
import { configure, shallow } from "enzyme";
import * as Adapter from "enzyme-adapter-react-16";
import { shallow } from "enzyme";
import * as React from "react";
import styled from "styled-components";
import Column from "./Column";

configure({ adapter: new Adapter() });

describe("<Column />", () => {
it("should match the snapshot (no properties set)", () => {
// act
Expand Down
6 changes: 2 additions & 4 deletions src/column/Column.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// These imports are needed for declaration files
import * as _React from "react";
import * as _StyledComponents from "styled-components";
// -------------------------------------------------------------------
import "../utils/bootstrap";
import { ClassAttributes, HTMLAttributes } from "react";
import { StyledComponentClass } from "styled-components";
import ColumnProperties from "./ColumnProperties";
import ColumnOffset from "./ColumnOffset";
import ColumnOrder from "./ColumnOrder";
Expand Down
55 changes: 17 additions & 38 deletions src/column/__snapshots__/Column.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@ exports[
width: 100%;
min-height: 1px;
margin-left: 25.000000%;
-webkit-box-ordinal-group: 3;
-ms-flex-order: 2;
-webkit-order: 2;
-ms-flex-order: 2;
order: 2;
-webkit-box-flex: 0;
-ms-flex: 0 0 75.000000%;
-webkit-flex: 0 0 75.000000%;
-ms-flex: 0 0 75.000000%;
flex: 0 0 75.000000%;
Expand All @@ -96,17 +92,13 @@ exports[
position: relative;
width: 100%;
min-height: 1px;
-webkit-box-ordinal-group: 0;
-ms-flex-order: -1;
-webkit-order: -1;
-ms-flex-order: -1;
order: -1;
}
@media (min-width:576px) {
.c0 {
-webkit-box-ordinal-group: 3;
-ms-flex-order: 2;
-webkit-order: 2;
-ms-flex-order: 2;
order: 2;
Expand All @@ -115,8 +107,6 @@ exports[
@media (min-width:768px) {
.c0 {
-webkit-box-ordinal-group: 13;
-ms-flex-order: 12;
-webkit-order: 12;
-ms-flex-order: 12;
order: 12;
Expand All @@ -140,8 +130,6 @@ exports[`<Column /> should match the snapshot (order: 5) 1`] = `
position: relative;
width: 100%;
min-height: 1px;
-webkit-box-ordinal-group: 5;
-ms-flex-order: 4;
-webkit-order: 4;
-ms-flex-order: 4;
order: 4;
Expand All @@ -153,39 +141,17 @@ exports[`<Column /> should match the snapshot (order: 5) 1`] = `
/>
`;

exports[`<Column /> should match the snapshot (size: 7) 1`] = `
.c0 {
position: relative;
width: 100%;
min-height: 1px;
-webkit-box-flex: 0;
-ms-flex: 0 0 58.333333%;
-webkit-flex: 0 0 58.333333%;
-ms-flex: 0 0 58.333333%;
flex: 0 0 58.333333%;
max-width: 58.333333%;
}
<div
className="c0"
size={7}
/>
`;

exports[
`<Column /> should match the snapshot (size: { xs: 'auto', sm: 7, md: 'none' }) 1`
] = `
.c0 {
position: relative;
width: 100%;
min-height: 1px;
-ms-flex-preferred-size: 0;
-webkit-flex-basis: 0;
-ms-flex-preferred-size: 0;
flex-basis: 0;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
Expand All @@ -194,8 +160,6 @@ exports[
@media (min-width:576px) {
.c0 {
-webkit-box-flex: 0;
-ms-flex: 0 0 58.333333%;
-webkit-flex: 0 0 58.333333%;
-ms-flex: 0 0 58.333333%;
flex: 0 0 58.333333%;
Expand All @@ -205,8 +169,6 @@ exports[
@media (min-width:768px) {
.c0 {
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
Expand All @@ -226,3 +188,20 @@ exports[
}
/>
`;

exports[`<Column /> should match the snapshot (size: 7) 1`] = `
.c0 {
position: relative;
width: 100%;
min-height: 1px;
-webkit-flex: 0 0 58.333333%;
-ms-flex: 0 0 58.333333%;
flex: 0 0 58.333333%;
max-width: 58.333333%;
}
<div
className="c0"
size={7}
/>
`;
7 changes: 7 additions & 0 deletions src/column/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`index should verify the API shape 1`] = `
Object {
"default": [Function],
}
`;
7 changes: 7 additions & 0 deletions src/column/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as module from ".";

describe("index", () => {
it("should verify the API shape", () => {
expect(module).toMatchSnapshot();
});
});
20 changes: 5 additions & 15 deletions src/column/renderOrder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ describe("renderOrder", () => {
const output = renderOrder(input);

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1;"
);
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe("order:-1;");
});

it("should render css for flex order (input: 0)", () => {
Expand All @@ -22,9 +20,7 @@ describe("renderOrder", () => {
const output = renderOrder(input);

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1;"
);
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe("order:-1;");
});

it("should render css for flex order (input: 5)", () => {
Expand All @@ -35,9 +31,7 @@ describe("renderOrder", () => {
const output = renderOrder(input);

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-ordinal-group:5;-ms-flex-order:4;order:4;"
);
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe("order:4;");
});

it("should render css for flex order (input: 'last')", () => {
Expand All @@ -48,9 +42,7 @@ describe("renderOrder", () => {
const output = renderOrder(input);

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-ordinal-group:13;-ms-flex-order:12;order:12;"
);
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe("order:12;");
});

it("should render css for flex order (input: 13)", () => {
Expand All @@ -61,8 +53,6 @@ describe("renderOrder", () => {
const output = renderOrder(input);

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-ordinal-group:13;-ms-flex-order:12;order:12;"
);
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe("order:12;");
});
});
2 changes: 0 additions & 2 deletions src/column/renderOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const renderOrder = (order?: ColumnOrder | 0 | 13): string => {

if (typeof order === "number") {
return `
-webkit-box-ordinal-group: ${order};
-ms-flex-order: ${order - 1};
order: ${order - 1};
`;
}
Expand Down
6 changes: 3 additions & 3 deletions src/column/renderSize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("renderSize", () => {

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-ms-flex-preferred-size:0;flex-basis:0;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;max-width:100%;"
"flex-basis:0;flex-grow:1;max-width:100%;"
);
});

Expand All @@ -23,7 +23,7 @@ describe("renderSize", () => {

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-flex:0;-ms-flex:00auto;flex:00auto;width:auto;max-width:none;"
"flex:00auto;width:auto;max-width:none;"
);
});

Expand All @@ -47,7 +47,7 @@ describe("renderSize", () => {

// assert
expect(output.replace(/\n|\r|\s|\t/gi, "")).toBe(
"-webkit-box-flex:0;-ms-flex:0050.000000%;flex:0050.000000%;max-width:50.000000%;"
"flex:0050.000000%;max-width:50.000000%;"
);
});
});
7 changes: 0 additions & 7 deletions src/column/renderSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export default (size?: ColumnSize): string => {

if (size === "none") {
return `
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
width: auto;
max-width: none;
Expand All @@ -18,10 +16,7 @@ export default (size?: ColumnSize): string => {

if (size === "auto") {
return `
-ms-flex-preferred-size: 0;
flex-basis: 0;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
max-width: 100%;
`;
Expand All @@ -30,8 +25,6 @@ export default (size?: ColumnSize): string => {
const calculatedPercentage = percentage(size);

return `
-webkit-box-flex: 0;
-ms-flex: 0 0 ${calculatedPercentage}%;
flex: 0 0 ${calculatedPercentage}%;
max-width: ${calculatedPercentage}%;
`;
Expand Down
8 changes: 1 addition & 7 deletions src/container/Container.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Module mocks must mocked before importing modules
jest.mock("../utils/bootstrap", () => jest.fn());

import "jest-styled-components";
import { configure, shallow } from "enzyme";
import * as Adapter from "enzyme-adapter-react-16";
import { shallow } from "enzyme";
import * as React from "react";
import styled from "styled-components";
import Container from "./Container";

configure({ adapter: new Adapter() });

describe("<Container />", () => {
it("should match the snapshot (no properties set)", () => {
// act
Expand Down
6 changes: 2 additions & 4 deletions src/container/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// These imports are needed for declaration files
import * as _React from "react";
import * as _StyledComponents from "styled-components";
// -------------------------------------------------------------------
import "../utils/bootstrap";
import { ClassAttributes, HTMLAttributes } from "react";
import { StyledComponentClass } from "styled-components";
import ContainerProperties from "./ContainerProperties";
import renderWidth from "./renderWidth";
import getWidth from "./width";
Expand Down
7 changes: 7 additions & 0 deletions src/container/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`index should verify the API shape 1`] = `
Object {
"default": [Function],
}
`;
7 changes: 7 additions & 0 deletions src/container/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as module from ".";

describe("index", () => {
it("should verify the API shape", () => {
expect(module).toMatchSnapshot();
});
});
Loading

0 comments on commit 2e3fb92

Please sign in to comment.