This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* First, create a type helper that represents | |
* the Result that we'll get from our safe function | |
*/ | |
type Result<T> = | |
| { | |
ok: true; | |
value: T; | |
} | |
| { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<span | |
v-if="icon" | |
:class="[ | |
'children-[svg]:h-full children-[svg]:w-full', | |
defaultStyles && 'inline-block h-[1em] w-[1em] align-middle', | |
]" | |
v-html="icon" | |
/> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
const props = withDefaults( | |
defineProps<{ | |
columnMaxWidth?: string; | |
}>(), | |
{ | |
columnMaxWidth: "25rem", | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormData as _FormData } from 'formdata-polyfill/esm.min.js' | |
export async function formDataToObject(formData: FormData) { | |
const obj: Record<string, any> = {} | |
for (const [key, value] of formData.entries()) { | |
if (value instanceof Blob) { | |
obj[key] = { | |
__type: 'blob', | |
...(await serializeBlob(value)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface SpreadsheetValues { | |
majorDimension: "DIMENSION_UNSPECIFIED" | "ROWS" | "COLUMNS"; | |
range: string; | |
values: string[][]; | |
} | |
export async function getSpreadsheetValues( | |
id: string, | |
sheet: string | |
): Promise<Record<string, string>[]> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { $fetch } from "ofetch"; | |
import { hash } from "ohash"; | |
import { toValue } from "@vueuse/core"; | |
import { useQuery } from "vue-unquery"; | |
import { useI18n } from "@byjohann/vue-i18n"; | |
import type { MaybeRefOrGetter } from "@vueuse/core"; | |
import type { TurboVueOptions } from "vue-unquery"; | |
import type { KirbyQueryRequest, KirbyQueryResponse } from "kirby-types"; | |
let responseCache: KirbyQueryResponse | undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a schema for a post | |
const Post = z.object({ | |
slug: z.string(), | |
content: z.string(), | |
}); | |
// Create a schema for a post collection | |
const Posts = z.array(Post); | |
// Fetch a post by slug with the correct typed response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useStorageAsync } from "@vueuse/core"; | |
import { get, set, del } from "idb-keyval"; | |
export const STORAGE_KEY_PREFIX = "app.session."; | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
export function useIdbStorage<T = any>(key: string, initialValue: T) { | |
return useStorageAsync(`${STORAGE_KEY_PREFIX}${key}`, initialValue, { | |
async getItem(key: string) { | |
return (await get<string>(key)) ?? null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media (hover: none) and (pointer: coarse) { | |
/* Touchscreens */ | |
} | |
@media (hover: none) and (pointer: fine) { | |
/* Stylus */ | |
} | |
@media (hover: hover) and (pointer: coarse) { | |
/* Controllers */ | |
} | |
@media (hover: hover) and (pointer: fine) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel.plugin("distantnative/block-accordion", { | |
blocks: { | |
accordion: { | |
methods: { | |
addRow() { | |
this.content.rows.push({ summary: "", detail: "" }); | |
this.update({ rows: this.content.rows }); | |
}, | |
removeRow(index) { | |
this.content.rows.splice(index, 1); |