Skip to content

Commit

Permalink
aded utils directory and utility type for PressLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
recondesigns committed Mar 11, 2024
1 parent 2135cde commit eb83f1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 9 additions & 10 deletions components/Press/PressLinks/PressLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Tabs from '@radix-ui/react-tabs';
import OutboundLink from 'components/OutboundLink/OutboundLink';
import * as Articles from './Articles';
import { objectKeys } from 'utils/types';
import styles from './PressLinks.module.css';

function PressLinks() {
Expand All @@ -19,21 +20,19 @@ function PressLinks() {
</Tabs.Trigger>
))}
</Tabs.List>
{Object.keys(Articles).map(region => (
{objectKeys(Articles).map(region => (
<Tabs.Content
key={`TabsContent_${region}`}
value={region}
className={styles.tabsContent}
>
{(Articles as Record<string, any>)[region].map(
(link: { url: string; title: string }) => (
<li key={`GroupLink_${link.url}`}>
<OutboundLink href={link.url} analyticsEventLabel="Press Article">
{link.title}
</OutboundLink>
</li>
),
)}
{Articles[region].map((link: { url: string; title: string }) => (
<li key={`GroupLink_${link.url}`}>
<OutboundLink href={link.url} analyticsEventLabel="Press Article">
{link.title}
</OutboundLink>
</li>
))}
</Tabs.Content>
))}
</Tabs.Root>
Expand Down
2 changes: 2 additions & 0 deletions utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const objectKeys = <Type extends object>(value: Type) =>
Object.keys(value) as Array<keyof Type>;

0 comments on commit eb83f1a

Please sign in to comment.