Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqiuxin committed Sep 11, 2023
1 parent f820a39 commit c9973f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@

A high performance and customized ellipsis component for react. Support to custom ellipsis char, custom ellipsis node, end char filter, rich text, ...etc.

Searching for Vue? Refer to [vue-ellipsis-component](https://github.com/ruofee/vue-ellipsis-component).
Searching for a Vue library? Refer to [vue-ellipsis-component](https://github.com/ruofee/vue-ellipsis-component).

![](https://img.shields.io/npm/v/react-ellipsis-component.svg) ![](https://img.shields.io/npm/dt/react-ellipsis-component.svg) ![](https://img.shields.io/badge/language-javascript-yellow.svg)

## Docs
![demo](https://static.quincychen.cn/demo.gif)

- [English Docs](https://react-ellipsis.quincychen.cn/)
- [中文文档](https://react-ellipsis.quincychen.cn/zh/)
## API Referrer

## Demo
### Props

![demo](https://static.quincychen.cn/demo.gif)
| Prop Name | Type | Default | Description |
| ----------------------- | --------- | -------- | ------------------------------------------------------------ |
| text | String | Required | Pure text that you want to ellipsis. Support \n to wrap with useJsEllipsis={true}. |
| maxLine | Number | 1 | Content will be truncated if the line count of content is bigger than `maxLine`. |
| maxHeight | Number | | Content will be truncated if the height of content is bigger than `maxHeight`. Priority higher than maxLine. |
| className | String | | Add className to component. |
| ellipsis | Boolean | true | Whether to ellipsis the text content. |
| ellipsisNode | ReactNode || Custom the ellipsis node. |
| endExcludes | String[] | [] | The characters that want to remove at the end(Before ellipsis char). |
| dangerouslyUseInnerHTML | Boolean | false | Parse text as html(Make sure the text that you pass is safe, or you may been attacked by XSS). |
| reflowOnResize | Boolean | | Whether update when container resize. Default true if native ellipsis support, otherwise false. |
| visibleLine | Number | maxLine | Line count of visible content(Can't bigger than maxLine). |
| visibleHeight | Number | | Visible height of content. Priority higher than `visibleLine`. |

### Events

| Event Name | Type | Description |
| --------------- | ----------------------------------------- | ------------------------------------------------------------ |
| onReflow | (ellipsis: Boolean, text: String) => void | Reflow callback, `ellipsis` is whether the text have been truncated. `text` is the visible content after truncating(Not include ellipsis char). |
| onEllipsisClick | () => void | Ellipsis click callback. |

## Buy Me A Coffee

Expand All @@ -31,8 +49,7 @@ Open source is not easy, you can buy me a coffee. _Note your name or github id s
</td>
</tr>
</table>

## Donation List
### Donation List

❤️ Thanks these guys for donations. Contact me with <a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer nofollow" title="EMail">email</a>, if you had donated but not on the list.

Expand Down
2 changes: 1 addition & 1 deletion src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const isBrowser = typeof window !== 'undefined' && typeof document !== 'u

/** Whether the environment support -webkit-line-clamp. */
export const isSupportNativeEllipsis =
isBrowser && typeof document.body.style.webkitLineClamp !== 'undefined';
isBrowser && typeof document.body?.style?.webkitLineClamp !== 'undefined';

/** Whether the environment support window.requestAnimationFrame. */
export const isSupportRequestAnimationFrame =
Expand Down

0 comments on commit c9973f2

Please sign in to comment.