Options
All
  • Public
  • Public/Protected
  • All
Menu

ncn-utils

Index

Namespaces

Variables

Functions

Variables

Portal: React.FC<PortalProps> = ...

Higher order component that manages creation and teardown of root elements and SSR to create a portal for the children that's passed into it.

remarks
  • The component prevents being rendered during SSR inherently, so there's no need to make preventions for this.
remarks
  • No automation testing.
param id

(Optional) Pass an id to an existing element to attach to that element. An element with a unique ID will be generated if one isn't provided.

param children

Children passed to the component.

Functions

  • NoSsr(children: { children: ReactNode }): Element
  • ccl(...args: (string | false)[]): string
  • Combines an array of strings after filtering out falsey values to produce a single string representing a classlist.

    Parameters

    • Rest ...args: (string | false)[]

      Array of strings each representing a classname. Falsey values will be filtered out.

    Returns string

    Single string representing a classname

  • useKeyboard(keys: KeyDownCondition[]): void
  • Custom hook to handle keyboard pressdown events.

    example

    Handles an event which focuses an element by id when ctrl+f is pressed:

    useKeyboard( [{
    key: "f", mods: ["ctrl"], action: ( e ) => {
    e.preventDefault();
    document.querySelector( "#filter-searchbar" ).focus();
    }
    }] );

    Parameters

    • keys: KeyDownCondition[]

    Returns void

Generated using TypeDoc