Skip to content

Commit

Permalink
Use Storyteller for handling all of our Story/Storybook needs (#267)
Browse files Browse the repository at this point in the history
# Problem

Our org has a new package for handling all Story and Storybook logic we
previously had baked into flipbook in the form of Storyteller.

https://github.com/flipbook-labs/storyteller

# Solution

This PR adds Storyteller to our dependencies and starts consuming it.
All Story and Storybook related logic has been stripped out and migrated
over

As a bonus, Storyteller gives us Fusion support out of the box.

Closes #225 

# Checklist

- [ ] Ran `lune run test` locally before merging
  • Loading branch information
vocksel authored Nov 10, 2024
1 parent a4cccd3 commit e85d110
Show file tree
Hide file tree
Showing 27 changed files with 175 additions and 734 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"@pkg": "./Packages",
"@root": "./src",
"@lune/": "~/.lune/.typedefs/0.8.3/"
},
"files.associations": {
"*.luau": "lua"
}
}
77 changes: 0 additions & 77 deletions src/Common/useDescendants.luau

This file was deleted.

108 changes: 0 additions & 108 deletions src/Common/useDescendants.spec.luau

This file was deleted.

4 changes: 2 additions & 2 deletions src/Explorer/types.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local storybookTypes = require("@root/Storybook/types")
local Storyteller = require("@pkg/Storyteller")

type Storybook = storybookTypes.Storybook
type Storybook = Storyteller.Storybook

export type ComponentTreeNode = {
name: string,
Expand Down
8 changes: 4 additions & 4 deletions src/Navigation/Screen.luau
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
local ModuleLoader = require("@pkg/ModuleLoader")
local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local AboutView = require("@root/About/AboutView")
local NavigationContext = require("@root/Navigation/NavigationContext")
local SettingsView = require("@root/UserSettings/SettingsView")
local StoryCanvas = require("@root/Storybook/StoryCanvas")
local storybookTypes = require("@root/Storybook/types")

local useMemo = React.useMemo

type Story = storybookTypes.Story
type Storybook = storybookTypes.Storybook
type ModuleLoader = ModuleLoader.ModuleLoader
type Storybook = Storyteller.Storybook

export type Props = {
loader: ModuleLoader.ModuleLoader,
loader: ModuleLoader,
story: ModuleScript?,
storybook: Storybook?,
}
Expand Down
7 changes: 4 additions & 3 deletions src/Panels/Sidebar.luau
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local Branding = require("@root/Common/Branding")
local ComponentTree = require("@root/Explorer")
local React = require("@pkg/React")
local ScrollingFrame = require("@root/Common/ScrollingFrame")
local Searchbar = require("@root/Forms/Searchbar")
local constants = require("@root/constants")
local createStoryNodes = require("@root/Storybook/createStoryNodes")
local explorerTypes = require("@root/Explorer/types")
local storybookTypes = require("@root/Storybook/types")
local useTheme = require("@root/Common/useTheme")

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

local e = React.createElement
Expand Down
5 changes: 3 additions & 2 deletions src/Plugin/PluginApp.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local ModuleLoader = require("@pkg/ModuleLoader")
local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local NavigationContext = require("@root/Navigation/NavigationContext")
local ResizablePanel = require("@root/Panels/ResizablePanel")
Expand All @@ -9,7 +10,6 @@ local Sidebar = require("@root/Panels/Sidebar")
local Topbar = require("@root/Panels/Topbar")
local constants = require("@root/constants")
local nextLayoutOrder = require("@root/Common/nextLayoutOrder")
local useStorybooks = require("@root/Storybook/useStorybooks")
local useTheme = require("@root/Common/useTheme")

local TOPBAR_HEIGHT_PX = 32
Expand All @@ -21,7 +21,7 @@ export type Props = {
local function App(props: Props)
local theme = useTheme()
local settingsContext = SettingsContext.use()
local storybooks = useStorybooks(game, props.loader)
local storybooks = Storyteller.useStorybooks(game, props.loader)
local story: ModuleScript?, setStory = React.useState(nil :: ModuleScript?)
local storybook, selectStorybook = React.useState(nil :: ModuleScript?)
local initialSidebarWidth = settingsContext.getSetting("sidebarWidth")
Expand Down Expand Up @@ -71,6 +71,7 @@ local function App(props: Props)
MainWrapper = React.createElement("Frame", {
LayoutOrder = nextLayoutOrder(),
Size = UDim2.fromScale(1, 1) - UDim2.fromOffset(sidebarWidth, 0),
BackgroundTransparency = 1,
}, {
Layout = React.createElement("UIListLayout", {
SortOrder = Enum.SortOrder.LayoutOrder,
Expand Down
9 changes: 6 additions & 3 deletions src/Storybook/StoryCanvas.luau
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
local ModuleLoader = require("@pkg/ModuleLoader")
local React = require("@pkg/React")
local Storyteller = require("@pkg/Storyteller")

local NoStorySelected = require("@root/Storybook/NoStorySelected")
local StoryView = require("@root/Storybook/StoryView")
local types = require("@root/Storybook/types")
local useTheme = require("@root/Common/useTheme")

local e = React.createElement

type ModuleLoader = ModuleLoader.ModuleLoader
type Storybook = Storyteller.Storybook

type Props = {
story: ModuleScript,
loader: ModuleLoader.ModuleLoader,
storybook: types.Storybook,
loader: ModuleLoader,
storybook: Storybook,
layoutOrder: number?,
}

Expand Down
9 changes: 7 additions & 2 deletions src/Storybook/StoryControls.luau
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ local function StoryControls(props: Props)
TextTruncate = Enum.TextTruncate.AtEnd,
}),

Option = e("Frame", {
OptionWrapper = e("Frame", {
LayoutOrder = 2,
BackgroundTransparency = 1,
Size = UDim2.fromScale(1, 0),
Expand All @@ -120,7 +120,12 @@ local function StoryControls(props: Props)
Flex = e("UIFlexItem", {
FlexMode = Enum.UIFlexMode.Shrink,
}),
}, option),
}, {
-- Keying by the identity of sortedControls fixes a bug where
-- the options visually do not update when two stories have the
-- exact same controls
[`Option_{sortedControls}`] = option,
}),
})
end

Expand Down
9 changes: 6 additions & 3 deletions src/Storybook/StoryMeta.luau
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
local React = require("@pkg/React")
local types = require("@root/Storybook/types")
local Storyteller = require("@pkg/Storyteller")

local useTheme = require("@root/Common/useTheme")

local MAX_SUMMARY_SIZE = 600

local e = React.createElement

type Story = Storyteller.Story<unknown>

export type Props = {
story: types.Story,
story: Story,
layoutOrder: number?,
}

Expand All @@ -31,7 +34,7 @@ local function StoryMeta(props: Props)
BackgroundTransparency = 1,
Font = theme.headerFont,
Size = UDim2.fromScale(0, 0),
Text = props.story.name:sub(1, #props.story.name - 6),
Text = props.story.name,
TextColor3 = theme.text,
TextSize = theme.headerTextSize,
}),
Expand Down
4 changes: 4 additions & 0 deletions src/Storybook/StoryMeta.story.luau
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ return {
story = {
name = "Story",
summary = "Story summary",
source = Instance.new("ModuleScript"),
storybook = {
storyRoots = {},
},
},
}),
}),
Expand Down
Loading

0 comments on commit e85d110

Please sign in to comment.