Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Android style default #1419

Closed
piu130 opened this issue Sep 11, 2018 · 3 comments
Closed

Make Android style default #1419

piu130 opened this issue Sep 11, 2018 · 3 comments
Milestone

Comments

@piu130
Copy link
Contributor

piu130 commented Sep 11, 2018

Is your feature request related to a problem? Please Describe.
Currently there is no consistent style applied to components for react-native-web (Platform web), electron (Platform desktop), etc.

Describe the solution you'd like
We should set android style as default for all platforms.

Describe alternatives you've considered
We could set ios as default or create a third default style.

Additional context
Some examples:

@iRoachie
Copy link
Collaborator

Sounds like a great idea, Can you make a PR to do this?

@iRoachie
Copy link
Collaborator

Also could you outline the steps you did to get react-native-web working? Would love to put it in the docs.

@piu130
Copy link
Contributor Author

piu130 commented Sep 11, 2018

Created a PR here.

I use neutrino for the setup. Just create a new project as described here and select react.

Then add react-native-web, babel-preset-react-native, (react-art - is optional but for my setup it fails without it), react-native-elements and react-native-vector-icons with your package manager.

Currently you must add .web.js and .web.jsx to webpacks resolve extensions (see .neutrinorc.js below). But you can remove it with the next neutrino release (fixed here).

Then you must add the react-native modules to webpacks include (see .neutrinorc.js below), because webpack does not transpile node_modules (webpack assumes they are already transpiled).

My .neutrinorc.js looks like this:

const { join } = require('path');

const nodeModulesDir = join(__dirname, 'node_modules')

module.exports = {
  use: [
    [
      '@neutrinojs/react',
      {
        html: {
          title: 'test'
        }
      }
    ],
    (neutrino) => {
      neutrino.config.resolve.extensions.prepend('.web.jsx').prepend('.web.js')
      neutrino.config.module
        .rule('compile')
          .include
            // Add other modules that needs to be compiled by babel
            .add(join(nodeModulesDir, 'react-native-elements'))
            .add(join(nodeModulesDir, 'react-native-vector-icons'))
            .add(join(nodeModulesDir, 'react-native-touchable-scale'))
            .end();
    }
  ]
};

For react-native-vector-icons to work you should add (described here):

const style = document.createElement('style')

const materialIconsFont = require('react-native-vector-icons/Fonts/MaterialIcons.ttf')
const materialIconsFontStyles = `@font-face {
  src: url(${materialIconsFont});
  font-family: 'MaterialIcons';
}`
style.type = 'text/css'
style.appendChild(document.createTextNode(materialIconsFontStyles))

document.head.appendChild(style)

@iRoachie iRoachie added the 📥 PR Submitted Pull request has been submitted to resolve this issue label Sep 12, 2018
@iRoachie iRoachie mentioned this issue Sep 14, 2018
@iRoachie iRoachie added this to the 1.0.0 milestone Oct 8, 2018
@iRoachie iRoachie added ✅ Fixed - Next Release and removed 📥 PR Submitted Pull request has been submitted to resolve this issue labels Dec 6, 2018
@iRoachie iRoachie closed this as completed Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants