Skip to content

Commit

Permalink
Move to aftman (#54)
Browse files Browse the repository at this point in the history
* Move to aftman

* Rename to aftman

* Sort requires
  • Loading branch information
chriscerie authored Jan 13, 2024
1 parent b804e25 commit 0334ee5
Show file tree
Hide file tree
Showing 31 changed files with 815 additions and 729 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
name: selene lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Aftman
uses: ok-nick/[email protected]

- name: Lint src
run: selene src

style:
name: style
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Check code style
uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.19.1
args: --check src stories test
6 changes: 6 additions & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tools]
rojo = "rojo-rbx/[email protected]"
wally-package-types = "JohnnyMorganz/[email protected]"
selene = "kampfkarren/[email protected]"
wally = "upliftgames/[email protected]"
StyLua = "JohnnyMorganz/[email protected]"
4 changes: 0 additions & 4 deletions foreman.toml

This file was deleted.

6 changes: 3 additions & 3 deletions src/Controller.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--!strict

local React = require(script.Parent.React)
local Promise = require(script.Parent.Promise)
local React = require(script.Parent.React)
local SpringValue = require(script.Parent.SpringValue)
local common = require(script.Parent.types.common)
local helpers = require(script.Parent.helpers)
local util = require(script.Parent.util)
local common = require(script.Parent.types.common)

local Controller = {}
Controller.__index = Controller
Expand Down Expand Up @@ -66,7 +66,7 @@ end
Process a single set of props using the given controller.
]]
local function flushUpdate(ctrl, props, isLoop: boolean?)
local function flushUpdate(ctrl, props, _isLoop: boolean?)
-- Looping must be handled in this function, or else the values
-- would end up looping out-of-sync in many common cases.
local loop = props.loop
Expand Down
6 changes: 3 additions & 3 deletions src/Controller.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ return function()
end)

it("should set the initial value of `from` if one is passed to constructor", function()
local styles, api = RoactSpring.Controller.new({ from = { x = 0 } })
local styles, _api = RoactSpring.Controller.new({ from = { x = 0 } })
expect(styles.x:getValue()).to.equal(0)
end)

it("should set the initial value of `to` if one is passed to constructor", function()
local styles, api = RoactSpring.Controller.new({ to = { x = 100 } })
local styles, _api = RoactSpring.Controller.new({ to = { x = 100 } })
expect(styles.x:getValue()).to.equal(100)
end)

it("should set the initial value of `from` if both `from` and `to` are passed to constructor", function()
local styles, api = RoactSpring.Controller.new({ from = { x = 0 }, to = { x = 100 } })
local styles, _api = RoactSpring.Controller.new({ from = { x = 0 }, to = { x = 100 } })
expect(styles.x:getValue()).to.equal(0)
end)

Expand Down
6 changes: 3 additions & 3 deletions src/SpringValue.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local RunService = game:GetService("RunService")

local Promise = require(script.Parent.Promise)
local Signal = require(script.Parent.Signal)
local Animation = require(script.Parent.Animation)
local AnimationConfig = require(script.Parent.AnimationConfig)
local util = require(script.Parent.util)
local Promise = require(script.Parent.Promise)
local Signal = require(script.Parent.Signal)
local helpers = require(script.Parent.helpers)
local util = require(script.Parent.util)

local SpringValue = {}
SpringValue.__index = SpringValue
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useSpring.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--!strict
local Promise = require(script.Parent.Parent.Promise)
local Controller = require(script.Parent.Parent.Controller)
local Promise = require(script.Parent.Parent.Promise)
local common = require(script.Parent.Parent.types.common)
local useSprings = require(script.Parent.useSprings)
local isRoact17 = require(script.Parent.Parent.isRoact17)
local useSprings = require(script.Parent.useSprings)

