forked from rojo-rbx/rojo
* Add Flipper * Remove old UI * Add boilerplate UI * Change plugin version * Merge upstream * Bunch of new UI changes Too lazy to list them all in individual commits * Touch ripple for buttons and a few other things * Make the close button on the PluginGui work * Set button state to guiEnabled * Implement Connecting, NotConnected; add Header; don't update plugin button on render * Replace mapLerpColor with mapLerp * Update blendAlpha to be 0 without any values * Add ActionFillTransparency to Theme.Button * Suffix all Theme entries * Update Flipper * Add disconnect button * Remove cancel button * Add settings page * Add scrollbar and dark theme support to settings * Include settings in startSession * Set context default value to nil I always thought this was the name, lol... * Add Error page * Fix preloadAssets * Fix preloadAssets import * Update checkbox colors a little * Add setting descriptions * Fix scrolling frame in settings panel * Remove .vscode * Rename Throbber to Spinner * Update merge * Move Spinner images to assets * Change casing of directories * Remove old directories * Add comments to getDerivedStateFromProps * Account for offset in host TextBox size * Turn width variables into constants * Attempt to fix the comments * Add a missing comma in Settings * Remove a double space * Remove Dummy object * Move most of the Studio logic out of render * Don't truncate port input * Replace merge with Dictionary.merge * Replace "Got it!" with "Okay" * Add projectName to setStatus call * Add Flipper to build.rs
137 lines
3.6 KiB
Lua
137 lines
3.6 KiB
Lua
local TextService = game:GetService("TextService")
|
|
|
|
local Rojo = script:FindFirstAncestor("Rojo")
|
|
local Plugin = Rojo.Plugin
|
|
|
|
local Roact = require(Rojo.Roact)
|
|
local Flipper = require(Rojo.Flipper)
|
|
|
|
local Theme = require(Plugin.App.Theme)
|
|
local Assets = require(Plugin.Assets)
|
|
local bindingUtil = require(Plugin.App.bindingUtil)
|
|
|
|
local SlicedImage = require(script.Parent.SlicedImage)
|
|
local TouchRipple = require(script.Parent.TouchRipple)
|
|
|
|
local SPRING_PROPS = {
|
|
frequency = 5,
|
|
dampingRatio = 1,
|
|
}
|
|
|
|
local e = Roact.createElement
|
|
|
|
local TextButton = Roact.Component:extend("TextButton")
|
|
|
|
function TextButton:init()
|
|
self.motor = Flipper.GroupMotor.new({
|
|
hover = 0,
|
|
enabled = self.props.enabled and 1 or 0,
|
|
})
|
|
self.binding = bindingUtil.fromMotor(self.motor)
|
|
end
|
|
|
|
function TextButton:didUpdate(lastProps)
|
|
if lastProps.enabled ~= self.props.enabled then
|
|
self.motor:setGoal({
|
|
enabled = Flipper.Spring.new(self.props.enabled and 1 or 0),
|
|
})
|
|
end
|
|
end
|
|
|
|
function TextButton:render()
|
|
return Theme.with(function(theme)
|
|
local textSize = TextService:GetTextSize(
|
|
self.props.text, 18, Enum.Font.GothamSemibold,
|
|
Vector2.new(math.huge, math.huge)
|
|
)
|
|
|
|
local style = self.props.style
|
|
|
|
theme = theme.Button[style]
|
|
|
|
local bindingHover = bindingUtil.deriveProperty(self.binding, "hover")
|
|
local bindingEnabled = bindingUtil.deriveProperty(self.binding, "enabled")
|
|
|
|
return e("ImageButton", {
|
|
Size = UDim2.new(0, 15 + textSize.X + 15, 0, 34),
|
|
Position = self.props.position,
|
|
AnchorPoint = self.props.anchorPoint,
|
|
|
|
LayoutOrder = self.props.layoutOrder,
|
|
BackgroundTransparency = 1,
|
|
|
|
[Roact.Event.Activated] = self.props.onClick,
|
|
|
|
[Roact.Event.MouseEnter] = function()
|
|
self.motor:setGoal({
|
|
hover = Flipper.Spring.new(1, SPRING_PROPS),
|
|
})
|
|
end,
|
|
|
|
[Roact.Event.MouseLeave] = function()
|
|
self.motor:setGoal({
|
|
hover = Flipper.Spring.new(0, SPRING_PROPS),
|
|
})
|
|
end,
|
|
}, {
|
|
TouchRipple = e(TouchRipple, {
|
|
color = theme.ActionFillColor,
|
|
transparency = self.props.transparency:map(function(value)
|
|
return bindingUtil.blendAlpha({ theme.ActionFillTransparency, value })
|
|
end),
|
|
zIndex = 2,
|
|
}),
|
|
|
|
Text = e("TextLabel", {
|
|
Text = self.props.text,
|
|
Font = Enum.Font.GothamSemibold,
|
|
TextSize = 18,
|
|
TextColor3 = bindingUtil.mapLerp(bindingEnabled, theme.Enabled.TextColor, theme.Disabled.TextColor),
|
|
TextTransparency = self.props.transparency,
|
|
|
|
Size = UDim2.new(1, 0, 1, 0),
|
|
|
|
BackgroundTransparency = 1,
|
|
}),
|
|
|
|
Border = style == "Bordered" and e(SlicedImage, {
|
|
slice = Assets.Slices.RoundedBorder,
|
|
color = bindingUtil.mapLerp(bindingEnabled, theme.Enabled.BorderColor, theme.Disabled.BorderColor),
|
|
transparency = self.props.transparency,
|
|
|
|
size = UDim2.new(1, 0, 1, 0),
|
|
|
|
zIndex = 0,
|
|
}),
|
|
|
|
HoverOverlay = e(SlicedImage, {
|
|
slice = Assets.Slices.RoundedBackground,
|
|
color = theme.ActionFillColor,
|
|
transparency = Roact.joinBindings({
|
|
hover = bindingHover:map(function(value)
|
|
return 1 - value
|
|
end),
|
|
transparency = self.props.transparency,
|
|
}):map(function(values)
|
|
return bindingUtil.blendAlpha({ theme.ActionFillTransparency, values.hover, values.transparency })
|
|
end),
|
|
|
|
size = UDim2.new(1, 0, 1, 0),
|
|
|
|
zIndex = -1,
|
|
}),
|
|
|
|
Background = style == "Solid" and e(SlicedImage, {
|
|
slice = Assets.Slices.RoundedBackground,
|
|
color = bindingUtil.mapLerp(bindingEnabled, theme.Enabled.BackgroundColor, theme.Disabled.BackgroundColor),
|
|
transparency = self.props.transparency,
|
|
|
|
size = UDim2.new(1, 0, 1, 0),
|
|
|
|
zIndex = -2,
|
|
}),
|
|
})
|
|
end)
|
|
end
|
|
|
|
return TextButton |