From d6623242072698c8b38af77df8a8e6102aa7b57e Mon Sep 17 00:00:00 2001 From: Manami <40730127+ManamiDev@users.noreply.github.com> Date: Wed, 22 Jul 2020 16:02:28 +0900 Subject: [PATCH 1/4] Delete [DEPRECATED] Snackbar.md --- [DEPRECATED] Snackbar.md | 112 --------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 [DEPRECATED] Snackbar.md diff --git a/[DEPRECATED] Snackbar.md b/[DEPRECATED] Snackbar.md deleted file mode 100644 index c0cb234..0000000 --- a/[DEPRECATED] Snackbar.md +++ /dev/null @@ -1,112 +0,0 @@ -```lua --- Simple Snackbar Generator --- @readme https://github.com/RoStrap/UI/blob/master/README.md --- @author Validark - --- Snackbar.new(string Text, ScreenGui Screen) --- Generates a SnackbarFrame with message Text --- Expect more parameters in the future --- @spec https://material.io/guidelines/components/snackbars-toasts.html - -local HEIGHT = 48 -local ENTER_TIME = 0.275 -local DISPLAY_TIME = 2 -local SMALLEST_WIDTH = 294 - -local ReplicatedStorage = game:GetService("ReplicatedStorage") -local Resources = require(ReplicatedStorage:WaitForChild("Resources")) - -local Tween = Resources:LoadLibrary("Tween") -local Janitor = Resources:LoadLibrary("Janitor") - -local TweenCompleted = Enum.TweenStatus.Completed - -HEIGHT = HEIGHT + 6 -local OpenSnackbar, OpenTween -local ExitPosition = UDim2.new(0.5, 0, 1, 0) -local EnterPosition = UDim2.new(0.5, 0, 1, -HEIGHT) - -local DefaultSnackbar = Instance.new("ImageLabel") -DefaultSnackbar.AnchorPoint = Vector2.new(0.5, 0) -DefaultSnackbar.BackgroundTransparency = 1 -DefaultSnackbar.Image = "rbxasset://textures/ui/btn_newWhite.png" -DefaultSnackbar.ImageColor3 = Color3.fromRGB(50, 50, 50) -DefaultSnackbar.Position = UDim2.new(0.5, 0, 1, 0) -DefaultSnackbar.ScaleType = Enum.ScaleType.Slice -DefaultSnackbar.Size = UDim2.new(0, 288 + 6, 0, HEIGHT) -DefaultSnackbar.SliceCenter = Rect.new(7, 7, 13, 13) -DefaultSnackbar.ZIndex = 4 - -local SnackbarText = Instance.new("TextLabel", DefaultSnackbar) -SnackbarText.AnchorPoint = Vector2.new(0, 0.5) -SnackbarText.Font = Enum.Font.SourceSans -SnackbarText.Name = "Label" -SnackbarText.Position = UDim2.new(0, 27, 0.5, 0) -SnackbarText.TextSize = 20 -SnackbarText.TextColor3 = Color3.fromRGB(255, 255, 255) -SnackbarText.TextXAlignment = Enum.TextXAlignment.Left -SnackbarText.ZIndex = 5 - -local Snackbar = {} - -function Snackbar.new(Text, Screen) - -- @param string Text the message you want to appear - -- @param ScreenGui Screen the Parent of the Snackbar - - if OpenSnackbar then - local PreviousSnackbar = OpenSnackbar - local PreviousLabel = PreviousSnackbar:FindFirstChild("Label") - - if PreviousLabel then - if PreviousLabel.Text == Text then - return - end - PreviousLabel.ZIndex = 3 - end - - OpenTween:Stop() - PreviousSnackbar.ZIndex = 2 - - Tween(PreviousSnackbar, "Position", ExitPosition, "Acceleration", ENTER_TIME * 0.7, false, function(Completed) - if Completed == TweenCompleted then - PreviousSnackbar:Destroy() - if OpenSnackbar == PreviousSnackbar then - OpenSnackbar = nil - end - end - end) - end - - local SnackbarJanitor = Janitor.new() - local SnackbarFrame = DefaultSnackbar:Clone() - OpenSnackbar = SnackbarFrame - local Label = SnackbarFrame:FindFirstChild("Label") - - if Label then - Label.Text = Text - SnackbarJanitor:LinkToInstance(SnackbarFrame) - SnackbarJanitor:Add(SnackbarFrame.Label:GetPropertyChangedSignal("TextBounds"):Connect(function() - SnackbarFrame.Size = UDim2.new(0, Label.TextBounds.X + HEIGHT > SMALLEST_WIDTH and Label.TextBounds.X + HEIGHT or SMALLEST_WIDTH, 0, HEIGHT) - end), "Disconnect") - end - - SnackbarFrame.Parent = Screen - - OpenTween = Tween(SnackbarFrame, "Position", EnterPosition, "Deceleration", ENTER_TIME, false, function(Completed) - if Completed == TweenCompleted and wait(DISPLAY_TIME - ENTER_TIME) then - Tween(SnackbarFrame, "Position", ExitPosition, "Acceleration", ENTER_TIME, false, function(Completed) - if Completed == TweenCompleted then - SnackbarFrame:Destroy() - if OpenSnackbar == SnackbarFrame then - OpenSnackbar = nil - end - end - end) - end - end) - - return setmetatable({}, Snackbar) -end - -return Snackbar -``` From 4e621e9dd11212f0fa4c26f69e34defeeb206084 Mon Sep 17 00:00:00 2001 From: va1kio <40730127+va1kio@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:14:04 +0800 Subject: [PATCH 2/4] Added ShadowColor3 property to Shadow.lua --- Shadow.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Shadow.lua b/Shadow.lua index 063b193..489d668 100644 --- a/Shadow.lua +++ b/Shadow.lua @@ -262,6 +262,16 @@ return PseudoInstance:Register("Shadow", { self:rawset("Elevation", Elevation) end); + + ShadowColor3 = Typer.AssignSignature(2, Typer.Color3, function(self, Color) + if self.ShadowColor3 == Color then return end + + for Name, Data in next, ShadowData[self.Elevation.Value] do + self[Name].ImageColor3 = Color + end + + self:rawset("ShadowColor3", Color) + end); Parent = Typer.AssignSignature(2, Typer.OptionalInstanceWhichIsAGuiObject, function(self, Parent) if Parent then @@ -331,6 +341,7 @@ return PseudoInstance:Register("Shadow", { end self:rawset("Transparency", 0) + self:rawset("ShadowColor3", Color3.fromRGB(0,0,0)) self:rawset("Elevation", Enumeration.ShadowElevation.Elevation0) self:superinit() end; From e217a54bdd5d8d93cd9f79c36800565ab6a74794 Mon Sep 17 00:00:00 2001 From: va1kio <40730127+va1kio@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:19:14 +0800 Subject: [PATCH 3/4] ButtonStyle.Contained changes ButtonStyle.Contained will no longer have elevation when not being interacted, shadow color will now follow button's primary color, shadow will be elevated (4) with mouse is hovering at it. --- RippleButton.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/RippleButton.lua b/RippleButton.lua index 2d05922..44cebcf 100644 --- a/RippleButton.lua +++ b/RippleButton.lua @@ -19,8 +19,9 @@ local Shadow = Resources:LoadLibrary("Shadow") local Rippler = Resources:LoadLibrary("Rippler") -- Elevations -local RAISED_BASE_ELEVATION = 3 -local RAISED_ELEVATION = 8 +local RAISED_BASE_ELEVATION = 0 +local RAISED_ELEVATION = 6 +local HOVERED_ELEVATION = 4 Enumeration.ButtonStyle = {"Flat", "Outlined", "Contained"} @@ -38,7 +39,7 @@ local StateOpacity = { -- TODO: Derive these values based on the PrimaryColor3's [Enumeration.ButtonStyle.Contained.Value] = { Hover = 0.12; --0.075; - Pressed = 0.3; -- 0.265; + Pressed = 0.16; -- 0.265; }; } @@ -122,7 +123,6 @@ return PseudoInstance:Register("RippleButton", { end local SecondaryColor3 = self.SecondaryColor3 or 0.5 < Luminosity and Color.Black or Color.White - self.Rippler.RippleColor3 = SecondaryColor3 self.TextLabel.TextColor3 = SecondaryColor3 self.Object.ImageColor3 = PrimaryColor3 @@ -293,6 +293,7 @@ return PseudoInstance:Register("RippleButton", { -- self.Object.ImageColor3 = self.PrimaryColor3 self.Shadow = PseudoInstance.new("Shadow") + self.Shadow.ShadowColor3 = self.PrimaryColor3 self.Shadow.Parent = self.Object self.Janitor:Add(self.Shadow, "Destroy", "Shadow") @@ -319,6 +320,10 @@ return PseudoInstance:Register("RippleButton", { PrimaryColor3 = Typer.AssignSignature(2, Typer.Color3, function(self, PrimaryColor3) self:rawset("PrimaryColor3", PrimaryColor3) + if self.Style == Enumeration.ButtonStyle.Contained then + self.Shadow.ShadowColor3 = self.PrimaryColor3 + end + self:Render() end); @@ -399,6 +404,7 @@ return PseudoInstance:Register("RippleButton", { IsHovered = true if self.Style == Enumeration.ButtonStyle.Contained then + self.Shadow:ChangeElevation(HOVERED_ELEVATION) Tween(self.Object, "ImageColor3", self.PrimaryColor3:Lerp(self.Rippler.RippleColor3, self.OverlayOpacity), Enumeration.EasingFunction.Deceleration, 0.1, true) else Tween(self.Object, "ImageTransparency", 1 - self.OverlayOpacity, Enumeration.EasingFunction.Deceleration, 0.1, true) From 7c3342cc83e2ef6122964945d69fc37755c35855 Mon Sep 17 00:00:00 2001 From: va1kio <40730127+va1kio@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:26:53 +0800 Subject: [PATCH 4/4] Added Gray and BlueGray (US Spelling) --- Color.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Color.lua b/Color.lua index 9d65fd6..975b2af 100644 --- a/Color.lua +++ b/Color.lua @@ -369,6 +369,9 @@ local Color = { White = rgb(255, 255, 255); } +Color.Gray = Color.Grey +Color.BlueGray = Color.BlueGrey + function Color.toRGBString(c, a) local r = c.r * 255 + 0.5 local g = c.g * 255 + 0.5