{"id":"karlobii/framelink","name":"framelink","scope":"karlobii","platform":"roblox","description":"Links frames and buttons with optional animations and one at a time menu management. Includes bulk-link and custom tweens.","version":"1.0.4","latest":"1.0.4","versions":["1.0.0","1.0.1","1.0.2-test","1.0.2","1.0.3-test","1.0.3","1.0.4-test","1.0.4"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"ef2781ad11ec11d1b91b85006f1e7d8e0850f62c38b1091ffec6b33851ada118","likes":0,"downloads":0,"install":"forest install karlobii/framelink","url":"https://forest.dev/p/roblox/karlobii/framelink","files":"https://api.forest.dev/ai/package/roblox/karlobii/framelink/files","readme":"# FrameLink\n\n**FrameLink** is a lightweight, type-safe Luau UI animation and state management framework designed for Roblox. It simplifies window management, handles single-frame visibility constraints, manages audio playback, and automates UI transitions with built-in or custom animations.\n\nWhether you build interfaces using traditional Instance hierarchies or declarative UI frameworks like **Vide**, **Fusion**, or **Roact**, FrameLink integrates seamlessly by allowing optional button binding (`button = nil`) and exposing imperative control methods (`:setOpen()`, `:setClosed()`, `:toggle()`).\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Luau Strict](https://img.shields.io/badge/Luau-Strict-blueviolet.svg)](https://luau-lang.org/)\n\n---\n\n## Key Features\n\n- 🎯 **Automatic State Locking:** Ensures only **one** linked UI frame can be open at a time, smoothly transitioning out active frames before opening new ones.\n- ⚛️ **Declarative Framework Support:** Pass `nil` as the trigger button to link frames generated dynamically via **Vide**, **Fusion**, or **Roact/React**, controlling them directly through action hooks or signal callbacks.\n- ⚡ **Type-Safe Luau:** Built from the ground up using `--!strict` mode for full autocomplete and static analysis support.\n- 📂 **Multi-Linking:** Automatically link whole folders of buttons and corresponding frames with a single method call.\n- 🎨 **Built-in Presets:** Out-of-the-box support for popular UI animations like `Pop`, `PopSpin`, `SlideBottom`, `SlideLeft`, `SlideRight`, and `Top`.\n- 🧩 **Custom Animation Engine:** Register custom tween definitions globally or pass dynamic per-frame transitions.\n- 🎧 **Built-in Audio & Overlay Support:** Assign open/close sound effects and modal backdrop buttons directly through property tables.\n\n---\n\n# Install\n\n## Manual\n\nPlace `FrameLink` inside your project's client hierarchy (e.g., `ReplicatedStorage` or `StarterPlayerScripts`):\n\n```text\nFrameLink (ModuleScript)\n└── Animations (ModuleScript)\n\n```\n\n## Wally\n\n```text\nFrameLink = \"karlobii/framelink@^1.0.0\"\n```\n\n---\n\n## Usage Examples\n\n### 1. Traditional Instance Workflow\n\nLink a single trigger button directly to a UI frame:\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal FrameLink = require(ReplicatedStorage.FrameLink)\n\nlocal playerGui = game:GetService(\"Players\").LocalPlayer:WaitForChild(\"PlayerGui\")\nlocal mainGui = playerGui:WaitForChild(\"MainGui\")\n\nlocal openButton = mainGui.ShopButton\nlocal shopFrame = mainGui.ShopFrame\n\n-- Link button to frame with a built-in animation preset\nlocal shopWindow = FrameLink.link(openButton, shopFrame, {\n    Anim = \"Pop\",\n    CloseButton = shopFrame:FindFirstChild(\"CloseButton\"),\n    Background = mainGui:FindFirstChild(\"ModalOverlay\"),\n    SoundIn = ReplicatedStorage.Sounds.Open,\n    SoundOut = ReplicatedStorage.Sounds.Close,\n    OnOpened = function(obj)\n        print(\"Shop opened!\")\n    end,\n    OnClosed = function(obj)\n        print(\"Shop closed!\")\n    end,\n})\n\n```\n\n---\n\n### 2. Declarative UI Workflow (Vide, Fusion, etc.)\n\nWhen using declarative UI libraries, pass `nil` as the first argument (`button`) in `FrameLink.link()`. This creates a `FrameLinkObj` managed directly through state handlers or click events.\n\n#### Vide Integration Example\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal Vide = require(ReplicatedStorage.Packages.Vide)\nlocal FrameLink = require(ReplicatedStorage.Packages.FrameLink)\n\nlocal create = Vide.create\nlocal action = Vide.action\n\nlocal function ShopComponent()\n    local shopLink: FrameLink.FrameLinkObj?\n\n    return create \"Frame\" {\n        Name = \"BigFramey\",\n        Size = UDim2.fromScale(1, 1),\n        BackgroundTransparency = 1,\n\n        -- Shop Window\n        create \"Frame\" {\n            Name = \"Shop\",\n            Size = UDim2.fromScale(0.5, 0.5),\n            AnchorPoint = Vector2.new(0.5, 0.5),\n            Position = UDim2.fromScale(0.5, 0.5),\n\n            -- Capture reference to node upon creation and link without explicit button\n            action(function(node: Instance)\n                shopLink = FrameLink.link(nil, node :: GuiObject, {\n                    Anim = \"PopSpin\",\n                    CloseButton = node:FindFirstChild(\"CloseButton\") :: GuiButton,\n                })\n            end),\n\n            create \"UICorner\" { CornerRadius = UDim.new(0.05, 0) },\n\n            create \"TextButton\" {\n                Name = \"CloseButton\",\n                AnchorPoint = Vector2.new(0.5, 0.5),\n                Position = UDim2.fromScale(1, 0),\n                Size = UDim2.fromScale(0.1, 0.1),\n                Text = \"X\",\n                Font = Enum.Font.FredokaOne,\n                BackgroundColor3 = Color3.new(1, 0, 0),\n            },\n        },\n\n        -- Open Trigger Button\n        create \"TextButton\" {\n            Name = \"ShopButton\",\n            Text = \"Shop\",\n            Position = UDim2.fromScale(0.026, 0.574),\n            Size = UDim2.fromScale(0.05, 0.05),\n            Font = Enum.Font.FredokaOne,\n\n            -- Call the FrameLink instance methods imperatively\n            Activated = function()\n                if shopLink then\n                    shopLink:toggle()\n                end\n            end,\n        },\n    }\nend\n\nreturn ShopComponent\n\n```\n\n---\n\n### 3. Folder-based Linking (`FrameLink.multiLink`)\n\nFor traditional static UI structures organized inside folders:\n\n```text\nStarterGui\n└── MainGui\n    ├── Buttons/\n    │   ├── Shop\n    │   ├── Inventory\n    │   └── Settings\n    └── Frames/\n        ├── Shop (contains CloseButton)\n        ├── Inventory (contains CloseButton)\n        └── Settings (contains CloseButton)\n\n```\n\nInitialize every interface with a single call:\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal FrameLink = require(ReplicatedStorage.FrameLink)\n\nlocal gui = game:GetService(\"Players\").LocalPlayer.PlayerGui:WaitForChild(\"MainGui\")\n\nFrameLink.multiLink(gui.Buttons, gui.Frames, {\n    Anim = \"PopSpin\",\n    CloseButtonName = \"CloseButton\",\n    BackgroundName = \"ModalOverlay\",\n    SoundIn = ReplicatedStorage.Sounds.OpenSound,\n    SoundOut = ReplicatedStorage.Sounds.CloseSound,\n})\n\n```\n\n---\n\n## Built-in Animations\n\nFrameLink includes standard presets provided via the `Animations` submodule:\n\n| Animation Name | Description |\n| --- | --- |\n| `Pop` | Scales frame up from `0` to its original size using `Back` easing. |\n| `PopSpin` | Scales up while un-spinning from `-60°`. |\n| `SlideBottom` | Slides in from below the screen (`Y Scale = 1.5`). |\n| `Top` | Drops in from above the screen (`Y Scale = -0.5`) with bounce easing. |\n| `SlideRight` | Slides in from the right screen boundary (`X Scale = 1.5`). |\n| `SlideLeft` | Slides in from the left screen boundary (`X Scale = -0.5`). |\n| `SlideLeftSpin` | Slides in from the left screen boundary while rotating 180 degrees. |\n| `SlideRightSpin` | Slides in from the right screen boundary while rotating -180 degrees. |\n\n---\n\n## Custom Animations\n\n### Registering Globally\n\nRegister custom preset transitions to make them available across all scripts:\n\n```lua\nlocal FrameLink = require(ReplicatedStorage.FrameLink)\n\nFrameLink.registerAnimation(\"FadeScale\", {\n    InfoIn = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),\n    InfoOut = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In),\n    StartState = function(defaults)\n        return {\n            Size = UDim2.new(0, 0, 0, 0),\n            GroupTransparency = 1,\n        }\n    end,\n    InGoals = function(defaults)\n        return {\n            Size = defaults.Size,\n            GroupTransparency = 0,\n        }\n    end,\n    OutGoals = function(defaults)\n        return {\n            Size = UDim2.new(0, 0, 0, 0),\n            GroupTransparency = 1,\n        }\n    end,\n})\n\n-- Use your custom animation\nFrameLink.link(button, frame, { Anim = \"FadeScale\" })\n\n```\n\n---\n\n## API Reference\n\n### `FrameLink.link(button, frame, props)`\n\nBinds an optional `GuiButton` trigger to a target `GuiObject` frame and returns a `FrameLinkObj` instance.\n\n* **`button`**: `GuiButton?` — Optional trigger button that toggles frame visibility. Pass `nil` for declarative framework UI workflow.\n* **`frame`**: `GuiObject` — Target UI element.\n* **`props`**: `Props?` — Config object (see [Props Reference](https://www.google.com/search?q=%23props-reference)).\n\n### `FrameLink.multiLink(buttonFolder, frameFolder, multiProps)`\n\nIterates over a folder of buttons, pairing them with named frames in a frame folder.\n\n### `FrameLink.registerAnimation(name, animDef)`\n\nAdds a named `AnimationDefinition` table to the internal registry.\n\n### Instance Methods (`FrameLinkObj`)\n\n```lua\nwindow:setOpen()   -- Opens the frame and closes any previously opened active frame\nwindow:setClosed() -- Closes the frame\nwindow:toggle()    -- Toggles between open/closed states\nwindow:destroy()   -- Disconnects events and cancels active tweens\n\n```\n\n---\n\n## Props Reference\n\n```lua\ntype Props = {\n    In: (string | AnimationDefinition)?,        -- Animation for opening\n    Out: (string | AnimationDefinition)?,       -- Animation for closing\n    Anim: (string | AnimationDefinition)?,      -- Unified animation for both In/Out\n    CloseButton: GuiButton?,                   -- Button that explicitly closes the frame\n    Background: GuiButton?,                    -- Backdrop overlay button (closes frame on click)\n    SoundIn: Sound?,                           -- Sound played when opening\n    SoundOut: Sound?,                          -- Sound played when closing\n    OnOpened: ((FrameLinkObj) -> ())?,         -- Callback executed on open\n    OnClosed: ((FrameLinkObj) -> ())?,         -- Callback executed on close\n    tweenInfoIn: TweenInfo?,                   -- Override TweenInfo for open transition\n    tweenInfoOut: TweenInfo?,                  -- Override TweenInfo for close transition\n}\n\n```\n\n---\n\n## License\n\nCopyright (c) 2026 karlobii\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n```\n\n```#","readmeTruncated":false}