Git Product home page Git Product logo

react-device-frameset's Introduction

React Device Frameset

NPM

publish workflow pages workflow npm version

This is yet another device frameset component for React.

Features

  • Powered by pure css device prototype showcase Marvel Devices.css

  • language Type Safe and under maintainable

  • Sample for reference

    • Device Selector frameset-screenshot

    • Device Emulator frameset-screenshot

Installation

yarn add react-device-frameset (or npm/pnpm)

Usage

Stylesheet importing

react-device-frameset supports conditional exports.

If the application bundler supports this feature and above node v12.11.0, you can import the stylesheet through the recommended path react-device-frameset/styles, it is largely supported in real developing environments, otherwise, you need to import it from react-device-frameset/dist/styles.

Basic Example

import { DeviceFrameset } from 'react-device-frameset'
import 'react-device-frameset/styles/marvel-devices.min.css'

export const App = () => {
    return (
        <DeviceFrameset device="iPhone 8" color="gold" landscape>
            <div>Hello world</div>
        </DeviceFrameset>
    )
}

Props Signature

DeviceFramesetProps:

| { device: 'iPhone X', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPhone 8', color: 'black' | 'silver' | 'gold', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPhone 8 Plus', color: 'black' | 'silver' | 'gold', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPhone 5s', color: 'black' | 'silver' | 'gold', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPhone 5c', color: 'white' | 'red' | 'yellow' | 'green' | 'blue', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPhone 4s', color: 'black' | 'silver', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'Galaxy Note 8', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'Nexus 5', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'Lumia 920', color: 'black' | 'white' | 'yellow' | 'red' | 'blue', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'Samsung Galaxy S5', color: 'white' | 'black', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'HTC One', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'iPad Mini', color: 'black' | 'silver', landscape?: boolean, width?: number, height?: number, zoom?: number }
| { device: 'MacBook Pro', width?: number, height?: number, zoom?: number }

If you like the frameset selector?

type DeviceName = "iPhone X" | "iPhone 8" | "iPhone 8 Plus" | "iPhone 5s" | "iPhone 5c" | "iPhone 4s" | "Galaxy Note 8" | "Nexus 5" | "Lumia 920" | "Samsung Galaxy S5" | "HTC One" | "iPad Mini" | "MacBook Pro"

type DeviceEmulatorProps = {
    banDevices?: DeviceName[]
    children: (props: DeviceFramesetProps) => React.ReactNode,
    value?: DeviceName,
    onChange?: (deviceName: DeviceName) => void, 
}
import { DeviceFrameset, DeviceSelector } from 'react-device-frameset'
import 'react-device-frameset/styles/marvel-devices.min.css'
import 'react-device-frameset/styles/device-selector.min.css'

export const App = () => {
    return (
        <DeviceSelector>
            {props => <DeviceFrameset {...props} />}
        </DeviceSelector>
    )
}

If you like the frameset emulator?

type DeviceName = "iPhone X" | "iPhone 8" | "iPhone 8 Plus" | "iPhone 5s" | "iPhone 5c" | "iPhone 4s" | "Galaxy Note 8" | "Nexus 5" | "Lumia 920" | "Samsung Galaxy S5" | "HTC One" | "iPad Mini" | "MacBook Pro"

type DeviceEmulatorProps = {
    banDevices?: DeviceName[]
    children: (props: DeviceFramesetProps) => React.ReactNode,
    value?: DeviceFramesetProps,
    onChange?: (deviceConfig: DeviceFramesetProps) => void, 
}
import { DeviceFrameset, DeviceEmulator } from 'react-device-frameset'
import 'react-device-frameset/styles/marvel-devices.min.css'
import 'react-device-frameset/styles/device-emulator.min.css'

export const App = () => {
    return (
        <DeviceEmulator banDevices={["HTC One"]}>
            {props => <DeviceFrameset {...props} />}
        </DeviceEmulator>
    )
}

react-device-frameset's People

Contributors

dependabot[bot] avatar zheeeng avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

react-device-frameset's Issues

i try to use it but got an errors

ERROR in ../node_modules/react-device-frameset/dist/index.mjs 210:29-40
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 221:28-39
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 230:34-45
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 289:29-41
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 296:33-45
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 306:34-46
Can't import the named export 'useCallback' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 225:2-11
Can't import the named export 'useEffect' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 319:2-12
Can't import the named export 'useEffect' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 414:2-12
Can't import the named export 'useEffect' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 432:2-12
Can't import the named export 'useEffect' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 146:16-23
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 207:22-30
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 209:29-37
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 218:50-58
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 219:21-29
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 229:29-37
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 235:30-38
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 283:22-30
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 285:29-37
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 302:50-58
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 303:21-29
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 305:29-37
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 311:30-38
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 404:16-24
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 409:20-28
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 410:22-30
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 411:25-33
Can't import the named export 'useMemo' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 208:38-46
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 217:34-42
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 220:44-52
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 228:40-48
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 284:38-47
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 295:42-51
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 304:40-49
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 400:37-46
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 401:55-64
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 402:36-45
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 403:44-53
Can't import the named export 'useState' from non EcmaScript module (only default export is available)
ERROR in ../node_modules/react-device-frameset/dist/index.mjs 408:39-48
Can't import the named export 'useState' from non EcmaScript module (only default export is available)

Vercel deployment build failed

When i use the package in my react app created with vite, when i try to build the app in vercel it failed, when i comment the section that i use this package in, it build and everything is fine

Can't import anything from library

First time trying to use the library, when I do import { DeviceFrameset } from 'react-device-frameset';
I get this error on terminal

./node_modules/react-device-frameset/dist/index.mjs
Can't import the named export 'jsx' from non EcmaScript module (only default export is available)

Unclear how to scale size of device frames

I have tried using the width/height props but setting these to any numerical values produces inconsistent scaling, some of the frame scales while other parts do not.

As a workaround I was able to resize the entire frame properly using transform: scale() CSS on the outer wrapper div, but this obviously will leave empty space as transform doesn't cause the layout to reflow.

Any hint how I'm supposed to properly resize with props?

New iPhone models

Great library, thank you!
Will you also add the latest iPhone models in the near future?

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.