-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve platforms page #11925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Improve platforms page #11925
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e5c61b
add community illustration
a-hariti 0c15d71
reuse platforms filter on /platforms
a-hariti 2be0c88
add icons to community supported platforms
a-hariti 018b0f5
fix icons on platformFilter under /platforms
a-hariti 89cd96c
Update docs/platforms/index.mdx
a-hariti 0465bdf
change community illustration layout, use higher res
a-hariti cf7313e
Update src/components/platformFilter/client.tsx
a-hariti 39d0ad6
fix kubernetes icon casing
a-hariti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 hidden or 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 hidden or 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 hidden or 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,196 @@ | ||
| 'use client'; | ||
| import {useMemo, useState} from 'react'; | ||
| import * as Collapsible from '@radix-ui/react-collapsible'; | ||
| import {TriangleRightIcon} from '@radix-ui/react-icons'; | ||
| import classNames from 'classnames'; | ||
| import {matchSorter} from 'match-sorter'; | ||
| import Link from 'next/link'; | ||
|
|
||
| import {type Platform} from 'sentry-docs/types'; | ||
| import {splitToChunks, uniqByReference} from 'sentry-docs/utils'; | ||
|
|
||
| import styles from './style.module.scss'; | ||
|
|
||
| import {PlatformIcon} from '../platformIcon'; | ||
|
|
||
| export function PlatformFilterClient({platforms}: {platforms: Platform[]}) { | ||
| const platformsAndGuides = platforms | ||
| .map(p => [ | ||
| p, | ||
| p.guides.map(g => ({...g, platform: p})), | ||
| p.integrations.map(integ => ({...integ, platform: p})), | ||
| ]) | ||
| .flat(2); | ||
| const [filter, setFilter] = useState(''); | ||
|
|
||
| const matches = useMemo(() => { | ||
| if (!filter) { | ||
| return platformsAndGuides; | ||
| } | ||
| // any of these fields can be used to match the search value | ||
| const keys = ['title', 'aliases', 'name', 'sdk', 'keywords']; | ||
| const matches_ = matchSorter(platformsAndGuides, filter, {keys}); | ||
| return matches_; | ||
| }, [filter, platformsAndGuides]); | ||
|
|
||
| const platformColumns: Platform[][] = splitToChunks( | ||
| 3, | ||
| uniqByReference(matches.map(x => (x.type === 'platform' ? x : x.platform))).map(p => { | ||
| return { | ||
| ...p, | ||
| guides: matches | ||
| .filter(m => m.type === 'guide' && m.platform.key === p.key) | ||
| .map(m => p.guides.find(g => g.key === m.key)!) | ||
| .filter(Boolean), | ||
| integrations: p.integrations.filter(i => matches.some(m => m.key === i.key)), | ||
| }; | ||
| }) | ||
| ); | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 py-8 md:items-end"> | ||
| <div className="lg:col-span-2 space-y-2"> | ||
| <h2 className="text-2xl font-medium">Choose your SDK</h2> | ||
| <p className="m-0">If you use it, we probably support it.</p> | ||
a-hariti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| <div className="w-full flex justify-end"> | ||
| <input | ||
| placeholder="Search SDKs" | ||
| className={`${styles.input}`} | ||
| value={filter} | ||
| onChange={e => setFilter(e.target.value)} | ||
| /> | ||
| </div> | ||
| </div> | ||
| {matches.length > 0 && ( | ||
| <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> | ||
| {platformColumns.map((column, i) => ( | ||
| <div key={i} className={`flex flex-col gap-4 ${styles.platform}`}> | ||
| {column.map(platform => | ||
| platform.guides.length === 0 && platform.integrations.length === 0 ? ( | ||
| <Link | ||
| href={platform.url} | ||
| key={platform.key} | ||
| style={{ | ||
| textDecoration: 'none', | ||
| color: 'var(--foreground) !important', | ||
| }} | ||
| > | ||
| <div className={styles.StandalonePlatform}> | ||
| <PlatformIcon | ||
| size={20} | ||
| platform={platform.icon ?? platform.key} | ||
| format="lg" | ||
| className={styles.PlatformIcon} | ||
| /> | ||
| {platform.title} | ||
| </div> | ||
| </Link> | ||
| ) : ( | ||
| <PlatformWithGuides | ||
| key={platform.key} | ||
| platform={platform} | ||
| // force expand if the filter is long enough to have few results | ||
| forceExpand={filter.length >= 2} | ||
| /> | ||
| ) | ||
| )} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
| {!matches.length && ( | ||
| <div className="col-span-3 text-center text-gray-600">No SDKs found</div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function PlatformWithGuides({ | ||
| platform, | ||
| forceExpand, | ||
| }: { | ||
| forceExpand: boolean; | ||
| platform: Platform; | ||
| }) { | ||
| const [expanded, setExpanded] = useState(false); | ||
| return ( | ||
| <Collapsible.Root | ||
| className={styles.CollapsibleRoot} | ||
| open={forceExpand || expanded} | ||
| onOpenChange={setExpanded} | ||
| > | ||
| <Collapsible.Trigger asChild className={classNames(styles.CollapsibleTrigger)}> | ||
| <div> | ||
| <div className={styles.PlatformTitle} key={platform.key}> | ||
| <PlatformIcon | ||
| size={20} | ||
| platform={platform.icon ?? platform.key} | ||
| format="lg" | ||
| className={styles.PlatformIcon} | ||
| /> | ||
| {platform.title} | ||
| </div> | ||
| <button className={styles.ChevronButton}> | ||
| <TriangleRightIcon | ||
| className={styles.CollapsibleChevron} | ||
| aria-hidden | ||
| width="20" | ||
| height="20" | ||
| /> | ||
| </button> | ||
| </div> | ||
| </Collapsible.Trigger> | ||
| <Collapsible.Content | ||
| className={classNames(styles.CollapsibleContent)} | ||
| // scrollable if there are more than 8 (arbitrary limit) guides | ||
| data-scrollable={platform.guides.length >= 8 || platform.integrations.length >= 8} | ||
| > | ||
| {[platform, ...platform.guides].map((guide, i) => ( | ||
| <Link | ||
| href={guide.url} | ||
| style={{textDecoration: 'none', color: 'var(--foreground) !important'}} | ||
| key={guide.key} | ||
| > | ||
| <div | ||
| className={styles.Guide} | ||
| style={{ | ||
| animationDelay: `${i * 5}ms`, | ||
| }} | ||
| > | ||
| <PlatformIcon | ||
| size={20} | ||
| platform={guide.icon ?? guide.key} | ||
| format="lg" | ||
| className={styles.PlatformIcon} | ||
| /> | ||
| {guide.title} | ||
| </div> | ||
| </Link> | ||
| ))} | ||
| {platform.guides.length === 0 && | ||
| platform.integrations.map((integ, i) => { | ||
| return ( | ||
| <Link href={integ.url} key={integ.key}> | ||
| <div | ||
| className={styles.Guide} | ||
| style={{ | ||
| animationDelay: `${i * 5}ms`, | ||
| }} | ||
| > | ||
| <PlatformIcon | ||
| size={20} | ||
| format="lg" | ||
| platform={integ.icon} | ||
| className={styles.Platform} | ||
| /> | ||
| {integ.name} | ||
| </div> | ||
| </Link> | ||
| ); | ||
| })} | ||
| </Collapsible.Content> | ||
| </Collapsible.Root> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.