Skip to content

Commit 06e456a

Browse files
committed
Simplify attrs
1 parent 4b5f8b6 commit 06e456a

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.0.5
2+
3+
- Simplify `attrs()` my making it just a thin wrapper that overwrites `defaultProps`..
4+
15
# 0.0.4
26

37
- Support theming.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,5 @@ const Foo = styled.div({ background: '#eee' });
193193

194194
<Foo />; // <div style={{ background: '#eee' }} />
195195
```
196+
197+
[![Edit shakl](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/52kw0jrn94?module=%2Fsrc%2FExample.js)

‎package.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"license": "MIT",
33
"name": "shakl",
44
"description": "A utility to create styled components in React Native.",
5-
"version": "0.0.4",
5+
"version": "0.0.5",
66
"main": "lib/index.js",
77
"react-native": "lib/rn.js",
88
"repository": {
@@ -13,9 +13,9 @@
1313
"react": ">=16.3.0"
1414
},
1515
"devDependencies": {
16-
"@types/jest": "23.1.4",
16+
"@types/jest": "23.1.5",
1717
"@types/react": "16.4.6",
18-
"@types/react-native": "0.55.28",
18+
"@types/react-native": "~0.55",
1919
"@types/react-test-renderer": "16.0.1",
2020
"babel-eslint": "8.2.5",
2121
"babel-plugin-external-helpers": "6.22.0",
@@ -24,13 +24,13 @@
2424
"babel-preset-stage-0": "6.24.1",
2525
"benchmark": "2.1.4",
2626
"emotion": "9.2.5",
27-
"eslint": "5.0.1",
27+
"eslint": "~4",
2828
"eslint-config-airbnb": "17.0.0",
2929
"eslint-plugin-import": "2.13.0",
3030
"eslint-plugin-jsx-a11y": "6.1.0",
3131
"eslint-plugin-react": "7.10.0",
3232
"glamorous-native": "1.4.0",
33-
"jest": "23.3.0",
33+
"jest": "23.4.0",
3434
"react": "16.3.1",
3535
"react-emotion": "9.2.5",
3636
"react-native": "0.55.4",

‎src/styled.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ const styled = (Comp, { name, multi, ...opts } = {}) => style => {
4040
Styled.displayName = name || `styled(${Comp.displayName || Comp.name})`;
4141

4242
Styled.extend = more => styled(Styled, { name })(more);
43-
Styled.attrs = attrs => styled(Styled, { name, attrs })();
43+
44+
Styled.attrs = attrs => {
45+
Styled.defaultProps = {
46+
...Styled.defaultProps,
47+
...attrs
48+
};
49+
50+
return Styled;
51+
};
52+
4453
Styled.withComponent = comp => styled(Styled, { comp })(style);
4554
Styled.withChild = child => styled(Styled, { name, child })();
4655
Styled.withTheme = () => withTheme(Styled);

0 commit comments

Comments
 (0)