Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locked tooltip #998

Merged
merged 3 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugin/src/App/Components/Checkbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ function Checkbox:render()
end,
}, {
StateTip = e(Tooltip.Trigger, {
text = (if self.props.locked then "[LOCKED] " else "")
.. (if self.props.active then "Enabled" else "Disabled"),
text = (if self.props.locked
then (self.props.lockedTooltip or "(Cannot be changed right now)") .. "\n"
else "") .. (if self.props.active then "Enabled" else "Disabled"),
}),

Active = e(SlicedImage, {
Expand Down
7 changes: 7 additions & 0 deletions plugin/src/App/Components/Dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local getTextBoundsAsync = require(Plugin.App.getTextBoundsAsync)

local SlicedImage = require(script.Parent.SlicedImage)
local ScrollingFrame = require(script.Parent.ScrollingFrame)
local Tooltip = require(script.Parent.Tooltip)

local e = Roact.createElement

Expand Down Expand Up @@ -119,6 +120,12 @@ function Dropdown:render()
end),

BackgroundTransparency = 1,
}, {
StateTip = if self.props.locked
then e(Tooltip.Trigger, {
text = self.props.lockedTooltip or "(Cannot be changed right now)",
})
else nil,
}),
Active = e("TextLabel", {
Size = UDim2.new(1, -30, 1, 0),
Expand Down
9 changes: 3 additions & 6 deletions plugin/src/App/Components/Tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ local TooltipContext = Roact.createContext({})

local function Popup(props)
return Theme.with(function(theme)
local textXSpace = math.min(props.parentSize.X, 120)
local textBounds = Vector2.new(
textXSpace,
getTextBoundsAsync(props.Text, theme.Font.Main, theme.TextSize.Medium, textXSpace).Y
)
local textXSpace = math.min(props.parentSize.X, 250) - TEXT_PADDING.X
local textBounds = getTextBoundsAsync(props.Text, theme.Font.Main, theme.TextSize.Medium, textXSpace)
local contentSize = textBounds + TEXT_PADDING + (Vector2.one * 2)

local trigger = props.Trigger:getValue()
Expand All @@ -39,7 +36,7 @@ local function Popup(props)
-- If there's not enough space below, and there's more space above, then show the tooltip above the trigger
local displayAbove = spaceBelow < contentSize.Y and spaceAbove > spaceBelow

local X = math.clamp(props.Position.X - X_OFFSET, 0, props.parentSize.X - contentSize.X)
local X = math.clamp(props.Position.X - X_OFFSET, 0, math.max(props.parentSize.X - contentSize.X, 1))
local Y = 0

if displayAbove then
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/App/StatusPages/Settings/Setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function Setting:render()
then self.props.input
elseif self.props.options ~= nil then e(Dropdown, {
locked = self.props.locked,
lockedTooltip = self.props.lockedTooltip,
options = self.props.options,
active = self.state.setting,
transparency = self.props.transparency,
Expand All @@ -123,6 +124,7 @@ function Setting:render()
})
else e(Checkbox, {
locked = self.props.locked,
lockedTooltip = self.props.lockedTooltip,
active = self.state.setting,
transparency = self.props.transparency,
onClick = function()
Expand Down
1 change: 1 addition & 0 deletions plugin/src/App/StatusPages/Settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function SettingsPage:render()
name = "Two-Way Sync",
description = "Editing files in Studio will sync them into the filesystem",
locked = self.props.syncActive,
lockedTooltip = "(Cannot change while currently syncing. Disconnect first.)",
tag = "unstable",
transparency = self.props.transparency,
layoutOrder = layoutIncrement(),
Expand Down
Loading