react-middle-ellipsis

WebJar for react-middle-ellipsis

Лицензия

Лицензия

MIT
Категории

Категории

React Взаимодействие с пользователем Веб-фреймворки
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

react-middle-ellipsis
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

react-middle-ellipsis
WebJar for react-middle-ellipsis
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/bluepeter/react-middle-ellipsis

Скачать react-middle-ellipsis

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-middle-ellipsis/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-middle-ellipsis</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-middle-ellipsis/
implementation 'org.webjars.npm:react-middle-ellipsis:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/react-middle-ellipsis/
implementation ("org.webjars.npm:react-middle-ellipsis:1.1.0")
'org.webjars.npm:react-middle-ellipsis:jar:1.1.0'
<dependency org="org.webjars.npm" name="react-middle-ellipsis" rev="1.1.0">
  <artifact name="react-middle-ellipsis" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-middle-ellipsis', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "react-middle-ellipsis" % "1.1.0"
[org.webjars.npm/react-middle-ellipsis "1.1.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

React Middle Ellipsis

Check out the demo.

Adding ellipses to the end of long text is cool. But not always! Sometimes the end of the text contains vital information, particularly for URLs or filenames.

This React component is designed with that use case in mind.

Install

yarn add react-middle-ellipsis

Usage

Once imported, you can then wrap any node with <MiddleEllipsis>. This will compute the width of the surrounding parent node. Then, it will look for the child node (so make sure to add a span at minimum internally): it will use this element to compute the width of the child, and then shorten the text element whose class is ellipseMe (optional) to fit within the parent.

The component re-computes things if the browser window is resized, too!

import React from "react";
import MiddleEllipsis from "react-middle-ellipsis";

const Component = props => {
  return (
  <>
    <div style={{ width: "350px", whiteSpace: "nowrap" }}>
      <MiddleEllipsis>
        <span>
          I am some long text that should be ellipsed in the middle because
          the end contains important stuff.
        </span>
      </MiddleEllipsis>
    </div>
    <div style={{ width: "350px", whiteSpace: "nowrap" }}>
      <MiddleEllipsis>
        <span>
          Don't ellipse me.{" "}
          <span className="ellipseMe">
            I am some long text that should be ellipsed in the middle because
            the end contains important stuff.
          </span>
        </span>
      </MiddleEllipsis>
    </div>
  <>
  );
};

export default Component;

Development

Notes for developing this component.

yarn && yarn run start in this directory and separately also in /example. This will live reload any changes made in /src.

Change the version number in package.json and npm publish once complete.

License

MIT © bluepeter

Версии библиотеки

Версия
1.1.0