-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
107 additions
and
34 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
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,59 @@ | ||
local Root = script:FindFirstAncestor("rbxtheme") | ||
|
||
local React = require(Root.Packages.React) | ||
local Sift = require(Root.Packages.Sift) | ||
local styles = require(script.Parent.styles) | ||
local LoadingSpinner = require(script.Parent.LoadingSpinner) | ||
local ThemeDetails = require(script.Parent.ThemeDetails) | ||
local fetchExtensionThemes = require(script.Parent.Parent.fetchExtensionThemes) | ||
local types = require(script.Parent.Parent.types) | ||
|
||
local useState = React.useState | ||
local useEffect = React.useEffect | ||
|
||
export type Props = { | ||
extension: types.PublishedExtension, | ||
onBack: () -> (), | ||
} | ||
|
||
local function ThemeDetailsWrapper(props: Props) | ||
local err, setErr = useState(nil :: string?) | ||
local themes, setThemes = useState(nil :: { types.ExtensionTheme }?) | ||
|
||
useEffect(function() | ||
if props.extension.versions then | ||
local latestVersion = props.extension.versions[1] | ||
|
||
if latestVersion then | ||
fetchExtensionThemes(props.extension, latestVersion.version) | ||
:andThen(function(newThemes) | ||
setThemes(newThemes) | ||
end) | ||
:catch(function() | ||
setErr(`We couldn't find any themes for this extension. Sorry about that!`) | ||
end) | ||
else | ||
setErr(`We couldn't find any themes for this extension. Sorry about that!`) | ||
end | ||
end | ||
end, { props.extension }) | ||
|
||
if err then | ||
return React.createElement( | ||
"TextLabel", | ||
Sift.Dictionary.join(styles.text, { | ||
Text = err, | ||
}) | ||
) | ||
elseif themes then | ||
return React.createElement(ThemeDetails, { | ||
extension = props.extension, | ||
themes = themes, | ||
onBack = props.onBack, | ||
}) | ||
else | ||
return React.createElement(LoadingSpinner) | ||
end | ||
end | ||
|
||
return ThemeDetailsWrapper |
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 @@ | ||
local styles = {} | ||
|
||
local BODY_TEXT_COLOR = Color3.fromHex("#ffffff") | ||
local BODY_TEXT_SIZE = 16 | ||
local BODY_TEXT_FONT = Enum.Font.GothamMedium | ||
|
||
styles.text = { | ||
Text = "", | ||
Size = UDim2.fromScale(0, 0), | ||
AutomaticSize = Enum.AutomaticSize.XY, | ||
TextColor3 = BODY_TEXT_COLOR, | ||
TextSize = BODY_TEXT_SIZE, | ||
Font = BODY_TEXT_FONT, | ||
BackgroundTransparency = 1, | ||
} | ||
|
||
return styles |