-
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.
Taking a pass over UI components (#20)
- Factored out networking to "wrapper" components - Added stories for each component - Stories are removed from prod builds
- Loading branch information
Showing
17 changed files
with
362 additions
and
36 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
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,8 @@ | ||
local React = require("@pkg/React") | ||
local App = require("./App") | ||
|
||
return { | ||
story = function() | ||
return React.createElement(App) | ||
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,74 @@ | ||
local React = require("@pkg/React") | ||
local types = require("@root/types") | ||
local ExtensionsList = require("./ExtensionsList") | ||
|
||
-- TODO: Just use a real web response | ||
local function createMockExtension(name: string): types.PublishedExtension | ||
return { | ||
categories = {}, | ||
deploymentType = 0, | ||
displayName = name, | ||
extensionId = "1", | ||
extensionName = name, | ||
flags = "", | ||
installationTargets = {}, | ||
lastUpdated = tostring(DateTime.now()), | ||
longDescription = "", | ||
presentInConflictList = "", | ||
publishedDate = tostring(DateTime.now()), | ||
publisher = { | ||
displayName = "OnlyTwentyCharacters", | ||
domain = "", | ||
flags = "", | ||
isDomainVerified = false, | ||
publisherId = "", | ||
publisherName = "", | ||
}, | ||
releaseDate = tostring(DateTime.now()), | ||
sharedWith = {}, | ||
shortDescription = "", | ||
statistics = {}, | ||
tags = {}, | ||
versions = { | ||
{ | ||
version = "1.2.3", | ||
versionDescription = "", | ||
assetUri = "", | ||
fallbackAssetUri = "", | ||
files = {}, | ||
flags = 0, | ||
badges = {}, | ||
targetPlatform = "", | ||
lastUpdated = "", | ||
properties = {}, | ||
validationResultMessage = "", | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
local controls = { | ||
numExtensions = 10, | ||
} | ||
|
||
type Props = { | ||
controls: { | ||
numExtensions: number, | ||
}, | ||
} | ||
|
||
return { | ||
controls = controls, | ||
story = function(props: Props) | ||
local extensions = {} | ||
print(props.controls.numExtensions) | ||
for i = 1, props.controls.numExtensions do | ||
table.insert(extensions, createMockExtension(`Extension {i}`)) | ||
end | ||
|
||
return React.createElement(ExtensionsList, { | ||
extensions = extensions, | ||
onView = print, | ||
}) | ||
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
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,51 @@ | ||
local React = require("@pkg/React") | ||
local stories = require("./stories") | ||
local Home = require("./Home") | ||
|
||
return { | ||
story = stories({ | ||
{ | ||
name = "Primary", | ||
story = function() | ||
return React.createElement(Home, { | ||
extensions = { | ||
{ | ||
extensionName = "theme", | ||
displayName = "Theme", | ||
publisher = { | ||
publisherName = "OnlyTwentyCharacters", | ||
}, | ||
versions = { | ||
{ | ||
version = "1.2.3", | ||
}, | ||
}, | ||
}, | ||
}, | ||
onViewExtension = print, | ||
}) | ||
end, | ||
}, | ||
|
||
{ | ||
name = "Loading", | ||
story = function() | ||
return React.createElement(Home, { | ||
extensions = {}, | ||
onViewExtension = print, | ||
}) | ||
end, | ||
}, | ||
|
||
{ | ||
name = "Network error", | ||
story = function() | ||
return React.createElement(Home, { | ||
extensions = {}, | ||
err = "Network error occurred", | ||
onViewExtension = print, | ||
}) | ||
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,44 @@ | ||
local React = require("@pkg/React") | ||
local fetchVisualStudioExtensions = require("@root/requests/fetchVisualStudioExtensions") | ||
local types = require("@root/types") | ||
local Home = require("./Home") | ||
|
||
type PublishedExtension = types.PublishedExtension | ||
|
||
local useEffect = React.useEffect | ||
local useState = React.useState | ||
|
||
export type Props = { | ||
onViewExtension: (extension: PublishedExtension) -> (), | ||
} | ||
|
||
local function HomeWrapper(props: Props) | ||
local extensions, setExtensions = useState({} :: { PublishedExtension }) | ||
local searchTerm, setSearchTerm = useState(nil :: string?) | ||
local err, setErr = useState(nil :: string?) | ||
|
||
useEffect(function() | ||
setErr(nil) | ||
fetchVisualStudioExtensions({ | ||
-- page = page, -- TODO: Increment the page when scrolling to the bottom of the list | ||
pageSize = 20, | ||
searchTerm = if searchTerm then searchTerm else "theme", | ||
}) | ||
:andThen(function(newExtensions) | ||
setExtensions(newExtensions) | ||
end) | ||
:catch(function() | ||
setErr(`No extensions found. Please try again later`) | ||
end) | ||
end, { searchTerm }) | ||
|
||
return React.createElement(Home, { | ||
extensions = extensions, | ||
err = err, | ||
searchTerm = searchTerm, | ||
onSearch = setSearchTerm, | ||
onViewExtension = props.onViewExtension, | ||
}) | ||
end | ||
|
||
return HomeWrapper |
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 @@ | ||
local React = require("@pkg/React") | ||
local HomeWrapper = require("./HomeWrapper") | ||
|
||
return { | ||
story = function() | ||
return React.createElement(HomeWrapper, { | ||
onViewExtension = print, | ||
}) | ||
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,8 @@ | ||
local React = require("@pkg/React") | ||
local LoadingSpinner = require("./LoadingSpinner") | ||
|
||
return { | ||
story = function() | ||
return React.createElement(LoadingSpinner) | ||
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,27 @@ | ||
local React = require("@pkg/React") | ||
local ThemeDetails = require("./ThemeDetails") | ||
local themesSnapshot = require("@root/requests/snapshots/get-v1-themes") | ||
|
||
return { | ||
story = function() | ||
return React.createElement(ThemeDetails, { | ||
extension = { | ||
extensionName = "theme-monokai-pro-vscode", | ||
displayName = "Monokai Pro", | ||
publisher = { | ||
publisherName = "monokai", | ||
}, | ||
versions = { | ||
{ | ||
version = "1.2.2", | ||
}, | ||
}, | ||
}, | ||
themes = themesSnapshot, | ||
onBack = function() | ||
print("go back") | ||
end, | ||
studio = {}, | ||
}) | ||
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,24 @@ | ||
local React = require("@pkg/React") | ||
local ThemeDetailsWrapper = require("./ThemeDetailsWrapper") | ||
|
||
return { | ||
story = function() | ||
return React.createElement(ThemeDetailsWrapper, { | ||
extension = { | ||
extensionName = "theme-monokai-pro-vscode", | ||
displayName = "Monokai Pro", | ||
publisher = { | ||
publisherName = "monokai", | ||
}, | ||
versions = { | ||
{ | ||
version = "1.2.2", | ||
}, | ||
}, | ||
}, | ||
onBack = function() | ||
print("go back") | ||
end, | ||
}) | ||
end, | ||
} |
Oops, something went wrong.