@kompanion/style
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Kompanion utils

Tiny snippets of useful javascript code for websites and apps.

npm i @kompanion/utils
# or
yarn add @kompanion/utils

Utilities

As @kompanion/utils is written in Typescript, you get automatic intellisense by default if using editors like VS Code.

Arrays

shuffleArray

Self explanatory. The only argument is an array:

import { shuffleArray } from '@kompanion/utils';

const emojis = ['😄', '🤨', '🧡', '😝'];
const randomEmoji = shuffleArray(emojis)[0];

DOM-related

scrollToId

Single argument: id: string

Uses the scrollIntoView API to smoothly scroll the screen to the object defined by the given id. If no object is found, does nothing.

<button onClick="scrollToId('contact')">Get in contact</button>

getWindowSize

Checks if there's a window object (if it's a browser) and returns an object: {width: num, height: num}

TODO

  • Add another tsconfig for an ES5 bundle
  • Finish documentation

Package Sidebar

Install

npm i @kompanion/style

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

17.2 kB

Total Files

17

Last publish

Collaborators

  • hdoro