-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move featured links into a reusable component
- Loading branch information
1 parent
2719433
commit 2c29084
Showing
8 changed files
with
83 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Inline, LinkV2, Tag } from '@island.is/island-ui/core' | ||
import type { Featured } from '@island.is/web/graphql/schema' | ||
import { type LinkType, useLinkResolver } from '@island.is/web/hooks' | ||
|
||
interface FeaturedLinksProps { | ||
links: Featured[] | ||
} | ||
|
||
export const FeaturedLinks = ({ links }: FeaturedLinksProps) => { | ||
const { linkResolver } = useLinkResolver() | ||
return ( | ||
<Inline space={2}> | ||
{links.map(({ title, attention, thing }) => { | ||
const cardUrl = linkResolver(thing?.type as LinkType, [ | ||
thing?.slug as string, | ||
]) | ||
return cardUrl?.href && cardUrl?.href.length > 0 ? ( | ||
<Tag | ||
key={title} | ||
{...(cardUrl.href.startsWith('/') | ||
? { | ||
CustomLink: ({ children, ...props }) => ( | ||
<LinkV2 | ||
key={title} | ||
{...props} | ||
{...cardUrl} | ||
dataTestId="featured-link" | ||
> | ||
{children} | ||
</LinkV2> | ||
), | ||
} | ||
: { href: cardUrl.href })} | ||
variant="blue" | ||
attention={attention} | ||
> | ||
{title} | ||
</Tag> | ||
) : ( | ||
<Tag key={title} variant="blue" attention={attention}> | ||
{title} | ||
</Tag> | ||
) | ||
})} | ||
</Inline> | ||
) | ||
} |
54 changes: 0 additions & 54 deletions
54
apps/web/components/Organization/Slice/FeaturedLinks/FeaturedLinks.tsx
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
apps/web/components/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.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,17 @@ | ||
import { Stack, Text } from '@island.is/island-ui/core' | ||
import { FeaturedLinks } from '@island.is/web/components' | ||
import { FeaturedLinks as FeaturedLinksSchema } from '@island.is/web/graphql/schema' | ||
|
||
interface FeaturedLinksSliceProps { | ||
slice: FeaturedLinksSchema | ||
} | ||
|
||
export const FeaturedLinksSlice = ({ slice }: FeaturedLinksSliceProps) => { | ||
if (!slice.featuredLinks?.length) return null | ||
return ( | ||
<Stack space={2}> | ||
<Text variant="h4">{slice.title}</Text> | ||
<FeaturedLinks links={slice.featuredLinks} /> | ||
</Stack> | ||
) | ||
} |
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
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