Giter Club home page Giter Club logo

react-device-mockups's Introduction

react-device-mockups

NPM JavaScript Style Guide

Install

npm install --save react-device-mockups html5-device-mockups

Usage

To control the height of the device, see pixelsign/html5-device-mockups#47.

import React, { Component } from 'react';

import 'html5-device-mockups/dist/device-mockups.min.css';

import { IPad } from 'react-device-mockups';

export default class App extends Component {
    render () {
        return (
            <IPad width={300} orientation='landscape' color='black' buttonProps={ {
                onClick: () => alert('Home Button Clicked!')
            } }>
                <iframe title='showcase' src='https://example.com' style={ {
                    width: '100%',
                    height: '100%',
                    margin: 0
                } }/>
            </IPad>
        );
    }
}

License

MIT © kajchang

react-device-mockups's People

Contributors

jacobcwright avatar kajchang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-device-mockups's Issues

html5-device-mockups not found in nextjs

It seems this line is causing an error in Nextjs when I try to import the library

if (!found) {
throw new Error('Unable to find the html5-device-mockups stylesheet.');
}

image

My package.json

{
  "private": true,
  "scripts": {
    "dev": "next dev -p 3002",
    "build": "next build",
    "beta-deploy": "next build && next export",
    "start": "next start -p 3002"
  },
  "dependencies": {
    "@apollo/react-hooks": "^4.0.0",
    "@material-ui/core": "^4.11.4",
    "@material-ui/icons": "^4.11.2",
    "apollo-boost": "^0.4.9",
    "apollo-upload-client": "^16.0.0",
    "axios": "^0.21.1",
    "framer-motion": "^3.3.0",
    "graphql": "^15.5.1",
    "moment": "^2.29.1",
    "next": "^10.2.3",
    "next-compose-plugins": "^2.2.1",
    "next-optimized-images": "^2.6.2",
    "next-seo": "^4.28.1",
    "next-translate": "^1.0.6",
    "react": "17.0.1",
    "html5-device-mockups": "^3.2.1",
    "react-device-mockups": "^0.1.10",
    "react-dom": "17.0.1",
    "rollbar": "^2.21.1",
    "webp-loader": "^0.6.0"
  }
}

And at first I used it regularly in /pages/index.js of my project

import "html5-device-mockups/dist/device-mockups.min.css";
import { IPhoneX } from "react-device-mockups";

export default function Home() {
  return (
    <div>
           <IPhoneX height={500} orientation='landscape' color='black' buttonProps={ {
                onClick: () => alert('Home Button Clicked!')
            } }>
                <iframe title='showcase' src='https://example.com' style={ {
                    width: '100%',
                    height: '100%',
                    margin: 0
                } }/>
            </IPhoneX>
     </div>
  );
}

And then based on this answer, I tried using this approach by importing the css in pages/_apps.js

import "html5-device-mockups/dist/device-mockups.min.css";

function MyApp({ Component, pageProps }) {
  return (
    <ApolloProvider client={client}>
      <ThemeProvider theme={theme}>
        <Component {...pageProps} />
      </ThemeProvider>
    </ApolloProvider>
  );
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.