Skip to content

Commit 958c388

Browse files
committed
add prettier and react version to peerDependencies
1 parent 1b33bfb commit 958c388

File tree

11 files changed

+198
-166
lines changed

11 files changed

+198
-166
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5"
4+
}

package.json

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-layout-manager",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "Layout manager not to give margins to components",
55
"homepage": "http://osamu38.github.io/react-layout-manager",
66
"bugs": {
@@ -21,9 +21,7 @@
2121
"test": "node scripts/test.js --env=jsdom"
2222
},
2323
"babel": {
24-
"presets": [
25-
"react-app"
26-
]
24+
"presets": ["react-app"]
2725
},
2826
"eslintConfig": {
2927
"extends": "react-app"
@@ -75,16 +73,12 @@
7573
"whatwg-fetch": "2.0.3"
7674
},
7775
"peerDependencies": {
78-
"react": "^15.3.0 || ^17.0.0",
79-
"styled-components": "^3.1.6"
76+
"react": "^0.14.0 || ^15.0.0 || ^16.0.0",
77+
"styled-components": "^3.0.0"
8078
},
8179
"jest": {
82-
"collectCoverageFrom": [
83-
"src/**/*.{js,jsx,mjs}"
84-
],
85-
"setupFiles": [
86-
"<rootDir>/config/polyfills.js"
87-
],
80+
"collectCoverageFrom": ["src/**/*.{js,jsx,mjs}"],
81+
"setupFiles": ["<rootDir>/config/polyfills.js"],
8882
"testMatch": [
8983
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
9084
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
@@ -94,11 +88,10 @@
9488
"transform": {
9589
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
9690
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
97-
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
91+
"^(?!.*\\.(js|jsx|mjs|css|json)$)":
92+
"<rootDir>/config/jest/fileTransform.js"
9893
},
99-
"transformIgnorePatterns": [
100-
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
101-
],
94+
"transformIgnorePatterns": ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"],
10295
"moduleNameMapper": {
10396
"^react-native$": "react-native-web"
10497
},

src/demo/App.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function Password() {
9797
return (
9898
<RLM {...PasswordStyle}>
9999
<Label>Password</Label>
100-
<Input placeholder="rEaCtLaYoUtMaNaGeR"/>
100+
<Input placeholder="rEaCtLaYoUtMaNaGeR" />
101101
</RLM>
102102
);
103103
}
@@ -162,7 +162,7 @@ function PostalCode() {
162162
{
163163
breakpoint: 480,
164164
settings: {
165-
width: ['50%', 16, '50%']
165+
width: ['50%', 16, '50%'],
166166
},
167167
},
168168
],
@@ -254,9 +254,7 @@ function Main() {
254254

255255
class App extends Component {
256256
render() {
257-
return (
258-
<Main />
259-
);
257+
return <Main />;
260258
}
261259
}
262260

src/lib/components/LayoutManager.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import {
66

77
const LayoutManager = styled.div`
88
display: block;
9-
${({ wrapVerticalSpace }) => setBottomNegativeMargin(wrapVerticalSpace)}
10-
${(props) => setResponsivePropertyToLayoutManager(props)}
9+
${({ wrapVerticalSpace }) =>
10+
setBottomNegativeMargin(wrapVerticalSpace)} ${props =>
11+
setResponsivePropertyToLayoutManager(props)};
1112
`;
1213

13-
export default LayoutManager;
14+
export default LayoutManager;

src/lib/components/LayoutManagerChild.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const LayoutManagerChild = styled.div`
2121
${({ verticalSpace }) => setVerticalSpace(verticalSpace)}
2222
${({ childWidth }) => setWidth(childWidth)}
2323
${({ verticalAlign }) => setVerticalAlign(verticalAlign)}
24-
${(props) => setResponsivePropertyToChild(props)}
24+
${props => setResponsivePropertyToChild(props)}
2525
`;
2626

2727
export default LayoutManagerChild;

src/lib/components/LayoutManagerChildInner.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
const LayoutManagerChildInner = styled.div`
99
${({ align }) => setAlign(align)}
1010
${({ innerWidth }) => setInnerWidth(innerWidth)}
11-
${(props) => setResponsivePropertyToChildInner(props)}
11+
${props => setResponsivePropertyToChildInner(props)}
1212
`;
1313

1414
export default LayoutManagerChildInner;

src/lib/components/ReactLayoutManager.jsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class ReactLayoutManager extends Component {
2323
visible: true,
2424
wrap: false,
2525
responsive: [],
26-
}
26+
};
2727
render() {
2828
const {
2929
children,
@@ -46,15 +46,12 @@ export default class ReactLayoutManager extends Component {
4646

4747
return (
4848
<LayoutManager
49-
{...getLayoutManagerProperty(
50-
wrapVerticalSpace,
51-
responsive,
52-
)}
49+
{...getLayoutManagerProperty(wrapVerticalSpace, responsive)}
5350
>
54-
{isArray(children) ?
51+
{isArray(children) ? (
5552
children.map((child, i) => {
5653
const childrenLength = children.length;
57-
const isLastChild = (childrenLength - 1) === i;
54+
const isLastChild = childrenLength - 1 === i;
5855

5956
return (
6057
<LayoutManagerChild
@@ -69,7 +66,7 @@ export default class ReactLayoutManager extends Component {
6966
childrenLength,
7067
isLastChild,
7168
i,
72-
responsive,
69+
responsive
7370
)}
7471
key={i}
7572
>
@@ -78,27 +75,23 @@ export default class ReactLayoutManager extends Component {
7875
parseInnerWidth,
7976
align,
8077
i,
81-
responsive,
78+
responsive
8279
)}
8380
key={i}
8481
>
8582
{child}
8683
</LayoutManagerChildInner>
8784
</LayoutManagerChild>
8885
);
89-
}) :
90-
<LayoutManagerChild
91-
childWidth={parseWidth}
92-
>
93-
<LayoutManagerChildInner
94-
innerWidth={parseInnerWidth}
95-
align={align}
96-
>
86+
})
87+
) : (
88+
<LayoutManagerChild childWidth={parseWidth}>
89+
<LayoutManagerChildInner innerWidth={parseInnerWidth} align={align}>
9790
{children}
9891
</LayoutManagerChildInner>
9992
</LayoutManagerChild>
100-
}
93+
)}
10194
</LayoutManager>
10295
);
10396
}
104-
};
97+
}

