Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-middle-ellipsis
Advanced tools
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.
yarn add react-middle-ellipsis
Once import
ed, you can then wrap any element with
<MiddleEllipsis>
. This will compute the width of the surrounding
parent node. Then, it will look for a child node whose class is
constrainedChild
: it will use this element to compute the width
of the child, and then shorten the text element whose class is
constrainedEllipsis
to fit within the parent.
Why do we have both constrainedChild
and constrainedEllipsis
?
Because we want BOTH to fit within the parent, but only one of them
should be ellipse'd. This way, things such as icons or images won't
be ellipsed.
import React, { Component } from "react";
import MiddleEllipsis from "react-middle-ellipsis";
class Example extends Component {
render() {
return (
<div style={{ width: "350px", whiteSpace: "nowrap" }}>
<MiddleEllipsis>
<span className="constrainedChild">
Don't ellipse me.{" "}
<span className="constrainedEllipse">
I am some long text that should be ellipsed in the middle because
the end contains important stuff.
</span>
</span>
</MiddleEllipsis>
</div>
);
}
}
Notes for developing this component.
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.
MIT © bluepeter
FAQs
Put the dots in the middle of a long string, versus the end.
The npm package react-middle-ellipsis receives a total of 4,766 weekly downloads. As such, react-middle-ellipsis popularity was classified as popular.
We found that react-middle-ellipsis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.