@jswork/react-ratio-image
v1.0.0
Published
Ratio image for react.
Downloads
4
Readme
react-ratio-image
Ratio image for react.
installation
npm install -S @jswork/react-ratio-image
properties
| Name | Type | Required | Default | Description | | --------- | ------ | -------- | ------- | ------------------------------------- | | className | string | false | - | The extended className for component. | | value | number | false | 1 | The ratio value. |
usage
- import css
@import "~@jswork/react-ratio-image/dist/style.css";
// or use sass
@import "~@jswork/react-ratio-image/dist/style.scss";
// customize your styles:
$react-ratio-image-options: ()
- import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactRatioImage from '@jswork/react-ratio-image';
import './assets/style.scss';
class App extends React.Component {
render() {
return (
<ReactDemokit
className="p-3 app-container"
url="https://github.com/afeiship/react-ratio-image">
<div className="is-box-item">
<h2>Ratio: 0.5</h2>
<ReactRatioImage value={0.5}>
<img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1gexw87htqhj305k05k74o.jpg" />
</ReactRatioImage>
<h2>Ratio: 1</h2>
<ReactRatioImage value={1}>
<img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1gexw87htqhj305k05k74o.jpg" />
</ReactRatioImage>
<h2>Ratio: 2</h2>
<ReactRatioImage value={2}>
<img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1gexw87htqhj305k05k74o.jpg" />
</ReactRatioImage>
</div>
</ReactDemokit>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
documentation
- https://afeiship.github.io/react-ratio-image/
license
Code released under the MIT license.