forked from rojo-rbx/rojo
* Switch git submodules to Wally packages * Update build snapshot * Add wally to foreman and use latest versions * Install packages in CI runners * Fix indents * Install packages in the correct directory * Install packages in correct dir of release action too * Remove submodules from ci checkout * Remove submodules from release checkout * Update selene with latest fix * Fix whitespace Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
47 lines
1.1 KiB
Lua
47 lines
1.1 KiB
Lua
local Rojo = script:FindFirstAncestor("Rojo")
|
|
local Plugin = Rojo.Plugin
|
|
local Packages = Rojo.Packages
|
|
|
|
local Roact = require(Packages.Roact)
|
|
|
|
local Dictionary = require(Plugin.Dictionary)
|
|
|
|
local StudioToolbarContext = require(script.Parent.StudioToolbarContext)
|
|
local StudioPluginContext = require(script.Parent.StudioPluginContext)
|
|
|
|
local e = Roact.createElement
|
|
|
|
local StudioToolbar = Roact.Component:extend("StudioToolbar")
|
|
|
|
function StudioToolbar:init()
|
|
self.toolbar = self.props.plugin:CreateToolbar(self.props.name)
|
|
end
|
|
|
|
function StudioToolbar:render()
|
|
return e(StudioToolbarContext.Provider, {
|
|
value = self.toolbar,
|
|
}, self.props[Roact.Children])
|
|
end
|
|
|
|
function StudioToolbar:didUpdate(lastProps)
|
|
if self.props.name ~= lastProps.name then
|
|
self.toolbar.Name = self.props.name
|
|
end
|
|
end
|
|
|
|
function StudioToolbar:willUnmount()
|
|
self.toolbar:Destroy()
|
|
end
|
|
|
|
local function StudioToolbarWrapper(props)
|
|
return e(StudioPluginContext.Consumer, {
|
|
render = function(plugin)
|
|
return e(StudioToolbar, Dictionary.merge(props, {
|
|
plugin = plugin,
|
|
}))
|
|
end,
|
|
})
|
|
end
|
|
|
|
return StudioToolbarWrapper
|