Skip to content

Instantly share code, notes, and snippets.

View AleksejDix's full-sized avatar
💚
in love with vue

Dix AleksejDix

💚
in love with vue
View GitHub Profile
@AleksejDix
AleksejDix / gist:dbbb2c10944e606230c37eba2f043066
Created October 25, 2024 11:48
css character stagering animation
.char {
animation-delay: calc(
sin((var(--index) / var(--total)) * 90deg) *
var(--duration)
);
}
cat ~/.ssh/id_rsa.pub | pbcopy
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();function go(e,t){const n=Object.create(null),r=e.split(",");for(let o=0;o<r.length;o++)n[r[o]]=!0;return t?o=>!!n[o.toLowerCase()]:o=>!!n[o]}const me={},Qt=[],Ge=()=>{},Ml=()=>!1,$l=/^on[^a-z]/,ur=e=>$l.test(e),vo=e=>e.startsWith("onUpdate:"),_e=Object.assign,mo=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},H
<script lang="ts">
import App from './App.vue'
import { defineCustomElement, createApp, h, getCurrentInstance } from 'vue'
import { plugin as formkit } from '@formkit/vue'
import { formkitConfig } from './formkit.config'
import styles from './assets/style.css?inline'
import pro from './../node_modules/@formkit/pro/genesis.css?inline'
import axios from 'redaxios';
import type { Response } from 'redaxios';
export const API = axios.create();
const request = <T, E>(request: Promise<Response<T>>) =>
request
.then(({ data }) => data)
.catch((error: E) => {
throw error;
@AleksejDix
AleksejDix / component.vue
Last active May 24, 2023 21:42
useApi implementation
<template>
<div v-if="state.status === 'idle'">
<button @click="fetchData">Fetch Data</button>
</div>
<div v-else-if="state.status === 'loading'">Loading...</div>
<div v-else-if="state.status === 'success'">{{ state.data }}</div>
<div v-else-if="state.status === 'error'">Error: {{ state.message }}</div>
</template>
<script lang="ts">
function compare(a, b, key, order) {
if (a[key] === b[key]) {
return 0;
}
if (a[key] === null || a[key] === undefined) {
return order === 'asc' ? -1 : 1;
}
if (b[key] === null || b[key] === undefined) {
@AleksejDix
AleksejDix / all.js
Created December 10, 2021 08:15
Handling Promise.all errors
const results = await Promise.all(promises.map(p => p.catch(e => e)));
const validResults = results.filter(result => !(result instanceof Error));
module.exports = {
purge: ['./public/**/*.html', './src/**/*.vue'],
darkMode: 'class',
corePlugins: {
container: false
},
theme: {
colors: {
offwhite: 'var(--offwhite)',
nightblue: 'var(--nightblue)',
import { shallowReactive, watchEffect } from '@vue/composition-api'
import { Interpreter, EventObject, Typestate, Actor, State } from 'xstate'
export function useActor<
TContext,
TEvent extends EventObject,
TTypestate extends Typestate<TContext> = { value: any; context: TContext }
>(
service:
| Actor<TContext, TEvent>