src/lib/helpers/getProperty.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
isNumber,
3-
isArray,
4-
} from './type';
1+
import { isNumber, isArray } from './type';
52
import { getUnit } from './util';
63

74
function getProperty(property, index) {
@@ -10,20 +7,13 @@ function getProperty(property, index) {
107
function getHorizontalSpace(horizontalSpace, childWidth, isLastChild, index) {
118
const horizontalSpaceValue = getProperty(horizontalSpace, index);
129

13-
if (
14-
!horizontalSpaceValue ||
15-
String(childWidth) === '100%' ||
16-
isLastChild
17-
) {
10+
if (!horizontalSpaceValue || String(childWidth) === '100%' || isLastChild) {
1811
return 0;
1912
}
2013
return horizontalSpaceValue;
2114
}
2215
function getVerticalSpace(verticalSpace, index) {
23-
if (
24-
verticalSpace &&
25-
index
26-
) {
16+
if (verticalSpace && index) {
2717
return getProperty(verticalSpace, index - 1);
2818
}
2919
}
@@ -37,7 +27,10 @@ function getTotalHorizontalSpaces(horizontalSpace, childrenLength) {
3727
return horizontalSpace * (childrenLength - 1);
3828
}
3929
function getChildWidth(width, horizontalSpace, wrap, childrenLength, index) {
40-
const totalHorizontalSpaces = getTotalHorizontalSpaces(horizontalSpace, childrenLength);
30+
const totalHorizontalSpaces = getTotalHorizontalSpaces(
31+
horizontalSpace,
32+
childrenLength
33+
);
4134

4235
if (wrap) {
4336
return getProperty(width, index);
@@ -51,16 +44,20 @@ function getChildWidth(width, horizontalSpace, wrap, childrenLength, index) {
5144
if (fixedWidth.length) {
5245
const totalFixedWidth = getTotalFixedWidth(fixedWidth);
5346

54-
return `calc(${width[index]} - ${(totalHorizontalSpaces + totalFixedWidth) / variableWidth.length}px)`;
47+
return `calc(${width[index]} - ${(totalHorizontalSpaces +
48+
totalFixedWidth) /
49+
variableWidth.length}px)`;
5550
}
56-
return `calc(${width[index]} - ${totalHorizontalSpaces / childrenLength}px)`;
51+
return `calc(${width[index]} - ${totalHorizontalSpaces /
52+
childrenLength}px)`;
5753
}
5854
return width[index];
5955
}
6056
const isVariableWidth = `${width}`.includes('%');
6157

6258
if (isVariableWidth) {
63-
return `calc(${width + getUnit(width)} - ${totalHorizontalSpaces / childrenLength}px)`;
59+
return `calc(${width + getUnit(width)} - ${totalHorizontalSpaces /
60+
childrenLength}px)`;
6461
}
6562
return getProperty(width, index);
6663
}
@@ -86,14 +83,25 @@ export function getLayoutManagerChildProperty(
8683
childrenLength,
8784
isLastChild,
8885
index,
89-
responsive,
86+
responsive
9087
) {
91-
const childWidth = getChildWidth(width, horizontalSpace, wrap, childrenLength, index);
88+
const childWidth = getChildWidth(
89+
width,
90+
horizontalSpace,
91+
wrap,
92+
childrenLength,
93+
index
94+
);
9295

9396
return {
9497
childWidth,
9598
verticalAlign: getProperty(verticalAlign, index),
96-
horizontalSpace: getHorizontalSpace(horizontalSpace, childWidth, isLastChild, index),
99+
horizontalSpace: getHorizontalSpace(
100+
horizontalSpace,
101+
childWidth,
102+
isLastChild,
103+
index
104+
),
97105
verticalSpace: getVerticalSpace(verticalSpace, index),
98106
wrapVerticalSpace,
99107
isWrap: wrap,
@@ -114,7 +122,12 @@ export function getLayoutManagerChildProperty(
114122
index,
115123
};
116124
}
117-
export function getLayoutManagerChildInnerProperty(innerWidth, align, index, responsive) {
125+
export function getLayoutManagerChildInnerProperty(
126+
innerWidth,
127+
align,
128+
index,
129+
responsive
130+
) {
118131
return {
119132
innerWidth: getProperty(innerWidth, index),
120133
align: getProperty(align, index),

0 commit comments

Comments
 (0)