Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Add plasma.highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
evaera committed Jul 7, 2022
1 parent eef0e29 commit ea643fd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ return {
slider = require(script.widgets.slider),
space = require(script.widgets.space),
table = require(script.widgets.table),
highlight = require(script.widgets.highlight),
}
43 changes: 43 additions & 0 deletions src/widgets/highlight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Runtime = require(script.Parent.Parent.Runtime)
local create = require(script.Parent.Parent.create)

--[=[
@interface HighlightOptions
@within Plasma
.outlineColor?: Color3
.fillColor?: Color3
.fillTransparency?: number
.outlineTransparency?: number
.fillMode?: HighlightFillMode
]=]

--[=[
@within Plasma
@function highlight
@param adornee Instance
@param options? HighlightOptions
Creates a highlight over an instance with the specified options, using the Roblox [Highlight] instance
]=]
return Runtime.widget(function(adornee, options)
options = options or {}

local refs = Runtime.useInstance(function(ref)
return create("Highlight", {
[ref] = "highlight",
})
end)

refs.highlight.Adornee = adornee

Runtime.useEffect(function()
refs.highlight.OutlineColor = options.outlineColor or Color3.new(1, 1, 1)
refs.highlight.FillColor = options.fillColor or Color3.new(1, 0, 0)
end, options.fillColor, options.outlineColor)

refs.highlight.FillTransparency = options.fillTransparency or 0.5
refs.highlight.OutlineTransparency = options.outlineTransparency or 0
refs.highlight.DepthMode = options.depthMode or Enum.HighlightDepthMode.AlwaysOnTop
end)

0 comments on commit ea643fd

Please sign in to comment.