Icontem

File: src/stories/Line.js

Recommend this page to a friend!
  Classes of Manolo Salsas  >  React JS SVG Library  >  src/stories/Line.js  >  Download  
File: src/stories/Line.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: React JS SVG Library
Generate animated graphics in SVG using React JS
Author: By
Last change: Add strokeLinecap prop to Arc and Line. Update stories and README. Refactor code.
Date: 7 months ago
Size: 1,536 bytes
 

Contents

Class file image Download
import React from 'react';
import { storiesOf, action } from '@storybook/react';
import Line from '../Line';

storiesOf('Line', module)
    .add('orange 100px length, 45, butt stroke linecap', () => {
        const props = {
            lineLength: 100,
            degrees: 45,
            strokeWidth: 10,
            strokeColor: 'orange',
            strokeLinecap: 'butt'
        };

        return renderLine(props);
    })
    .add('yellow 50px length, 120, round stroke linecap', () => {
        const props = {
            lineLength: 50,
            degrees: 120,
            strokeWidth: 10,
            strokeColor: 'yellow',
            strokeLinecap: 'round'
        };

        return renderLine(props);
    })
    .add('red 80px length, 290, square stroke linecap', () => {
        const props = {
            lineLength: 80,
            degrees: 290,
            strokeWidth: 10,
            strokeColor: 'red',
            strokeLinecap: 'square'
        };

        return renderLine(props);
    })
    .add('green 130px length, 350', () => {
        const props = {
            lineLength: 130,
            degrees: 350,
            strokeWidth: 3,
            strokeColor: 'green'
        };

        return renderLine(props);
    })
    .add('without options', () => {
        const props = {};

        return renderLine(props);
    });


function renderLine(props) {
    return (
        <div className="svg-wrapper" style={{ background: 'gray' }}>
            <Line {...props} />
        </div>
    );
}