Skip to content

Instantly share code, notes, and snippets.

View akshay-nm's full-sized avatar
🎯
Focusing

Akshay Kumar akshay-nm

🎯
Focusing
View GitHub Profile
@akshay-nm
akshay-nm / use-form-state-login-form-call.js
Created May 1, 2021 09:54
use-form-state login form call
const {
isValid: formIsValid,
isValidating,
resetForm,
email,
showEmailWarning,
onEmailChange,
password,
showPasswordWarning,
onPasswordChange
@akshay-nm
akshay-nm / use-form-state-returns.js
Created May 1, 2021 09:51
Object returned by use-form-state
{
// form states and functions
isValid, // the overall form validity
isValidating, // are any validations still running
triggerValidation, // trigger validations
reset, // reset the form back to default configuration
// field wise states and functions
// for email
email,
@akshay-nm
akshay-nm / use-form-state-configuration-object.js
Last active May 1, 2021 09:43
use-form-state configuration for a login form
const config = {
states: [
{
name: 'email',
default: '',
defaultIsValid: false,
mustBeValid: true,
validator: () => true
},
{
{
name: 'nameInCamelCase', // Although I have added a camelize check but still...
default: '', // the default value of field
defaultIsValid: false, // is the field valid by default
mustBeValid: true, // is the field mandatory
validator: (value) => true // the validator
}
@akshay-nm
akshay-nm / publish.yml
Last active April 5, 2021 19:12
Publish your Node.js package using yarn to npm and gpr with codecoverage to codecov (Github workflow file)
name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
@akshay-nm
akshay-nm / adapter-logic.js
Last active November 4, 2020 13:42
Example for raghav
// No alterations in stuff before this as it is already configured...
const api = () => {
return {
login: {
post: (email, password) => {
const formData = new FormData()
formData.append('email', email)
formData.append('password', password)
@akshay-nm
akshay-nm / machine.js
Last active September 1, 2020 10:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@akshay-nm
akshay-nm / states.md
Last active May 26, 2020 10:11
Image Reveal component animation states
States Cover attributes Image attributes
S0 { left: 0%, width: 0% } { opacity: 0, transform: scale(0.5) }
S1 { width: 100% } no change
S2 { width: 0%, left: 100% } { transform: scale(1), opacity: 1 }
@akshay-nm
akshay-nm / styles.css
Created May 26, 2020 10:03
Final ImageRevealStyles
.image {
opacity: 0;
transform: scale(0.5);
width: 100%;
height: 100%;
position: absolute;
}
.cover {
width: 0%;
@akshay-nm
akshay-nm / ImageReveal.js
Created May 26, 2020 09:59
Final ImageReveal.js
import React, { useState } from 'react'
import { useSpring, animated, config } from 'react-spring'
import './styles.css'
const ImageReveal = () => {
const [reset, set] = useState(false)
const { coverWidth, coverLeft, imageScale, imageOpacity } = useSpring({
from: { coverWidth: 0, coverLeft: 0, imageScale: 0.5, imageOpacity: 0 },
to: async next => {
await next({ coverWidth: 100, coverLeft: 0, imageScale: 0.5, imageOpacity: 0 })