0.3.8 • Published 5 months ago

seemly v0.3.8

Weekly downloads
430
License
MIT
Repository
-
Last release
5 months ago

seemly

Util functions for creating user interface.

Installation

npm install --save-dev seemly

Usage

import { xxx } from 'seemly'

API

Animation

beforeNextFrame(callback: Function): void

Call the callback function before next frame.

beforeNextFrameOnce(callback: Function): void

Call the callback function before next frame. Same function won't be called more than once.

Color

In the following functions, RGBA is [number, number, number, number], RGB is [number, number, number].

rgba (color: string): RGBA

Get the rgba value of a string color.

Color could only be #000, #0000, #000000, #00000000, rgb(0, 0, 0), rgba(0, 0, 0, 0) formatted.

composite (background: string | RGB | RGBA, overlay: string | RGB | RGBA): string

Get the rgba formatted string of composited color of the two color.

For example: composite('#FFF', 'rgba(0, 0, 0, .5)') === 'rgba(127, 127, 127, 1)', composite('rgba(255, 255, 255, .5)', 'rgba(0, 0, 0, .5)') === 'rgba(85, 85, 85, 0.75)'.

CSS

depx (value: string | number): number

Remove the 'px' of the input value and get the number value of it.

For example: depx('1px') === 1, depx('1') === 1, depx(1) === 1.

pxfy (value: string | number): string

Append the 'px' on the input value.

For example: pxfy(1) === '1px', pxfy('1') === '1px', 'pxfy('1px') === '1px').

parseResponsiveProp (responsiveProp: string): Record<string, string>

Transform a css utility class to a js object.

For example: parseResponsiveProp('6 m:12 l:24') is { '': 6, m: '12', l: '24' }

parseResponsivePropValue (responsiveProp: string, activeKey: string): string | undefined

Get corresponding value by key.

For example: parseResponsiveProp('6 m:12 l:24', 'l') is '24'. parseResponsiveProp('6 m:12 l:24'), parseResponsiveProp('6 m:12 l:24', 'x') are '6'.

DOM

getScrollParent (node: Node | null): HTMLElement | Document | null

Get the scrollable parent node of current node.

unwrapElement (target: HTMLElement | string | () => HTMLElement): HTMLElement | null

Unwrap the HTMLElement from a element getter function or a element selector.

If the target is already a HTMLElement, the same value will be returned.

Misc

createId (length: number = 8): string

Get a unique random id with length of length.

0.3.8

5 months ago

0.3.7

5 months ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.0

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.29

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.26

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6-0

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1-alpha.2

3 years ago

0.0.1-alpha.1

3 years ago

0.0.1-alpha.0

3 years ago

0.0.1

5 years ago