diff --git a/docs/components.md b/docs/components.md
index f03369d..5b3f929 100644
--- a/docs/components.md
+++ b/docs/components.md
@@ -9,10 +9,11 @@ Components:
- View
- Text
+- TextInput
- TouchableOpacity
```js
-import C, { apply, extend, View, Text } from 'consistencss';
+import C, { apply, extend, View, Text, TextInput } from 'consistencss';
extend({
colors: {
@@ -22,6 +23,7 @@ extend({
components: {
View: C.p4,
Text: apply(C.textPrimary),
+ TextInput: apply(C.borderRed, C.borderHairline),
TouchableOpacity: apply(C.p2, C.bgSecondary),
},
});
@@ -35,6 +37,7 @@ const App = () => {
>
primary text
+
);
};
diff --git a/example/src/App.tsx b/example/src/App.tsx
index dbc293f..758806a 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -12,6 +12,7 @@ extend({
},
components: {
Text: apply(C.textBlue, C.m8, C.uppercase, { fontSize: 24 }),
+ TextInput: apply(C.borderRed, C.borderHairline, C.font4, C.px3),
},
sizing: {},
});
diff --git a/example/src/views/Another.tsx b/example/src/views/Another.tsx
index 3e28528..8481ebf 100644
--- a/example/src/views/Another.tsx
+++ b/example/src/views/Another.tsx
@@ -7,7 +7,13 @@
*/
import React, { FC } from 'react';
-import C, { apply, Text, TouchableOpacity, View } from 'consistencss';
+import C, {
+ apply,
+ Text,
+ TextInput,
+ TouchableOpacity,
+ View,
+} from 'consistencss';
import { NavigationStack } from '../types';
const row = apply(C.itemsCenter, C.justifyBetween, C.row);
@@ -19,6 +25,7 @@ const Another: FC<{ navigation: NavigationStack }> = ({ navigation }) => {
left
right
+
navigation.goBack()}
diff --git a/package.json b/package.json
index 32cd23f..a32784d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "consistencss",
- "version": "0.3.0",
+ "version": "0.4.0",
"description": "react native css",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
diff --git a/src/__tests__/index.test.tsx b/src/__tests__/index.test.tsx
index a293de4..9c27e16 100644
--- a/src/__tests__/index.test.tsx
+++ b/src/__tests__/index.test.tsx
@@ -3,6 +3,7 @@ import C, {
exists,
extend,
Text,
+ TextInput,
TouchableOpacity,
View,
} from '../index';
@@ -128,11 +129,13 @@ test('extend should change the default style from components', () => {
expect(View({}).props.style).toEqual([{}, {}]);
expect(Text({}).props.style).toEqual([{}, {}]);
expect(TouchableOpacity({}).props.style).toEqual([{}, {}]);
+ expect(TextInput({}).props.style).toEqual([{}, {}]);
extend({
components: {
View: apply(C.m4),
Text: apply(C.textRed),
TouchableOpacity: apply(C.p4),
+ TextInput: apply(C.px2),
},
});
expect(View({}).props.style).toEqual([{ margin: 8 }, {}]);
@@ -147,4 +150,5 @@ test('extend should change the default style from components', () => {
]);
expect(Text({}).props.style).toEqual([{ color: 'red' }, {}]);
expect(TouchableOpacity({}).props.style).toEqual([{ padding: 8 }, {}]);
+ expect(TextInput({}).props.style).toEqual([{ paddingHorizontal: 4 }, {}]);
});
diff --git a/src/__tests__/performance.test.tsx b/src/__tests__/performance.test.tsx
index 630273b..cdc08f0 100644
--- a/src/__tests__/performance.test.tsx
+++ b/src/__tests__/performance.test.tsx
@@ -16,15 +16,10 @@ test("perfomance matters, consistencss's apply should be similar than StyleSheet
color: 'skyblue',
paddingVertical: 16,
},
- test2: {
- flexDirection: 'row',
- justifyContent: 'space-between',
- },
});
})
.add('apply', function() {
apply(C.bgRed, C.m4, C.alignCenter, C.textSkyblue, C.py);
- apply(C.row, C.justifyBetween);
})
// add listeners
.on('cycle', function(event: any) {
diff --git a/src/components.tsx b/src/components.tsx
index b89525d..2a34838 100644
--- a/src/components.tsx
+++ b/src/components.tsx
@@ -2,6 +2,8 @@ import React, { ReactNode } from 'react';
import {
Text as RNText,
TextProps,
+ TextInput as RNTextInput,
+ TextInputProps,
TouchableOpacity as RNTouchableOpacity,
TouchableOpacityProps,
View as RNView,
@@ -20,6 +22,10 @@ export const Text = ({ children, style = {}, ...rest }: Props & TextProps) => (
);
+export const TextInput = ({ style = {}, ...rest }: TextInputProps) => (
+
+);
+
export const TouchableOpacity = ({
children,
style = {},
diff --git a/src/constants.tsx b/src/constants.tsx
index cf8a901..21ec29f 100644
--- a/src/constants.tsx
+++ b/src/constants.tsx
@@ -11,6 +11,7 @@ const sizing: AnyObject = {
export const components: DynamicObject = {
Text: {},
+ TextInput: {},
TouchableOpacity: {},
View: {},
};
diff --git a/src/index.tsx b/src/index.tsx
index 737a529..73cea27 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,6 +1,6 @@
import { StyleSheet, StyleProp } from 'react-native';
import constants from './constants';
-import { Text, TouchableOpacity, View } from './components';
+import { Text, TextInput, TouchableOpacity, View } from './components';
import dictionary from './dictionary';
import { DynamicObject, Styles, StylesObject } from './types';
import { camelCaseSplit, isEmpty, warnOnInvalidKey } from './utils';
@@ -56,7 +56,7 @@ const handler = {
},
};
-export { apply, exists, extend, Text, TouchableOpacity, View };
+export { apply, exists, extend, Text, TextInput, TouchableOpacity, View };
const C: StylesObject = StyleSheet.create(new Proxy({}, handler));
diff --git a/website/i18n/en.json b/website/i18n/en.json
index 284e413..920aa2c 100644
--- a/website/i18n/en.json
+++ b/website/i18n/en.json
@@ -108,6 +108,9 @@
},
"version-0.3.0/version-0.3.0-typography": {
"title": "Typography"
+ },
+ "version-0.4.0/version-0.4.0-components": {
+ "title": "Components"
}
},
"links": {
diff --git a/website/versioned_docs/version-0.4.0/components.md b/website/versioned_docs/version-0.4.0/components.md
new file mode 100644
index 0000000..fba66df
--- /dev/null
+++ b/website/versioned_docs/version-0.4.0/components.md
@@ -0,0 +1,45 @@
+---
+id: version-0.4.0-components
+title: Components
+original_id: components
+---
+
+Consistencss gives an implementation of RN components, with default styles
+
+Components:
+
+- View
+- Text
+- TextInput
+- TouchableOpacity
+
+```js
+import C, { apply, extend, View, Text, TextInput } from 'consistencss';
+
+extend({
+ colors: {
+ primary: 'red',
+ secondary: 'blue',
+ },
+ components: {
+ View: C.p4,
+ Text: apply(C.textPrimary),
+ TextInput: apply(C.borderRed, C.borderHairline),
+ TouchableOpacity: apply(C.p2, C.bgSecondary),
+ },
+});
+
+const App = () => {
+ return (
+
+ primary text
+ console.log('button with background secondary')}
+ >
+ primary text
+
+
+
+ );
+};
+```
diff --git a/website/versions.json b/website/versions.json
index 42933b7..7b92004 100644
--- a/website/versions.json
+++ b/website/versions.json
@@ -1,4 +1,5 @@
[
+ "0.4.0",
"0.3.0",
"0.2.0",
"0.1.1"