Skip to content

Commit

Permalink
final few changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmesrje committed Dec 15, 2024
1 parent aa2c783 commit 14fbf89
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 182 deletions.
16 changes: 13 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
## Summary

<!-- Summarize your changes here -->
<!-- Summarize any of the significant changes you made -->

## Files Changed

<!-- Add a list of the files you changed -->

## Notes

<!-- Add any additional notices you think might be useful -->

## Checks

By submitting your pull request for review, you agree to the following:
By submitting this pull request for maintainer review, you agree to the following terms:

<!-- If your pull request doesn't comply with these, it will be ignored until it does -->

- [ ] I give full permission for maintainers and contributors of this repository to change my code in any way.
- [ ] I am open to this pull request being a part of a completely open source repository which can be modified at any time, and I abide by the license terms.
- [ ] To the best of my knowledge, there are no issues present in this pull request.
- [ ] To the best of my knowledge, there are no bugs present in this pull request.
29 changes: 0 additions & 29 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![package](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Flumin-org%2Fui%2Frefs%2Fheads%2Fmain%2Fpesde.toml&query=version&prefix=lumin%2Fui%40&style=plastic&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI%2BCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNDkuNjAyNSAwTDkyLjkwMzggMjVWNzVMNDkuNjAyNSAxMDBMNi4zMDEyNyA3NVYyNUw0OS42MDI1IDBaTTE0LjMwMTMgMjkuNjE4OE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zMDc2IDUwLjY2NDEgNDguODM4MSA0OS44NzEgNDguMjM2NyA0OS4xODk4QzQ4LjA4ODUgNDkuMDIxOSA0Ny45MzIzIDQ4Ljg2MDkgNDcuNzY4MSA0OC43MDY3QzQ2LjA4NSA0Ny4wNzQ2IDQ0LjA0NDkgNDYuMjU4NSA0MS42NDc4IDQ2LjI1ODVDNDAuMTE3NyA0Ni4yNTg1IDM4LjYxMzEgNDYuNTY0NSAzNy4xMzQgNDcuMTc2NkMzNS44NTk0IDQ3LjY3NzMgMzQuNjg2MyA0OC41NDM4IDMzLjYxNDggNDkuNzc1OVY2MS40N0MzNC42ODYzIDYyLjY2NjQgMzUuODU5NCA2My41Mzc4IDM3LjEzNCA2NC4wODRDMzguNjEzMSA2NC42OTYxIDQwLjExNzcgNjUuMDAyMSA0MS42NDc4IDY1LjAwMjFDNDQuMDQ0OSA2NS4wMDIxIDQ2LjA4NSA2NC4xODYxIDQ3Ljc2ODEgNjIuNTU0QzQ5LjQ1MTIgNjAuOTIxOSA1MC4yOTI4IDU4LjYwMTIgNTAuMjkyOCA1NS41OTIxQzUwLjI5MjggNTQuMDY3OSA1MC4wNzY5IDUyLjcyNyA0OS42NDUxIDUxLjU2OTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K&label=pesde&color=F19D1E)](https://pesde.dev/packages/lumin/ui)
[![ci](https://img.shields.io/github/actions/workflow/status/lumin-org/ui/release.yml?style=plastic&logo=github&logoColor=FFFFFF&label=ci)](https://github.com/lumin-org/ui/blob/main/.github/workflows/release.yml)
[![discord](https://img.shields.io/discord/1105688855375511642?logo=discord&logoColor=white&label=chat&color=4d3dff&style=plastic)](https://lumin-org.github.io/link/discord)
[![discord](https://img.shields.io/discord/1105688855375511642?logo=discord&logoColor=white&label=chat&color=4d3dff&style=plastic)](https://lumin-org.github.io/to/discord)

A small, fast, and efficient UI framework that has a small learning curve.

Expand Down
14 changes: 9 additions & 5 deletions src/Action.luau
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
-- Variables
local Root = script.Parent
local Types = require(Root.Types)
local Actions = {}
local Actions: {[string]: Types.Action} = {}

-- Functions

--[=[
Creates a new action, which allows for custom modifications to instances.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/#action)
[Open Documentation](https://lumin-org.github.io/ui/api/#action)
]=]
return function(name: string, apply: (Instance) -> ()): Types.Action
if not Actions[name] then
local function New(name: string, apply: (Instance) -> ())
if not Actions[name] then -- Cache the action so a new one is created each time
Actions[name] = apply
end
return Actions[name]
end

return {
New = New,
List = Actions,
}
16 changes: 9 additions & 7 deletions src/Apply.luau
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
local Root = script.Parent
local Types = require(Root.Types)

-- Functions
-- Module

return function(instance: Instance, property: any, value: any)
if type(property) == "number" then
if type(value) == "function" then
local PropType = type(property)
local ValueType = type(value)
if PropType == "number" then -- If the property is a modifier
if ValueType == "function" then -- If the value is an action
(value :: Types.Action)(instance)
else
else -- If the value is an instance
value.Parent = instance
value.Name = property
end
elseif type(property) == "string" then
if type(value) == "table" then
elseif PropType == "string" then -- If the property is a string
if ValueType == "table" then -- If the value is a constructor
(value :: Types.Constructor<any, any>):_Bind(property, instance)
else
else -- If the value is anything else, it is the value of a property
(instance :: any)[property] = value
end
end
Expand Down
23 changes: 13 additions & 10 deletions src/Change.luau
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ local Debugger = require(Root.Parent.roblox_packages.debugger)
--[=[
Connects a callback to a certain property change event, and supplies the changed prop as an arg.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/actions/#change)
[Open Documentation](https://lumin-org.github.io/ui/api/actions/#change)
]=]
return function(prop: string, callback: (changed: any) -> ()): Types.Action
return Action("Changed", function(instance)
local Success, Event = pcall(instance.GetPropertyChangedSignal, instance :: any, prop :: any)
if not Success or type(callback) ~= "function" then
Debugger.Fatal("InvalidPropOrEvent", prop)
end
Event:Connect(function()
callback((instance :: any)[prop])
end)
end)
if not Action.List["Changed"] then
Action.New("Changed", function(instance)
local Success, Event = pcall(instance.GetPropertyChangedSignal, instance :: any, prop :: any) -- Ensure prop exists
if not Success or type(callback) ~= "function" then
Debugger.Fatal("InvalidPropOrEvent", prop)
end
Event:Connect(function()
callback((instance :: any)[prop]) -- Pass new value through callback
end)
end)
end
return Action.List["Changed"]
end
29 changes: 16 additions & 13 deletions src/Clean.luau
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ local Debugger = require(Root.Parent.roblox_packages.debugger)
--[=[
Cleans and removes the items provided to they key when the parent instance is destroyed.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/keys/#clean)
[Open Documentation](https://lumin-org.github.io/ui/api/keys/#clean)
]=]
return function(values: { any }): Types.Action
return Action("Clean", function(instance: Instance)
Debugger.Assert(type(values) == "table", "InvalidType", "table", type(values))
instance.Destroying:Once(function()
for _, value in values do
if (type(value) == "table" and value._Bind) or typeof(value) == "Instance" then
value:Destroy()
elseif typeof(value) == "RBXScriptConnection" then
value:Disconnect()
end
end
end)
end)
if not Action.List["Clean"] then
Action.New("Clean", function(instance: Instance)
Debugger.Assert(type(values) == "table", "InvalidType", "table", type(values))
instance.Destroying:Once(function()
for _, value in values do
if (type(value) == "table" and value._Bind) or typeof(value) == "Instance" then
value:Destroy()
elseif typeof(value) == "RBXScriptConnection" then
value:Disconnect()
end
end
end)
end)
end
return Action.List["Clean"]
end
8 changes: 4 additions & 4 deletions src/Computed.luau
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local Class = {}
--[=[
Gets the current value of a value object for use within the compute.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/computed/#use)
[Open Documentation](https://lumin-org.github.io/ui/api/computed/#use)
]=]
local function Use(value: Types.State | any)
if type(value) == "table" then
Expand All @@ -35,7 +35,7 @@ end
--[=[
Gets the current value of the compute object.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/computed/#get)
[Open Documentation](https://lumin-org.github.io/ui/api/computed/#get)
]=]
function Class.Get(self: Types.Computed): any
return self._Value
Expand All @@ -53,7 +53,7 @@ end
--[=[
Destroys the compute object.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/computed/#destroy)
[Open Documentation](https://lumin-org.github.io/ui/api/computed/#destroy)
]=]
function Class.Destroy(self: Types.Computed)
if self._Dependencies then
Expand All @@ -72,7 +72,7 @@ end
--[=[
Creates a new computed value, which changes the final value when a dependency is changed.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/#computed)
[Open Documentation](https://lumin-org.github.io/ui/api/#computed)
]=]
return function(
processor: (use: (value: Types.State | any) -> ()) -> (),
Expand Down
19 changes: 11 additions & 8 deletions src/Event.luau
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ end
--[=[
Connects a callback to an event on the instance.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/keys/#event)
[Open Documentation](https://lumin-org.github.io/ui/api/keys/#event)
]=]
return function(event: string, callback: (...any) -> ()): Types.Action
return Action("Event", function(instance: Instance)
local Success, Event = pcall(Find, instance :: any, event :: any)
if not Success or type(callback) ~= "function" then
Debugger.Fatal("InvalidPropOrEvent", event)
end
Event:Connect(callback)
end)
if not Action.List["Event"] then
Action.New("Event", function(instance: Instance)
local Success, Event = pcall(Find, instance :: any, event :: any) -- Ensure event exists
if not Success or type(callback) ~= "function" then
Debugger.Fatal("InvalidPropOrEvent", event)
end
Event:Connect(callback)
end)
end
return Action.List["Event"]
end
56 changes: 26 additions & 30 deletions src/New.luau
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,39 @@ local Defaults = require(Root.Defaults)
-- Module

--[=[
Clones or creates a new isntance with the provided properties. Default properties are not
set on clones.
Creates a new instance with the provided properties.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/#new)
[Open Documentation](https://lumin-org.github.io/ui/api/#new)
]=]
return function(class: string | Instance, props: { any }?): Instance
Debugger.Assert(type(class) == "string" or typeof(class) == "Instance", "FailedCreation", class, "")

local Success, New

if type(class) == "string" then
Success, New = pcall(Instance.new, class)
else
Success, New = true, class:Clone()
end

if Success then
if type(class) == "string" and Defaults[class] then
for prop, value in Defaults[class] do
(New :: any)[prop] = value
return function(class: string)
Debugger.Assert(type(class) == "string", "InvalidType", class, "invalid")
return function(props: { any }): Instance
local Success, New = pcall(Instance.new, class)

if Success then
-- Apply default properties
if Defaults[class] then
for prop, value in Defaults[class] do
(New :: any)[prop] = value
end
end
end

if props then
for prop, value in props :: any do
if prop == "Parent" then
continue
if props then
for prop, value in props :: any do
if prop == "Parent" then
continue
end
Apply(New, prop, value)
end
Apply(New, prop, value)
end

if (props :: any).Parent then
New.Parent = (props :: any).Parent
if (props :: any).Parent then
New.Parent = (props :: any).Parent
end
end
else
Debugger.Fatal("FailedCreation", class, New)
end
else
Debugger.Fatal("FailedCreation", class, New)

return New
end
return New
end
30 changes: 16 additions & 14 deletions src/Spring.luau
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ local Animatable = {
-- Functions

function Class._Bind(self: Types.Spring, prop: string, instance: Instance)
(instance :: any)[prop] = self._Goal:Get()
table.insert(self._Instances, instance)
self._Goal:Listen(function(new)
(instance :: any)[prop] = self._Goal:Get() -- Set the prop of the instance to the initial goal
table.insert(self._Instances, instance)
self._Goal:Listen(function(new) -- When the goal changes, set the target to the new value
Spr.target(instance, self._Damping, self._Frequency, {
[prop] = new,
})
Expand All @@ -35,20 +35,22 @@ end
--[[
Stops the current spring from moving, leaving it at its current position.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/spring/#stop)
[Open Documentation](https://lumin-org.github.io/ui/api/spring/#stop)
]]
function Class.Stop(self: Types.Spring)
if self._Instances then
for _, instance in self._Instances do
Spr.stop(instance)
end
end
if self._Instances then
-- Iterate through all instances to make sure if the spring is used on
-- multiple objects, they are all stopped
for _, instance in self._Instances do
Spr.stop(instance)
end
end
end

--[[
Gets the end goal of the spring.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/spring/#get)
[Open Documentation](https://lumin-org.github.io/ui/api/spring/#get)
]]
function Class.Get(self: Types.Spring): Types.Animatable
return self._Goal:Get()
Expand All @@ -57,7 +59,7 @@ end
--[[
Destroys the spring object.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/spring/#destroy)
[Open Documentation](https://lumin-org.github.io/ui/api/spring/#destroy)
]]
function Class.Destroy(self: Types.Spring)
(self :: any)._Goal:Destroy()
Expand All @@ -68,18 +70,18 @@ end
--[=[
Creates a new spring with a set goal.
[Learn More](https://luminlabsdev.github.io/ui-framework/api/#spring)
[Open Documentation](https://lumin-org.github.io/ui/api/#spring)
]=]
return function(goal: Types.State, damping: number?, frequency: number?): Types.SpringExport
Debugger.Assert(table.find(Animatable, typeof((goal :: any):Get())), "NotAnimatable", typeof((goal :: any):Get()))
Debugger.Assert(type(goal) == "table" and goal._Type == "State", "InvalidType", "State", type(goal))

local self = setmetatable({}, { __index = Class })

self._Type = "Spring"
self._Type = "Spring"
self._Damping = damping or 1
self._Frequency = frequency or 1
self._Instances = {}
self._Instances = {}
self._Goal = goal

return self :: any
Expand Down
Loading

0 comments on commit 14fbf89

Please sign in to comment.