}
+ \ No newline at end of file diff --git a/app/src/helpers/FitText.js b/app/src/helpers/FitText.js new file mode 100644 index 0000000..1a16919 --- /dev/null +++ b/app/src/helpers/FitText.js @@ -0,0 +1,17 @@ +export default class FitText { + constructor(el, defaultSize, increment) { + this.element = el; + this.defaultSize = defaultSize; + this.increment = increment; + } + fit() { + this.element.style.fontSize = this.defaultSize + "rem"; + this.recalc(); + } + recalc(shouldRecalc) { + if (shouldRecalc || this.element.clientHeight < this.element.scrollHeight) { + this.element.style.fontSize = (parseFloat(this.element.style.fontSize.replace(/[^0-9.]/g,'')) - this.increment) + "rem"; + this.recalc(); + } + } +} \ No newline at end of file