This file contains hidden or 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 type { GraphQLScalarTypeConfig } from "graphql"; | |
import { GraphQLScalarType } from "graphql"; | |
import { DateTimeResolver } from "graphql-scalars"; | |
import { DateTime } from "luxon"; | |
export const GraphQLDateTimeConfig: GraphQLScalarTypeConfig<DateTime, DateTime> = | |
{ | |
name: "DateTime", | |
description: "An ISO8601 date-time string represented by a Luxon DateTime instance.", |
This file contains hidden or 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 { RefObject, useEffect, useState } from "react"; | |
import ResizeObserver from "resize-observer-polyfill"; | |
type BoundingRect = Omit<DOMRectReadOnly, "toJSON">; | |
export function useResizeObserver<T extends HTMLElement>(target: RefObject<T>) | |
{ | |
const [state, setState] = useState<BoundingRect>({ bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 }); |
This file contains hidden or 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
// util to code generate an object from another object where all the resulting object | |
// keys equal their respective paths within the object. | |
// | |
// useful for removing magic i18n strings from code. | |
/* eslint-disable @typescript-eslint/no-var-requires */ | |
const dot = require("dot-object"); | |
const fs = require("fs"); | |
const path = require("path"); |
This file contains hidden or 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 { expect } from "chai"; | |
import { describe, it } from "mocha"; | |
import * as faker from "faker"; | |
import { Guid, GuidFormat } from "../Guid"; | |
describe(nameof(Guid), () => | |
{ | |
const empty = "00000000-0000-0000-0000-000000000000"; |
This file contains hidden or 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 enum HttpStatus | |
{ | |
Continue = 100, | |
SwitchingProtocols = 101, | |
Processing = 102, | |
EarlyHints = 103, | |
OK = 200, | |
Created = 201, | |
Accepted = 202, |
This file contains hidden or 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
// using ts-nameof | |
useLogStateChanges(nameof(SomeComponent), | |
[ | |
[nameof(value), value], | |
[nameof(startDate), startDate, val => (val as Date).valueOf().toString()], | |
[nameof(endDate), endDate] | |
]); | |
// using strings :( | |
useLogStateChanges("SomeComponent", |
This file contains hidden or 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 React from "react"; | |
import { Avatar } from "./Avatar"; | |
export default function App() | |
{ | |
return ( | |
<div className="App"> | |
<Avatar name="display middle name" background="#1FDA8A" size={32} highContrast={false} rounded={false} bold={true} /> | |
</div> |
This file contains hidden or 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 { AzureCustomizationsLight, AzureCustomizationsDark } from "@uifabric/azure-themes"; | |
import { ThemeProvider as FluentThemeProvider } from "@fluentui/react-theme-provider"; | |
import React, { createContext, PropsWithChildren, useContext, useState } from "react"; | |
import { useLocalStorage } from "../hooks/useLocalStorage"; | |
interface IThemeContext | |
{ | |
themeName: string; |
This file contains hidden or 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 {useLayoutEffect, useRef} from "react"; | |
export default function useFadeOut(ref, fadeTime, visible) | |
{ | |
const timerId = useRef(); | |
useLayoutEffect(() => | |
{ | |
clearTimeout(timerId.current); |
This file contains hidden or 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 React, { Component } from 'react'; | |
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; | |
import Login from 'components/Login' | |
import DefaultComponent from 'components/DefaultComponent' | |
class DebugRouter extends Router { | |
constructor(props){ | |
super(props); | |
console.log('initial history is: ', JSON.stringify(this.history, null,2)) | |
this.history.listen((location, action)=>{ |
NewerOlder