Skip to content

Instantly share code, notes, and snippets.

View genox's full-sized avatar

Oliver Studer genox

View GitHub Profile
@genox
genox / example-query.ts
Created July 14, 2023 12:37
qwik graphql requests with server side in-memory cache
import { graphql } from '~/library/saleor/gql';
import { server$ } from '@builder.io/qwik-city';
import { gqlQuery } from '~/library/gql-fetch/gql-fetch';
import { FetchProductBySlugDocument } from '~/library/saleor/gql/graphql';
import type { VariablesOf } from '@graphql-typed-document-node/core';
export const queryFetchProductBySlug = server$(async function (
variables: VariablesOf<typeof FetchProductBySlugDocument>
) {
const tokens = extractTokens(this);
@genox
genox / dialog.tsx
Created July 10, 2023 06:58
Confirmation dialog component for Qwik, Daisy ui
import type { PropFunction, Signal } from '@builder.io/qwik';
import { $, component$, Slot, useSignal, useTask$ } from '@builder.io/qwik';
import { useTranslate } from 'qwik-speak';
type Props = {
title?: string;
confirmAction?: PropFunction<() => void>;
cancelAction?: PropFunction<() => void>;
openSignal: Signal<boolean>;
isDangerous?: boolean;
@genox
genox / emoji.ts
Created May 29, 2023 18:24
Using satori with qwik to emulate vercel/og
/**
* Modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
*/
/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */
const U200D = String.fromCharCode(8205); // zero-width joiner
const UFE0Fg = /\uFE0F/g; // variation selector regex
export function getIconCode(char: string) {
return toCodePoint(char.indexOf(U200D) < 0 ? char.replace(UFE0Fg, '') : char);
}
function toCodePoint(unicodeSurrogates: string) {