Skip to content

Commit

Permalink
Port more stories
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel committed Apr 8, 2024
1 parent 44c6e1e commit bb7f9fb
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 145 deletions.
7 changes: 5 additions & 2 deletions src/Common/Branding.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local Branding = require(script.Parent.Branding)

local stories = {}

stories.Primary = React.createElement(Branding)

return {
summary = "Icon and Typography for flipbook",
controls = {},
story = React.createElement(Branding),
stories = stories,
}
52 changes: 28 additions & 24 deletions src/Common/ScrollingFrame.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ type Props = {
controls: typeof(controls),
}

return {
controls = controls,
story = function(props: Props)
local children = {}
local stories = {}

children.Layout = React.createElement("UIListLayout", {
SortOrder = Enum.SortOrder.LayoutOrder,
Padding = UDim.new(0, 16),
})
stories.Primary = function(props: Props)
local children = {}

children.Layout = React.createElement("UIListLayout", {
SortOrder = Enum.SortOrder.LayoutOrder,
Padding = UDim.new(0, 16),
})

for i = 1, props.controls.numItems do
children["Box" .. i] = React.createElement("Frame", {
LayoutOrder = i,
Size = UDim2.fromOffset(100, 100),
BackgroundColor3 = if props.controls.useGradient
then Color3.fromRGB(0, 255 / i, 0)
else Color3.fromRGB(0, 255, 0),
})
end

return React.createElement("Frame", {
Size = UDim2.new(1, 0, 0, 200),
BackgroundTransparency = 1,
}, {
ScrollingFrame = React.createElement(ScrollingFrame, {}, children),
for i = 1, props.controls.numItems do
children["Box" .. i] = React.createElement("Frame", {
LayoutOrder = i,
Size = UDim2.fromOffset(100, 100),
BackgroundColor3 = if props.controls.useGradient
then Color3.fromRGB(0, 255 / i, 0)
else Color3.fromRGB(0, 255, 0),
})
end,
end

return React.createElement("Frame", {
Size = UDim2.new(1, 0, 0, 200),
BackgroundTransparency = 1,
}, {
ScrollingFrame = React.createElement(ScrollingFrame, {}, children),
})
end

return {
controls = controls,
stories = stories,
}
54 changes: 29 additions & 25 deletions src/Common/Sprite.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,34 @@ local React = require(flipbook.Packages.React)
local assets = require(flipbook.assets)
local Sprite = require(script.Parent.Sprite)

return {
story = React.createElement("Folder", {}, {
Layout = React.createElement("UIListLayout", {
SortOrder = Enum.SortOrder.LayoutOrder,
}),

flipbook = React.createElement(Sprite, {
layoutOrder = 1,
image = assets.flipbook,
}),

Storybook = React.createElement(Sprite, {
layoutOrder = 2,
image = assets.Storybook,
}),

Folder = React.createElement(Sprite, {
layoutOrder = 3,
image = assets.Folder,
}),

Component = React.createElement(Sprite, {
layoutOrder = 4,
image = assets.Component,
}),
local stories = {}

stories.Primary = React.createElement("Folder", {}, {
Layout = React.createElement("UIListLayout", {
SortOrder = Enum.SortOrder.LayoutOrder,
}),

flipbook = React.createElement(Sprite, {
layoutOrder = 1,
image = assets.flipbook,
}),

Storybook = React.createElement(Sprite, {
layoutOrder = 2,
image = assets.Storybook,
}),

Folder = React.createElement(Sprite, {
layoutOrder = 3,
image = assets.Folder,
}),

Component = React.createElement(Sprite, {
layoutOrder = 4,
image = assets.Component,
}),
})

return {
stories = stories,
}
20 changes: 12 additions & 8 deletions src/Forms/Button.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ type Props = {
controls: typeof(controls),
}

local stories = {}

stories.Primary = function(props: Props)
return React.createElement(Button, {
text = props.controls.text,
onClick = function()
print("click")
end,
})
end

return {
summary = "A generic button component that can be used anywhere",
controls = controls,
story = function(props: Props)
return React.createElement(Button, {
text = props.controls.text,
onClick = function()
print("click")
end,
})
end,
stories = stories,
}
16 changes: 10 additions & 6 deletions src/Forms/Checkbox.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local Checkbox = require(script.Parent.Checkbox)

local stories = {}

stories.Primary = React.createElement(Checkbox, {
initialState = true,
onStateChange = function(newState)
print("Checkbox state changed to", newState)
end,
})

return {
summary = "Generic checkbox used for story controls",
story = React.createElement(Checkbox, {
initialState = true,
onStateChange = function(newState)
print("Checkbox state changed to", newState)
end,
}),
stories = stories,
}
34 changes: 19 additions & 15 deletions src/Forms/Dropdown.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ type Props = {
controls: typeof(controls),
}

local stories = {}

stories.Primary = function(props: Props)
local options = {}
for i = 1, props.controls.numOptions do
table.insert(options, "Option " .. i)
end

return React.createElement(Dropdown, {
placeholder = "Select an option",
default = if props.controls.useDefault then options[1] else nil,
options = options,
onOptionChange = function(option)
print("Selected", option)
end,
})
end

return {
controls = controls,
story = function(props: Props)
local options = {}
for i = 1, props.controls.numOptions do
table.insert(options, "Option " .. i)
end

return React.createElement(Dropdown, {
placeholder = "Select an option",
default = if props.controls.useDefault then options[1] else nil,
options = options,
onOptionChange = function(option)
print("Selected", option)
end,
})
end,
stories = stories,
}
30 changes: 17 additions & 13 deletions src/Forms/InputField.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local InputField = require(script.Parent.InputField)

local stories = {}

stories.Primary = React.createElement(InputField, {
placeholder = "Enter information...",
autoFocus = true,
onSubmit = function(text)
print(text)
end,
validate = function(text: string)
return #text <= 4
end,
transform = function(text: string)
return text:upper()
end,
})

return {
story = React.createElement(InputField, {
placeholder = "Enter information...",
autoFocus = true,
onSubmit = function(text)
print(text)
end,
validate = function(text: string)
return #text <= 4
end,
transform = function(text: string)
return text:upper()
end,
}),
stories = stories,
}
6 changes: 5 additions & 1 deletion src/Forms/Searchbar.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local Searchbar = require(script.Parent.Searchbar)

local stories = {}

stories.Primary = React.createElement(Searchbar)

return {
summary = "Searchbar used to search for components",
controls = {},
story = React.createElement(Searchbar),
stories = stories,
}
14 changes: 9 additions & 5 deletions src/Forms/SelectableTextLabel.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ type Props = {
controls: typeof(controls),
}

local stories = {}

stories.Primary = function(props: Props)
return React.createElement(SelectableTextLabel, {
Text = props.controls.text,
})
end

return {
summary = "A styled TextLabel with selectable text. Click and drag with the mouse to select content",
controls = controls,
story = function(props: Props)
return React.createElement(SelectableTextLabel, {
Text = props.controls.text,
})
end,
stories = stories,
}
28 changes: 16 additions & 12 deletions src/Panels/ResizablePanel.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ type Props = {
controls: typeof(controls),
}

local stories = {}

stories.Primary = function(props)
return React.createElement(ResizablePanel, {
initialSize = UDim2.fromOffset(props.controls.maxWidth - props.controls.minWidth, 300),
maxSize = Vector2.new(props.controls.maxWidth, props.controls.maxHeight),
minSize = Vector2.new(props.controls.minWidth, props.controls.minHeight),
dragHandles = { "Right", "Bottom" },
}, {
Content = React.createElement("Frame", {
Size = UDim2.fromScale(1, 1),
}),
})
end

return {
controls = controls,
story = function(props)
return React.createElement(ResizablePanel, {
initialSize = UDim2.fromOffset(props.controls.maxWidth - props.controls.minWidth, 300),
maxSize = Vector2.new(props.controls.maxWidth, props.controls.maxHeight),
minSize = Vector2.new(props.controls.minWidth, props.controls.minHeight),
dragHandles = { "Right", "Bottom" },
}, {
Content = React.createElement("Frame", {
Size = UDim2.fromScale(1, 1),
}),
})
end,
stories = stories,
}
26 changes: 15 additions & 11 deletions src/Panels/Sidebar.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ local React = require(flipbook.Packages.React)
local internalStorybook = require(flipbook["init.storybook"])
local Sidebar = require(script.Parent.Sidebar)

local stories = {}

stories.Primary = React.createElement(Sidebar, {
storybooks = {
internalStorybook,
},
selectStory = function(storyModule)
print(storyModule)
end,
selectStorybook = function(storybook)
print(storybook)
end,
})

return {
summary = "Sidebar containing brand, searchbar, and component tree",
controls = {},
story = React.createElement(Sidebar, {
storybooks = {
internalStorybook,
},
selectStory = function(storyModule)
print(storyModule)
end,
selectStorybook = function(storybook)
print(storybook)
end,
}),
stories = stories,
}
12 changes: 8 additions & 4 deletions src/Plugin/PluginApp.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ local React = require(flipbook.Packages.React)
local ModuleLoader = require(flipbook.Packages.ModuleLoader)
local PluginApp = require(script.Parent.PluginApp)

local stories = {}

stories.Primary = React.createElement(PluginApp, {
loader = ModuleLoader.new(),
plugin = plugin,
})

return {
summary = "The main component that handles the entire plugin",
controls = {},
story = React.createElement(PluginApp, {
loader = ModuleLoader.new(),
plugin = plugin,
}),
stories = stories,
}
6 changes: 5 additions & 1 deletion src/Storybook/NoStorySelected.stories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local NoStorySelected = require(script.Parent.NoStorySelected)

local stories = {}

stories.Primary = React.createElement(NoStorySelected)

return {
story = React.createElement(NoStorySelected),
stories = stories,
}
Loading

0 comments on commit bb7f9fb

Please sign in to comment.