-
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.
- Loading branch information
Showing
22 changed files
with
170 additions
and
651 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
|
||
local React = require(ReplicatedStorage.Packages.React) | ||
|
||
local ReactButton = require(script.Parent.ReactButton) | ||
|
||
return { | ||
story = function() | ||
return React.createElement(ReactButton, { | ||
text = "Click Me", | ||
onActivated = function() | ||
print("click") | ||
end, | ||
}) | ||
end, | ||
} |
25 changes: 25 additions & 0 deletions
25
code-samples/src/React/ReactButtonExplicitPackages.story.luau
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,25 @@ | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
|
||
local React = require(ReplicatedStorage.Packages.React) | ||
local ReactRoblox = require(ReplicatedStorage.Packages.ReactRoblox) | ||
|
||
return { | ||
story = function() | ||
return React.createElement("TextButton", { | ||
Text = "Click Me", | ||
TextSize = 16, | ||
Font = Enum.Font.BuilderSansExtraBold, | ||
TextColor3 = Color3.fromRGB(50, 50, 50), | ||
BackgroundColor3 = Color3.fromRGB(255, 255, 255), | ||
BorderSizePixel = 0, | ||
Size = UDim2.fromOffset(200, 40), | ||
[React.Event.Activated] = function() | ||
print("clicked") | ||
end, | ||
}) | ||
end, | ||
packages = { | ||
React = React, | ||
ReactRoblox = ReactRoblox, | ||
}, | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
import CodeBlock from "@theme/CodeBlock"; | ||
|
||
import DefaultStorybook from "!!raw-loader!@site/../code-samples/src/Default/ProjectName.storybook.luau"; | ||
import DefaultStory from "!!raw-loader!@site/../code-samples/src/Default/Button.story.luau"; | ||
import ReactStorybook from "!!raw-loader!@site/../code-samples/src/React/React.storybook.luau"; | ||
import ReactButton from "!!raw-loader!@site/../code-samples/src/React/ReactButton.luau"; | ||
import ReactButtonControls from "!!raw-loader!@site/../code-samples/src/React/ReactButtonControls.luau"; | ||
import ReactButtonControlsStory from "!!raw-loader!@site/../code-samples/src/React/ReactButtonControls.story.luau"; | ||
import ReactButtonExplicitPackagesStory from "!!raw-loader!@site/../code-samples/src/React/ReactButtonExplicitPackages.story.luau"; | ||
|
||
# Controls | ||
|
||
Stories can define controls that make it possible to quickly test out the behavior and variants of the UI you're working on. | ||
|
||
Here's an example React component that we will build a Story around. The props it takes in will be configurable by the Story's controls. | ||
|
||
<CodeBlock language="lua" title="ReactButtonControls.luau"> | ||
{ReactButtonControls} | ||
</CodeBlock> | ||
|
||
The Story creates the element and passes in controls through the `props` argument. | ||
|
||
<CodeBlock language="lua" title="ReactButtonControls.story.luau"> | ||
{ReactButtonControlsStory} | ||
</CodeBlock> | ||
|
||
Opening the ReactButtonControls Story in flipbook will include an accompanying panel for configuring the controls. | ||
|
||
![Story preview for ReactButtonControls showing the Controls panel](./button-with-controls.png) | ||
|
||
As controls are modified the Story will live-reload with the new props. | ||
|
||
![Story preview for ReactButtonControls showing modifications made to the controls](./button-with-controls-changed.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
import CodeBlock from "@theme/CodeBlock"; | ||
|
||
import DefaultStorybook from "!!raw-loader!@site/../code-samples/src/Default/ProjectName.storybook.luau"; | ||
import DefaultStory from "!!raw-loader!@site/../code-samples/src/Default/Button.story.luau"; | ||
import ReactStorybook from "!!raw-loader!@site/../code-samples/src/React/React.storybook.luau"; | ||
import ReactButton from "!!raw-loader!@site/../code-samples/src/React/ReactButton.luau"; | ||
import ReactButtonStory from "!!raw-loader!@site/../code-samples/src/React/ReactButton.story.luau"; | ||
import ReactButtonExplicitPackagesStory from "!!raw-loader!@site/../code-samples/src/React/ReactButtonExplicitPackages.story.luau"; | ||
|
||
# Typechecking |
Oops, something went wrong.