0.1.60 • Published 3 years ago

react-smartphone v0.1.60

Weekly downloads
484
License
MIT
Repository
github
Last release
3 years ago

react-smartphone

Demo

If you just want to see the showcase please jump to the DEMO!

Sections

  • About
  • Install
  • Examples
  • Props

About

Smartphone container, acts as a regular container with relative positioning, with a fixed height and width. I used it in a personal project and thought I might as well publish it to share with the community :)

Simply add to the container your React components and they will be rendered in the screen!

Features

  • Adjustable colors
  • Adjust width && height
  • Scroll vertically like in a real smartphone
  • Bind Volume && Home buttons to trigger your custom callback
  • Toggle the phone lock button to activate lockscreen

Please add feedback if there is anything you might find missing.

Install

Run

npm i react-smartphone

and import as usual

import SmartphoneContainer from 'react-smartphone'

Examples

In the DEMO I added the default react component that is generated whe you perform a create-react-app app-name to showcase the smartphone container.

You can either place it entirely as follows with/without props (see props section)

import SmartphoneContainer from 'react-smartphone'

...

<SmartphoneContainer>
  <div className="App">
    <header className="App-header">
      <img src={logo} className="App-logo" alt="logo" />
      <h1 className="App-title">Welcome to React</h1>
    </header>
    <p className="App-intro">
      To get started, edit <code>src/App.js</code> and save to reload.
    </p>
  </div>
</SmartphoneContainer>

or in a cleaner way

import SmartphoneContainer from 'react-smartphone'

...

<SmartphoneContainer>
  <App />
</SmartphoneContainer>

If you want to customiz the phone you can specify props like color and dimensions. All styling props are strings. This gives you the flexibility to add for example height in vh or % or px etc... Same goes for colors, you can either use rgb or hex. Example:

  <SmartphoneContainer
    height='700px'
    width='380px'
    caseColor='rgb(30,30,30)'
    shadowColor='rgb(200,200,230)'
  >
    <!-- your component goes here -->
  </SmartphoneContainer>

Props

ALL props are OPTIONAL.

Prop NameDefault ValueType
height700pxstring
width380pxstring
caseColor#f3f0ddstring
detailsColor#374D5Cstring
cameraColor#f4745dstring
shadowColor#b0b3b2string
volumeButtonsColorContent Cellstring
textThanks for using react-phone.string: if instead of a react component you just want to render a sentence you can pass a string and it will be rendered in the center of the phone screen
screenColor374D5Cstring
childrennoneReact Component
contentnoneReact Component: if the are children, it will prioritize rendering children instead of content prop
onVolumeButtonPressnonecallback function ()=> {}
onHomeButtonPressnonecallback function ()=>{}

Thanks and please do not forget to submit feedback if you something doesn't work properly or you simply want more fun features :)

0.1.60

3 years ago

0.1.54

3 years ago

0.1.55

3 years ago

0.1.56

3 years ago

0.1.57

3 years ago

0.1.58

3 years ago

0.1.59

3 years ago

0.1.53

3 years ago

0.1.52

3 years ago

0.1.50

3 years ago

0.1.49

3 years ago

0.1.46

3 years ago

0.1.47

3 years ago

0.1.48

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.37

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.41

3 years ago

0.1.20

3 years ago

0.1.43

3 years ago

0.1.21

3 years ago

0.1.44

3 years ago

0.1.22

3 years ago

0.1.45

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.39

3 years ago

0.1.19

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago