local U=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer:WaitForChild("\080\108\097\121\101\114\071\117\105")local k={{name="\104\101\108\108\111-\114\111\097\099\116",label="\072\101\108\108\111\044 \082\111\097\099\116\033"},{name="\099\108\111\099\107",label="\067\108\111\099\107"},{name="\099\104\097\110\103\101\100-\115\105\103\110\097\108";label="\067\104\097\110\103\101\100 \083\105\103\110\097\108"};{name="\115\116\114\101\115\115-\116\101\115\116";label="\083\116\114\101\115\115 \084\101\115\116"},{name="\101\118\101\110\116";label="\069\118\101\110\116"};{name="\114\101\102",label="\082\101\102"},{name="\098\105\110\100\105\110\103";label="\066\105\110\100\105\110\103"}}for U,k in ipairs(k)do k.source=script:WaitForChild(k.name)k.start=require(k.source)end local z={}z.exampleList=nil function z.makeBackButton()local k=Instance.new("\083\099\114\101\101\110\071\117\105")k.Name="\066\097\099\107 \116\111 \069\120\097\109\112\108\101\115"local d=Instance.new("\084\101\120\116\066\117\116\116\111\110")d.Font=Enum.Font.SourceSans d.TextSize=20 d.Size=UDim2.new(0,150,0,80)d.Position=UDim2.new(0,0,.5,0)d.AnchorPoint=Vector2.new(0,.5)d.Text="\066\097\099\107 \116\111 \069\120\097\109\112\108\101\115"d.BackgroundColor3=Color3.new(.9,.9,.9)d.BorderColor3=Color3.new(0,0,0)d.Activated:Connect(function()k:Destroy()z.onStop()z.onStop=nil z.exampleList=z.makeExampleList()z.exampleList.Parent=U end)d.Parent=k return k end function z.openExample(k)z.exampleList:Destroy()local d=z.makeBackButton()d.Parent=U z.onStop=k.start()end function z.makeExampleList()local U=Instance.new("\083\099\114\101\101\110\071\117\105")U.Name="\082\111\097\099\116 \069\120\097\109\112\108\101\115"local d=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")d.Size=UDim2.new(0,400,0,600)d.CanvasSize=UDim2.new(0,400,0,80*#k)d.Position=UDim2.new(.5,0,.5,0)d.AnchorPoint=Vector2.new(.5,.5)d.BorderSizePixel=2 d.BackgroundColor3=Color3.new(1,1,1)d.TopImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\057\048\053\048\054\055\054"d.MidImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\057\048\053\048\054\055\054"d.BottomImage="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\057\048\053\048\054\055\054"d.Parent=U local m=Instance.new("\085\073\076\105\115\116\076\097\121\111\117\116")m.SortOrder=Enum.SortOrder.LayoutOrder m.Parent=d for U,k in ipairs(k)do local m=("\037\115\n\101\120\097\109\112\108\101\115\047\037\115"):format(k.label,k.name)local a=Instance.new("\084\101\120\116\066\117\116\116\111\110")a.Name="\069\120\097\109\112\108\101\058 "..k.name a.BackgroundColor3=Color3.new(.9,.9,.9)a.BorderSizePixel=0 a.Text=m a.Font=Enum.Font.SourceSans a.TextSize=20 a.Size=UDim2.new(1,0,0,80)a.LayoutOrder=U a.Activated:Connect(function()z.openExample(k)end)a.Parent=d local r=Instance.new("\070\114\097\109\101")r.Name="\066\111\116\116\111\109 \066\111\114\100\101\114"r.Position=UDim2.new(0,0,1,-1)r.Size=UDim2.new(0,400,0,1)r.BorderSizePixel=0 r.BackgroundColor3=Color3.new(0,0,0)r.ZIndex=2 r.Parent=a end return U end z.exampleList=z.makeExampleList()z.exampleList.Parent=U
local PlayerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

