Skip to content

Commit

Permalink
0.451.0.412446 (Packages)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roblox-Client-Tracker committed Oct 7, 2020
1 parent 5705976 commit e56c010
Show file tree
Hide file tree
Showing 61 changed files with 1,860 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies = [
"Roact roblox/roact 1.3.0 url+https://github.com/roblox/roact",
"RoactRodux roblox/roact-rodux 0.2.2 url+https://github.com/roblox/roact-rodux",
"Rodux roblox/rodux 1.0.0 url+https://github.com/roblox/rodux",
"UIBlox <patched> UIBlox a253d523 git+https://github.com/roblox/uiblox#master",
"UIBlox <patched> UIBlox d3684f48 git+https://github.com/roblox/uiblox#master",
"t roblox/t 1.2.5 url+https://github.com/roblox/t",
]
2 changes: 1 addition & 1 deletion LuaPackages/Packages/_Index/LuaChatDeps/lock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ dependencies = [
"AssetCard asset-card c7b683fb git+https://github.com/roblox/asset-card#v1.0.2",
"InfiniteScroller roblox/infinite-scroller 0.5.6 url+https://github.com/roblox/infinite-scroller",
"RoduxNetworking rodux-networking ea19cfe3 git+https://github.rbx.com/roblox/rodux-networking#v1.0.1",
"UIBlox UIBlox a253d523 git+https://github.com/roblox/uiblox#master",
"UIBlox UIBlox d3684f48 git+https://github.com/roblox/uiblox#master",
]
181 changes: 181 additions & 0 deletions LuaPackages/Packages/_Index/UIBlox/UIBlox/App/Button/ActionBar.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
local Button = script.Parent
local App = Button.Parent
local UIBlox = App.Parent
local Packages = UIBlox.Parent

local Roact = require(Packages.Roact)
local Cryo = require(Packages.Cryo)
local RoactGamepad = require(Packages.RoactGamepad)
local t = require(Packages.t)

local FitFrame = require(Packages.FitFrame)
local FitFrameOnAxis = FitFrame.FitFrameOnAxis

local PrimaryContextualButton = require(Button.PrimaryContextualButton)
local PrimarySystemButton = require(Button.PrimarySystemButton)
local IconButton = require(Button.IconButton)
local withStyle = require(UIBlox.Core.Style.withStyle)
local IconSize = require(App.ImageSet.Enum.IconSize)
local getPageMargin = require(App.Container.getPageMargin)
local UIBloxConfig = require(UIBlox.UIBloxConfig)
local validateButtonProps = require(Button.validateButtonProps)
local validateIconButtonProps = IconButton.validateProps

local ActionBar = Roact.PureComponent:extend("ActionBar")

local BUTTON_PADDING = 12
local BUTTON_HEIGHT = 48
local ICON_SIZE = 36

function ActionBar:init()
self.buttonRefs = RoactGamepad.createRefCache()

self.state = {
frameWidth = 0
}

self.updateFrameSize = function(rbx)
local frameWidth = rbx.AbsoluteSize.X
if frameWidth ~= self.state.frameWidth then
self:setState({
frameWidth = frameWidth,
})
end
end
end

ActionBar.validateProps = t.strictInterface({
-- buttons: A table of button tables that contain props that PrimaryContextualButton allow.
button = t.optional(t.strictInterface({
props = validateButtonProps,
})),

-- icons: A table of button tables that contain props that IconButton allow.
icons = t.optional(t.array(t.strictInterface({
props = validateIconButtonProps
}))),

-- Children
[Roact.Children] = t.optional(t.table),

-- optional parameters for RoactGamepad
NextSelectionLeft = t.optional(t.table),
NextSelectionRight = t.optional(t.table),
NextSelectionUp = t.optional(t.table),
NextSelectionDown = t.optional(t.table),
[Roact.Ref] = t.optional(t.table),
})

function ActionBar:render()

