Skip to content

Commit

Permalink
chore: icons works
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibazavr committed Apr 9, 2022
1 parent 23ccb56 commit e73bea8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
23 changes: 19 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
/**
* @format
*/

import {AppRegistry} from 'react-native';
import Index from './src/index';
import appName from './app.json';

// Generate required css
import iconFont from 'react-native-vector-icons/Fonts/FontAwesome.ttf';
const iconFontStyles = `@font-face {
src: url(${iconFont});
font-family: FontAwesome;
}`;

AppRegistry.registerComponent(appName.name, () => Index);

// Run application on web
if (typeof document !== 'undefined') {
// Create stylesheet
const style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = iconFontStyles;
} else {
style.appendChild(document.createTextNode(iconFontStyles));
}

// Inject stylesheet
document.head.appendChild(style);

AppRegistry.runApplication(appName.name, {
rootTag: document.getElementById('root'),
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@typescript-eslint/parser": "^5.17.0",
"babel-loader": "^8.2.4",
"eslint": "^7.32.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.67.0",
Expand Down
2 changes: 1 addition & 1 deletion src/ThemeSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ThemeSwitcher = () => {
}));
};

return <Icon name={'copy'} type={'font-awesome'} onPress={toggleTheme} />;
return <Icon name="paper-plane" type="font-awesome" onPress={toggleTheme} />;
};

export default ThemeSwitcher;
8 changes: 8 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ module.exports = {
},
{enforce: 'pre', test: /\.js$/, loader: 'source-map-loader'},
imageLoaderConfiguration,
{
test: /\.ttf$/,
loader: 'url-loader', // or directly file-loader
include: path.resolve(
__dirname,
'node_modules/react-native-vector-icons',
),
},
],
},
plugins: [
Expand Down

0 comments on commit e73bea8

Please sign in to comment.