Skip to content
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

feat: Update platforms grid UI #13066

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 44 additions & 48 deletions src/components/platformFilter/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {matchSorter, rankings} from 'match-sorter';
import Link from 'next/link';

import {type Platform} from 'sentry-docs/types';
import {splitToChunks, uniqByReference} from 'sentry-docs/utils';
import {uniqByReference} from 'sentry-docs/utils';

import styles from './style.module.scss';

Expand Down Expand Up @@ -70,19 +70,18 @@ export function PlatformFilterClient({platforms}: {platforms: Platform[]}) {
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)),
};
})
);
const filteredPlatforms: Platform[] = 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>
Expand Down Expand Up @@ -133,41 +132,38 @@ export function PlatformFilterClient({platforms}: {platforms: Platform[]}) {
/>
</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} !border-none !shadow-none`}
/>
{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}
{filteredPlatforms.length > 0 && (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 auto-rows-min">
{filteredPlatforms.map(platform =>
platform.guides.length === 0 && platform.integrations.length === 0 ? (
<Link
href={platform.url}
key={platform.key}
style={{
textDecoration: 'none',
color: 'var(--foreground) !important',
}}
className="self-start"
>
<div className={styles.StandalonePlatform}>
<PlatformIcon
size={20}
platform={platform.icon ?? platform.key}
format="lg"
className={`${styles.PlatformIcon} !border-none !shadow-none`}
/>
)
)}
</div>
))}
{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>
)}
{!matches.length && (
Expand Down
11 changes: 2 additions & 9 deletions src/components/platformFilter/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,17 @@
.CollapsibleRoot {
border-radius: 0.25rem;
box-shadow: var(--shadow-6);
align-self: flex-start;
}

.CollapsibleTrigger {
cursor: pointer;
padding-right: 0.5rem;
padding-left: 0.5rem;
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 15px;
line-height: 1;
background-color: var(--item-bg);
padding-top: 6px;
padding-bottom: 6px;
padding: 0.75rem 1rem;
border-radius: 0.25rem;
user-select: none;

Expand All @@ -67,7 +63,6 @@
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem;
}
}

Expand Down Expand Up @@ -154,8 +149,6 @@
}

.ChevronButton {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
Expand Down
Loading