return withStyle(function(stylePalette)
local margin = getPageMargin(self.state.frameWidth)
local contentWidth = self.state.frameWidth - margin * 2
local iconSize = IconSize.Medium

local iconNumber = 0
if self.props.icons and #self.props.icons then
iconNumber = #self.props.icons
end

local buttonTable = {}

if iconNumber ~= 0 then
for iconButtonIndex, iconButton in ipairs(self.props.icons) do
local newProps = {
layoutOrder = iconButtonIndex,
iconSize = iconSize,
}
local iconButtonProps = Cryo.Dictionary.join(newProps, iconButton.props)

if UIBloxConfig.enableExperimentalGamepadSupport then
local gamepadFrameProps = {
Size = UDim2.fromOffset(ICON_SIZE,ICON_SIZE),
BackgroundTransparency = 1,
[Roact.Ref] = self.buttonRefs[iconButtonIndex],
NextSelectionUp = nil,
NextSelectionDown = nil,
NextSelectionLeft = iconButtonIndex > 1 and self.buttonRefs[iconButtonIndex - 1] or nil,
NextSelectionRight = iconButtonIndex < iconNumber and self.buttonRefs[iconButtonIndex + 1] or nil,
inputBindings = {
[Enum.KeyCode.ButtonA] = iconButtonProps.onActivated,
},
}

table.insert(buttonTable, Roact.createElement(RoactGamepad.Focusable.Frame, gamepadFrameProps, {
Roact.createElement(IconButton, iconButtonProps)
}))
else
table.insert(buttonTable, Roact.createElement(IconButton, iconButtonProps))
end
end
end

if self.props.button then
local button = self.props.button

local buttonSize = UDim2.fromOffset(contentWidth - iconNumber * (ICON_SIZE + BUTTON_PADDING), BUTTON_HEIGHT)

local newProps = {
layoutOrder = iconNumber + 1,
size = buttonSize,
}
local buttonProps = Cryo.Dictionary.join(newProps, button.props)

if UIBloxConfig.enableExperimentalGamepadSupport then
local gamepadFrameProps = {
Size = buttonSize,
BackgroundTransparency = 1,
[Roact.Ref] = self.buttonRefs[iconNumber + 1],
NextSelectionUp = nil,
NextSelectionDown = nil,
NextSelectionLeft = iconNumber and self.buttonRefs[iconNumber] or nil,
NextSelectionRight = nil,
inputBindings = {
[Enum.KeyCode.ButtonA] = buttonProps.onActivated,
},
}

table.insert(buttonTable, Roact.createElement(RoactGamepad.Focusable.Frame, gamepadFrameProps, {
Roact.createElement(iconNumber == 0 and PrimarySystemButton or PrimaryContextualButton, buttonProps)
}))
else
table.insert(buttonTable,
Roact.createElement(iconNumber == 0 and PrimarySystemButton or PrimaryContextualButton, buttonProps))
end
end

if self.props[Roact.Children] then
buttonTable = self.props[Roact.Children]
end

return Roact.createElement(UIBloxConfig.enableExperimentalGamepadSupport and
RoactGamepad.Focusable[FitFrameOnAxis] or FitFrameOnAxis, {
BackgroundTransparency = 1,
minimumSize = UDim2.new(1, 0, 0, BUTTON_HEIGHT),
FillDirection = Enum.FillDirection.Horizontal,
HorizontalAlignment = Enum.HorizontalAlignment.Center,
VerticalAlignment = Enum.VerticalAlignment.Center,
Position = UDim2.new(0, 0, 1, -24),
AnchorPoint = Vector2.new(0, 1),
contentPadding = UDim.new(0, BUTTON_PADDING),
[Roact.Ref] = self.props[Roact.Ref],
[Roact.Change.AbsoluteSize] = self.updateFrameSize,
margin = {
left = margin,
right = margin,
top = 0,
bottom = 0
},

NextSelectionLeft = self.props.NextSelectionLeft,
NextSelectionRight = self.props.NextSelectionRight,
NextSelectionUp = self.props.NextSelectionUp,
NextSelectionDown = self.props.NextSelectionDown,
},
buttonTable
)
end)
end

return ActionBar
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
return function()
local Button = script.Parent
local App = Button.Parent
local UIBlox = App.Parent
local Packages = UIBlox.Parent

local Roact = require(Packages.Roact)
local Images = require(App.ImageSet.Images)

local icon = Images["icons/common/robux_small"]
local mockStyleComponent = require(UIBlox.Utility.mockStyleComponent)

local ActionBar = require(Button.ActionBar)

it("should create and destroy ActionBar with one button without errors", function()
local element = mockStyleComponent({
ActionBar = Roact.createElement(ActionBar, {
button = {
props = {
onActivated = function() end,
text = "Button",
},
}
})
})
local instance = Roact.mount(element)
Roact.unmount(instance)
end)

