Skip to content

Commit

Permalink
Improve prop override support
Browse files Browse the repository at this point in the history
  • Loading branch information
ImAvafe committed Jun 14, 2024
1 parent 293c8c0 commit 31bb91b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 35 deletions.
48 changes: 33 additions & 15 deletions src/Components/ScrollingFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local Fusion = require(OnyxUI.Parent.Fusion)
local Themer = require(OnyxUI.Utils.Themer)
local PubTypes = require(OnyxUI.Utils.PubTypes)
local CombineProps = require(OnyxUI.Utils.CombineProps)
local EnsureValue = require(OnyxUI.Utils.EnsureValue)

local Hydrate = Fusion.Hydrate
local Computed = Fusion.Computed
Expand All @@ -28,34 +29,51 @@ export type Props = Base.Props & {
}

return function(Props: Props)
return Hydrate(Base(CombineProps(Props, {
ClassName = "ScrollingFrame",
Name = "ScrollingFrame",
}))) {
BottomImage = Computed(function()
local BottomImage = EnsureValue(
Props.BottomImage,
"string",
Computed(function()
if Themer.Theme.CornerRadius["1"]:get() >= 3 then
return "rbxassetid://16547643439"
else
return "rbxassetid://16547330984"
end
end),
TopImage = Computed(function()
end)
)
local TopImage = EnsureValue(
Props.TopImage,
"string",
Computed(function()
if Themer.Theme.CornerRadius["1"]:get() >= 3 then
return "rbxassetid://16547667444"
else
return "rbxassetid://16547330984"
end
end),
MidImage = "rbxassetid://16547330984",
end)
)
local MidImage = EnsureValue(Props.MidImage, "string", "rbxassetid://16547330984")
local ScrollBarImageColor3 =
EnsureValue(Props.ScrollBarImageColor3, "Color3", Themer.Theme.Colors.NeutralContent.Dark)
local ScrollBarImageTransparency = EnsureValue(Props.ScrollBarImageTransparency, "number", 0)
local ScrollBarThickness = EnsureValue(Props.ScrollBarThickness, "number", 8)
local AutomaticCanvasSize = EnsureValue(Props.AutomaticCanvasSize, "EnumItem", Enum.AutomaticSize.Y)
local ScrollingDirection = EnsureValue(Props.ScrollingDirection, "EnumItem", Enum.ScrollingDirection.Y)

return Hydrate(Base(CombineProps(Props, {
ClassName = "ScrollingFrame",
Name = "ScrollingFrame",
Selectable = false,
ScrollBarImageColor3 = Themer.Theme.Colors.NeutralContent.Dark,
ScrollBarImageTransparency = 0,
ScrollBarThickness = 8,
BackgroundTransparency = 1,
AutomaticCanvasSize = Enum.AutomaticSize.Y,
ScrollingDirection = Enum.ScrollingDirection.Y,
AutomaticSize = Enum.AutomaticSize.None,

}))) {
BottomImage = BottomImage,
TopImage = TopImage,
MidImage = MidImage,
ScrollBarImageColor3 = ScrollBarImageColor3,
ScrollBarImageTransparency = ScrollBarImageTransparency,
ScrollBarThickness = ScrollBarThickness,
AutomaticCanvasSize = AutomaticCanvasSize,
ScrollingDirection = ScrollingDirection,
CanvasPosition = Props.CanvasPosition,
CanvasSize = Props.CanvasSize,
ElasticBehavior = Props.ElasticBehavior,
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ return function(Props: Props)
ClassName = "TextLabel",
Name = "Text",
AutomaticSize = Enum.AutomaticSize.XY,
ClipsDescendants = false,
BackgroundTransparency = 1,
}))) {
TextColor3 = TextColor3,
TextSize = TextSize,
RichText = RichText,
FontFace = FontFace,
TextWrapped = TextWrapped,
ClipsDescendants = false,
TextXAlignment = TextXAlignment,
TextYAlignment = TextYAlignment,
BackgroundTransparency = 1,

Text = Props.Text,
TextTransparency = Props.TextTransparency,
Expand Down
62 changes: 44 additions & 18 deletions src/Components/TextInput.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export type Props = Base.Props & {
ClearTextOnFocus: PubTypes.CanBeState<boolean>?,
TextWrapped: PubTypes.CanBeState<boolean>?,
MultiLine: PubTypes.CanBeState<boolean>?,
TextSize: PubTypes.CanBeState<number>?,
TextColor3: PubTypes.CanBeState<Color3>?,
FontFace: PubTypes.CanBeState<Font>?,
PlaceholderColor3: PubTypes.CanBeState<Color3>?,
TextXAlignment: PubTypes.CanBeState<Enum.TextXAlignment>?,
TextYAlignment: PubTypes.CanBeState<Enum.TextYAlignment>?,

IsFocused: PubTypes.CanBeState<boolean>?,
OnFocused: PubTypes.CanBeState<() -> ()>?,
OnFocusLost: PubTypes.CanBeState<() -> ()>?,
Expand All @@ -39,6 +46,34 @@ return function(Props: Props)
local CharacterLimit = EnsureValue(Props.CharacterLimit, "number", -1)
local ClearTextOnFocus = EnsureValue(Props.ClearTextOnFocus, "boolean", false)
local PlaceholderText = EnsureValue(Props.PlaceholderText, "string", "")
local TextSize = EnsureValue(Props.TextSize, "number", Themer.Theme.TextSize["1"])
local PlaceholderColor3 = EnsureValue(
Props.PlaceholderColor3,
"Color3",
Computed(function()
if Disabled:get() then
return Themer.Theme.Colors.NeutralContent.Dark:get()
else
return Themer.Theme.Colors.NeutralContent.Light:get()
end
end)
)
local TextColor3 = EnsureValue(
Props.TextColor3,
"Color3",
Computed(function()
return Themer.Theme.Colors.BaseContent.Main:get()
end)
)
local FontFace = EnsureValue(
Props.FontFace,
"Font",
Computed(function()
return Font.new(Themer.Theme.Font.Body:get(), Themer.Theme.FontWeight.Body:get())
end)
)
local TextXAlignment = EnsureValue(Props.TextXAlignment, "EnumItem", Enum.TextXAlignment.Left)
local TextYAlignment = EnsureValue(Props.TextYAlignment, "EnumItem", Enum.TextYAlignment.Top)

local RemainingCharaters = Value(-1)
local IsFocused = EnsureValue(Props.IsFocused, "boolean", false)
Expand Down Expand Up @@ -98,29 +133,20 @@ return function(Props: Props)
[Cleanup] = Observers,
}))) {
Text = Text,
TextColor3 = Computed(function()
return Themer.Theme.Colors.BaseContent.Main:get()
end),
TextSize = Themer.Theme.TextSize["1"],
FontFace = Computed(function()
return Font.new(Themer.Theme.Font.Body:get(), Themer.Theme.FontWeight.Body:get())
end),
PlaceholderColor3 = Computed(function()
if Disabled:get() then
return Themer.Theme.Colors.NeutralContent.Dark:get()
else
return Themer.Theme.Colors.NeutralContent.Light:get()
end
end),
TextColor3 = TextColor3,
TextSize = TextSize,
FontFace = FontFace,
PlaceholderColor3 = PlaceholderColor3,
PlaceholderText = PlaceholderText,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
MultiLine = Props.MultiLine,
TextXAlignment = TextXAlignment,
TextYAlignment = TextYAlignment,
ClearTextOnFocus = ClearTextOnFocus,
MultiLine = Props.MultiLine,
TextWrapped = Props.TextWrapped,

TextEditable = Computed(function()
return not Disabled:get()
end),
TextWrapped = Props.TextWrapped,

[OnEvent "Focused"] = function()
if not Disabled:get() then
Expand Down

0 comments on commit 31bb91b

Please sign in to comment.