Skip to content

Commit 61571a8

Browse files
authored
Merge pull request #17 from barajs/build/bara-react-icons
Build/bara react icons
2 parents 06bcbe4 + a8a2daa commit 61571a8

File tree

16 files changed

+495
-57
lines changed

16 files changed

+495
-57
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
declare module 'react-native-vector-icons' {
2+
export * from 'react-native-vector-icons'
3+
}
4+
5+
declare module 'react-native-vector-icons/dist/MaterialIcons' {}
6+
7+
declare module 'react-native-vector-icons/dist/Octicons' {}
8+
9+
declare module 'react-native-vector-icons/Fonts/MaterialIcons.ttf' {}
10+
11+
declare module 'react-native-vector-icons/Fonts/Octicons.ttf' {}

@types/react-native-web/index.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
declare module 'react-native-web' {
2+
export * from 'react-native'
3+
}
4+
5+
namespace JSX {
6+
import * as ReactNative from 'react-native'
7+
interface IntrinsicAttributes extends React.Attributes {
8+
accessibilityRole?:
9+
| ReactNative.AccessibilityRole
10+
| 'article' // article
11+
| 'banner' // header
12+
| 'button' // button
13+
| 'complementary' // aside
14+
| 'contentinfo' // footer
15+
| 'form' // form
16+
| 'heading' // h1, h2, h3, ...
17+
| 'label' // label
18+
| 'link' // a
19+
| 'list' // ul
20+
| 'listitem' // li
21+
| 'main' // main
22+
| 'navigation' // nav
23+
| 'region' // section
24+
className?: string
25+
tabIndex?: number
26+
}
27+
}

@types/react-native/index.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export * from 'react-native'
2+
3+
declare module 'react-native' {
4+
export namespace Animated {
5+
export type AnimatedComponent<
6+
T extends React.ComponentClass
7+
> = (T extends React.ComponentClass<infer P>
8+
? React.ComponentClass<P>
9+
: React.ComponentClass) & {
10+
getNode(): InstanceType<T>
11+
}
12+
13+
export function createAnimatedComponent<
14+
T extends React.ComponentClass<any, any>
15+
>(component: T): AnimatedComponent<T>
16+
17+
export const View: AnimatedComponent<typeof View>
18+
export const Image: AnimatedComponent<typeof Image>
19+
export const Text: AnimatedComponent<typeof Text>
20+
export const ScrollView: AnimatedComponent<typeof ScrollView>
21+
}
22+
}

craco.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const appDirectory = fs.realpathSync(process.cwd())
5+
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)
6+
const appIncludes = [resolveApp('src')]
7+
module.exports = {
8+
babel: {
9+
plugins: ['@babel/plugin-proposal-class-properties'],
10+
},
11+
webpack: {
12+
configure: (config, { env, paths }) => {
13+
config.module.rules[0].include = appIncludes
14+
config.module.rules[1] = null
15+
config.module.rules[2].oneOf[1].include = appIncludes
16+
config.module.rules[2].oneOf[1].options.plugins = [
17+
require.resolve('babel-plugin-react-native-web'),
18+
].concat(config.module.rules[2].oneOf[1].options.plugins)
19+
20+
config.module.rules = config.module.rules.filter(Boolean) // Clear null rules
21+
22+
config.plugins[9].tsconfig = resolveApp('tsconfig.web.json')
23+
24+
return config
25+
},
26+
},
27+
}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import { name as appName } from './app.json'
99
import registerBaraFeatures from './src/bara'
1010