it("should create and destroy ActionBar with one button and one icon button without errors", function()
local element = mockStyleComponent({
ActionBar = Roact.createElement(ActionBar, {
button = {
props = {
onActivated = function() end,
text = "Button",
icon = icon,
},
},
icons = {
{
props = {
anchorPoint = Vector2.new(0.5, 0.5),
position = UDim2.fromScale(0.5, 0.5),
icon = icon,
userInteractionEnabled = true,
onActivated = function()
print("Text Button Clicked!")
end,
onStateChanged = function(oldState, newState)
print("state changed \n oldState:", oldState, " newState:", newState)
end
}
}
}
})
})

local instance = Roact.mount(element)
Roact.unmount(instance)
end)

it("should create and destroy ActionBar with one button and two icon button without errors", function()
local element = mockStyleComponent({
ActionBar = Roact.createElement(ActionBar, {
button = {
props = {
onActivated = function() end,
text = "Button",
icon = icon,
},
},
icons = {
{
props = {
anchorPoint = Vector2.new(0.5, 0.5),
position = UDim2.fromScale(0.5, 0.5),
icon = icon,
userInteractionEnabled = true,
onActivated = function()
print("Text Button Clicked!")
end,
onStateChanged = function(oldState, newState)
print("state changed \n oldState:", oldState, " newState:", newState)
end
}
},
{
props = {
anchorPoint = Vector2.new(0.5, 0.5),
position = UDim2.fromScale(0.5, 0.5),
icon = icon,
userInteractionEnabled = true,
onActivated = function()
print("Text Button Clicked!")
end,
onStateChanged = function(oldState, newState)
print("state changed \n oldState:", oldState, " newState:", newState)
end
}
}
}
})
})

local instance = Roact.mount(element)
Roact.unmount(instance)
end)

it("should create and destroy a ActionBar with children without errors", function()
local element = mockStyleComponent({
ActionBar = Roact.createElement(ActionBar, {}, {
ChildFrame = Roact.createElement("Frame",{})
})
})

local instance = Roact.mount(element)
Roact.unmount(instance)
end)
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local InformativeToast = Roact.PureComponent:extend("InformativeToast")
local validateProps = t.strictInterface({
anchorPoint = t.optional(t.Vector2),
iconProps = t.optional(validateToastIcon),
iconChildren = t.optional(t.table),
layoutOrder = t.optional(t.integer),
padding = t.optional(t.numberMin(0)),
position = t.optional(t.UDim2),
Expand Down Expand Up @@ -52,6 +53,7 @@ function InformativeToast:render()
}, {
ToastFrame = Roact.createElement(ToastFrame, {
iconProps = self.props.iconProps,
iconChildren = self.props.iconChildren,
padding = self.props.padding,
subtitleTextProps = self.props.subtitleTextProps,
textFrameSize = self.props.textFrameSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,25 @@ return function()
local instance = Roact.mount(element)
Roact.unmount(instance)
end)

it("should create and destroy without errors with composed image", function()
local element = createInformativeToast({
iconProps = {
Image = Images["icons/status/warning"],
Size = UDim2.new(0, ICON_SIZE, 0, ICON_SIZE),
},
iconChildren = {
Child = Roact.createElement("TextLabel"),
},
titleTextProps = {
colorStyle = TestStyle.Theme.TextEmphasis,
fontStyle = TestStyle.Font.Header2,
Size = UDim2.new(1, -ICON_SIZE, 1, 0),
Text = testText,
},
})

local instance = Roact.mount(element)
Roact.unmount(instance)
end)
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local InteractiveToast = Roact.PureComponent:extend("InteractiveToast")
local validateProps = t.strictInterface({
anchorPoint = t.optional(t.Vector2),
iconProps = t.optional(validateToastIcon),
iconChildren = t.optional(t.table),
layoutOrder = t.optional(t.integer),
padding = t.optional(t.numberMin(0)),
position = t.optional(t.UDim2),
Expand Down Expand Up @@ -92,6 +93,7 @@ function InteractiveToast:render()
}),
ToastFrame = Roact.createElement(ToastFrame, {
iconProps = self.props.iconProps,
iconChildren = self.props.iconChildren,
padding = self.props.padding,
subtitleTextProps = self.props.subtitleTextProps,
textFrameSize = self.props.textFrameSize,
Expand Down

0 comments on commit e56c010

Please sign in to comment.