export type UseSpringApi<T> = {
start: (startProps: Controller.ControllerProps<T>) -> typeof(Promise.new()),
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useSprings.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--!strict

local React = require(script.Parent.Parent.React)
local Promise = require(script.Parent.Parent.Promise)
local Controller = require(script.Parent.Parent.Controller)
local util = require(script.Parent.Parent.util)
local Promise = require(script.Parent.Parent.Promise)
local React = require(script.Parent.Parent.React)
local common = require(script.Parent.Parent.types.common)
local isRoact17 = require(script.Parent.Parent.isRoact17)
local util = require(script.Parent.Parent.util)

local useRefKey = if isRoact17 then "current" else "value"

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTrail.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--!strict
local React = require(script.Parent.Parent.React)
local Controller = require(script.Parent.Parent.Controller)
local React = require(script.Parent.Parent.React)
local isRoact17 = require(script.Parent.Parent.isRoact17)
local useSprings = require(script.Parent.useSprings)
local util = require(script.Parent.Parent.util)
local isRoact17 = require(script.Parent.Parent.isRoact17)

local useRefKey = if isRoact17 then "current" else "value"

Expand Down
2 changes: 1 addition & 1 deletion src/init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--!strict

local Controller = require(script.Controller)
local common = require(script.types.common)
local useSprings = require(script.hooks.useSprings)
local Controller = require(script.Controller)

export type AnimatableType = common.AnimatableType
export type AnimationStyle = common.AnimationStyle
Expand Down
38 changes: 19 additions & 19 deletions stories/components/CircleButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ local e = React.createElement

local function Button(props)
return e("TextButton", {
AnchorPoint = props.AnchorPoint or Vector2.new(0.5, 0.5),
Position = props.Position or UDim2.fromScale(0.5, 0.5),
AnchorPoint = props.AnchorPoint or Vector2.new(0.5, 0.5),
Position = props.Position or UDim2.fromScale(0.5, 0.5),
Size = props.Size or UDim2.fromOffset(150, 150),
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
AutoButtonColor = false,
Text = "",
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
AutoButtonColor = false,
Text = "",

[React.Event.Activated] = props[React.Event.Activated],
[React.Event.InputBegan] = props[React.Event.InputBegan],
[React.Event.InputEnded] = props[React.Event.InputEnded],
[React.Event.Activated] = props[React.Event.Activated],
[React.Event.InputBegan] = props[React.Event.InputBegan],
[React.Event.InputEnded] = props[React.Event.InputEnded],
}, {
UICorner = e("UICorner", {
CornerRadius = UDim.new(1, 0),
}),
UIGradient = e("UIGradient", {
Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(110, 255, 183)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 119, 253)),
}),
Rotation = 25,
}),
})
UICorner = e("UICorner", {
CornerRadius = UDim.new(1, 0),
}),
UIGradient = e("UIGradient", {
Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(110, 255, 183)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 119, 253)),
}),
Rotation = 25,
}),
})
end

return Button
36 changes: 18 additions & 18 deletions stories/hooks/useSpringBouncePause.story.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local CircleButton = require(script.Parent.Parent.components.CircleButton)
local React = require(ReplicatedStorage.Packages.React)
local ReactRoblox = require(ReplicatedStorage.Packages.ReactRoblox)
local RoactSpring = require(ReplicatedStorage.Packages.RoactSpring)
local CircleButton = require(script.Parent.Parent.components.CircleButton)

local e = React.createElement
local PAUSE_AFTER_SECONDS = 1.5

local function Button(_)
local styles, api = RoactSpring.useSpring(function()
return {
position = UDim2.fromScale(0.5, 0.5),
}
end)
local styles, api = RoactSpring.useSpring(function()
return {
position = UDim2.fromScale(0.5, 0.5),
}
end)

