Skip to content

Instantly share code, notes, and snippets.

View krystalcampioni's full-sized avatar

Krystal Campioni krystalcampioni

View GitHub Profile
@krystalcampioni
krystalcampioni / conventional-commits.sh
Created January 26, 2024 15:52
Enforcing conventional commit messages
# 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.
@mixin removeDefaultStyles() {
background-color: transparent;
border: none;
margin: 0;
padding: 0;
text-align: inherit;
font-family: inherit;
border-radius: 0;
appearance: none;
}
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(() => {
export interface DataPoint {
key: number | string;
value: number | null;
}
export interface DataSeries {
data: DataPoint[];
color?: Color;
isComparison?: boolean;
name: string;
export function useYScale({
drawableHeight,
integersOnly,
data
}) {
// ...
return { yScale, yTicks }
}
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}), {});
}
export const SPACING_TIGHT = Number(variables.spacingTight);
export const SPACING_EXTRA_TIGHT = Number(variables.spacingExtraTight);
export const SPACING = Number(variables.spacing);
export const SPACING_BASE_TIGHT = Number(variables.spacingBaseTight);
export const SPACING_LOOSE = Number(variables.spacingLoose);
export const BASE_ANIMATION_DURATION = 200;
export const LOAD_ANIMATION_DURATION = 500;
export const BAR_ANIMATION_HEIGHT_BUFFER = 20;
import React from 'react';
import Svg, {
Circle,
Rect
} from 'react-native-svg';
function SomeComponent() {
return (
<Svg viewBox='0 0 100 100'>
<Circle
export function usePrefersReducedMotion() {
const prefersReducedMotion =
typeof window === 'undefined'
? false
: window.matchMedia('(prefers-reduced-motion: reduce)').matches;
return {prefersReducedMotion};
}
import {AccessibilityInfo} from 'react-native';
export function usePrefersReducedMotion() {
AccessibilityInfo.isReduceMotionEnabled()
.then((result) => {
return { prefersReducedMotion: result };
})
.catch((error) => {
return { prefersReducedMotion: error };
});