Skip to content

Instantly share code, notes, and snippets.

@Fizzyhex
Last active September 8, 2023 15:12
Show Gist options
  • Save Fizzyhex/f7af220dc6a40d469ab941f3a796f40e to your computer and use it in GitHub Desktop.
Save Fizzyhex/f7af220dc6a40d469ab941f3a796f40e to your computer and use it in GitHub Desktop.
Text with image support test (Fusion v0.2)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Fusion = require(ReplicatedStorage.Fusion)
local New = Fusion.New
local ForPairs = Fusion.ForPairs
local Children = Fusion.Children
local Computed = Fusion.Computed
local Value = Fusion.Value
local function ImageText(props)
local textSize = props.TextSize or 20
local textBounds = Value(props.TextSize or 0)
return New "Frame" {
Name = "Container",
BackgroundTransparency = 1,
AutomaticSize = Enum.AutomaticSize.XY,
ClipsDescendants = true,
Parent = props.Parent,
[Children] = {
New "UIListLayout" {
FillDirection = Enum.FillDirection.Horizontal,
SortOrder = Enum.SortOrder.LayoutOrder,
},
ForPairs(props.Content, function(index, value)
if typeof(value) == "table" then
return index, New "ImageLabel" {
LayoutOrder = index,
BackgroundTransparency = 1,
Image = value[1],
Size = UDim2.fromOffset(textSize, textSize),
}
else
return index, New "TextLabel" {
LayoutOrder = index,
TextColor3 = props.TextColor,
BackgroundTransparency = 1,
AutomaticSize = Enum.AutomaticSize.XY,
TextSize = textSize,
Text = value
}
end
end, Fusion.cleanup)
}
}
end
return function(target)
local ui = ImageText {
Parent = target,
TextColor = Color3.new(1, 1, 1),
TextSize = 40,
Content = Value({"This robux icon ", { "rbxassetid://11560341824" }, " is followed by text!" })
}
return function()
ui:Destroy()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment