Giter VIP home page Giter VIP logo

kushaneranga / vue-read-more-esy Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 220 KB

"vue-read-more-esy" is a Vue.js package that offers a convenient way to display text content with a responsive design and customizable word count. It features a "read more" button that allows the user to expand and read the full text.

License: MIT License

JavaScript 6.19% Vue 87.80% TypeScript 6.01%
npm-package readmore seemore vuejs seeless seemorebutton vue readless

vue-read-more-esy's Introduction

my banner

vue-read-more-esy

"vue-read-more-esy" is a Vue.js package that offers a convenient way to display text content with a responsive design and customizable word count. It features a "read more" button that allows the user to expand and read the full text. This package is easy to use and provides a great way to manage long text content in a user-friendly manner.

Table of Contents

  1. Setup
  2. How to use
  3. Try on
  4. Props
  5. Custom Example
  6. Extra

Setup

Install with npm:

npm i vue-read-more-esy

How to use

This allows you to break text with common punctuations like space, dot ('.'), exclamation mark ('!'), and question mark ('?'). Breaking text with these characters creates a visually appealing and easy-to-read layout for displaying lengthy text content.

Add dependencies to your main.js:

You want to handle text character count based on screen size percentage:

import Vue           from 'vue'
import ReadMorePre from 'vue-read-more-pre'

Vue.use(ReadMorePre)

Add the global component to your App.vue:

<ReadMorePre longTextData="Lorem.ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit,....."><ReadMorePre/>

You want to handle number of characters:

import Vue           from 'vue'
import ReadMoreVal from 'vue-read-more-val'

Vue.use(ReadMoreVal)

Add the global component to your App.vue:

<ReadMoreVal longTextData="Lorem.ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit,....."><ReadMorePre/>

Use the component directly:

<!-- read-more.vue -->
<template>
  <ReadMorePre longTextData="Lorem.ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit,....."><ReadMorePre/>

  <!-- Or -->

  <ReadMoreVal longTextData="Lorem.ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit,....."><ReadMoreVal/>
</template>

<script>
  import { ReadMorePre } from 'vue-read-more-pre';
  // Or
  import { ReadMoreVal } from 'vue-read-more-val';

  export default {
    components: {
      ReadMorePre,
      // Or
      ReadMoreVal.
    },
  };
</script>

Try on:

ReadMoreVal with Vue SFC Playground:

ReadMorePre with Vue SFC Playground:

Props

Note that all props are optional.

Common props:

Name Type Default Description
longTextData String '' Used to pass large amounts of text data (Required data)
readMore String Read more But you can use any text that you prefer.
readLess String Read less But you can use any text that you prefer.
mobMediaQuarrySize Number 576 Package uses a media breakpoint query of 576px for mobile screen sizes. However, this value is customizable, and you can adjust it to meet your specific needs.
tabMediaQuarrySize Number 992 Package uses a media breakpoint query of 992px for Tab screen sizes. However, this value is customizable, and you can adjust it to meet your specific needs.

ReadMorePre props:

Name Type Default Description
mobileSizePre Number 0.5 Allows you to specify the percentage of text that should appear on the mobile screen based on the screen size. By default, the value is set to 0.5, meaning that 50% of the text content will appear on the mobile screen. this value is customizable
tabSizePre Number 0.5 Allows you to specify the percentage of text that should appear on the Tab screen based on the screen size. By default, the value is set to 0.5, meaning that 50% of the text content will appear on the Tab screen. this value is customizable
deskSizePre Number 0.5 Allows you to specify the percentage of text that should appear on the Desktop screen based on the screen size. By default, the value is set to 0.5, meaning that 50% of the text content will appear on the Desktop screen. this value is customizable

ReadMoreVal props:

Name Type Default Description
mobileSizeVal Number 100 Maximum number of characters that should appear on the mobile screen.
tabSizeVal Number 200 Maximum number of characters that should appear on the Tab screen.
deskSizeVal Number 300 Maximum number of characters that should appear on the Desktop screen.

Custom Example:

<ReadMoreVal
  longTextData="
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit, interdum ac sapien ut, dapibus fermentum purus. In sit amet finibus ante, eu facilisis nisi. Suspendisse elit orci, facilisis a suscipit lacinia, placerat vel est. Proin molestie semper dolor, eget volutpat massa rutrum vitae. Suspendisse finibus facilisis lectus ac commodo.
  "
  readMore="See more"
  readLess="See less"
  :mobMediaQuarrySize="575"
  :tabMediaQuarrySize="767"
  :mobileSizeVal="80"
  :tabSizeVal="180"
  :deskSizeVal="280"
>
</ReadMoreVal>

<!-- Or -->

<ReadMorePre
  longTextData="
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus elit, interdum ac sapien ut, dapibus fermentum purus. In sit amet finibus ante, eu facilisis nisi. Suspendisse elit orci, facilisis a suscipit lacinia, placerat vel est. Proin molestie semper dolor, eget volutpat massa rutrum vitae. Suspendisse finibus facilisis lectus ac commodo.
  "
  readMore="See more"
  readLess="See less"
  :mobMediaQuarrySize="575"
  :tabMediaQuarrySize="767"
  :mobileSizePre="0.3"
  :tabSizePre="0.5"
  :deskSizePre="0.4"
>
</ReadMorePre>

Extra

If you like vue-read-more-esy, please support it:

Thank you!

vue-read-more-esy's People

Contributors

kushaneranga avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.