Skip to content

Commit 5468776

Browse files
authored
docs(components): refactor examples with js code and framework icon components
1 parent 327ce36 commit 5468776

40 files changed

+1867
-1377
lines changed

docs/src/articles/guides/create-screen.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We suppose that you have a separate component per screen, let's open your `some-
1515
## Create a Component
1616

1717
```js
18-
import * as React from 'react';
18+
import React from 'react';
1919
import { Layout, Text, Button } from 'react-native-ui-kitten';
2020

2121
export const HomeScreen = () => (
@@ -35,7 +35,7 @@ The example above will render a simple screen with a welcome text and a button.
3535
Now let's add some styles to fit the full available space on the device screen.
3636

3737
```js
38-
import * as React from 'react';
38+
import React from 'react';
3939
import { StyleSheet } from 'react-native';
4040
import { Button, Layout, Text } from 'react-native-ui-kitten';
4141

@@ -47,13 +47,8 @@ export const HomeScreen = () => (
4747
);
4848

4949
const styles = StyleSheet.create({
50-
container: {
51-
flex: 1,
52-
alignItems: 'center',
53-
},
54-
text: {
55-
marginVertical: 16,
56-
},
50+
container: { flex: 1, alignItems: 'center' },
51+
text: { marginVertical: 16 },
5752
});
5853

5954
```
@@ -65,15 +60,13 @@ const styles = StyleSheet.create({
6560
Let's now set this screen as `ApplicationProvider` children to quickly review changes
6661

6762
```js
68-
import * as React from 'react';
63+
import React from 'react';
6964
import { mapping, light as lightTheme } from '@eva-design/eva';
7065
import { ApplicationProvider } from 'react-native-ui-kitten';
7166
import { HomeScreen } from './path-to/some-screen.component' // <-- Import a screen we've created
7267

7368
const App = () => (
74-
<ApplicationProvider
75-
mapping={mapping}
76-
theme={lightTheme}>
69+
<ApplicationProvider mapping={mapping} theme={lightTheme}>
7770
<HomeScreen/>
7871
</ApplicationProvider>
7972
);

docs/src/articles/guides/install-existing.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ In your **App.js**:
2020
```js
2121
import React from 'react';
2222
import { mapping, light as lightTheme } from '@eva-design/eva';
23-
import { ApplicationProvider } from 'react-native-ui-kitten';
24-
import { RootComponent } from '../path-to/root.component'; // <-- Import your application entry point
23+
import { ApplicationProvider, Layout, Text } from 'react-native-ui-kitten';
24+
25+
const ApplicationContent = () => (
26+
<Layout style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
27+
<Text>Welcome to UI Kitten</Text>
28+
</Layout>
29+
);
2530

2631
const App = () => (
27-
<ApplicationProvider
28-
mapping={mapping}
29-
theme={lightTheme}>
30-
<RootComponent />
32+
<ApplicationProvider mapping={mapping} theme={lightTheme}>
33+
<ApplicationContent />
3134
</ApplicationProvider>
3235
);
3336

docs/src/articles/guides/setup-icons-module.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ npm i @ui-kitten/eva-icons
2626
## Configure Icon Registry
2727

2828
```js
29-
import * as React from 'react';
29+
import React from 'react';
3030
import { mapping, light as lightTheme } from '@eva-design/eva';
3131
import { EvaIconsPack } from '@ui-kitten/eva-icons';
32-
import { ApplicationProvider, Layout, IconRegistry } from 'react-native-ui-kitten';
32+
import { ApplicationProvider, IconRegistry, Layout, Text } from 'react-native-ui-kitten';
33+
34+
const ApplicationContent = () => (
35+
<Layout style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
36+
<Text>Welcome to UI Kitten</Text>
37+
</Layout>
38+
);
3339

3440
const App = () => (
35-
<ApplicationProvider
36-
mapping={mapping}
37-
theme={lightTheme}>
38-
<IconRegistry icons={EvaIconsPack}/>
39-
<Layout style={{flex: 1}}/>
40-
</ApplicationProvider>
41+
<React.Fragment>
42+
<IconRegistry icons={EvaIconsPack} />
43+
<ApplicationProvider mapping={mapping} theme={lightTheme}>
44+
<ApplicationContent />
45+
</ApplicationProvider>
46+
<React.Fragment />
4147
);
4248

4349
export default App;
@@ -48,7 +54,7 @@ export default App;
4854
## Use it with UI Kitten components
4955

5056
```js
51-
import * as React from 'react';
57+
import React from 'react';
5258
import { Button, Icon } from 'react-native-ui-kitten';
5359

5460
export const FacebookIcon = (style) => (

docs/src/articles/guides/setup-vector-icons.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ After vector-icons is installed and you have everything in place, we need to cre
2525
Let's create a separate file `feather-icons.js` and place there the following code.
2626

2727
```js
28-
import * as React from 'react';
28+
import React from 'react';
2929
import { StyleSheet } from 'react-native';
3030
import Icon from 'react-native-vector-icons/Feather'; // <-- Import Feather icons
3131

