diff --git a/plugin/src/Components/FitList.lua b/plugin/src/Components/FitList.lua index d7a1c8c0..4aa49cb9 100644 --- a/plugin/src/Components/FitList.lua +++ b/plugin/src/Components/FitList.lua @@ -1,23 +1,9 @@ local Roact = require(script:FindFirstAncestor("Rojo").Roact) +local Dictionary = require(script.Parent.Parent.Dictionary) + 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") function FitList:init() @@ -34,8 +20,8 @@ function FitList:render() padding = e("UIPadding", paddingProps) end - local children = merge(self.props[Roact.Children], { - ["$Layout"] = e("UIListLayout", merge({ + local children = Dictionary.merge(self.props[Roact.Children], { + ["$Layout"] = e("UIListLayout", Dictionary.merge({ SortOrder = Enum.SortOrder.LayoutOrder, [Roact.Change.AbsoluteContentSize] = function(instance) local size = instance.AbsoluteContentSize @@ -53,7 +39,7 @@ function FitList:render() ["$Padding"] = padding, }) - local fullContainerProps = merge(containerProps, { + local fullContainerProps = Dictionary.merge(containerProps, { Size = self.sizeBinding, }) diff --git a/plugin/src/Components/FitText.lua b/plugin/src/Components/FitText.lua index 76524e03..2ec0b51b 100644 --- a/plugin/src/Components/FitText.lua +++ b/plugin/src/Components/FitText.lua @@ -2,29 +2,10 @@ local TextService = game:GetService("TextService") local Roact = require(script:FindFirstAncestor("Rojo").Roact) +local Dictionary = require(script.Parent.Parent.Dictionary) + 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") function FitText:init() @@ -34,9 +15,9 @@ end function FitText:render() local kind = self.props.Kind - local containerProps = merge(self.props, { - Kind = None, - Padding = None, + local containerProps = Dictionary.merge(self.props, { + Kind = Dictionary.None, + Padding = Dictionary.None, Size = self.sizeBinding }) diff --git a/plugin/src/Dictionary.lua b/plugin/src/Dictionary.lua new file mode 100644 index 00000000..c4b1e532 --- /dev/null +++ b/plugin/src/Dictionary.lua @@ -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, +} \ No newline at end of file