How to use shave - 10 common examples

To help you get started, we’ve selected a few shave examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vivaxy / react-text-more-less / src / index.js View on Github external
setDOM = () => {
    const {
      className,
      collapsed,
      showMoreText,
      lessHeight,
      showMoreElement,
      showLessElement,
    } = this.props;
    if (collapsed) {
      shave(this.root, lessHeight, {
        classname: className,
        character: showMoreText,
        spaces: false,
      });
      const shaveChar = this.root.querySelector(`.${jsShaveCharClassName}`);
      if (shaveChar && showMoreElement) {
        // 如果不需要 ellipse,则没有 `shaveChar`
        render(showMoreElement, shaveChar);
      }
    } else {
      const hasShowLess = !!this.root.querySelector(
        `.${showLessTextClassName}`
      );
      if (
        this.root.offsetHeight > lessHeight &&
        showLessElement &&
github learningequality / kolibri / kolibri / core / assets / src / views / TextTruncator.vue View on Github external
handleUpdate() {
        // TODO make "View Less" disappear when user expands window
        // and text isn't truncated any more.
        shave(this.$refs.shaveEl, this.maxHeight);
        this.$nextTick(() => {
          this.textIsTruncated = Boolean(this.$el.querySelector('.js-shave'));
        });
      },
    },
github vanilla / vanilla / library / src / scripts / user-content / embeds / link.tsx View on Github external
function truncateTextBasedOnMaxHeight(excerpt: Element) {
    const maxHeight = parseInt(getComputedStyle(excerpt)["max-height"], 10);
    if (maxHeight && maxHeight > 0) {
        shave(excerpt, maxHeight);
    }
}
github pluralsight / design-system / packages / row / src / react / shave.js View on Github external
const truncate = useCallback(() => {
    const maxHeight = lineHeight * lines
    shave(elRef.current, maxHeight, { character: character })
  }, [lineHeight, lines, character])
  useEffect(() => {
github vanilla / vanilla / library / src / scripts / content / TruncatedText.tsx View on Github external
private truncateTextBasedOnMaxHeight() {
        const element = this.ref.current!;
        const maxHeight = parseInt(getComputedStyle(element)["max-height"], 10);
        if (maxHeight && maxHeight > 0) {
            shave(element, maxHeight);
        }
    }
github vanilla / vanilla / src / scripts / app / user-content / embeds.ts View on Github external
export function truncateTextBasedOnMaxHeight(excerpt: Element) {
    const maxHeight = parseInt(getComputedStyle(excerpt)["max-height"], 10);
    if (maxHeight && maxHeight > 0) {
        shave(excerpt, maxHeight);
    }
}
github vanilla / vanilla / library / src / scripts / content / TruncatedText.tsx View on Github external
private truncateBasedOnLines() {
        const lineHeight = this.calculateLineHeight();
        if (lineHeight !== null) {
            const maxHeight = this.props.lines! * lineHeight;
            shave(this.ref.current!, maxHeight);
        }
    }
github pluto-net / scinapse-web-client / app / components / profile / components / reviewItem.tsx View on Github external
private shaveTexts() {
    if (!!this.summaryElement) {
      shave(this.summaryElement, 40);
    }
  }
github pluto-net / scinapse-web-client / app / components / articleFeed / components / feedItem.tsx View on Github external
private shaveTexts() {
    if (!!this.abstractElement) {
      shave(this.abstractElement, 88);
    }
  }

shave

Shave is a javascript plugin that truncates multi-line text within a html element based on set max height

MIT
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis

Popular shave functions