Skip to content

Instantly share code, notes, and snippets.

@erick2014
erick2014 / media-query.css
Created Oct 29, 2018 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
View media-query.css
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@erick2014
erick2014 / countDuplicatedElements.js
Created Jun 17, 2018
Count duplicated elements using Array.prototype.reduce
View countDuplicatedElements.js
var arr = ['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a'];
return arr.reduce(function(acc, cur) {
acc[cur] = (acc[cur] || 0) + 1;
return acc;
},{});
// prints { a: 3, b: 2, c: 2, d: 2, e: 2, f: 1, g: 1, h: 3 }
@erick2014
erick2014 / ConsumerComp.js
Last active Jun 3, 2018
React Context api Consumer implementation
View ConsumerComp.js
// Session Actions
export const setSessionInfo = data => {
return {
payload: data,
type: SESSION_SET_USER_INFO
}
}
// Login Comp
onClickLoginBtn = dispatch => {
@erick2014
erick2014 / Provider.js
Last active Jun 3, 2018
React Context Api - Provider implementation
View Provider.js
import { SESSION_SET_USER_INFO } from '../constants'
const sessionData = {
userName:'',
userId
}
const orders = {
orders: false
}
@erick2014
erick2014 / Hoc.js
Last active Apr 20, 2018
HOC in react, simple demo
View Hoc.js
/***define the Home component here***/
import React, { Component } from 'react'
class Home extends Component {
componentDidMount () {
// dispatch action to fetch users
this.props.fetchUsers()
}
View clientThubmnailController.js
class ClientThumbnailController {
constructor(ClientFactory, $mdDialog, $state) {
"ngInject";
this.ClientFactory = ClientFactory;
this.sortOptions = {
"Sort by": '',
"name": 'data.commercialName',
"country": 'data.country.label',
}
View clientThubmnailSpec.js
import clientThumbnailModule from './clientThumbnail'
import clientThumbnailController from './clientThumbnail.controller';
import clientThumbnailComponent from './clientThumbnail.component';
import clientThumbnailTemplate from './clientThumbnail.html';
describe('clientThumbnail', () => {
let $rootScope, $q, makeController;
beforeEach(window.module(clientThumbnailModule));
View appNavigations.js
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
/*Navigation stuff*/
import { addNavigationHelpers, StackNavigator } from 'react-navigation';
/*Custom components*/
import Login from '../components/Login/Login';
import WeeksPage from '../components/WeeksPage/WeeksPage';
You can’t perform that action at this time.