local exampleData = {
	{
		name = "hello-roact",
		label = "Hello, Roact!",
	},
	{
		name = "clock",
		label = "Clock",
	},
	{
		name = "changed-signal",
		label = "Changed Signal",
	},
	{
		name = "stress-test",
		label = "Stress Test",
	},
	{
		name = "event",
		label = "Event",
	},
	{
		name = "ref",
		label = "Ref",
	},
	{
		name = "binding",
		label = "Binding",
	},
}

for _, example in ipairs(exampleData) do
	example.source = script:WaitForChild(example.name)
	example.start = require(example.source)
end

local Examples = {}

Examples.exampleList = nil

function Examples.makeBackButton()
	local screenGui = Instance.new("ScreenGui")
	screenGui.Name = "Back to Examples"

	local button = Instance.new("TextButton")
	button.Font = Enum.Font.SourceSans
	button.TextSize = 20
	button.Size = UDim2.new(0, 150, 0, 80)
	button.Position = UDim2.new(0, 0, 0.5, 0)
	button.AnchorPoint = Vector2.new(0, 0.5)
	button.Text = "Back to Examples"
	button.BackgroundColor3 = Color3.new(0.9, 0.9, 0.9)
	button.BorderColor3 = Color3.new(0, 0, 0)

	button.Activated:Connect(function()
		screenGui:Destroy()

		Examples.onStop()
		Examples.onStop = nil

		Examples.exampleList = Examples.makeExampleList()
		Examples.exampleList.Parent = PlayerGui
	end)

	button.Parent = screenGui

	return screenGui
end

function Examples.openExample(example)
	Examples.exampleList:Destroy()

	local back = Examples.makeBackButton()
	back.Parent = PlayerGui

	Examples.onStop = example.start()
end

function Examples.makeExampleList()
	local screenGui = Instance.new("ScreenGui")
	screenGui.Name = "Roact Examples"

	local exampleList = Instance.new("ScrollingFrame")
	exampleList.Size = UDim2.new(0, 400, 0, 600)
	exampleList.CanvasSize = UDim2.new(0, 400, 0, 80 * #exampleData)
	exampleList.Position = UDim2.new(0.5, 0, 0.5, 0)
	exampleList.AnchorPoint = Vector2.new(0.5, 0.5)
	exampleList.BorderSizePixel = 2
	exampleList.BackgroundColor3 = Color3.new(1, 1, 1)
	exampleList.TopImage = "rbxassetid://29050676"
	exampleList.MidImage = "rbxassetid://29050676"
	exampleList.BottomImage = "rbxassetid://29050676"
	exampleList.Parent = screenGui

	local listLayout = Instance.new("UIListLayout")
	listLayout.SortOrder = Enum.SortOrder.LayoutOrder
	listLayout.Parent = exampleList

	for index, example in ipairs(exampleData) do
		local label = ("%s\nexamples/%s"):format(example.label, example.name)

		local exampleCard = Instance.new("TextButton")
		exampleCard.Name = "Example: " .. example.name
		exampleCard.BackgroundColor3 = Color3.new(0.9, 0.9, 0.9)
		exampleCard.BorderSizePixel = 0
		exampleCard.Text = label
		exampleCard.Font = Enum.Font.SourceSans
		exampleCard.TextSize = 20
		exampleCard.Size = UDim2.new(1, 0, 0, 80)
		exampleCard.LayoutOrder = index

		exampleCard.Activated:Connect(function()
			Examples.openExample(example)
		end)

		exampleCard.Parent = exampleList

		local bottomBorder = Instance.new("Frame")
		bottomBorder.Name = "Bottom Border"
		bottomBorder.Position = UDim2.new(0, 0, 1, -1)
		bottomBorder.Size = UDim2.new(0, 400, 0, 1)
		bottomBorder.BorderSizePixel = 0
		bottomBorder.BackgroundColor3 = Color3.new(0, 0, 0)
		bottomBorder.ZIndex = 2
		bottomBorder.Parent = exampleCard
	end

	return screenGui
end

Examples.exampleList = Examples.makeExampleList()
Examples.exampleList.Parent = PlayerGui
