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
# Enforcing Conventional Commits with a Git Hook | |
# This gist provides instructions on how to set up a `commit-msg` | |
# Git hook to enforce [conventional commits](http://www.conventionalcommits.org) in your project. | |
# The `commit-msg` script checks the commit message against a regex pattern to ensure | |
# it follows the conventional commit format. | |
# The `text-styles.sh` script is used to colorize the output of the `commit-msg` script for better readability. | |
# ----- 1. Copy the hook files to .git/hooks ----- | |
# You need to copy the files from <root>/hooks into <root>/.git/hooks when initializing your project. |
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
@mixin removeDefaultStyles() { | |
background-color: transparent; | |
border: none; | |
margin: 0; | |
padding: 0; | |
text-align: inherit; | |
font-family: inherit; | |
border-radius: 0; | |
appearance: none; | |
} |
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
function useThrottle<T>(value: T, interval = 500): T { | |
const [throttledValue, setThrottledValue] = useState<T>(value); | |
const lastExecuted = useRef<number>(Date.now()); | |
useEffect(() => { | |
if (Date.now() >= lastExecuted.current + interval) { | |
lastExecuted.current = Date.now(); | |
setThrottledValue(value); | |
} else { | |
const timerId = setTimeout(() => { |
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
export interface DataPoint { | |
key: number | string; | |
value: number | null; | |
} | |
export interface DataSeries { | |
data: DataPoint[]; | |
color?: Color; | |
isComparison?: boolean; | |
name: 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
export function useYScale({ | |
drawableHeight, | |
integersOnly, | |
data | |
}) { | |
// ... | |
return { yScale, yTicks } | |
} | |
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
export function getBarId(id: string, groupIndex: number, seriesIndex: number) { | |
return `${id}-series-${groupIndex}-${seriesIndex}`; | |
} | |
export function removeFalsyValues(object) { | |
return Object.entries(object) | |
.filter(([_, value]) => value != null) | |
.reduce((acc, [key, value]) => ({...acc, [key]: value}), {}); | |
} |
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 Svg, { | |
Circle, | |
Rect | |
} from 'react-native-svg'; | |
function SomeComponent() { | |
return ( | |
<Svg viewBox='0 0 100 100'> | |
<Circle |
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
export function usePrefersReducedMotion() { | |
const prefersReducedMotion = | |
typeof window === 'undefined' | |
? false | |
: window.matchMedia('(prefers-reduced-motion: reduce)').matches; | |
return {prefersReducedMotion}; | |
} |
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 {AccessibilityInfo} from 'react-native'; | |
export function usePrefersReducedMotion() { | |
AccessibilityInfo.isReduceMotionEnabled() | |
.then((result) => { | |
return { prefersReducedMotion: result }; | |
}) | |
.catch((error) => { | |
return { prefersReducedMotion: error }; | |
}); |
NewerOlder