Skip to content

Commit 80f383d

Browse files
feat(styling): add styled components (#495)
* feat(*): add Styled Components * docs(contributing): Update Contributing
1 parent b6e2941 commit 80f383d

4 files changed

Lines changed: 105 additions & 28 deletions

File tree

App.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import React, { Component } from 'react';
22
import { Provider } from 'react-redux';
3-
import {
4-
AppRegistry,
5-
AsyncStorage,
6-
Image,
7-
StyleSheet,
8-
View,
9-
LayoutAnimation,
10-
} from 'react-native';
3+
import styled from 'styled-components/native';
4+
import { AppRegistry, AsyncStorage, LayoutAnimation } from 'react-native';
115
import { persistStore } from 'redux-persist';
126
import createEncryptor from 'redux-persist-transform-encrypt';
137
import DeviceInfo from 'react-native-device-info';
@@ -19,18 +13,17 @@ import { getCurrentLocale, configureLocale } from 'utils';
1913
import { GitPoint } from './routes';
2014
import { configureStore } from './root.store';
2115

22-
const styles = StyleSheet.create({
23-
logoContainer: {
24-
backgroundColor: colors.white,
25-
flex: 1,
26-
justifyContent: 'center',
27-
alignItems: 'center',
28-
},
29-
logo: {
30-
width: 100,
31-
height: 100,
32-
},
33-
});
16+
const Container = styled.View`
17+
align-items: center;
18+
background-color: ${() => colors.white}
19+
flex: 1;
20+
justify-content: center;
21+
`;
22+
23+
const Logo = styled.Image`
24+
height: 100;
25+
width: 100;
26+
`;
3427

3528
if (console) {
3629
console.disableYellowBox = true; // eslint-disable-line no-console
@@ -87,12 +80,9 @@ class App extends Component {
8780
render() {
8881
if (!this.state.rehydrated) {
8982
return (
90-
<View style={styles.logoContainer}>
91-
<Image
92-
style={styles.logo}
93-
source={require('./src/assets/logo-black.png')}
94-
/>
95-
</View>
83+
<Container>
84+
<Logo source={require('./src/assets/logo-black.png')} />
85+
</Container>
9686
);
9787
}
9888

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Translation contributions are always welcome! If you happen to speak/read any la
5252
4. And lastly, in order for the language to be displayed in the options screen, we'll need to add a [two-letter code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) in lowercase (for example: _es_ for Spanish) and the native language name (for example: _España_ for Spanish) to the [language-settings.js](https://github.com/gitpoint/git-point/blob/master/src/auth/screens/language-settings.js) file. Please make sure the two-letter code matches the code used for the `moment` library to allow for date/time compatibility (you can view the list [here](https://github.com/moment/moment/tree/develop/locale)).
5353
5. Test out selecting your new translation and if it all looks good, submit that PR in! :smile:
5454

55+
## Styled Components
56+
We're moving from React Native's styles implementation and we are start using [Styled Components](https://www.styled-components.com/) This will let us write the styles for the app in a more _css way_. If you like to know why we're taking this decision you can read [This issue](https://github.com/gitpoint/git-point/issues/480)
57+
5558
## Troubleshooting
5659

5760
If you happen to see an error like below when you try to run the application:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"redux-persist-transform-encrypt": "^1.0.2",
8888
"redux-thunk": "^2.2.0",
8989
"reselect": "^3.0.1",
90-
"rn-app-intro": "^0.0.4"
90+
"rn-app-intro": "^0.0.4",
91+
"styled-components": "^2.2.1"
9192
},
9293
"devDependencies": {
9394
"@commitlint/cli": "^3.1.0",

yarn.lock

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ base64-js@0.0.8:
11711171
version "0.0.8"
11721172
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978"
11731173

1174-
base64-js@^1.1.2:
1174+
base64-js@^1.0.2, base64-js@^1.1.2:
11751175
version "1.2.1"
11761176
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
11771177

@@ -1293,6 +1293,13 @@ buffer-crc32@~0.2.3:
12931293
version "0.2.13"
12941294
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
12951295

1296+
buffer@^5.0.3:
1297+
version "5.0.8"
1298+
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.0.8.tgz#84daa52e7cf2fa8ce4195bc5cf0f7809e0930b24"
1299+
dependencies:
1300+
base64-js "^1.0.2"
1301+
ieee754 "^1.1.4"
1302+
12961303
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
12971304
version "1.1.1"
12981305
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
@@ -1814,6 +1821,18 @@ csrf@~3.0.0:
18141821
tsscmp "1.0.5"
18151822
uid-safe "2.1.4"
18161823

1824+
css-color-keywords@^1.0.0:
1825+
version "1.0.0"
1826+
resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05"
1827+
1828+
css-to-react-native@^2.0.3:
1829+
version "2.0.4"
1830+
resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-2.0.4.tgz#cf4cc407558b3474d4ba8be1a2cd3b6ce713101b"
1831+
dependencies:
1832+
css-color-keywords "^1.0.0"
1833+
fbjs "^0.8.5"
1834+
postcss-value-parser "^3.3.0"
1835+
18171836
cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
18181837
version "0.3.2"
18191838
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b"
@@ -2600,6 +2619,18 @@ fbjs@0.8.12:
26002619
setimmediate "^1.0.5"
26012620
ua-parser-js "^0.7.9"
26022621

2622+
fbjs@^0.8.16, fbjs@^0.8.5:
2623+
version "0.8.16"
2624+
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
2625+
dependencies:
2626+
core-js "^1.0.0"
2627+
isomorphic-fetch "^2.1.1"
2628+
loose-envify "^1.0.0"
2629+
object-assign "^4.1.0"
2630+
promise "^7.1.1"
2631+
setimmediate "^1.0.5"
2632+
ua-parser-js "^0.7.9"
2633+
26032634
fbjs@^0.8.9:
26042635
version "0.8.14"
26052636
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.14.tgz#d1dbe2be254c35a91e09f31f9cd50a40b2a0ed1c"
@@ -3072,6 +3103,10 @@ hoek@2.x.x:
30723103
version "2.16.3"
30733104
resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"
30743105

3106+
hoist-non-react-statics@^1.2.0:
3107+
version "1.2.0"
3108+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"
3109+
30753110
hoist-non-react-statics@^2.2.0, hoist-non-react-statics@^2.2.1:
30763111
version "2.2.2"
30773112
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.2.2.tgz#c0eca5a7d5a28c5ada3107eb763b01da6bfa81fb"
@@ -3184,6 +3219,10 @@ iconv-lite@0.4.18, iconv-lite@^0.4.17, iconv-lite@~0.4.13:
31843219
version "0.4.18"
31853220
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2"
31863221

3222+
ieee754@^1.1.4:
3223+
version "1.1.8"
3224+
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
3225+
31873226
ignore@^3.2.0:
31883227
version "3.3.3"
31893228
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.3.tgz#432352e57accd87ab3110e82d3fea0e47812156d"
@@ -3410,6 +3449,10 @@ is-fullwidth-code-point@^2.0.0:
34103449
version "2.0.0"
34113450
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
34123451

3452+
is-function@^1.0.1:
3453+
version "1.0.1"
3454+
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
3455+
34133456
is-glob@^2.0.0, is-glob@^2.0.1:
34143457
version "2.0.1"
34153458
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863"
@@ -3461,6 +3504,12 @@ is-path-inside@^1.0.0:
34613504
dependencies:
34623505
path-is-inside "^1.0.1"
34633506

3507+
is-plain-object@^2.0.1:
3508+
version "2.0.4"
3509+
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
3510+
dependencies:
3511+
isobject "^3.0.1"
3512+
34643513
is-posix-bracket@^0.1.0:
34653514
version "0.1.1"
34663515
resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
@@ -3529,6 +3578,10 @@ isobject@^2.0.0:
35293578
dependencies:
35303579
isarray "1.0.0"
35313580

3581+
isobject@^3.0.1:
3582+
version "3.0.1"
3583+
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
3584+
35323585
isomorphic-fetch@^2.1.1:
35333586
version "2.2.1"
35343587
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
@@ -5092,6 +5145,10 @@ pos@^0.4.2:
50925145
version "0.4.2"
50935146
resolved "https://registry.yarnpkg.com/pos/-/pos-0.4.2.tgz#20e9c77fbeedcc356823cea63c7585cace93be2a"
50945147

5148+
postcss-value-parser@^3.3.0:
5149+
version "3.3.0"
5150+
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15"
5151+
50955152
prelude-ls@~1.1.2:
50965153
version "1.1.2"
50975154
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
@@ -5153,6 +5210,14 @@ prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8:
51535210
fbjs "^0.8.9"
51545211
loose-envify "^1.3.1"
51555212

5213+
prop-types@^15.5.4:
5214+
version "15.6.0"
5215+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
5216+
dependencies:
5217+
fbjs "^0.8.16"
5218+
loose-envify "^1.3.1"
5219+
object-assign "^4.1.1"
5220+
51565221
proxy-agent@2:
51575222
version "2.1.0"
51585223
resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-2.1.0.tgz#a3a2b3866debfeb79bb791f345dc9bc876e7ff86"
@@ -6462,6 +6527,24 @@ structured-source@^3.0.2:
64626527
dependencies:
64636528
boundary "^1.0.1"
64646529

6530+
styled-components@^2.2.1:
6531+
version "2.2.1"
6532+
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-2.2.1.tgz#f4835f1001c37bcc301ac3865b5d93466de4dd5b"
6533+
dependencies:
6534+
buffer "^5.0.3"
6535+
css-to-react-native "^2.0.3"
6536+
fbjs "^0.8.9"
6537+
hoist-non-react-statics "^1.2.0"
6538+
is-function "^1.0.1"
6539+
is-plain-object "^2.0.1"
6540+
prop-types "^15.5.4"
6541+
stylis "^3.2.1"
6542+
supports-color "^3.2.3"
6543+
6544+
stylis@^3.2.1:
6545+
version "3.3.2"
6546+
resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.3.2.tgz#95ef285836e98243f8b8f64a9a72706ea6c893ea"
6547+
64656548
superagent-proxy@^1.0.0:
64666549
version "1.0.2"
64676550
resolved "https://registry.yarnpkg.com/superagent-proxy/-/superagent-proxy-1.0.2.tgz#92d3660578f618ed43a82cf8cac799fe2938ba2d"

0 commit comments

Comments
 (0)