Giter Site home page Giter Site logo

react-responsive's Introduction

react-responsive

A responsive utility toolkit for React Lua

Installation

Wally

ReactResponsive = "flipbook-labs/react-responsive@<version>

Usage

ScreenProvider

Should be created at the root of your App

local React = require(React)
local e = React.createElement

local ReactResponsive = require(ReactResponsive)
local ScreenProvider = ReactResponsive.ScreenProvider

local function App()
    local children = {}

    return e(ScreenProvider, {
        --[[
        baseFontSize: number?,
        baseScreenSize: Vector2?,
        breakpoints: { Breakpoint }?,
            How often you want rem, and the current breakpoint
            to update.
        updateInterval: number?,
        ]]
    }, children)
end

useRem

local React = require(React)
local e = React.createElement

local ReactResponsive = require(ReactResponsive)
local useRem = ReactResponsive.useRem

local function MyComponent()
    local rem = useRem()

    return e("Frame", {
        Size = UDim2.fromOffset(rem(10), rem(10))
    })
end

useMediaQuery

local React = require(React)
local e = React.createElement

local ReactResponsive = require(ReactResponsive)
local useMediaQuery = ReactResponsive.useMediaQuery

local function MyComponent()
    local showSideNav = useMediaQuery({
        minBreakpoint = "sm",
        maxBreakpoint = "lg"
    })

    return showSideNav and e(SideNav) or e(TopNav)
end

useBreakpointValue

local React = require(React)
local e = React.createElement

local ReactResponsive = require(ReactResponsive)
local useBreakpointValue = ReactResponsive.useBreakpointValue

local function MyComponent()
    local text = useBreakpointValue({
        lg = "I am a large breakpoint text label",
        xl = "I am an extra large breakpoint text label",
        base = "I am a text label for any breakpoint smaller than large."
    })

    return e("TextLabel", {
        Text = text,
    })
end

react-responsive's People

Contributors

passhley avatar rusty483 avatar

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.