npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-cut

v2.3.1

Published

Angular directives for cutting texts

Downloads

648

Readme

npm version Package License NPM Downloads Build & Publish Snyk codecov stars forks HitCount

Angular directive for cutting texts with responsive options

Angular 18 compatible

Here's the demo or stackblitz live preview or codesandbox live preview

  • Lightweight
  • No dependencies!
  • Directive way
  • Highly customizable options...
  • Responsivity supported
  • Predefined breakpoints (Bootrstrap, CDK, FxLayout, Tailwind)

🛠️ Install

  1. Use yarn (or npm) to install the package
yarn add ngx-cut
  1. Add NgxCutModule into your imports

  export const appConfig: ApplicationConfig = {
    providers: [
      importProvidersFrom(
        BrowserModule,
        NgxCutModule.forRoot({
          size: 1,
          breakpoints: { sm: 300, md: 400, lg: 500, xl: 600 },
          responsiveSizes: {
            xs: { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 },
            sm: { xs: 2, sm: 3, md: 4, lg: 5, xl: 6 },
            md: { xs: 3, sm: 4, md: 5, lg: 6, xl: 7 },
            lg: { xs: 4, sm: 5, md: 6, lg: 7, xl: 8 },
            xl: { xs: 5, sm: 6, md: 7, lg: 8, xl: 9 }
          }
        })
      )
    ]
  };

  // or

  import { NgxCutModule } from 'ngx-cut';

  @NgModule({
   // ...
   imports: [
     // ...
     NgxCutModule.forRoot({
       // directive without [size] uses this value
       size: 1,
       // custom breakpoints
       breakpoints: { sm: 300, md: 400, lg: 500, xl: 600 },
       // lines be truncated in responsive mode
       responsiveSizes: {
         xs: { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 },
         sm: { xs: 2, sm: 3, md: 4, lg: 5, xl: 6 },
         md: { xs: 3, sm: 4, md: 5, lg: 6, xl: 7 },
         lg: { xs: 4, sm: 5, md: 6, lg: 7, xl: 8 },
         xl: { xs: 5, sm: 6, md: 7, lg: 8, xl: 9 }
       }
     })
   ]
  })

  // or

  @NgModule({
   // ...
   imports: [
     // ...
     NgxCutModule.forRoot({
       // directive without [size] uses responsiveSizes.sm
       size: 'sm',
       // predefined breakpoint ('BOOTSTRAP', 'FX_LAYOUT' or 'CDK')
       breakpoints: 'BOOTSTRAP',
       // lines be truncated in responsive mode
       responsiveSizes: {
         xs: { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 },
         sm: { xs: 2, sm: 3, md: 4, lg: 5, xl: 6 },
         md: { xs: 3, sm: 4, md: 5, lg: 6, xl: 7 },
         lg: { xs: 4, sm: 5, md: 6, lg: 7, xl: 8 },
         xl: { xs: 5, sm: 6, md: 7, lg: 8, xl: 9 }
       }
     })
   ]
  })

  // or

  @NgModule({
   // ...
   imports: [
     // ...
     NgxCutModule
   ]
  })

🚀 Quick start

Example code

<p ngxCut>some long text</p>

Result

  some long...

🛠️ Options

Root options

| Option | Type | Default | Description | | ------------------- | ---------------- | ------------------------ | ------------------------------------------------------ | | size | string or number | 1 | Number of truncated lines | | breakpoints | object | DEFAULT_BREAKPOINTS | Breakpoints used in responsive mode | | responsiveSizes | object | DEFAULT_RESPONSIVE_SIZES | How many lines should be truncated for each breakpoint |

Directive

| Option | Type | Default | Description | | ---------------------- | ------------ | ----------------------------- | -------------------------------------------- | | [size] | object | value taken from root options | Number of truncated lines or responsive mode | | [truncateDisabled] | boolean | false | Whether truncation is active or not | | (truncateChange) | () => object | none | Event called when truncation is changed. |

🔧 Compatibility

| Angular | ngx-cut | Install | | --------- | ------- | -------------------- | | >= 12 | 2.x | yarn add ngx-cut | | >= 5 < 13 | 1.x | yarn add ngx-cut@1 | | >= 5 < 13 | 0.x | yarn add ngx-cut@0 |

📦 Dependencies

None

🪪 License

Copyright © 2020 - 2024 Dominik Hladik

All contents are licensed under the MIT license.