-
Notifications
You must be signed in to change notification settings - Fork 102
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
1 parent
144d24d
commit 1ff4e57
Showing
9 changed files
with
115 additions
and
1 deletion.
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,4 @@ | ||
declare module '*.svg' { | ||
const content: string; | ||
export default content; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/components/src/LearningResourcesWidget/Bookmarks_empty-state.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
packages/components/src/LearningResourcesWidget/EmptyState.tsx
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,32 @@ | ||
import React from 'react'; | ||
// import { Button } from '@patternfly/react-core/dist/dynamic/components/Button'; | ||
import { EmptyState } from '@patternfly/react-core/dist/dynamic/components/EmptyState'; | ||
import { EmptyStateBody } from '@patternfly/react-core/dist/dynamic/components/EmptyState'; | ||
import { EmptyStateFooter } from '@patternfly/react-core/dist/dynamic/components/EmptyState'; | ||
import { EmptyStateHeader } from '@patternfly/react-core/dist/dynamic/components/EmptyState'; | ||
import { EmptyStateVariant } from '@patternfly/react-core/dist/dynamic/components/EmptyState'; | ||
import { Stack } from '@patternfly/react-core/dist/dynamic/layouts/Stack'; | ||
import { StackItem } from '@patternfly/react-core/dist/dynamic/layouts/Stack'; | ||
import BookMarkEmptyState from './Bookmarks_empty-state.svg'; | ||
|
||
const LearningResourcesEmptyState: React.FunctionComponent = () => { | ||
return ( | ||
<EmptyState variant={EmptyStateVariant.lg}> | ||
<EmptyStateHeader titleText="No bookmarked learning resources" icon={<img src={BookMarkEmptyState} />} headingLevel="h4" /> | ||
<EmptyStateBody> | ||
<Stack> | ||
<StackItem>Add documentation, quickstarts, learning paths, and more to your bookmarks for easy access in the future.</StackItem> | ||
</Stack> | ||
</EmptyStateBody> | ||
<EmptyStateFooter> | ||
{/* | ||
Button to be re-enabled only after completion of All learning catalog | ||
<Button variant="secondary" component="a" href="settings/learning-resources#documentation"> | ||
View all learning resources | ||
</Button> */} | ||
</EmptyStateFooter> | ||
</EmptyState> | ||
); | ||
}; | ||
|
||
export default LearningResourcesEmptyState; |
66 changes: 66 additions & 0 deletions
66
packages/components/src/LearningResourcesWidget/LearningResourcesWidget.tsx
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,66 @@ | ||
import React from 'react'; | ||
import { Text, TextContent, TextVariants } from '@patternfly/react-core/dist/dynamic/components/Text'; | ||
import useChrome from '@redhat-cloud-services/frontend-components/useChrome'; | ||
import { Link } from 'react-router-dom'; | ||
import { Gallery } from '@patternfly/react-core/dist/dynamic/layouts/Gallery'; | ||
import { Label } from '@patternfly/react-core/dist/dynamic/components/Label'; | ||
import LearningResourcesEmptyState from './EmptyState'; | ||
import useQuickStarts from './quickstarts'; | ||
import { Flex, FlexItem } from '@patternfly/react-core'; | ||
|
||
export const API_BASE = '/api/quickstarts/v1'; | ||
export const QUICKSTARTS = '/quickstarts'; | ||
export const FAVORITES = '/favorites'; | ||
|
||
export type FavoriteQuickStart = { | ||
favorite: boolean; | ||
quickstartName: string; | ||
}; | ||
|
||
const LinkWrapper = ({ pathname, title }: { pathname: string; title: string }) => { | ||
const { updateDocumentTitle } = useChrome(); | ||
return ( | ||
<Link onClick={() => updateDocumentTitle(title)} to={pathname}> | ||
{title} | ||
</Link> | ||
); | ||
}; | ||
|
||
const LearningResourcesWidget: React.FunctionComponent = () => { | ||
const { contentReady, documentation, learningPaths, other, quickStarts, bookmarks, toggleFavorite } = useQuickStarts(); | ||
console.log(bookmarks); | ||
|
||
return ( | ||
<div> | ||
{quickStarts.length === 0 ? ( | ||
<LearningResourcesEmptyState /> | ||
) : ( | ||
<Gallery hasGutter> | ||
{quickStarts.map(({ metadata, spec }, index) => ( | ||
<div key={index}> | ||
<TextContent> | ||
<LinkWrapper title={spec.displayName} pathname={spec.link?.href || ''} /> | ||
</TextContent> | ||
<Flex direction={{ default: 'row' }}> | ||
<FlexItem style={{ marginRight: 'var(--pf-v5-global--spacer--sm)' }}> | ||
{spec.type && ( | ||
<Label className="pfext-quick-start-tile-header--margin" color={spec.type.color}> | ||
{spec.type.text} | ||
</Label> | ||
)} | ||
</FlexItem> | ||
<FlexItem> | ||
<TextContent> | ||
<Text component={TextVariants.small}>some.domain.redhat</Text> | ||
</TextContent> | ||
</FlexItem> | ||
</Flex> | ||
</div> | ||
))} | ||
</Gallery> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default LearningResourcesWidget; |
1 change: 1 addition & 0 deletions
1
packages/components/src/LearningResourcesWidget/bookmark-regular.svg
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,2 @@ | ||
export { default } from './LearningResourcesWidget'; | ||
export { default as LearningResourcesWidget } from './LearningResourcesWidget'; |
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