Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile
Qwik
Deprecated functions and their replacements
Deprecated Replacements
useWatch$ useTask$
useMount$ useTask$
useServerMount useTask$ + isServer
useClientMount useTask$ + isBrowser
useClientEffect useVisibleTask$
useClientEffectQrl useVisibleTask$
useBrowserVisibleTask useVisibleTask$
@PatrickJS
PatrickJS / method-missing-proxy.js
Created March 11, 2024 01:59 — forked from torgeir/method-missing-proxy.js
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
<div
class={`flex aspect-square w-full grow flex-col items-center justify-center rounded-3xl ${
props.useBorder ? 'border-4 border-gray-200' : ''
} p-5 max-md:mt-10 max-md:max-w-full`}
>
<Lottie
path={props.lottie}
loop={props.loop}
speed={props.speed}
/>
@PatrickJS
PatrickJS / Button.tsx
Last active February 1, 2024 01:18
Qwik Button
import { component$, sync$, Slot } from "@builder.io/qwik";
// save it's Tailwind
export const LoadingSpinner = () => (
<div class="absolute bottom-[2px] left-[2px] right-[2px] top-[2px] flex items-center justify-center rounded-3xl backdrop-blur-[1px]">
<svg
aria-hidden="true"
class="h-8 w-8 animate-spin fill-blue-600 text-gray-200 dark:text-gray-600"
viewBox="0 0 100 101"
fill="none"
@PatrickJS
PatrickJS / gource.sh
Created January 31, 2024 00:41 — forked from peterjmag/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
import { component$, sync$ } from "@builder.io/qwik";
export const RefreshButton = component$(({loading, onClick$, ...props}: any) => {
const loading$ = sync$((_e: Event, target: HTMLButtonElement) => {
const span = target.querySelector("span");
target.disabled = span!.hidden;
span!.hidden = !span!.hidden;
});
let clickListener = {};
if (onClick$) {
import { component$, type Signal, type JSXOutput } from "@builder.io/qwik";
export function Show(props: {
when: boolean;
"bind:when": Signal<boolean | undefined>;
children?: JSXOutput;
else?: JSXOutput;
}) {
if (props["bind:when"] !== undefined) {
return props["bind:when"].value ? props.children : props.else;
<BlogIndex> <-- readDir
<RefreshButton />
<Toggle>
<ArticlePreview filename="something.mdx"> <-- read file
first 50 chars
</ArticlePreview>
</Toggle>
<Toggle>
<ArticlePreview filename="something.mdx"> <-- read file
@PatrickJS
PatrickJS / global.tsx
Last active January 26, 2024 03:16
qwik global app context
import {
Slot,
component$,
createContextId,
useContextProvider,
useSignal,
useStore,
type Signal,
} from '@builder.io/qwik';
import { component$, useVisibleTask$, useStore, useSignal, noSerialize } from '@builder.io/qwik';
import lottie from 'lottie-web';
import { Options } from './types';
export interface OptionsProps {
options: Options;
}
export const QwikLottie = component$(({ options }: OptionsProps) => {
const store = useStore({