From 40c01a0e0834daeedfc9052e55e115c521216f1a Mon Sep 17 00:00:00 2001 From: Nightcycle <77173389+nightcycle@users.noreply.github.com> Date: Sat, 24 Feb 2024 02:39:59 -0300 Subject: [PATCH] More slider functionality --- src/Component/Slider/cfusion.story.luau | 72 ++++++++- src/Component/Slider/init.luau | 200 +++++++++++++++++++----- 2 files changed, 236 insertions(+), 36 deletions(-) diff --git a/src/Component/Slider/cfusion.story.luau b/src/Component/Slider/cfusion.story.luau index ff20611c..a86b508e 100644 --- a/src/Component/Slider/cfusion.story.luau +++ b/src/Component/Slider/cfusion.story.luau @@ -38,6 +38,9 @@ return function(frame: Frame) do local button = maid:GiveTask( Module.ColdFusion.new( + function(val: number) + print(`value={val}`) + end, 50, 0, 100, @@ -55,7 +58,74 @@ return function(frame: Frame) button.Parent = halfFrame end - + do + local button = maid:GiveTask( + Module.ColdFusion.new( + function(val: number) + print(`value={val}`) + end, + 50, + 0, + 100, + 10, + "Low", + "High", + style:GetColor(Enums.ColorRoleType.OnSurface), + style:GetColor(Enums.ColorRoleType.Surface), + style:GetColor(Enums.ColorRoleType.Primary), + style:GetColor(Enums.ColorRoleType.PrimaryContainer), + 1, + style + ) + ) + button.Parent = halfFrame + end + + do + local button = maid:GiveTask( + Module.ColdFusion.new( + function(val: number) + print(`value={val}`) + end, + 50, + 0, + 100, + 10, + Icons.remove, + Icons.add, + style:GetColor(Enums.ColorRoleType.OnSurface), + style:GetColor(Enums.ColorRoleType.Surface), + style:GetColor(Enums.ColorRoleType.Primary), + style:GetColor(Enums.ColorRoleType.PrimaryContainer), + 1, + style + ) + ) + button.Parent = halfFrame + end + + do + local button = maid:GiveTask( + Module.ColdFusion.new( + function(val: number) + print(`value={val}`) + end, + 50, + 0, + 100, + nil, + nil, + nil, + style:GetColor(Enums.ColorRoleType.OnSurface), + style:GetColor(Enums.ColorRoleType.Surface), + style:GetColor(Enums.ColorRoleType.Primary), + style:GetColor(Enums.ColorRoleType.PrimaryContainer), + 1, + style + ) + ) + button.Parent = halfFrame + end return halfFrame end diff --git a/src/Component/Slider/init.luau b/src/Component/Slider/init.luau index b9a22e69..9b23fc7a 100644 --- a/src/Component/Slider/init.luau +++ b/src/Component/Slider/init.luau @@ -11,6 +11,7 @@ local ColdFusion = require(_Packages:WaitForChild("ColdFusion")) local Types = require(_Package:WaitForChild("Types")) local Style = require(_Package:WaitForChild("Style")) local Util = require(_Package:WaitForChild("Util")) +local Enums = require(_Package:WaitForChild("Enums")) -- Types type Maid = Maid.Maid @@ -57,13 +58,14 @@ Interface.ColdFusion = {} function Interface.ColdFusion.new( + onChange: CanBeState<(onChange: number) -> ()>, initialValue: CanBeState, minimum: CanBeState, maximum: CanBeState, increment: CanBeState, - leftIcon: CanBeState, - rightIcon: CanBeState, + leftTextOrIcon: CanBeState, + rightTextOrIcon: CanBeState, onBackgroundColor: CanBeState, onBackgroundTextColor: CanBeState, @@ -86,11 +88,16 @@ function Interface.ColdFusion.new( local _Computed = _fuse.Computed local styleState: State