Created
October 31, 2019 17:52
-
-
Save Nimblz/2e7c7f8b4755ae66be1bb85a1579fd72 to your computer and use it in GitHub Desktop.
Wierd component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local common = ReplicatedStorage:WaitForChild("common") | |
local util = common:WaitForChild("util") | |
local lib = ReplicatedStorage:WaitForChild("lib") | |
local component = script:FindFirstAncestor("uiComponents") | |
local Dictionary = require(util:WaitForChild("Dictionary")) | |
local Roact = require(lib:WaitForChild("Roact")) | |
local ScreenScaler = require(component:WaitForChild("ScreenScaler")) | |
local function withScale(kind) | |
return function(props) | |
local children = props[Roact.Children] | |
local prunedProps = Dictionary.join(props, { | |
[Roact.Children] = Dictionary.None, | |
}) | |
local joinedChildren = Dictionary.join(children, { | |
["scaler"] = Roact.createElement(ScreenScaler, ScreenScaler.defaultProps) | |
}) | |
return Roact.createElement(kind, prunedProps, joinedChildren) | |
end | |
end | |
return withScale |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intended usage:
this is so I dont have to do this whenever I want a component that reacts to screen size changes