return e(CircleButton, {
Position = styles.position,
[React.Event.Activated] = function()
api.start({
to = { position = UDim2.fromScale(0.5, 0.8) },
config = { bounce = 1, tension = 180, friction = 0 },
})
task.wait(PAUSE_AFTER_SECONDS)
api.pause()
end
Position = styles.position,
[React.Event.Activated] = function()
api.start({
to = { position = UDim2.fromScale(0.5, 0.8) },
config = { bounce = 1, tension = 180, friction = 0 },
})
task.wait(PAUSE_AFTER_SECONDS)
api.pause()
end,
})
end

return function(target)
local root = ReactRoblox.createRoot(Instance.new("Folder"))
root:render(ReactRoblox.createPortal({
App = e(Button)
}, target))
root:render(ReactRoblox.createPortal({
App = e(Button),
}, target))

return function()
root:unmount()
Expand Down
36 changes: 18 additions & 18 deletions stories/hooks/useSpringBounceStop.story.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local CircleButton = require(script.Parent.Parent.components.CircleButton)
local React = require(ReplicatedStorage.Packages.React)
local ReactRoblox = require(ReplicatedStorage.Packages.ReactRoblox)
local RoactSpring = require(ReplicatedStorage.Packages.RoactSpring)
local CircleButton = require(script.Parent.Parent.components.CircleButton)

local e = React.createElement
local STOP_AFTER_SECONDS = 3

local function Button(_)
local styles, api = RoactSpring.useSpring(function()
return {
position = UDim2.fromScale(0.5, 0.3),
}
end)
local styles, api = RoactSpring.useSpring(function()
return {
position = UDim2.fromScale(0.5, 0.3),
}
end)

return e(CircleButton, {
Position = styles.position,
[React.Event.Activated] = function()
api.start({
to = { position = UDim2.fromScale(0.5, 0.8) },
config = { mass = 2.5, bounce = 1, tension = 180, friction = 0 },
})
task.wait(STOP_AFTER_SECONDS)
api.stop()
end
Position = styles.position,
[React.Event.Activated] = function()
api.start({
to = { position = UDim2.fromScale(0.5, 0.8) },
config = { mass = 2.5, bounce = 1, tension = 180, friction = 0 },
})
task.wait(STOP_AFTER_SECONDS)
api.stop()
end,
})
end

return function(target)
local root = ReactRoblox.createRoot(Instance.new("Folder"))
root:render(ReactRoblox.createPortal({
App = e(Button)
}, target))
root:render(ReactRoblox.createPortal({
App = e(Button),
}, target))

return function()
root:unmount()
Expand Down
36 changes: 18 additions & 18 deletions stories/hooks/useSpringColorDeclarative.story.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ local RoactSpring = require(ReplicatedStorage.Packages.RoactSpring)
local e = React.createElement

local function Button(_)
local toggle, setToggle = React.useState(false)
local styles = RoactSpring.useSpring({
color = if toggle then Color3.fromRGB(0, 0, 0) else Color3.fromRGB(255, 255, 255),
})
local toggle, setToggle = React.useState(false)
local styles = RoactSpring.useSpring({
color = if toggle then Color3.fromRGB(0, 0, 0) else Color3.fromRGB(255, 255, 255),
})

return e("TextButton", {
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.fromScale(0.5, 0.5),
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.fromScale(0.5, 0.5),
Size = UDim2.fromOffset(200, 200),
BackgroundColor3 = styles.color,
AutoButtonColor = false,
Text = "",
AutoButtonColor = false,
Text = "",

[React.Event.Activated] = function()
setToggle(function(prevState)
return not prevState
end)
end,
[React.Event.Activated] = function()
setToggle(function(prevState)
return not prevState
end)
end,
}, {
UICorner = e("UICorner"),
})
UICorner = e("UICorner"),
})
end

return function(target)
local root = ReactRoblox.createRoot(Instance.new("Folder"))
root:render(ReactRoblox.createPortal({
App = e(Button)
}, target))
root:render(ReactRoblox.createPortal({
App = e(Button),
}, target))

return function()
root:unmount()
Expand Down
Loading

0 comments on commit 0334ee5

Please sign in to comment.