-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a button to create the first storybook, story, and component
- Loading branch information
Showing
5 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export type Props = { | ||
nameToGreet: string, | ||
} | ||
|
||
local function HelloWorld(props: Props) | ||
local label = Instance.new("TextLabel") | ||
label.Text = `Hello, {props.nameToGreet}!` | ||
label.AutomaticSize = Enum.AutomaticSize.XY | ||
label.BackgroundTransparency = 1 | ||
label.TextColor3 = Color3.fromRGB(255, 255, 255) | ||
label.TextSize = 24 | ||
label.Font = Enum.Font.BuilderSansMedium | ||
|
||
return label | ||
end | ||
|
||
return HelloWorld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local HelloWorld = require(script.Parent.HelloWorld) | ||
|
||
local controls = { | ||
nameToGreet = "World", | ||
} | ||
|
||
type Props = { | ||
controls: typeof(controls), | ||
} | ||
|
||
return { | ||
controls = controls, | ||
story = function(props: Props) | ||
return HelloWorld({ | ||
nameToGreet = props.controls.nameToGreet, | ||
}) | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
return { | ||
storyRoots = { | ||
script.Parent.Components, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
local STORYBOOK_TEMPLATE = script.Parent.OnboardingTemplate["StorybookTemplate"] | ||
local STORY_TEMPLATE = script.Parent.OnboardingTemplate["StoryTemplate"] | ||
local COMPONENT_TEMPLATE = script.Parent.OnboardingTemplate["ComponentTemplate"] | ||
|
||
local function createOnboardingStorybook(parent: Instance) | ||
local components = Instance.new("Folder") | ||
components.Name = "Components" | ||
|
||
local component = COMPONENT_TEMPLATE:Clone() | ||
component.Name = "HelloWorld" | ||
component.Parent = components | ||
|
||
local story = STORY_TEMPLATE:Clone() | ||
story.Name = "HelloWorld.story" | ||
story.Parent = components | ||
|
||
local storybookModule = STORYBOOK_TEMPLATE:Clone() | ||
storybookModule.Name = `{string.gsub(game.Name, "%.", "_")}.storybook` | ||
|
||
components.Parent = parent | ||
storybookModule.Parent = parent | ||
end | ||
|
||
return createOnboardingStorybook |