1.0.1 • Published 3 years ago

react-fitmeplz v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-fitmeplz

Twitter

Showcase

Install

npm install --save react-fitmeplz
yarn add react-fitmeplz

Usage

import React from "react";
import Fitmeplz from "react-fitmeplz";

function Header() {
  return (
    <div style={{width: "100px", height: "300px"}}>
      <Fitmeplz
        min={10}
        max={100}
        start={50}
        throttle={0}
        step={5}
        hideOnMount={true}
        hideOnCalc={true}
        onStart={() => console.log("Calculating optimal font size!")}
        onEnd={() => console.log("Finished calculating optimal font size!")}
        onFontsize={(size) => console.log(`Current font size is: ${size}`)}
      >
        This is a test!
      </Fitmeplz>
    </div>
  );
}

export default Header;

Props

NameTypeDefaultDescription
minnumber1Minimum font size in pixels.
maxnumber300Maximum font size in pixels.
startnumber100Font size in pixels when the component first mounts.
throttlenumber0Throttle (in milliseconds) the rate in which font size is changed and text elements size is compared with its parent.
stepnumber1Font size change in pixels when calculating optimal font size.WARNING! A large value may cause infinite loops.
hideOnMountbooleantrueText will be hidden on component mount until font size calculation has finished.
hideOnCalcbooleantrueText will be hidden every time a new font size has to be calculated.
onStartfunction() => {}Function will be called when font size is calculating.
onEndfunction() => {}Function will be called when font size has finished being calculated.
onFontsizefunction() => {}Function will be called every time the font size changes.Will return the new font size in pixels as a string.

License

MIT © NotBaldrick