Skip to content

Instantly share code, notes, and snippets.

View igorcaldeira's full-sized avatar
🔥

Igor Caldeira igorcaldeira

🔥
View GitHub Profile
@igorcaldeira
igorcaldeira / maskContent.js
Created May 10, 2024 00:53
JS Function to format a string based on mask (with imask)
// how to use :)
// mask: "(00) 0 0000-0000"
// input: "31999699601"
// result: "(31) 9 9969-9606"
export const maskContent = (mask, input) => {
const m = IMask.createMask({
mask,
});
@igorcaldeira
igorcaldeira / react
Created June 4, 2021 14:47
Hide extra text with js+react+resizeobserver
const isElement = (obj) => {
try {
return obj instanceof HTMLElement;
} catch (e) {
return (
typeof obj === "object" &&
obj.nodeType === 1 &&
typeof obj.style === "object" &&
typeof obj.ownerDocument === "object"
@igorcaldeira
igorcaldeira / MessageHandler.js
Last active April 2, 2019 23:06
The relevant parts of a section of code using reactjs that shows part of a message handler component. This component handle various types of messages that appears fixed and above the main menu of a system. It has some rules like show the message only for 3 seconds each and group messages with the same content. Hope you like it!
import React from 'react'
import { translate } from 'react-i18next'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { simpleId } from 'utils/utility'
import * as actions from 'store/messages/messages.useCases'
import './MessageHandler.scss'
import { ReactComponent as IcCheck } from 'assets/icons/message/check.svg'