@@ -54,6 +54,8 @@ function createIconsMap() {
5454
And providing function
5555

5656
```js
57+
import Icon from 'react-native-vector-icons/Feather'; // <-- Import Feather icons
58+
5759
function IconProvider(name) {
5860
return {
5961
toReactElement: (props) => FeatherIcon({ name, ...props }),
@@ -81,18 +83,24 @@ function FeatherIcon({ name, style }) {
8183
After everything is configured, we simply need to import a feather icon map and register it with UI Kitten APIs.
8284

8385
```js
84-
import * as React from 'react';
86+
import React from 'react';
8587
import { mapping, light as lightTheme } from '@eva-design/eva';
86-
import { ApplicationProvider, Layout, IconRegistry } from 'react-native-ui-kitten';
88+
import { ApplicationProvider, IconRegistry, Layout, Text } from 'react-native-ui-kitten';
8789
import { FeatherIconsPack } from './path-to/feather-icons.js'; // <-- Feather icons map
8890

91+
const ApplicationContent = () => (
92+
<Layout style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
93+
<Text>Welcome to UI Kitten</Text>
94+
</Layout>
95+
);
96+
8997
const App = () => (
90-
<ApplicationProvider
91-
mapping={mapping}
92-
theme={lightTheme}>
93-
<IconRegistry icons={[FeatherIconsPack]}/>
94-
<Layout style={{flex: 1}}/>
95-
</ApplicationProvider>
98+
<React.Fragment>
99+
<IconRegistry icons={[FeatherIconsPack]} />
100+
<ApplicationProvider mapping={mapping} theme={lightTheme}>
101+
<ApplicationContent />
102+
</ApplicationProvider>
103+
</React.Fragment>
96104
);
97105

98106
export default App;
@@ -103,7 +111,7 @@ export default App;
103111
## Use it with UI Kitten components
104112

105113
```js
106-
import * as React from 'react';
114+
import React from 'react';
107115
import { Button, Icon } from 'react-native-ui-kitten';
108116

109117
export const FacebookIcon = (style) => (
@@ -128,6 +136,8 @@ As a result, you should have a Button looking similar to this:
128136
As you might notice, UI Kitten API allows you to register **multiple** icon packages with the following instruction.
129137

130138
```js
139+
import { IconRegistry } from 'react-native-ui-kitten';
140+
131141
<IconRegistry icons={[FeatherIconsPack]}/>
132142
```
133143

@@ -175,19 +185,25 @@ function MaterialIcon({ name, style }) {
175185
Now all we need to do is to extend our `IconRegistry`:
176186

177187
```js
178-
import * as React from 'react';
188+
import React from 'react';
179189
import { mapping, light as lightTheme } from '@eva-design/eva';
180-
import { ApplicationProvider, Layout, IconRegistry } from 'react-native-ui-kitten';
190+
import { ApplicationProvider, IconRegistry, Layout, Text } from 'react-native-ui-kitten';
181191
import { FeatherIconsPack } from './path-to/feather-icons.js'; // <-- Feather icons map
182192
import { MaterialIconsPack } from './path-to/material-icons.js'; // <-- Material icons map
183193

194+
const ApplicationContent = () => (
195+
<Layout style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
196+
<Text>Welcome to UI Kitten</Text>
197+
</Layout>
198+
);
199+
184200
const App = () => (
185-
<ApplicationProvider
186-
mapping={mapping}
187-
theme={lightTheme}>
201+
<React.Fragment>
188202
<IconRegistry icons={[FeatherIconsPack, MaterialIconsPack]}/>
189-
<Layout style={{flex: 1}}/>
190-
</ApplicationProvider>
203+
<ApplicationProvider mapping={mapping} theme={lightTheme}>
204+
<ApplicationContent />
205+
</ApplicationProvider>
206+
</React.Fragment>
191207
);
192208

193209
export default App;
@@ -200,7 +216,7 @@ export default App;
200216
Now you're able to choose an icon library with simply changing `pack` property.
201217

202218
```js
203-
import * as React from 'react';
219+
import React from 'react';
204220
import { Button, Icon } from 'react-native-ui-kitten';
205221

206222
export const HomeIcon = (style) => (

docs/src/structure.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ export const structure = [
287287
},
288288
],
289289
},
290+
{
291+
type: 'tabs',
292+
name: 'Menu',
293+
icon: 'menu.svg',
294+
source: [
295+
'Menu',
296+
],
297+
},
290298
{
291299
type: 'tabs',
292300
name: 'Icon',
@@ -307,10 +315,11 @@ export const structure = [
307315
},
308316
{
309317
type: 'tabs',
310-
name: 'Top Navigation',
318+
name: 'TopNavigation',
311319
icon: 'top-navigation.svg',
312320
source: [
313321
'TopNavigation',
322+
'TopNavigationAction',
314323
],
315324
overview: [
316325
{
@@ -321,7 +330,7 @@ export const structure = [
321330
},
322331
{
323332
type: 'tabs',
324-
name: 'Bottom Navigation',
333+
name: 'BottomNavigation',
325334
icon: 'bottom-navigation.svg',
326335
source: [
327336
'BottomNavigation',
@@ -359,11 +368,10 @@ export const structure = [
359368
},
360369
{
361370
type: 'tabs',
362-
name: 'Tab View',
371+
name: 'TabView',
363372
icon: 'tab.svg',
364373
source: [
365374
'TabView',
366-
'TabBar',
367375
'Tab',
368376
],
369377
overview: [
@@ -373,15 +381,6 @@ export const structure = [
373381
},
374382
],
375383
},
376-
{
377-
type: 'tabs',
378-
name: 'Menu',
379-
icon: 'menu.svg',
380-
source: [
381-
'Menu',
382-
'MenuItem',
383-
],
384-
},
385384
{
386385
type: 'group',
387386
name: 'Forms',

src/framework/theme/application/applicationProvider.component.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ interface State {
5656
* ```
5757
* import React from 'react';
5858
* import { mapping, light as lightTheme } from '@eva-design/eva';
59-
* import { ApplicationProvider } from 'react-native-ui-kitten';
60-
* import { Application } from './path-to/root.component';
59+
* import { ApplicationProvider, Layout, Text } from 'react-native-ui-kitten';
6160
*
6261
* export default class App extends React.Component {
6362
*
64-
* public render(): React.ReactNode {
63+
* render() {
6564
* return (
6665
* <ApplicationProvider
6766
* mapping={mapping}
6867
* theme={lightTheme}>
69-
* <Application/>
68+
* <Layout style={{ flex: 1 }}>
69+
* <Text>Welcome to UI Kitten</Text>
70+
* </Layout>
7071
* </ApplicationProvider>
7172
* );
7273
* }
7374
* }
7475
* ```
7576
*/
76-
7777
export class ApplicationProvider extends React.Component<ApplicationProviderProps, State> {
7878

7979
private schemaProcessor: SchemaProcessor = new SchemaProcessor();

src/framework/theme/modal/modal.service.tsx

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,52 +23,38 @@ import { ModalPresentingBased } from '../../ui/support/typings';
2323
*
2424
* ```
2525
* import React from 'react';
26-
* import {
27-
* View,
28-
* ViewProps,
29-
* } from 'react-native';
30-
* import {
31-
* Button,
32-
* Text,
33-
* ModalService,
34-
* } from 'react-native-ui-kitten';
26+
* import { Layout, Button, Text, ModalService } from 'react-native-ui-kitten';
3527
*
36-
* export const ModalServiceShowcase = (): React.ReactElement<ViewProps> => {
28+
* export const ModalServiceShowcase = () => {
3729
*
38-
* const modalID: string = '';
30+
* const modalID = '';
3931
*
4032
* const showModal = () => {
41-
* const component: React.ReactElement<ViewProps> = this.renderModalContentElement();
42-
*
43-
* this.modalID = ModalService.show(component, { allowBackdrop: true, onBackdropPress: this.hideModal });
33+
* const contentElement = this.renderModalContentElement();
34+
* this.modalID = ModalService.show(contentElement, { allowBackdrop: true, onBackdropPress: this.hideModal });
4435
* };
4536
*
4637
* const hideModal = () => {
4738
* ModalService.hide(this.modalID);
4839
* };
4940
*
50-
* const renderModalContentElement = (): React.ReactElement<ViewProps> => {
41+
* const renderModalContentElement = () => {
5142
* return (
52-
* <View>
43+
* <Layout>
5344
* <Text>Hi, I'm modal!</Text>
54-
* </View>
45+
* </Layout>
5546
* );
5647
* };
5748
*
5849
* return (
59-
* <View>
60-
* <Button onPress={this.showModal}>
61-
* SHOW MODAL
62-
* </Button>
63-
* <Button onPress={this.hideModal}>
64-
* HIDE MODAL
65-
* </Button>
66-
* </View>
50+
* <Layout>
51+
* <Button onPress={showModal}>SHOW MODAL</Button>
52+
* <Button onPress={hideModal}>HIDE MODAL</Button>
53+
* </Layout>
6754
* );
6855
* }
6956
* ```
7057
*/
71-
7258
class ModalServiceType {
7359

7460
panel: ModalPresenting | null = null;

0 commit comments

Comments
 (0)