1.3.1 • Published 4 years ago

@muzikanto/picture v1.3.1

Weekly downloads
229
License
MIT
Repository
github
Last release
4 years ago

Picture (material-ui)

npm version downloads dependencies Status size

npm.io

Introduction

Peer dependencies: react, react-dom, material-ui/core, material-ui/styles

Installation

npm i @muzikanto/picture
# or
yarn add @muzikanto/picture

Examples

Example in storybook

Base

function Component() {
  return (
     <Picture
        src={"your image url"}
        aspectRatio={16 / 9}
       />
  )
}

use image aspectRatio

function Component() {
    const [aspectRatio, setAspectRatio] = React.useState(16 / 10);
    
  return (
     <Picture
        src={"your image url"}
        aspectRatio={aspectRatio}
        onLoad={e => {
            setAspectRatio(e.currentTarget.naturalWidth / e.currentTarget.naturalHeight);
        }}
     />
  )
}

Advanced

const StyledPicture = withStyles(() => ({
    error: {
        color: 'red',
        fontSize: 50,
    },
}))(Picture)

function Component() {
  return (
     <Picture
        src={"your image url"}
        aspectRatio={16 / 9}
        onClick={(e) => alert('onClick')}
        onLoad={(e) => alert('onLoad')}
        onError={(e) => alert('onError')}
          
        renderLoading={() => ...Custom Loading Component}
        renderError={() => ...Custom Error Component}
       />
  )
}

License

MIT

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.1-beta

4 years ago

1.0.0-beta

4 years ago