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

react-text-expand-collapse

v0.0.1

Published

文字展开收起组件

Downloads

6

Readme

文字展开收起组件

Install

npm install

Start

npm run dev

Run Build

npm run build

使用

import TextExpand from 'react-text-expand-collapse/src/index';

(注:如果没有安装sass,请先安装sass。npm install node-sass sass --save-dev

import TextExpand from 'react-text-expand-collapse/src/index'

1.示例

import * as React from "react";
import {createRoot} from 'react-dom/client';
import TextExpand from 'react-text-expand-collapse/src/index';

// 示例文字
const str: string = '金杯里装的名酒,每斗要价十千;玉盘中盛的精美菜肴,收费万钱。胸中郁闷啊,我停杯投箸吃不下;拔剑环顾四周,我心里委实茫然。想渡黄河,冰雪堵塞了这条大川;要登太行,莽莽的风雪早已封山。像姜尚垂钓溪,闲待东山再起;伊尹乘舟梦日,受聘在商汤身边。何等艰难!何等艰难!歧路纷杂,真正的大道究竟在哪边?相信总有一天,能乘长风破万里浪;高高挂起云帆,在沧海中勇往直前!'


const App = () => {
    return (
        <div style={{width: 500, margin: '20px auto'}}>
            <TextExpand
                content={str}
                maxLen={100}
                contentRender={(text: string, handler: any) => {
                    return (
                        <>
                            <span>{text}</span>
                            {handler}
                        </>
                    )
                }}
            />
        </div>
    );
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);

2.效果

gif1.gif

API

| 参数 | 说明 | 类型 | | --- | --- | --- | | content | 文本内容(必传) | String | | maxLen | 字最大显示长度(可选,默认值为:300) | Number | | expandText | 展开按钮文字(可选,默认值为:查看全部) | String | | collapseText | 收起按钮文字(可选,默认值为:收起) | String | | contentRender | 自定义内容(必传) | (text: string, handler: React.ReactNode) => React.ReactNode | | onExpand | 展开、收起后触发事件(可选) | (expanded: boolean) => void |

Author

👤 jacky010

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator