Skip to content

Commit

Permalink
Expose state props
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAvafe committed Oct 24, 2024
1 parent 1371a85 commit d7c9f94
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Components/Button.luau
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ return function(Scope: Fusion.Scope<any>, Props: Props)
local ContentSize = Util.Fallback(Props.ContentSize, Theme.TextSize["1"])
local ContentWrapped = Util.Fallback(Props.ContentWrapped, false)

local IsHolding = Scope:Value(false)
local IsHovering = Scope:Value(false)
local IsHovering = Scope:EnsureValue(Util.Fallback(Props.IsHovering, false))
local IsHolding = Scope:EnsureValue(Util.Fallback(Props.IsHolding, false))
local EffectiveColor = Scope:Computed(function(Use)
if Use(Disabled) then
return Use(Theme.Colors.BaseContent.Main)
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Checkbox.luau
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ return function(Scope: Fusion.Scope<any>, Props: Props)
local Color = Util.Fallback(Props.Color, Theme.Colors.Primary.Main)
local IconId = Util.Fallback(Props.Icon, "rbxassetid://13858821963")

local IsHovering = Scope:Value(false)
local IsHolding = Scope:Value(false)
local IsHovering = Scope:EnsureValue(Util.Fallback(Props.IsHovering, false))
local IsHolding = Scope:EnsureValue(Util.Fallback(Props.IsHolding, false))
local EffectiveColor = Scope:Computed(function(Use)
if Use(Disabled) then
return Use(Theme.Colors.BaseContent.Main)
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Dropdown.luau
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local Util = require(OnyxUI.Util)
local Themer = require(OnyxUI.Themer)

local OnEvent = Fusion.OnEvent
local Peek = Fusion.peek
local Children = Fusion.Children

local Base = require(OnyxUI.Components.Base)
Expand All @@ -13,13 +12,15 @@ local Components = {
Frame = require(OnyxUI.Components.Frame),
}

export type Props = Base.Props & {}
export type Props = Base.Props & {
Open: Fusion.UsedAs<boolean>?,
}

return function(Scope: Fusion.Scope<any>, Props: Props)
local Scope = Fusion.innerScope(Scope, Fusion, Components, Util)
local Theme = Themer.Theme:now()

local Open = Scope:Value(false)
local Open = Scope:EnsureValue(Util.Fallback(Props.Open, false))

return Scope:Hydrate(Scope:TextInput(Util.CombineProps(Props, {
Name = script.Name,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/MenuFrame.luau
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ return function(Scope: Fusion.Scope<any>, Props: Props)
local Scope = InnerScope(Scope, Fusion, Util, Components)
local Theme = Themer.Theme:now()

local AutomaticSize = Scope:Value(Enum.AutomaticSize.None)
local AutomaticSize = Scope:EnsureValue(Util.Fallback(Props.AutomaticSize, Enum.AutomaticSize.None))

return Scope:Group(Util.CombineProps(Props, {
Name = "MenuFrame",
Expand Down
11 changes: 5 additions & 6 deletions src/Components/SwitchInput.luau
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ local Components = {
BaseButton = BaseButton,
}

export type Props = Frame.Props & {
export type Props = BaseButton.Props & {
Switched: Fusion.UsedAs<boolean>?,
Disabled: Fusion.UsedAs<boolean>?,
Color: Fusion.UsedAs<Color3>?,
}

--[=[
@within SwitchInput
@interface SwitchInputProps
@field ... FrameProps
@field ... BaseButtonProps
@field Switched Fusion.UsedAs<boolean>?
@field Disabled Fusion.UsedAs<boolean>?
@field Color Fusion.UsedAs<Color3>?
Expand All @@ -42,7 +41,7 @@ return function(Scope: Fusion.Scope<any>, Props: Props)
local Theme = Themer.Theme:now()

local Switched = Scope:EnsureValue(Util.Fallback(Props.Switched, false))
local Disabled = Util.Fallback(Props.Disabled, false)
local Disabled = Scope:EnsureValue(Util.Fallback(Props.Disabled, false))
local Color = Util.Fallback(Props.Color, Theme.Colors.Primary.Main)
local Size = Util.Fallback(
Props.Size,
Expand All @@ -52,8 +51,8 @@ return function(Scope: Fusion.Scope<any>, Props: Props)
)
local AutomaticSize = Util.Fallback(Props.AutomaticSize, Enum.AutomaticSize.None)

local IsHolding = Scope:Value(false)
local IsHovering = Scope:Value(false)
local IsHovering = Scope:EnsureValue(Util.Fallback(Props.IsHovering, false))
local IsHolding = Scope:EnsureValue(Util.Fallback(Props.IsHolding, false))
local EffectiveColor = Scope:Computed(function(Use)
local ActiveColor
if Use(Switched) then
Expand Down

0 comments on commit d7c9f94

Please sign in to comment.