forked from rojo-rbx/rojo
Factor out form text input
This commit is contained in:
@@ -9,6 +9,7 @@ local Assets = require(Plugin.Assets)
|
|||||||
local FitList = require(Plugin.Components.FitList)
|
local FitList = require(Plugin.Components.FitList)
|
||||||
local FitText = require(Plugin.Components.FitText)
|
local FitText = require(Plugin.Components.FitText)
|
||||||
local FormButton = require(Plugin.Components.FormButton)
|
local FormButton = require(Plugin.Components.FormButton)
|
||||||
|
local FormTextInput = require(Plugin.Components.FormTextInput)
|
||||||
|
|
||||||
local WhiteCross = Assets.Sprites.WhiteCross
|
local WhiteCross = Assets.Sprites.WhiteCross
|
||||||
local GrayBox = Assets.Slices.GrayBox
|
local GrayBox = Assets.Slices.GrayBox
|
||||||
@@ -153,34 +154,15 @@ function ConnectPanel:render()
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
InputOuter = e("ImageLabel", {
|
Input = e(FormTextInput, {
|
||||||
LayoutOrder = 2,
|
layoutOrder = 2,
|
||||||
Image = GrayBox.asset,
|
size = UDim2.new(0, 300, 0, 24),
|
||||||
ImageRectOffset = GrayBox.offset,
|
value = self.state.address,
|
||||||
ImageRectSize = GrayBox.size,
|
onValueChange = function(newValue)
|
||||||
ScaleType = Enum.ScaleType.Slice,
|
self:setState({
|
||||||
SliceCenter = GrayBox.center,
|
address = newValue,
|
||||||
Size = UDim2.new(0, 300, 0, 24),
|
})
|
||||||
BackgroundTransparency = 1,
|
end,
|
||||||
}, {
|
|
||||||
InputInner = e("TextBox", {
|
|
||||||
BackgroundTransparency = 1,
|
|
||||||
Size = UDim2.new(1, -8, 1, -8),
|
|
||||||
Position = UDim2.new(0.5, 0, 0.5, 0),
|
|
||||||
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
||||||
Font = Enum.Font.SourceSans,
|
|
||||||
ClearTextOnFocus = false,
|
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
|
||||||
TextSize = FORM_TEXT_SIZE,
|
|
||||||
Text = self.state.address,
|
|
||||||
TextColor3 = TEXT_COLOR,
|
|
||||||
|
|
||||||
[Roact.Change.Text] = function(rbx)
|
|
||||||
self:setState({
|
|
||||||
address = rbx.Text,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -214,34 +196,15 @@ function ConnectPanel:render()
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
InputOuter = e("ImageLabel", {
|
Input = e(FormTextInput, {
|
||||||
LayoutOrder = 2,
|
layoutOrder = 2,
|
||||||
Image = GrayBox.asset,
|
size = UDim2.new(0, 300, 0, 24),
|
||||||
ImageRectOffset = GrayBox.offset,
|
value = self.state.port,
|
||||||
ImageRectSize = GrayBox.size,
|
onValueChange = function(newValue)
|
||||||
ScaleType = Enum.ScaleType.Slice,
|
self:setState({
|
||||||
SliceCenter = GrayBox.center,
|
port = newValue,
|
||||||
Size = UDim2.new(0, 300, 0, 24),
|
})
|
||||||
BackgroundTransparency = 1,
|
end,
|
||||||
}, {
|
|
||||||
InputInner = e("TextBox", {
|
|
||||||
BackgroundTransparency = 1,
|
|
||||||
Size = UDim2.new(1, -8, 1, -8),
|
|
||||||
Position = UDim2.new(0.5, 0, 0.5, 0),
|
|
||||||
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
||||||
Font = Enum.Font.SourceSans,
|
|
||||||
ClearTextOnFocus = false,
|
|
||||||
TextXAlignment = Enum.TextXAlignment.Left,
|
|
||||||
TextSize = FORM_TEXT_SIZE,
|
|
||||||
Text = self.state.port,
|
|
||||||
TextColor3 = TEXT_COLOR,
|
|
||||||
|
|
||||||
[Roact.Change.Text] = function(rbx)
|
|
||||||
self:setState({
|
|
||||||
port = rbx.Text,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
47
plugin/src/Components/FormTextInput.lua
Normal file
47
plugin/src/Components/FormTextInput.lua
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
local Rojo = script:FindFirstAncestor("Rojo")
|
||||||
|
local Plugin = Rojo.Plugin
|
||||||
|
|
||||||
|
local Roact = require(Rojo.Roact)
|
||||||
|
|
||||||
|
local Assets = require(Plugin.Assets)
|
||||||
|
|
||||||
|
local e = Roact.createElement
|
||||||
|
|
||||||
|
local GrayBox = Assets.Slices.GrayBox
|
||||||
|
|
||||||
|
local function FormTextInput(props)
|
||||||
|
local value = props.value
|
||||||
|
local onValueChange = props.onValueChange
|
||||||
|
local layoutOrder = props.layoutOrder
|
||||||
|
local size = props.size
|
||||||
|
|
||||||
|
return e("ImageLabel", {
|
||||||
|
LayoutOrder = layoutOrder,
|
||||||
|
Image = GrayBox.asset,
|
||||||
|
ImageRectOffset = GrayBox.offset,
|
||||||
|
ImageRectSize = GrayBox.size,
|
||||||
|
ScaleType = Enum.ScaleType.Slice,
|
||||||
|
SliceCenter = GrayBox.center,
|
||||||
|
Size = size,
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
}, {
|
||||||
|
InputInner = e("TextBox", {
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
Size = UDim2.new(1, -8, 1, -8),
|
||||||
|
Position = UDim2.new(0.5, 0, 0.5, 0),
|
||||||
|
AnchorPoint = Vector2.new(0.5, 0.5),
|
||||||
|
Font = Enum.Font.SourceSans,
|
||||||
|
ClearTextOnFocus = false,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextSize = 20,
|
||||||
|
Text = value,
|
||||||
|
TextColor3 = Color3.new(0.05, 0.05, 0.05),
|
||||||
|
|
||||||
|
[Roact.Change.Text] = function(rbx)
|
||||||
|
onValueChange(rbx.Text)
|
||||||
|
end,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return FormTextInput
|
||||||
Reference in New Issue
Block a user