Skip to content

Instantly share code, notes, and snippets.

View vicasas's full-sized avatar
😎
Writing the future

Víctor Casas vicasas

😎
Writing the future
View GitHub Profile
@vicasas
vicasas / utils.ts
Last active May 21, 2024 19:26
Utilities to JavaScript and TypeScript
/**
* Returns the origin URL (protocol, hostname, and port) of the current location.
*
* @returns {string} The origin URL.
*/
export function getLocationOrigin() {
const { protocol, hostname, port } = window.location;
return `${protocol}//${hostname}${port ? ':' + port : ''}`;
}
@vicasas
vicasas / demo-todo-app.spec.ts
Created April 8, 2023 13:03
Test example for Playwright
import { test, expect, type Page } from '@playwright/test'
test.beforeEach(async ({ page }) => {
await page.goto('https://demo.playwright.dev/todomvc')
})
const TODO_ITEMS = [
'buy some cheese',
'feed the cat',
'book a doctors appointment',
@vicasas
vicasas / Counterdown.tsx
Created May 17, 2022 00:57
How to do a countdown
import { useEffect, useState } from 'react'
import Head from 'next/head'
import { Box, Typography } from '@mui/material'
const getReturnValues = (countDown: number) => {
const days = Math.floor(countDown / (1000 * 60 * 60 * 24))
const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60))
const seconds = Math.floor((countDown % (1000 * 60)) / 1000)
@vicasas
vicasas / .eslintignore
Created October 28, 2021 12:10
Next.js Lint with Eslint + Airbnb Style + Husky + Lint-Staged
.next
public
node_modules
yarn.lock
package-lock.json
**/*.test.js
coverage
@vicasas
vicasas / settings.json
Created June 21, 2021 17:04
Config vscode
{
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontWeight": "300",
"editor.fontSize": 12,
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"workbench.editor.highlightModifiedTabs": true,
@vicasas
vicasas / chips.md
Created April 10, 2021 16:50
[docs] Material UI Chips
title components githubLabel materialDesign
React Chip component
Chip
component: Chip

Chip

Chips are compact elements that represent an input, attribute, or action.

@vicasas
vicasas / CONTRIBUTING.md
Created January 17, 2021 16:30
CONTRIBUTING DPACL

Contributing to DPACL

Si estás leyendo esto, ¡eres increíble! Gracias por ayudarnos a hacer que este proyecto sea excelente y por ser parte de la comunidad DPACL. Queremos que la contribución sea lo más fácil y transparente posible, aquí hay algunas pautas que lo ayudarán en el camino.

Your first Pull Request

¿Estás trabajando en tu primer Pull Request? Puede aprender cómo en esta serie de videos gratuitos.

Cómo contribuir a un proyecto de código abierto en GitHub

@vicasas
vicasas / FieldArray.jsx
Created June 6, 2020 20:55
Example of how to create a dynamic array form using Formik 🙌
import React from "react";
import { Divider, Button, TextField } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import { FieldArray, Form, Formik, getIn } from "formik";
import * as Yup from "yup";
const validationSchema = Yup.object().shape({
people: Yup.array().of(
Yup.object().shape({
firstName: Yup.string().required("First name is required"),