Skip to content

Instantly share code, notes, and snippets.

View mmazzarolo's full-sized avatar
🐌
Busy — I'll be slow to respond!

Matteo Mazzarolo mmazzarolo

🐌
Busy — I'll be slow to respond!
View GitHub Profile
@mmazzarolo
mmazzarolo / Checkbox.js
Last active March 30, 2016 13:47
Checkbox.js
//
// MDL-style Checkbox component.
//
// - @see [MDL Checkbox](http://www.getmdl.io/components/index.html#toggles-section/checkbox)
// - [Props](#props)
// - [Defaults](#defaults)
// - [Built-in builders](#builders)
//
// Created by ywu on 15/12/13.
//
@mmazzarolo
mmazzarolo / configureStore.js
Created April 18, 2016 11:53
Cleaning up the messy seamless-immutable functions in redux-logger
import createLogger from 'redux-logger'
// Seamless-Immutable logger cleanup
const stateTransformer = (state) => {
if (typeof state === 'object' && state !== null && Object.keys(state).length) {
let newState = {}
for (var i of Object.keys(state)) {
if (state[i].asMutable) newState[i] = state[i].asMutable({ deep: true })
else newState[i] = state[i]
}
import React, { PropTypes } from 'react'
import { Platform, View, TouchableNativeFeedback, TouchableOpacity } from 'react-native'
const IS_ANDROID = Platform.OS === 'android'
const IS_RIPPLE_EFFECT_SUPPORTED = Platform.Version >= 21 && IS_ANDROID
const TouchableView = ({ isRippleEnabled, children, style, ...props }) => {
if (IS_RIPPLE_EFFECT_SUPPORTED && !isRippleEnabled) {
const background = TouchableNativeFeedback.Ripple(null, false)
return (
/**
* @providesModule LoadingSpinner
*/
import React, { ActivityIndicatorIOS, Platform, ProgressBarAndroid, StyleSheet } from 'react-native'
const IS_ANDROID = Platform.OS === 'android'
export default ({ ...props }) => IS_ANDROID
? <ProgressBarAndroid style={styles.spinner} {...props} />
: <ActivityIndicatorIOS style={styles.spinner} {...props} />
@mmazzarolo
mmazzarolo / 0info.js
Last active August 11, 2016 00:05
NavigationExperimental setup
// Redux navigations tore
{
key: '1',
index: 0,
children: [{ key: 'museumList', title: 'I musei' }],
isDrawerOpen: false
}
// Navigation structure
@mmazzarolo
mmazzarolo / redux_naming_example.js
Created September 6, 2016 21:44
Redux naming example
import { find, findIndex, pullAt } from 'lodash'
import { actionTypes as appActionTypes } from 'reducers/appReducer'
export const actionTypes = {
CREATE_MENU_ENTRY_REQUEST: 'MENU/CREATE_MENU_ENTRY_REQUEST',
CREATE_MENU_ENTRY_SUCCESS: 'MENU/CREATE_MENU_ENTRY_SUCCESS',
CREATE_MENU_ENTRY_FAILURE: 'MENU/CREATE_MENU_ENTRY_FAILURE',
UPDATE_MENU_ENTRY_REQUEST: 'MENU/UPDATE_MENU_ENTRY_REQUEST',
UPDATE_MENU_ENTRY_SUCCESS: 'MENU/UPDATE_MENU_ENTRY_SUCCESS',
UPDATE_MENU_ENTRY_FAILURE: 'MENU/UPDATE_MENU_ENTRY_FAILURE',
@mmazzarolo
mmazzarolo / CustomDatePickerIOS.js
Created September 13, 2016 20:11
IOS ActionSheet DatePicker
import React, { Component, PropTypes } from 'react'
import { DatePickerIOS, Text, TouchableOpacity, View } from 'react-native'
import { noop } from 'lodash'
import CustomModal from '../CustomModal'
import styles from './CustomDatePickerIOS.style'
export default class CustomDatePickerIOS extends Component {
static propTypes = {
visible: PropTypes.bool,
@mmazzarolo
mmazzarolo / CustomListItem.js
Created October 5, 2016 07:17
Container and component
import React, { PropTypes } from 'react'
import styles from './index.style.css'
const CustomListItem = ({ onClick, leftContent, rightContent, ...props }) => {
return (
<div className={styles.container} onClick={onClick} {...props}>
<div className={styles.left}>{leftContent}</div>
<div className={styles.right}>{rightContent}</div>
</div>
@mmazzarolo
mmazzarolo / twilio_with_ui.js
Last active October 11, 2017 20:10
WebTask - twilio_with_ui
'use latest';
/**
* A simple tasks that renders a page where an user can input a phone number and its recipient to send an SMS message using the Twilio APis.
* Please keep in mind that the following environment variables are required:
* TWILIO_SID: The SID token of your Twilio account
* TWILIO_AUTH_TOKEN: The auth token of your Twilio account
* TWILIO_FROM_NUMBER: The sender of the SMS (created in your Twilio account)
*/