Skip to content

Instantly share code, notes, and snippets.

View kaleem-elahi's full-sized avatar
🌍
Remote Frontend Engineer

Kaleem Elahi Shaikh kaleem-elahi

🌍
Remote Frontend Engineer
View GitHub Profile
@kaleem-elahi
kaleem-elahi / isElementInViewport.js
Last active October 10, 2019 12:30
Check if Element is visible in Viewport
export const isElementInViewport = (el) => {
var rect = el.getBoundingClientRect();
return rect.bottom > 0 &&
rect.right > 0 &&
rect.left < (window.innerWidth || document.documentElement.clientWidth) /* or $(window).width() */ &&
rect.top < (window.innerHeight || document.documentElement.clientHeight) /* or $(window).height() */;
}
@kaleem-elahi
kaleem-elahi / index.html
Created May 15, 2019 08:25
Error Boundaries in V16
<div id="root">
<!-- This div's content will be managed by React. -->
</div>
@kaleem-elahi
kaleem-elahi / Example-RenderByTenant.js
Last active April 25, 2019 18:34
An example of rendering by multi-tenant with component in ReactJs
//RenderByTenant.js
class RenderByTenant extends Component {
render() {
const {
roles,
currentTenant,
} = this.props.accountInfo; // from redux store
return currentTenant === 'tenant1' ? this.props.tenant1(roles) : this.props.tenant2(roles);
}
@kaleem-elahi
kaleem-elahi / RenderByTenant.js
Created April 16, 2019 09:45
Manage multi-tenant by using this file - RenderByTenant. Multitenant + role-based
import {
Component,
} from 'react';
import PropTypes from 'prop-types';
import {
connect,
} from 'react-redux';
class RenderByTenant extends Component {
render() {
@kaleem-elahi
kaleem-elahi / RenderByTenantFunc.js
Last active April 16, 2019 07:27
Function that help in managing multi-tenant conditions, So, RenderByTenantFunc
export const RenderByTenantFunc = (erg, wp) => (tenant === 'WP' ? wp() : erg());
@kaleem-elahi
kaleem-elahi / InputField
Created April 10, 2019 09:11
Redux InputField html
import React from 'react';
import PropTypes from 'prop-types';
import 'react-select/dist/react-select.css';
const InputField = (props) => {
const {
type,
autoComplete,
className,
@kaleem-elahi
kaleem-elahi / Frame.js
Last active April 5, 2024 15:30
WYSIWYG Editor for React apps with redux-form field
import React, { Component } from 'react';
// import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import Linkify from 'react-linkify';
import {
renderToString,
} from 'react-dom/server';
import Parser from 'html-react-parser';
const style =
@kaleem-elahi
kaleem-elahi / sorting job data by latest date
Created February 12, 2019 10:55
To sort Job details date's with Present(Current) employer(company)
let final = [];
const currentCompany = this.props.profile.position_history.filter(d => d.is_current_employer); // current company
// Sorted latest to old job position
const otherSortedComapny = this.props.profile.position_history.sort((a, b) => {
if (a.end_date) {
return new Date(b.end_date) - new Date(a.end_date);
}
return new Date(b.start_date) - new Date(a.start_date);
@kaleem-elahi
kaleem-elahi / sketch-never-ending.md
Created December 2, 2018 07:20 — forked from Bhavdip/sketch-never-ending.md
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@kaleem-elahi
kaleem-elahi / media-query.css
Created November 27, 2018 12:27 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS