You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/8-styling/8.2-common-styles-mixins.md
+170-1Lines changed: 170 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,5 +106,174 @@ import styles from './styles.js';
106
106
</View>
107
107
```
108
108
109
-
This way our mixins/common style file will provide us the base styles which are common across the app and we write componeny t specific styles in the component style file.
109
+
This way our mixins/common style file will provide us the base styles which are common across the app and we write component specific styles in the component style file.
110
110
Thus allowing significant style reuse and avoiding code duplication.
111
+
112
+
113
+
## Integrating common/mixin styles into our NoteTaker demo
114
+
115
+
Before we go into common styles , lets modify our code a bit to add another component for entering title for our note.
If you notice, even though we have theme file, our style code has lot of duplicated code. Primarily because we are repeating our styling for text input and also for the heading.
212
+
213
+
The solution to this problem as discussed before is common styles/ mixins
214
+
215
+
Lets create the file `common.style.js`
216
+
**`app/styles/common.style.js`**
217
+
```js
218
+
importthemefrom'./theme.style';
219
+
220
+
exportconstheadingText= {
221
+
fontSize:theme.FONT_SIZE_MEDIUM,
222
+
alignSelf:'flex-start',
223
+
padding:10,
224
+
fontWeight:theme.FONT_WEIGHT_BOLD,
225
+
};
226
+
227
+
exportconsttextInput= {
228
+
padding:theme.TEXT_INPUT_PADDING,
229
+
backgroundColor:theme.BACKGROUND_COLOR_LIGHT,
230
+
alignSelf:'stretch'
231
+
};
232
+
```
233
+
234
+
And modify our component style files to include the `common.style.js`
0 commit comments