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 _axios, { type AxiosRequestConfig } from "axios"; | |
import defu from "defu"; | |
import { FB_EXPIRATION_DATE, IS_DEV } from "@/constants/globals"; | |
import { useBearerToken } from "./useBearerToken"; | |
export function useAxios<T, D = any>(url: string, options?: Omit<AxiosRequestConfig<D>, "url">) { | |
const { bearerToken, getIdTokenResult } = useBearerToken(); |
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"> | |
import CharacterCount from "@tiptap/extension-character-count"; | |
import Link from "@tiptap/extension-link"; | |
import Subscript from "@tiptap/extension-subscript"; | |
import Superscript from "@tiptap/extension-superscript"; | |
import StarterKit from "@tiptap/starter-kit"; | |
import { Editor, EditorContent } from "@tiptap/vue-3"; | |
const { | |
name, |
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> | |
... | |
<RadioGroup | |
v-model="value" | |
@option-click="next" // or @change | |
> | |
<template | |
v-for="(item, i) in isOwnedData" |
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 function findFirstFocusableElement( | |
element: HTMLElement | null, | |
tags: string = "", | |
{ withDefaults } = { withDefaults: false } | |
) { | |
if (!element) return; | |
const defaults = | |
"a[href], button, input, textarea, select, details, [tabindex]:not([tabindex='-1'])"; |
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 { BigNumber } from "@ethersproject/bignumber"; | |
import { formatUnits, parseUnits } from "@ethersproject/units"; | |
/** | |
* @param balance Token balance in BigNumber format | |
* @param decimals Token decimals | |
* @param fixed The number of decimal places to show | |
* @returns string representation of the balance | |
*/ | |
export function bigNumberToTrimmed( |
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 { computed, onMounted, onUnmounted, ref } from 'vue'; | |
export default function useBreakpoints() { | |
const windowWidth = ref(window.innerWidth); | |
const onWidthChange = () => (windowWidth.value = window.innerWidth); | |
onMounted(() => window.addEventListener('resize', onWidthChange)); | |
onUnmounted(() => window.removeEventListener('resize', onWidthChange)); | |
const bp = computed(() => { |
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 "tippy.js/dist/tippy.css"; | |
import "tippy.js/animations/scale.css"; | |
import tippy, { | |
type DefaultProps as DefaultTippyProps, | |
type Props as TippyProps, | |
} from "tippy.js"; | |
import type { Directive } from "vue"; | |
const defaultProps: Partial<DefaultTippyProps> = { |
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
/** | |
* @jest-environment jsdom | |
* @jest-environment-options {"url": "https://website.com"} | |
*/ | |
import { defaultPeriod } from "../../src/utils/date"; | |
let windowSpy: ReturnType<typeof jest.spyOn>; | |
describe("test date.ts", () => { |
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
// ! Co2 always in tons | |
export function convertCO2Units(co2t: number): string { | |
const units = ["g", "kg", "t"]; | |
let co2g = co2t * 1_000_000; // convert to grams | |
let unitIndex = 0; | |
while (co2g > 1000 && unitIndex < units.length - 1) { | |
co2g /= 1000; | |
unitIndex++; | |
} |
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> | |
<el-table | |
ref="table" | |
row-key="someKey" | |
@row-click="rowClick" | |
@expand-change="expandChange" | |
:data="data" | |
> | |
<el-table-column type="expand"> | |
<template v-slot:default="{ row }"> |
NewerOlder