Created
July 11, 2023 19:31
-
-
Save Fizzyhex/8d5a2c490b7720fa90c5cab48fe28ae0 to your computer and use it in GitHub Desktop.
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 Fusion = require(ReplicatedStorage.Fusion) | |
local Observer = Fusion.Observer | |
local Computed = Fusion.Computed | |
local Value = Fusion.Value | |
local New = Fusion.New | |
local Children = Fusion.Children | |
local function ProgressSquare(props) | |
return New "Frame" { | |
Size = UDim2.fromOffset(50, 50), | |
BackgroundColor3 = Computed(function() | |
return if props.IsHighlighted:get() then Color3.fromRGB(0, 255, 0) else Color3.fromRGB(255, 255, 255) | |
end) | |
} | |
end | |
local function ProgressBar(props) | |
local barCount = props.BarCount | |
local currentLevel = props.CurrentLevel | |
return New "Frame" { | |
Parent = props.Parent, | |
BackgroundTransparency = 1, | |
AutomaticSize = Enum.AutomaticSize.XY, | |
[Children] = { | |
New "UIListLayout" { | |
SortOrder = Enum.SortOrder.LayoutOrder, | |
FillDirection = Enum.FillDirection.Horizontal, | |
Padding = UDim.new(0, 8) | |
}, | |
Computed(function() | |
local bars = {} | |
for i = 1, barCount do | |
table.insert(bars, ProgressSquare({ | |
IsHighlighted = Computed(function() | |
return i <= currentLevel:get() | |
end) | |
})) | |
end | |
return bars | |
end, Fusion.cleanup) | |
} | |
} | |
end | |
return function(target) | |
local ui = ProgressBar { | |
Parent = target, | |
BarCount = 10, | |
CurrentLevel = Value(3) | |
} | |
return function() | |
ui:Destroy() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment