Skip to content

Instantly share code, notes, and snippets.

View majirosstefan's full-sized avatar
🏠
Working from home

Stefan Majiros majirosstefan

🏠
Working from home
View GitHub Profile
@majirosstefan
majirosstefan / tree-like-navigation
Created January 24, 2020 09:31
React Navigation Example
import {
createStackNavigator,
createBottomTabNavigator
} from "react-navigation";
const AppBottomTab = createBottomTabNavigator({
firstTab: {
screen: Home,
navigationOptions: {
title: "Home"
@majirosstefan
majirosstefan / Storybook Init Commands
Last active March 29, 2020 12:38
For React and React Native
// in React setup
npx -p @storybook/cli sb init --type react
// in React Native setup
npx -p @storybook/cli sb init --use-npm --type react_native
@majirosstefan
majirosstefan / Storybook Commands inside package.json
Last active March 23, 2020 11:53
for React and React Native
// React setup
"scripts": {
"build-storybook": "build-storybook -s public",
"storybook": "start-storybook -p 9009 -s public", etc..
}
// React Native setup
"scripts": {
"storybook": "start-storybook -p 6006", etc..
}
@majirosstefan
majirosstefan / main.js. - for react-native
Last active March 23, 2020 18:54
The configuration file for Storybook
module.exports = {
stories: ['../stories/**/*.stories.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
};
@majirosstefan
majirosstefan / Imports Replace Example
Created March 24, 2020 18:25
React-Native Components To React-Native-Web Components
// your component written for react-native - how the metro bundler see it
import {View, Text} from "react-native";
const MyComponent = () => {
return(
<View>
<Text>Hello</Text>
</View>
)
module.exports = {
stories: ['../storybook/stories/index.js'],
webpackFinal: async config => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
'react-native$': 'react-native-web',
// make sure we're rendering output using **web** Storybook not react-native
'@storybook/react-native': '@storybook/react',
// plugin-level react-native-web extensions
@majirosstefan
majirosstefan / package.json
Created March 24, 2020 19:01
for the Static Storybook Build With React Native
{
"name": "example",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
@majirosstefan
majirosstefan / React Native SVG example
Created March 24, 2020 19:26
metro.config.js for SVGs support
const {getDefaultConfig} = require('metro-config');
module.exports = (async () => {
const {
resolver: {sourceExts, assetExts},
} = await getDefaultConfig();
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
@majirosstefan
majirosstefan / Search.png
Created March 29, 2020 20:09
Quick and Dirty Icon Example
<svg width="51px" height="53px" viewBox="0 0 51 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter x="-48.6%" y="-44.7%" width="191.9%" height="189.5%" filterUnits="objectBoundingBox" id="filter-1">
<feOffset dx="0" dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
@majirosstefan
majirosstefan / SVG support inside main.js
Created March 29, 2020 20:22
in Storybook for React (web version)
// handle svg support
const fileLoaderRule = config.module.rules.find(rule =>
rule.test.test('.svg'),
);
fileLoaderRule.exclude = /\.svg$/;
config.module.rules.push({
test: /\.svg$/,
loader: 'svg-react-loader',
});