1.0.0 • Published 5 years ago

@jamespotz/react-simple-readmore v1.0.0

Weekly downloads
8
License
GPL-3.0
Repository
github
Last release
5 years ago

React Simple Readmore

React component for animating height using Spring Factor.

Quick start

Get it from npm

$ npm install --save @jamespotz/react-simple-readmore

Note

For React >= 16.8 because of Hooks.

How to use

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import ReadMore from '@jamespotz/react-simple-readmore';
import text from './data';

const App = () => {
	const [shown, setShown] = useState(false);

	return (
		<ReadMore
			onClick={value => setShown(value)}
			fade
			btn={
				<button
					style={{
						background: `${shown ? 'red' : 'blue'}`,
						padding: '10px 15px',
						color: '#fff'
					}}
				>
					{shown ? 'Read Less' : 'Read More'}
				</button>
			}
			preset='wobbly'
		>
			<p
				dangerouslySetInnerHTML={{
					__html: text
				}}
			/>
		</ReadMore>
	);
};

ReactDOM.render(<App />, document.getElementById('root'));

Demo

Live Demo: https://codesandbox.io/embed/kind-night-bqd8e

To build the examples locally, run:

npm install
npm start

Then open localhost:3000 in your browser of choice.

API

PropTypeDefault
minHeightNumber/String50
displayHeightNumber/String'auto'
btnTextText/Component (props ignored if btn is present)
btnTextShownText/Component (props ignored if btn is present)
defaultShownOnLessText/Component
btnComponent
onClickFunction
btnClassNameString
btnStylesObject
fadeBoolean
fadeHeightNumberminHeight/2
colorStopTopString'rgba(255, 255, 255, 0)'
colorStopBottomString'white'
precisionNumber0.01
velocityNumber0
massNumber1
stiffnessNumber
dampingNumber
prestString of type 'noWobble', 'gentle', 'wobbly', 'stiff', 'slow', 'molasses'
1.0.0

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago