Skip to content

Commit

Permalink
Fixed density for default search component options
Browse files Browse the repository at this point in the history
  • Loading branch information
nightcycle committed Jul 15, 2024
1 parent 044b08f commit 962b775
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
26 changes: 19 additions & 7 deletions src/Component/Search/Base.luau
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function newPanel(
scaleState
)
)({
Name = "BackButton",
LayoutOrder = 1,
}) :: GuiObject

Expand All @@ -169,6 +170,7 @@ function newPanel(
scaleState
)
)({
Name = "ClearButton",
LayoutOrder = 3,
}) :: GuiObject

Expand Down Expand Up @@ -227,6 +229,7 @@ function newPanel(
end)

local inst = _bind(Util.PopUp.ColdFusion.new(absolutePositionState, Vector2.zero))({
Name = "SearchMenu",
BackgroundColor3 = _Computed(function(st: Enums.SchemeType, bC: Color3, e: number): Color3
return Theme.getElevatedColor(bC, e, st)
end, schemeTypeState, backgroundColorState, elevationState),
Expand All @@ -235,10 +238,11 @@ function newPanel(
Children = {
_new("UICorner")({
CornerRadius = _Computed(function(sc: number): UDim
return UDim.new(0, sc * CORNER_DP)
return UDim.new(0, math.round(sc * CORNER_DP))
end, scaleState),
}),
_new("Frame")({
Name = "InputContainer",
LayoutOrder = 1,
BackgroundTransparency = 1,
AutomaticSize = Enum.AutomaticSize.None,
Expand Down Expand Up @@ -268,6 +272,7 @@ function newPanel(
)
),
_bind(maid:GiveTask(Util.Container.ColdFusion.new()))({
Name = "BackButtonContainer",
LayoutOrder = 1,
Children = {
_new("UIScale")({
Expand All @@ -279,6 +284,7 @@ function newPanel(
}),
-- backButton,
_bind(maid:GiveTask(Util.Container.ColdFusion.new()))({
Name = "ClearButtonContainer",
LayoutOrder = 2,
Children = {
_new("UIScale")({
Expand Down Expand Up @@ -321,7 +327,7 @@ end
-- Class
local Base = {}

function Base.newBar(
function Base.new(
isFilled: boolean,
onInputEntered: CanBeState<(input: string) -> string>,
label: CanBeState<string?>,
Expand Down Expand Up @@ -363,7 +369,7 @@ function Base.newBar(
end, elevationState)
local backgroundColorState: State<Color3> = _import(backgroundColor, Color3.new())

local function newLabel(key: string, onClick: (key: string) -> ()): GuiObject
local function newDefaultOption(key: string, onClick: (key: string) -> ()): GuiObject
local labelMaid = Maid.new()
local fuse = ColdFusion.fuse(labelMaid)

Expand All @@ -386,6 +392,7 @@ function Base.newBar(
local isHoveredState = fuse.Value(false)

local out = fuse.new("TextButton")({
Name = "OptionButton",
Text = key,
AutomaticSize = Enum.AutomaticSize.Y,
TextXAlignment = Enum.TextXAlignment.Left,
Expand Down Expand Up @@ -427,9 +434,14 @@ function Base.newBar(
return UDim.new(0, sc * PADDING_DP)
end, scaleState),
_Computed(function(sc: number): UDim
return UDim.new(0, sc * PADDING_DP * 0.25)
return UDim.new(0, sc * PADDING_DP * 0.75)
end, scaleState)
)),
)) :: Instance,
_new("UICorner")({
CornerRadius = _Computed(function(sc: number): UDim
return UDim.new(0, math.round(sc * CORNER_DP))
end, scaleState),
}),
},
}) :: TextButton

Expand All @@ -443,7 +455,7 @@ function Base.newBar(
local optionSolverState = _import(optionSolver, function(input: string): { string }
return {}
end)
local optionConstructorState: State<OptionConstructor> = _import(optionConstructor, newLabel)
local optionConstructorState: State<OptionConstructor> = _import(optionConstructor, newDefaultOption)
local labelState: State<string> = _import(label, "Search")
local inputState = _Value("")
local buttonTextState = _Computed(function(l: string, i: string): string
Expand Down Expand Up @@ -708,7 +720,7 @@ function Base.newBar(
end)

button = _new("TextButton")({
Name = "TextButton",
Name = "Search",
Text = "",
BackgroundTransparency = _Computed(function(renderData: RenderData): number
if renderData.Shadow then
Expand Down
14 changes: 7 additions & 7 deletions src/Component/Search/Filled/ColdFusion.luau
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Interface.tertiaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.TERTIARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.TERTIARY_CONTAINER.ELEVATION or 0)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.TERTIARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.TERTIARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -110,7 +110,7 @@ function Interface.tertiary(
local styleState: State<Style> = _import(style, DEFAULTS.TERTIARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.TERTIARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.TERTIARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.TERTIARY.LABEL),
Expand Down Expand Up @@ -162,7 +162,7 @@ function Interface.secondaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.SECONDARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.SECONDARY_CONTAINER.ELEVATION)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.SECONDARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.SECONDARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -214,7 +214,7 @@ function Interface.secondary(
local styleState: State<Style> = _import(style, DEFAULTS.SECONDARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.SECONDARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.SECONDARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.SECONDARY.LABEL),
Expand Down Expand Up @@ -266,7 +266,7 @@ function Interface.primaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.PRIMARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.PRIMARY_CONTAINER.ELEVATION)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.PRIMARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.PRIMARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -318,7 +318,7 @@ function Interface.primary(
local styleState: State<Style> = _import(style, DEFAULTS.PRIMARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.PRIMARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
true,
_import(onInputEntered, DEFAULTS.PRIMARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.PRIMARY.LABEL),
Expand Down Expand Up @@ -360,7 +360,7 @@ function Interface.new(
fontData: CanBeState<FontData>,
scale: CanBeState<number>
): GuiObject
return Base.newBar(
return Base.new(
true,
if onInputEntered ~= nil then onInputEntered else DEFAULTS.NEW.ON_INPUT_ENTERED,
if label ~= nil then label else DEFAULTS.NEW.LABEL,
Expand Down
14 changes: 7 additions & 7 deletions src/Component/Search/Text/ColdFusion.luau
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Interface.onTertiaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.ON_TERTIARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_TERTIARY_CONTAINER.ELEVATION or 0)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_TERTIARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_TERTIARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -111,7 +111,7 @@ function Interface.onTertiary(
local styleState: State<Style> = _import(style, DEFAULTS.ON_TERTIARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_TERTIARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_TERTIARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_TERTIARY.LABEL),
Expand Down Expand Up @@ -163,7 +163,7 @@ function Interface.onSecondaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.ON_SECONDARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_SECONDARY_CONTAINER.ELEVATION)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_SECONDARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_SECONDARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -215,7 +215,7 @@ function Interface.onSecondary(
local styleState: State<Style> = _import(style, DEFAULTS.ON_SECONDARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_SECONDARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_SECONDARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_SECONDARY.LABEL),
Expand Down Expand Up @@ -266,7 +266,7 @@ function Interface.onPrimaryContainer(
local styleState: State<Style> = _import(style, DEFAULTS.ON_PRIMARY_CONTAINER.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_PRIMARY_CONTAINER.ELEVATION)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_PRIMARY_CONTAINER.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_PRIMARY_CONTAINER.LABEL),
Expand Down Expand Up @@ -318,7 +318,7 @@ function Interface.onPrimary(
local styleState: State<Style> = _import(style, DEFAULTS.ON_PRIMARY.STYLE)
local elevationState = _import(elevation, DEFAULTS.ON_PRIMARY.ELEVATION)

local out = Base.newBar(
local out = Base.new(
false,
_import(onInputEntered, DEFAULTS.ON_PRIMARY.ON_INPUT_ENTERED),
_import(label, DEFAULTS.ON_PRIMARY.LABEL),
Expand Down Expand Up @@ -360,7 +360,7 @@ function Interface.new(
fontData: CanBeState<FontData>,
scale: CanBeState<number>
): GuiObject
return Base.newBar(
return Base.new(
false,
if onInputEntered ~= nil then onInputEntered else DEFAULTS.NEW.ON_INPUT_ENTERED,
if label ~= nil then label else DEFAULTS.NEW.LABEL,
Expand Down

0 comments on commit 962b775

Please sign in to comment.