1111
register(() => {
12-
useReactApp({ name: appName, isNative: true, App })
1312
registerBaraFeatures()
13+
useReactApp({ name: appName, isNative: true, App })
1414
})

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"homepage": "https://example.barajs.dev",
77
"scripts": {
88
"dev": "run-p start:web start:mobile start:desktop",
9-
"start:web": "react-scripts start",
9+
"start:web": "craco start --verbose",
1010
"start:mobile": "node node_modules/react-native/local-cli/cli.js start",
1111
"start:desktop": "cross-env BROWSER=none concurrently \"yarn compile:desktop -w\" \"wait-on http://localhost:3000 && yarn watch:desktop\"",
1212
"watch:desktop": "nodemon --watch dist --exec \"electron ./dist\"",
1313
"do:web": "concurrently --kill-others \"yarn compile -w\" \"yarn start:web\"",
1414
"do:desktop": "cross-env BROWSER=none concurrently \"yarn dev:web\" \"yarn compile:desktop -w\" \"wait-on http://localhost:3000 && yarn watch:desktop\"",
1515
"compile": "run-s compile:tsc compile:web compile:desktop",
1616
"compile:tsc": "tsc -b",
17-
"compile:web": "react-scripts build",
17+
"compile:web": "craco build",
1818
"compile:desktop": "tsc -b ./tsconfig.desktop.json",
1919
"build:desktop": "run-s clean compile:desktop compile:web build:desktop:cpres build:desktop:electron",
2020
"build:desktop:cpres": "shx cp -R build dist/web",
@@ -26,18 +26,24 @@
2626
},
2727
"dependencies": {
2828
"bara": "2.3.1",
29-
"bara-react": "2.0.0",
29+
"bara-react": "2.0.1",
30+
"bara-react-icons": "1.1.0",
3031
"electron-store": "3.2.0",
3132
"electron-updater": "4.0.6",
3233
"jsonfile": "5.0.0",
3334
"mkdirp": "0.5.1",
3435
"react": "16.8.6",
36+
"react-app-polyfill": "0.2.2",
3537
"react-dom": "16.8.6",
36-
"react-native": "0.59.4"
38+
"react-native": "0.59.4",
39+
"react-native-vector-icons": "6.4.2"
3740
},
3841
"devDependencies": {
3942
"@babel/core": "7.4.3",
43+
"@babel/plugin-proposal-class-properties": "7.4.0",
44+
"@babel/polyfill": "7.4.3",
4045
"@babel/runtime": "7.4.3",
46+
"@craco/craco": "4.1.0",
4147
"@types/electron-devtools-installer": "2.2.0",
4248
"@types/electron-store": "1.3.1",
4349
"@types/jest": "24.0.11",
@@ -46,7 +52,9 @@
4652
"@types/node": "11.13.4",
4753
"@types/react": "16.8.13",
4854
"@types/react-native": "0.57.45",
55+
"@types/react-native-vector-icons": "6.4.0",
4956
"@types/react-test-renderer": "16.8.1",
57+
"babel-plugin-react-native-web": "0.11.2",
5058
"concurrently": "4.1.0",
5159
"cross-env": "5.2.0",
5260
"electron": "4.1.4",

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { BaraProvider, TouchableOpacity } from 'bara-react'
1212
import React, { Component } from 'react'
1313
import { Platform, StyleSheet, Text, View } from 'react-native'
1414

15+
import { Octicons as Icon } from 'bara-react-icons/es'
16+
1517
import { Sidebar } from './features/sidebar'
1618

1719
const instructions = Platform.select({
@@ -27,6 +29,7 @@ export default class App extends Component<Props> {
2729
return (
2830
<BaraProvider>
2931
<View style={styles.container}>
32+
<Icon name="chevron-right" size={30} />
3033
<Text style={styles.welcome}>Welcome to Bara React Native!</Text>
3134
<Text style={styles.instructions}>To get started, edit App.tsx</Text>
3235
<Text style={styles.instructions}>{instructions}</Text>

src/bara.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { useInitStream } from 'bara'
12
import { useTouchableOpacityStream } from 'bara-react'
23
import { useWelcome } from './features/welcome'
34

45
export const useStreams = () => {
6+
useInitStream()
57
useTouchableOpacityStream()
68
}
79

src/index.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
::-webkit-scrollbar {
2+
width: 1px;
3+
height: 1px;
4+
background-color: transparent;
5+
}
6+
7+
::-webkit-scrollbar-thumb
8+
{
9+
background-color: transparent;
10+
}
11+
12+
*:focus {
13+
outline-color: #49d3b4;
14+
}
15+
16+
*[tabIndex^="-1"]:focus {
17+
outline: none;
18+
}
19+
20+
html, body, #root, #root > div {
21+
width: 100%;
22+
height: 100%;
23+
overflow: hidden;
24+
}
25+
26+
html {
27+
scroll-behavior: smooth;
28+
}
29+
30+
body {
31+
background-color: #292C33;
32+
text-rendering: optimizeLegibility;
33+
-webkit-font-smoothing: antialiased;
34+
-moz-osx-font-smoothing: grayscale;
35+
}
36+
37+
a:hover, a:hover > *:not([class*='touchAction']) {
38+
text-decoration: underline;
39+
}
40+
41+
input:focus {
42+
outline: none !important;
43+
}
44+
45+
/* https://github.com/necolas/react-native-web/issues/1299 */
46+
.pagingEnabledFix > div > div > div {
47+
height: 100%;
48+
}
49+

src/index.js renamed to src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
* @format
33
*/
44

5+
// Security precaution
6+
;(window as any).eval = global.eval = (payload: string) => {
7+
const error = new Error(`This app does not allow window.eval().`)
8+
Object.assign(error, { payload })
9+
10+
throw error
11+
}
12+
13+
import '@babel/polyfill'
14+
import 'react-app-polyfill/ie9'
15+
516
import { register } from 'bara'
617
import { useReactApp } from 'bara-react'
718
import App from './App'
819
import registerBaraFeatures from './bara'
920

1021
register(() => {
11-
useReactApp({ name: 'bara-demo', isNative: false, App })
1222
registerBaraFeatures()
23+
useReactApp({ name: 'bara-demo', isNative: false, App })
1324
})

0 commit comments

Comments
 (0)