Skip to content

Instantly share code, notes, and snippets.

View yinkakun's full-sized avatar
🍊
Focusing

Yinka Adedire yinkakun

🍊
Focusing
View GitHub Profile
export interface CircularProgressProps {
progress: number;
size: number;
}
export const CircularProgress = ({ progress, size }: CircularProgressProps) => {
// Calculate the percentage of the size
const xPercentOfSize = (x: number) => (x / 100) * size;
const strokeWidth = xPercentOfSize(8);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
export default function App() {
return (
<div
style={{
height: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "space-around",
}}
>
@yinkakun
yinkakun / react-types.ts
Created September 12, 2023 09:23
react-types.ts
// Type definitions for React 18.2
// Project: https://react.dev/
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
// Microsoft <https://microsoft.com>
// John Reilly <https://github.com/johnnyreilly>
// Benoit Benezech <https://github.com/bbenezech>
// Patricio Zavolinsky <https://github.com/pzavolinsky>
// Eric Anderson <https://github.com/ericanderson>
// Dovydas Navickas <https://github.com/DovydasNavickas>
@yinkakun
yinkakun / is-mobile.ts
Created October 1, 2023 09:26
is mobile?
export function isAndroid(): boolean {
return (
typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent)
);
}
export function isSmallIOS(): boolean {
return (
typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent)
);
/* GLOBALLY */
* {
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
}
*::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
import React from 'react';
type Props = React.ComponentProps<'input'> & {};
export const NumericInput = React.forwardRef<HTMLInputElement, Props>(
({ className, onChange, ...props }, forwardedRef) => {
const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {
const numericValue = event.currentTarget.value.replace(/[^0-9]/g, '');
event.currentTarget.value = numericValue;
if (onChange) {
import { ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
type ButtonProps = React.ComponentProps<'button'>;
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
import { ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
@yinkakun
yinkakun / utils.ts
Created October 20, 2023 14:57
createQueryStrings
type CreateQueryStringsOpts = {
[key: string]: string;
};
export const createQueryStrings = (opts: CreateQueryStringsOpts) => {
const params = new URLSearchParams();
Object.keys(opts).forEach((key) => params.set(key, opts[key]));
return params.toString();
};