forked from rojo-rbx/rojo
plugin: Migrate 'merge' utility into Dictionary module
This commit is contained in:
@@ -1,23 +1,9 @@
|
|||||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||||
|
|
||||||
|
local Dictionary = require(script.Parent.Parent.Dictionary)
|
||||||
|
|
||||||
local e = Roact.createElement
|
local e = Roact.createElement
|
||||||
|
|
||||||
local function merge(...)
|
|
||||||
local output = {}
|
|
||||||
|
|
||||||
for i = 1, select("#", ...) do
|
|
||||||
local source = select(i, ...)
|
|
||||||
|
|
||||||
if source ~= nil then
|
|
||||||
for key, value in pairs(source) do
|
|
||||||
output[key] = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return output
|
|
||||||
end
|
|
||||||
|
|
||||||
local FitList = Roact.Component:extend("FitList")
|
local FitList = Roact.Component:extend("FitList")
|
||||||
|
|
||||||
function FitList:init()
|
function FitList:init()
|
||||||
@@ -34,8 +20,8 @@ function FitList:render()
|
|||||||
padding = e("UIPadding", paddingProps)
|
padding = e("UIPadding", paddingProps)
|
||||||
end
|
end
|
||||||
|
|
||||||
local children = merge(self.props[Roact.Children], {
|
local children = Dictionary.merge(self.props[Roact.Children], {
|
||||||
["$Layout"] = e("UIListLayout", merge({
|
["$Layout"] = e("UIListLayout", Dictionary.merge({
|
||||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||||
[Roact.Change.AbsoluteContentSize] = function(instance)
|
[Roact.Change.AbsoluteContentSize] = function(instance)
|
||||||
local size = instance.AbsoluteContentSize
|
local size = instance.AbsoluteContentSize
|
||||||
@@ -53,7 +39,7 @@ function FitList:render()
|
|||||||
["$Padding"] = padding,
|
["$Padding"] = padding,
|
||||||
})
|
})
|
||||||
|
|
||||||
local fullContainerProps = merge(containerProps, {
|
local fullContainerProps = Dictionary.merge(containerProps, {
|
||||||
Size = self.sizeBinding,
|
Size = self.sizeBinding,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,29 +2,10 @@ local TextService = game:GetService("TextService")
|
|||||||
|
|
||||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||||
|
|
||||||
|
local Dictionary = require(script.Parent.Parent.Dictionary)
|
||||||
|
|
||||||
local e = Roact.createElement
|
local e = Roact.createElement
|
||||||
|
|
||||||
local None = newproxy(false)
|
|
||||||
local function merge(...)
|
|
||||||
local output = {}
|
|
||||||
|
|
||||||
for i = 1, select("#", ...) do
|
|
||||||
local source = select(i, ...)
|
|
||||||
|
|
||||||
if source ~= nil then
|
|
||||||
for key, value in pairs(source) do
|
|
||||||
if value == None then
|
|
||||||
output[key] = nil
|
|
||||||
else
|
|
||||||
output[key] = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return output
|
|
||||||
end
|
|
||||||
|
|
||||||
local FitText = Roact.Component:extend("FitText")
|
local FitText = Roact.Component:extend("FitText")
|
||||||
|
|
||||||
function FitText:init()
|
function FitText:init()
|
||||||
@@ -34,9 +15,9 @@ end
|
|||||||
function FitText:render()
|
function FitText:render()
|
||||||
local kind = self.props.Kind
|
local kind = self.props.Kind
|
||||||
|
|
||||||
local containerProps = merge(self.props, {
|
local containerProps = Dictionary.merge(self.props, {
|
||||||
Kind = None,
|
Kind = Dictionary.None,
|
||||||
Padding = None,
|
Padding = Dictionary.None,
|
||||||
Size = self.sizeBinding
|
Size = self.sizeBinding
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
33
plugin/src/Dictionary.lua
Normal file
33
plugin/src/Dictionary.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
--[[
|
||||||
|
This is a placeholder module waiting for Cryo to become available.
|
||||||
|
]]
|
||||||
|
|
||||||
|
local None = newproxy(true)
|
||||||
|
getmetatable(None).__tostring = function()
|
||||||
|
return "None"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function merge(...)
|
||||||
|
local output = {}
|
||||||
|
|
||||||
|
for i = 1, select("#", ...) do
|
||||||
|
local source = select(i, ...)
|
||||||
|
|
||||||
|
if source ~= nil then
|
||||||
|
for key, value in pairs(source) do
|
||||||
|
if value == None then
|
||||||
|
output[key] = nil
|
||||||
|
else
|
||||||
|
output[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
None = None,
|
||||||
|
merge = merge,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user