mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refactor DomLabel and SelectionOption components for improved readability
- Simplified conditional logic for caret visibility in the SelectionOption component. - Enhanced the rendering logic in the ConfirmingPage to improve clarity and maintainability. - Updated the Abort button rendering to use a more concise syntax for conditional display.
This commit is contained in:
parent
af65056c44
commit
a8752b6b8d
2 changed files with 18 additions and 19 deletions
|
|
@ -71,10 +71,7 @@ function SelectionOption:render()
|
||||||
-- Determine if we should show the caret:
|
-- Determine if we should show the caret:
|
||||||
-- - Parent-only nodes: always show caret (they only do subtree operations)
|
-- - Parent-only nodes: always show caret (they only do subtree operations)
|
||||||
-- - Normal nodes with children: show caret when already selected AND hovering
|
-- - Normal nodes with children: show caret when already selected AND hovering
|
||||||
local showCaret = if isParentOnly
|
local showCaret = if isParentOnly then true elseif hasChildren and isSelected and isHovered then true else false
|
||||||
then true
|
|
||||||
elseif hasChildren and isSelected and isHovered then true
|
|
||||||
else false
|
|
||||||
|
|
||||||
local bgColor = if isSelected
|
local bgColor = if isSelected
|
||||||
then (if props.optionType == "push"
|
then (if props.optionType == "push"
|
||||||
|
|
@ -125,13 +122,8 @@ function SelectionOption:render()
|
||||||
self:setState({ isHovered = false })
|
self:setState({ isHovered = false })
|
||||||
end,
|
end,
|
||||||
[Roact.Event.Activated] = function()
|
[Roact.Event.Activated] = function()
|
||||||
if isParentOnly then
|
if isParentOnly or (isSelected and hasChildren) then
|
||||||
-- Parent-only: single click applies to subtree
|
-- Parent-only or already selected with children: click applies to subtree
|
||||||
if props.onSubtreeClick then
|
|
||||||
props.onSubtreeClick()
|
|
||||||
end
|
|
||||||
elseif isSelected and hasChildren then
|
|
||||||
-- Already selected with children: click applies to subtree
|
|
||||||
if props.onSubtreeClick then
|
if props.onSubtreeClick then
|
||||||
props.onSubtreeClick()
|
props.onSubtreeClick()
|
||||||
end
|
end
|
||||||
|
|
@ -508,7 +500,12 @@ function DomLabel:render()
|
||||||
SelectionRadio = e(SelectionRadio, {
|
SelectionRadio = e(SelectionRadio, {
|
||||||
-- Visible for nodes with patchType, or for parent-only nodes on hover
|
-- Visible for nodes with patchType, or for parent-only nodes on hover
|
||||||
visible = (props.patchType ~= nil and props.onSelectionChange ~= nil)
|
visible = (props.patchType ~= nil and props.onSelectionChange ~= nil)
|
||||||
or (props.patchType == nil and props.hasChildren and self.state.isHovered and props.onSubtreeSelectionChange ~= nil),
|
or (
|
||||||
|
props.patchType == nil
|
||||||
|
and props.hasChildren
|
||||||
|
and self.state.isHovered
|
||||||
|
and props.onSubtreeSelectionChange ~= nil
|
||||||
|
),
|
||||||
nodeId = props.nodeId,
|
nodeId = props.nodeId,
|
||||||
selection = props.selection,
|
selection = props.selection,
|
||||||
transparency = props.transparency,
|
transparency = props.transparency,
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,15 @@ function ConfirmingPage:render()
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
}, {
|
}, {
|
||||||
-- Only show Abort button when there are changes
|
-- Only show Abort button when there are changes
|
||||||
Abort = if hasChanges then e(TextButton, {
|
Abort = if hasChanges
|
||||||
text = "Abort",
|
then e(TextButton, {
|
||||||
style = "Bordered",
|
text = "Abort",
|
||||||
transparency = self.props.transparency,
|
style = "Bordered",
|
||||||
layoutOrder = 1,
|
transparency = self.props.transparency,
|
||||||
onClick = self.props.onAbort,
|
layoutOrder = 1,
|
||||||
}) else nil,
|
onClick = self.props.onAbort,
|
||||||
|
})
|
||||||
|
else nil,
|
||||||
|
|
||||||
Accept = e(TextButton, {
|
Accept = e(TextButton, {
|
||||||
text = if hasChanges then "Accept" else "OK",
|
text = if hasChanges then "Accept" else "OK",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue