-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add live code playground in uilib docs (#3254)
* Add live code playground in uilib docs * Update live code example
- Loading branch information
Showing
6 changed files
with
9,264 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
module.exports = ({siteDir}, options) => { | ||
const baseProjectSource = [ | ||
path.resolve(siteDir, 'src'), | ||
path.resolve(siteDir, 'node_modules/react-native-web'), | ||
path.resolve(siteDir, 'node_modules/react-native-ui-lib'), | ||
// // just for not getting warnings | ||
path.resolve(siteDir, 'node_modules/react-native-shimmer-placeholder'), | ||
path.resolve(siteDir, 'node_modules/react-native-linear-gradient') | ||
// // end just for not getting warnings | ||
// path.resolve(siteDir, 'node_modules/react-native-haptic-feedback'), | ||
// path.resolve(siteDir, 'node_modules/react-native-animatable'), | ||
// path.resolve(siteDir, 'node_modules/react-native-reanimated'), | ||
// path.resolve(siteDir, 'node_modules/react-native-svg'), | ||
// path.resolve(siteDir, 'node_modules/react-native-svg-transformer'), | ||
// path.resolve(siteDir, 'node_modules/@react-native-community/netinfo'), | ||
// path.resolve(siteDir, 'node_modules/@react-native-community/datetimepicker'), | ||
// path.resolve(siteDir, 'node_modules/react-native-color'), | ||
|
||
// path.resolve(siteDir, 'node_modules/postcss'), | ||
// path.resolve(siteDir, 'node_modules/postcss-js') | ||
]; | ||
|
||
const useBabelForRN = { | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: false, | ||
// The 'react-native' preset is recommended to match React Native's packager | ||
presets: ['module:metro-react-native-babel-preset'], | ||
plugins: ['react-native-web', 'react-native-reanimated/plugin'] | ||
} | ||
}; | ||
|
||
const babelLoaderAppConfiguration = { | ||
test: /\.(js|jsx|ts|tsx)$/, | ||
include: baseProjectSource, | ||
use: useBabelForRN | ||
}; | ||
|
||
return { | ||
name: 'uilib-plugin', | ||
configureWebpack(config, isServer, utils) { | ||
return { | ||
mergeStrategy: { | ||
'resolve.extensions': 'prepend' | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
process: {env: {}}, | ||
__DEV__: 'false', | ||
setImmediate: () => {} | ||
}) | ||
], | ||
module: { | ||
rules: [babelLoaderAppConfiguration] | ||
}, | ||
resolve: { | ||
alias: { | ||
'react-native$': 'react-native-web' | ||
}, | ||
extensions: ['.web.js'] | ||
} | ||
}; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import Text from 'react-native-ui-lib/text'; | ||
import View from 'react-native-ui-lib/view'; | ||
import Button from 'react-native-ui-lib/button'; | ||
import TextField from 'react-native-ui-lib/textField'; | ||
import SegmentedControl from 'react-native-ui-lib/segmentedControl'; | ||
|
||
// Add react-live imports you need here | ||
const ReactLiveScope = { | ||
React, | ||
...React, | ||
/* uilib components */ | ||
View, | ||
Text, | ||
Button, | ||
TextField, | ||
SegmentedControl | ||
}; | ||
|
||
export default ReactLiveScope; |
Oops, something went wrong.