This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Action Creator | |
type ActionCreator<P> = <A extends keyof P, TParams extends any[]>( | |
type: A, | |
prepare?: P[A] extends void ? undefined : (...args: TParams) => P[A], | |
) => ( | |
...args: P[A] extends void ? [] : TParams extends undefined[] ? [payload: P[A]] : TParams | |
) => Action<A, P> | |
/** | |
* Function return action create helper that based on actions payloads interface. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { merge as dotPropMerge, set as setPropMerge } from 'dot-prop-immutable' | |
import { CaseReducer, PayloadAction } from '@reduxjs/toolkit' | |
type PropsNames<T> = Exclude<keyof T, symbol> | |
type DotPrefix<T extends string> = T extends '' ? '' : `.${T}` | |
type RecursivePropsNames<T> = { | |
[K in PropsNames<T>]: `${K}${DotPrefix<DotNestedKeys<T[K]>>}` | `${K}` | |
}[PropsNames<T>] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ClassObject { | |
[className: string]: boolean | undefined | |
} | |
const addClass = ( | |
collection: string, | |
className?: string, | |
statement: boolean = false | |
): string => { | |
if (className === undefined || className === '' || !statement) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import cx from 'helpers/cx' | |
import s from './style.module.css' | |
interface DiceProps { | |
number: number | |
} | |
const Dice: React.FC<DiceProps> = ({ number }) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import { MODAL_ID } from 'core' | |
import cx from 'helpers/cx' | |
import Button from 'components/Button/Button' | |
import s from './style.module.css' | |
interface ModalProps { | |
title?: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Nullable<T, NullKeys = false> = NullKeys extends true ? { [key in keyof T]: null | T[key] } : T | null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from 'react' | |
import { render } from 'lit-html' | |
export const RenderLit = ({ html }) => { | |
const container = useRef(null) | |
useEffect(() => { | |
const element = container.current | |
if (element) { |