F3XTeam / RBX-Building-Tools

A set of powerful, easy building tools for ROBLOX.
41 stars 22 forks source link

Create Snackbar.lua #121

Closed howmanysmall closed 5 years ago

howmanysmall commented 6 years ago

Material Design Snackbar.

Usage:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local Roact = require(ReplicatedStorage:WaitForChild("Roact"))
local Snackbar = require(script:WaitForChild("Snackbar"))
local CreateElement = Roact.createElement

local function NewSnackbar(Properties)
    return CreateElement("ScreenGui", { }, {
        CurrentSnackbar = CreateElement(Snackbar, Properties or { }),
    })
end

local SnackbarElement = NewSnackbar { SnackbarText = "SnackbarText" }
local Handle = Roact.mount(SnackbarElement, PlayerGui, "Snackbar")
GigsD4X commented 6 years ago

This should probably use packaged libraries instead of ones in ReplicatedStorage (since they're not guaranteed to be there) -- something like this: https://github.com/F3XTeam/RBX-Building-Tools/blob/development/UI/Frame.lua#L2