Skip to content

Commit

Permalink
Restructure the project into semantic folders (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel authored Dec 4, 2023
1 parent f72c57a commit 020c234
Show file tree
Hide file tree
Showing 80 changed files with 173 additions and 160 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Components/Branding.lua → src/Common/Branding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local assets = require(flipbook.assets)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local useTheme = require(flipbook.Common.useTheme)
local Sprite = require(flipbook.Common.Sprite)

local e = React.createElement

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local Sift = require(flipbook.Packages.Sift)
local React = require(flipbook.Packages.React)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

export type Props = {
[string]: any,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
return function()
local React = require(flipbook.Packages.React)
local ReactRoblox = require(flipbook.Packages.ReactRoblox)
local newFolder = require(flipbook.TestHelpers.newFolder)
local newFolder = require(flipbook.Testing.newFolder)
local useDescendants = require(script.Parent.useDescendants)

local container = Instance.new("ScreenGui")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
return function()
local React = require(flipbook.Packages.React)
local ReactRoblox = require(flipbook.Packages.ReactRoblox)
local useEvent = require(flipbook.Hooks.useEvent)
local useEvent = require(script.Parent.useEvent)

local container = Instance.new("ScreenGui")
local root = ReactRoblox.createRoot(container)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
return function()
local React = require(flipbook.Packages.React)
local ReactRoblox = require(flipbook.Packages.ReactRoblox)
local useEvent = require(flipbook.Hooks.useEvent)
local useEvent = require(flipbook.Common.useEvent)
local usePrevious = require(script.Parent.usePrevious)

local container = Instance.new("ScreenGui")
Expand Down
3 changes: 1 addition & 2 deletions src/Hooks/useTheme.lua → src/Common/useTheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local themes = require(flipbook.themes)
local types = require(flipbook.types)

local MOCK_STUDIO = {
ThemeChanged = Instance.new("BindableEvent").Event,
Expand All @@ -20,7 +19,7 @@ local function useTheme()
return if success then result else MOCK_STUDIO
end, {})

local theme: types.Theme, set = React.useState(themes[studio.Theme.Name])
local theme: themes.Theme, set = React.useState(themes[studio.Theme.Name])

React.useEffect(function()
local conn = studio.ThemeChanged:Connect(function()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Hooks/useZoom.spec.lua → src/Common/useZoom.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
return function()
local React = require(flipbook.Packages.React)
local ReactRoblox = require(flipbook.Packages.ReactRoblox)
local useEvent = require(flipbook.Hooks.useEvent)
local useEvent = require(flipbook.Common.useEvent)
local useZoom = require(script.Parent.useZoom)

local container = Instance.new("ScreenGui")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local React = require(flipbook.Packages.React)
local RoactSpring = require(flipbook.Packages.RoactSpring)
local assets = require(flipbook.assets)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local types = require(flipbook.types)
local useTheme = require(flipbook.Common.useTheme)
local Sprite = require(flipbook.Common.Sprite)
local types = require(flipbook.Explorer.types)

local e = React.createElement

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local React = require(flipbook.Packages.React)
local RoactSpring = require(flipbook.Packages.RoactSpring)
local assets = require(flipbook.assets)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local types = require(flipbook.types)
local useTheme = require(flipbook.Common.useTheme)
local Sprite = require(flipbook.Common.Sprite)
local types = require(flipbook.Explorer.types)

local e = React.createElement

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local Directory = require(script.Directory)
local Story = require(script.Story)
local types = require(flipbook.types)
local getTreeDescendants = require(flipbook.Modules.getTreeDescendants)
local types = require(flipbook.Explorer.types)
local getTreeDescendants = require(flipbook.Explorer.getTreeDescendants)

local e = React.createElement

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local flipbook = script:FindFirstAncestor("flipbook")

local types = require(flipbook.types)
local types = require(flipbook.Explorer.types)

local function getTreeDescendants(root: types.ComponentTreeNode): { types.ComponentTreeNode }
local descendants: { types.ComponentTreeNode } = {}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Component = require(script.Component)
local types = require(flipbook.types)
local types = require(script.types)

local e = React.createElement

Expand Down
14 changes: 14 additions & 0 deletions src/Explorer/types.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local flipbook = script:FindFirstAncestor("flipbook")

local storybookTypes = require(flipbook.Storybook.types)
type Storybook = storybookTypes.Storybook

export type ComponentTreeNode = {
name: string,
children: { ComponentTreeNode },
icon: string?,
instance: Instance?,
storybook: Storybook?,
}

return nil
2 changes: 1 addition & 1 deletion src/Components/Button.lua → src/Forms/Button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

export type Props = {
initialState: boolean,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

export type Props = {
placeholder: string?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Dropdown = require(flipbook.Components.Fields.Dropdown)
local Dropdown = require(flipbook.Forms.Dropdown)

local controls = {
useDefault = true,
Expand Down
4 changes: 2 additions & 2 deletions src/Components/InputField.lua → src/Forms/InputField.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand All @@ -14,7 +14,7 @@ local defaultProps = {

export type Props = typeof(defaultProps) & {
layoutOrder: number?,
onSubmit: ((text: string) -> ()),
onSubmit: (text: string) -> (),
onFocus: (() -> ())?,
onFocusLost: (() -> ())?,
onTextChange: ((new: string, old: string) -> ())?,
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/Components/Searchbar.lua → src/Forms/Searchbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ local RoactSpring = require(flipbook.Packages.RoactSpring)
local Sift = require(flipbook.Packages.Sift)
local assets = require(flipbook.assets)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local mapRanges = require(flipbook.Modules.mapRanges)
local InputField = require(flipbook.Components.InputField)
local Sprite = require(flipbook.Components.Sprite)
local useTheme = require(flipbook.Common.useTheme)
local mapRanges = require(flipbook.Common.mapRanges)
local InputField = require(flipbook.Forms.InputField)
local Sprite = require(flipbook.Common.Sprite)

local e = React.createElement

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local defaultProps = {
AutomaticSize = Enum.AutomaticSize.XY,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Navbar/Item.lua → src/Navigation/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local RoactSpring = require(flipbook.Packages.RoactSpring)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local RunService = game:GetService("RunService")
local Sift = require(flipbook.Packages.Sift)
local React = require(flipbook.Packages.React)
local PluginContext = require(flipbook.Plugin.PluginContext)
local types = require(flipbook.types)
local types = require(flipbook.Panels.types)

local defaultProps = {
size = 8, -- px
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local DragHandle = require(flipbook.Components.DragHandle)
local types = require(flipbook.types)
local DragHandle = require(flipbook.Panels.DragHandle)
local types = require(flipbook.Panels.types)

local defaultProps = {
dragHandleSize = 8, -- px
Expand Down
File renamed without changes.
24 changes: 14 additions & 10 deletions src/Components/Sidebar.lua → src/Panels/Sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local constants = require(flipbook.constants)
local createStoryNodes = require(flipbook.Story.createStoryNodes)
local Branding = require(flipbook.Components.Branding)
local ComponentTree = require(flipbook.Components.ComponentTree)
local Searchbar = require(flipbook.Components.Searchbar)
local ScrollingFrame = require(flipbook.Components.ScrollingFrame)
local useTheme = require(flipbook.Hooks.useTheme)
local types = require(flipbook.types)
local createStoryNodes = require(flipbook.Storybook.createStoryNodes)
local Branding = require(flipbook.Common.Branding)
local ComponentTree = require(flipbook.Explorer)
local Searchbar = require(flipbook.Forms.Searchbar)
local ScrollingFrame = require(flipbook.Common.ScrollingFrame)
local useTheme = require(flipbook.Common.useTheme)
local storybookTypes = require(flipbook.Storybook.types)
local explorerTypes = require(flipbook.Explorer.types)

type Storybook = storybookTypes.Storybook
type ComponentTreeNode = explorerTypes.ComponentTreeNode

local e = React.createElement

type Props = {
layoutOrder: number?,
selectStory: (ModuleScript) -> (),
selectStorybook: (types.Storybook) -> (),
storybooks: { types.Storybook },
selectStorybook: (Storybook) -> (),
storybooks: { Storybook },
}

local function Sidebar(props: Props)
local theme = useTheme()

local activeNode, setActiveNode = React.useState(nil)
local onClick = React.useCallback(function(node: types.ComponentTreeNode)
local onClick = React.useCallback(function(node: ComponentTreeNode)
if node.instance and node.instance:IsA("ModuleScript") and node.name:match(constants.STORY_NAME_PATTERN) then
if node.storybook then
props.selectStorybook(node.storybook)
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/Panels/types.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type DragHandle = "Top" | "Right" | "Bottom" | "Left"

return nil
12 changes: 6 additions & 6 deletions src/Components/App.lua → src/Plugin/PluginApp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local constants = require(flipbook.constants)
local useStorybooks = require(flipbook.Hooks.useStorybooks)
local useTheme = require(flipbook.Hooks.useTheme)
local useStorybooks = require(flipbook.Storybook.useStorybooks)
local useTheme = require(flipbook.Common.useTheme)
local PluginContext = require(flipbook.Plugin.PluginContext)
local ResizablePanel = require(flipbook.Components.ResizablePanel)
local Canvas = require(flipbook.Components.Canvas)
local Sidebar = require(flipbook.Components.Sidebar)
local ResizablePanel = require(flipbook.Panels.ResizablePanel)
local StoryCanvas = require(flipbook.Storybook.StoryCanvas)
local Sidebar = require(flipbook.Panels.Sidebar)

export type Props = {
plugin: Plugin,
Expand Down Expand Up @@ -63,7 +63,7 @@ local function App(props: Props)
LayoutOrder = 2,
Size = UDim2.fromScale(1, 1) - UDim2.fromOffset(sidebarWidth, 0),
}, {
Canvas = React.createElement(Canvas, {
StoryCanvas = React.createElement(StoryCanvas, {
loader = props.loader,
story = story,
storybook = storybook,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local ModuleLoader = require(flipbook.Packages.ModuleLoader)
local App = require(script.Parent.App)
local PluginApp = require(script.Parent.PluginApp)

return {
summary = "The main component that handles the entire plugin",
controls = {},
story = React.createElement(App, {
story = React.createElement(PluginApp, {
loader = ModuleLoader.new(),
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local assets = require(flipbook.assets)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local useTheme = require(flipbook.Common.useTheme)
local Sprite = require(flipbook.Common.Sprite)

local e = React.createElement

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/Components/Canvas.lua → src/Storybook/StoryCanvas.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local types = require(flipbook.types)
local NoStorySelected = require(flipbook.Components.NoStorySelected)
local StoryView = require(flipbook.Components.StoryView)
local useTheme = require(flipbook.Hooks.useTheme)
local types = require(flipbook.Storybook.types)
local NoStorySelected = require(flipbook.Storybook.NoStorySelected)
local StoryView = require(flipbook.Storybook.StoryView)
local useTheme = require(flipbook.Common.useTheme)

local e = React.createElement

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)

local useTheme = require(flipbook.Hooks.useTheme)
local InputField = require(flipbook.Components.InputField)
local Checkbox = require(flipbook.Components.Fields.Checkbox)
local Dropdown = require(flipbook.Components.Fields.Dropdown)
local useTheme = require(flipbook.Common.useTheme)
local InputField = require(flipbook.Forms.InputField)
local Checkbox = require(flipbook.Forms.Checkbox)
local Dropdown = require(flipbook.Forms.Dropdown)

local e = React.createElement

Expand Down
Loading

0 comments on commit 020c234

Please sign in to comment.