npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-camera-ios

v0.2.1

Published

Simple react implementation of iPhone / iPad photo camera

Downloads

427

Readme

GitHub Actions

React Camera iOS

A simple react implementation of iPhone / iPad photo camera with all native styles and ability to change camera (user / environment).

The following technologies were used to create the library:

  • WebRTC for getting the access to camera media stream,
  • HTML <video> element for display the camera stream,
  • HTML <canvas> element for taking a screenshot (photo) from the <video> element.

Installation

You can install the library using NPM:

npm install react-camera-ios

or Yarn:

yarn add react-camera-ios

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import Camera, { DEVICE, FACING_MODE, PLACEMENT } from 'react-camera-ios';

// Styles
import 'react-camera-ios/build/styles.css';

const containerStyle = { display: 'flex', height: '300px', width: '300px' };

ReactDOM.render(
  <div style={containerStyle}>
    <Camera
      device={DEVICE.MOBILE}
      facingMode={FACING_MODE.ENVIRONMENT}
      placement={PLACEMENT.COVER}
      quality="1"
      onError={error => console.log(error)}
      onTakePhoto={dataUrl => console.log(dataUrl)}
    />
  </div>,
  document.getElementById('root'),
);

Constants

The library provides some constants, you can use them as values of camera properties:

const DEVICE = {
  MOBILE: 'mobile',
  TAB: 'tab',
};

const FACING_MODE = {
  ENVIRONMENT: 'environment',
  USER: 'user',
};

const PLACEMENT = {
  CONTAIN: 'contain',
  COVER: 'cover',
};

PropTypes

Name | Description | Type | Default value --- | --- | --- | --- device|Which style of camera do you want to see:DEVICE.MOBILE - iPhone camera style,DEVICE.TAB - iPad camera style.|string|DEVICE.MOBILE facingMode| In which side of device do you want to open camera:FACING_MODE.ENVIRONMENT - back (main) camera,FACING_MODE.USER - front camera.It works like MediaTrackConstraints.facingMode|string|FACING_MODE.ENVIRONMENT isTurnedOn| Camera power indicator | bool | true placement|Camera placement relative to the container:PLACEMENT.CONTAIN - scales the camera as large as possible without cropping,PLACEMENT.COVER - scales the camera as large as possible (but if the proportions of the camera differ from the container, it is cropped either vertically or horizontally so that no empty space remains).It works like CSS background-size property|string|PLACEMENT.COVER quality|The quality of photo (a number between 0 and 1). It will be passed to canvas.toDataURL()|number|0.92 onError(error)|Called when an error is occured (error object will be passed as an agrument)|func| onTakePhoto(dataUrl)|Called when a photo is taken (dataUrl will be passed as an argument)|func|

Demo

React Camera iOS