Skip to content

Commit bb892ad

Browse files
authored
Implemented fullscreen feature
* Refined Readme and bettercodehub config * Added lint-staged for prettyfing code on commit * Implemented fullscreen feature
1 parent 660443e commit bb892ad

27 files changed

+527
-53
lines changed

.bettercodehub.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
component_depth: 2
1+
component_depth: 2
2+
languages:
3+
- name: typescript
4+
production:
5+
exclude:
6+
- .*/__snapshots__/.*\.snap
7+
- .*/__utils__/.*\.ts
8+
- .*/__utils__/.*\.tsx
9+
- .*\.story\.tsx
10+
- .*\.test\.ts
11+
- .*\.test\.tsx

.lintstagedrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"src/**/*": ["yarn prettier", "git add"]
3+
}

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
**The most powerful and flexible grid system for _React_**
88

9-
_React Rasta_ is a 12 column grid system and works underneath with the _CSS flexbox_ layout.
10-
But because it can be difficult to work with _CSS flexbox_, _React Rasta_ offers a simple _API_
11-
so you don't have to worry about that.
9+
_React Rasta_ is a 12 column grid system built on top of `styled-components` which works underneath
10+
with the _CSS flexbox_ layout. _React Rasta_ implements all features from the _Bootstrap V4.1_ grid
11+
system but adds more flexibility on top of it.
1212

1313
## Getting Started
1414

@@ -30,9 +30,16 @@ And when using _npm_ it looks like this.
3030
npm install react-rasta --save
3131
```
3232

33-
### Code Example
33+
#### Required Dependencies
3434

35-
_React Rasta_ implements all features from the _Bootstrap V4_ grid system and adds more flexibility on top of it.
35+
_React Rasta_ depends on the following packages which need to be installed manually.
36+
37+
| Package | Version |
38+
| ------------------- | ------------ |
39+
| `react` | 16 or higher |
40+
| `styled-components` | 3 or higher |
41+
42+
### Code Examples
3643

3744
```tsx
3845
import { Component } from "react";

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
"build-storybook": "build-storybook",
1818
"cover": "coveralls < coverage/lcov.info",
1919
"lint": "tslint -c tslint.json 'src/**/*.ts*'",
20+
"precommit": "lint-staged",
2021
"prettier": "prettier \"./*.+(js|json|md)\" \"./src/**/*.*\" --write",
2122
"storybook": "start-storybook -p 6006",
2223
"test": "jest --runInBand --config jest.config.json",
2324
"test:coverage": "jest --runInBand --coverage --config jest.config.json"
2425
},
2526
"peerDependencies": {
26-
"styled-components": ">= 1 < 4"
27+
"styled-components": ">= 3 < 4"
2728
},
2829
"devDependencies": {
2930
"@storybook/addon-actions": "^3.4.0",
@@ -44,9 +45,11 @@
4445
"enzyme": "^3.3.0",
4546
"enzyme-adapter-react-16": "^1.1.1",
4647
"enzyme-to-json": "^3.3.3",
48+
"husky": "^0.14.3",
4749
"jest": "^22.0.5",
4850
"jest-junit": "^3.6.0",
4951
"jest-styled-components": "^5.0.1",
52+
"lint-staged": "^7.0.5",
5053
"prettier": "^1.11.1",
5154
"react": "^16.2.0",
5255
"react-dom": "^16.2.0",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as _React from "react";
33
import * as _StyledComponents from "styled-components";
44
// -------------------------------------------------------------------
55
import styled from "styled-components";
6+
import StoryProperties from "./StoryProperties";
67
import Column from "../column";
78
import Container from "../container";
89
import Row from "../row";
@@ -11,11 +12,12 @@ const Story = styled.div`
1112
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
1213
"Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
1314
"Segoe UI Symbol";
15+
${(props: StoryProperties) => (props.fullscreen ? "height: 100%;" : "")}
1416
1517
${Container},
1618
${Row} {
1719
background: #ccc;
18-
height: 300px;
20+
${(props: StoryProperties) => (props.fullscreen ? "" : "height: 300px;")}
1921
}
2022
2123
${Row} > ${Column} {

src/__utils__/StoryProperties.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface StoryProperties {
2+
fullscreen?: boolean;
3+
}
4+
5+
export default StoryProperties;

src/column/ColumnProperties.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import ColumnSize from "./ColumnSize";
66
import { BreakpointValue } from "../media";
77
import { ThemeProperties } from "../theme";
88

9-
export default interface ColumnProperties extends ThemeProperties {
9+
interface ColumnProperties extends ThemeProperties {
1010
alignSelf?: BreakpointValue<ColumnAlignSelf>;
1111
flex?: BreakpointValue<ColumnFlex>;
1212
offset?: BreakpointValue<ColumnOffset>;
1313
order?: BreakpointValue<ColumnOrder>;
1414
size?: BreakpointValue<ColumnSize>;
15-
};
15+
}
16+
17+
export default ColumnProperties;

src/container/Container.story.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ storiesOf("Container", module)
3030
</Container>
3131
</Story>
3232
))
33+
.add("fullscreen", () => (
34+
<Story fullscreen>
35+
<Container fullscreen>
36+
<Row>
37+
<Column>fullscreen</Column>
38+
</Row>
39+
</Container>
40+
</Story>
41+
))
3342
.add("themeProvider", () => (
3443
<Story>
3544
<Title>themeProvider</Title>

src/container/Container.test.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ describe("<Container />", () => {
1313
expect(result).toMatchSnapshot();
1414
});
1515

16-
it("should match the snapshot (fluid property set to true) ", () => {
16+
it("should match the snapshot (fluid property set to true)", () => {
1717
// act
1818
const result = shallow(<Container fluid />);
1919

2020
// assert
2121
expect(result).toMatchSnapshot();
2222
});
2323

24+
it("should match the snapshot (fullscreen property set to true)", () => {
25+
// act
26+
const result = shallow(<Container fullscreen />);
27+
28+
// assert
29+
expect(result).toMatchSnapshot();
30+
});
31+
2432
it("should match the snapshot (width property set to { xs: 100, sm: 200, md: 300 })", () => {
2533
// act
2634
const result = shallow(<Container width={{ xs: 100, sm: 200, md: 300 }} />);
@@ -32,7 +40,17 @@ describe("<Container />", () => {
3240
it("should match the snapshot (ignores width when fluid is set)", () => {
3341
// act
3442
const result = shallow(
35-
<Container fluid={true} width={{ xs: 100, sm: 200, md: 300 }} />
43+
<Container fluid width={{ xs: 100, sm: 200, md: 300 }} />
44+
);
45+
46+
// assert
47+
expect(result).toMatchSnapshot();
48+
});
49+
50+
it("should match the snapshot (ignores fluid and width when fullscreen is set)", () => {
51+
// act
52+
const result = shallow(
53+
<Container fluid fullscreen width={{ xs: 100, sm: 200, md: 300 }} />
3654
);
3755

3856
// assert

0 commit comments

Comments
 (0)