Skip to content

Instantly share code, notes, and snippets.

View Verthon's full-sized avatar
🐢

Krzysztof Sordyl Verthon

🐢
View GitHub Profile
let parent = document.querySelector(".your-position-sticky-class").parentElement;
while (parent) {
const hasOverflow = getComputedStyle(parent).overflow;
if (hasOverflow !== "visible") {
console.log(hasOverflow, parent);
parent.style.overflow = "auto";
}
parent = parent.parentElement;
}
export const InputWithCounter = ({ maxLength, control, placeholder, name, rules }: Props) => {
const [counter, setCounter] = useState(0);
const handleInputCounter = (e: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => {
const value = e.target.value.length;
setCounter(value);
};
return (
<Controller
render={() => (
@Verthon
Verthon / home.test.tsx
Last active August 20, 2020 06:29
home test
/* eslint-disable @typescript-eslint/camelcase */
import React from 'react';
import { ThemeProvider } from 'styled-components';
import axiosMock from 'axios';
import { render, waitForElement } from 'tests';
import { theme } from 'assets/theme/theme';
import { Home } from './Home';
@Verthon
Verthon / doFetch.js
Last active June 10, 2020 13:09
Async Await Fetch API 2 examples
// Without try catch
const doFetch = async (path) => {
const res = await fetch('https://api.github.com/users/' + path)
if (res.ok) {
return res.json()
}
throw await res.json()
}
// With try catch
@Verthon
Verthon / component.ts
Created April 7, 2020 09:21
Function to navigate to the activity page wit EditMode
goToActivity(action, data, report, preview) {
let pageUrl = action.toLowerCase();
const routeParams = {
date: moment().format(),
href: this.getCurrentUrlWithoutTabs(this.router.url),
report: data,
editMode: true,
reportData: report,
previewMode: preview
}
@Verthon
Verthon / app-routing.ts
Created April 7, 2020 09:19
App routing
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { AuthGuard } from './guards/auth.guard';
import { DataResolverService } from './resolver/data-resolver.service';
const routes: Routes = [
{
path: '',
redirectTo: '/tabs',
pathMatch: 'full'
@Verthon
Verthon / activity-page.ts
Created April 7, 2020 09:18
Page doesn't reload problem Ionic4 Angular
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { NavController } from '@ionic/angular';
import * as moment from 'moment';
import {
textAreaLimitCharsLarge,
selectAllChildrenText,
unselectAllChildrenText,
TagColorsEnum
} from '../../../constants';
@Verthon
Verthon / auth.ts
Last active April 3, 2020 19:10
Ionic4 React Firestore problem with setting protected route for the '/account'
// useAuth.ts
export default () => {
const dispatch = useDispatch()
const currentUser = useSelector(selectCurrentUser)
console.log('current User in useAuth hook', currentUser)
useEffect(() => {
const setUser = (user: any) => {
if(user) {
dispatch(login({ uid: user.uid, email: user.email }))
import React from 'react'
import styled from 'styled-components'
import dayjs from 'dayjs'
import { Link } from 'react-router-dom'
import { useDispatch } from 'react-redux'
import { EventModel } from '../interfaces'
import { showEventDetails } from '../reducers/event'
const EventItem = (props: any) => {