-
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.
Merge branch 'main' into my-pages/fix-mobile-menu-scroll
- Loading branch information
Showing
13 changed files
with
259 additions
and
63 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
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
29 changes: 29 additions & 0 deletions
29
.../Slice/LatestNewsSlice/DigitalIcelandLatestNewsSlice/DigitalIcelandLatestNewsSlice.css.ts
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,29 @@ | ||
import { style } from '@vanilla-extract/css' | ||
|
||
import { theme, themeUtils } from '@island.is/island-ui/theme' | ||
|
||
export const itemContainer = style({ | ||
borderStyle: 'solid', | ||
borderWidth: theme.border.width.standard, | ||
borderColor: theme.color.transparent, | ||
borderRadius: theme.border.radius.large, | ||
transition: 'border-color 150ms ease, opacity 150ms ease', | ||
padding: theme.spacing[2], | ||
':hover': { | ||
borderColor: theme.color.blue400, | ||
}, | ||
}) | ||
|
||
export const itemListContainer = style({ | ||
display: 'grid', | ||
gap: theme.spacing[4], | ||
...themeUtils.responsiveStyle({ | ||
xs: { | ||
gridTemplateColumns: 'minmax(230px, 500px)', | ||
justifyContent: 'center', | ||
}, | ||
md: { | ||
gridTemplateColumns: 'repeat(auto-fit, minmax(302px, 1fr))', | ||
}, | ||
}), | ||
}) |
149 changes: 149 additions & 0 deletions
149
...ion/Slice/LatestNewsSlice/DigitalIcelandLatestNewsSlice/DigitalIcelandLatestNewsSlice.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,149 @@ | ||
import React from 'react' | ||
|
||
import { | ||
Box, | ||
Button, | ||
GridContainer, | ||
Hidden, | ||
Inline, | ||
LinkV2, | ||
Stack, | ||
Tag, | ||
Text, | ||
} from '@island.is/island-ui/core' | ||
import { BackgroundImage } from '@island.is/web/components' | ||
import { LatestNewsSlice as LatestNewsSliceSchema } from '@island.is/web/graphql/schema' | ||
import { useLinkResolver } from '@island.is/web/hooks' | ||
import { shortenText } from '@island.is/web/screens/IcelandicGovernmentInstitutionVacancies/IcelandicGovernmentInstitutionVacanciesList' | ||
|
||
import * as styles from './DigitalIcelandLatestNewsSlice.css' | ||
|
||
interface ItemProps { | ||
imageSrc: string | ||
date: string | ||
title: string | ||
description?: string | null | ||
tags: string[] | ||
href: string | ||
} | ||
|
||
const Item = (item: ItemProps) => { | ||
return ( | ||
<LinkV2 href={item.href} className={styles.itemContainer}> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
flexWrap="nowrap" | ||
rowGap={[2, 2, 2, 5]} | ||
justifyContent="spaceBetween" | ||
height="full" | ||
> | ||
<Stack space={2}> | ||
<BackgroundImage | ||
positionX="left" | ||
backgroundSize="cover" | ||
image={{ url: item.imageSrc }} | ||
ratio="396:210" | ||
boxProps={{ | ||
alignItems: 'center', | ||
width: 'full', | ||
display: 'inlineFlex', | ||
overflow: 'hidden', | ||
borderRadius: 'large', | ||
}} | ||
/> | ||
|
||
<Stack space={1}> | ||
<Text variant="h3">{item.title}</Text> | ||
<Text variant="medium"> | ||
{shortenText(item.description ?? '', 80)} | ||
</Text> | ||
</Stack> | ||
</Stack> | ||
<Box> | ||
<Inline space={1}> | ||
{item.tags.map((tag) => ( | ||
<Tag key={tag} disabled> | ||
{tag} | ||
</Tag> | ||
))} | ||
</Inline> | ||
</Box> | ||
</Box> | ||
</LinkV2> | ||
) | ||
} | ||
|
||
const SeeMoreLink = ({ slice, slug }: SliceProps) => { | ||
const { linkResolver } = useLinkResolver() | ||
return ( | ||
<LinkV2 | ||
href={ | ||
slice.readMoreLink?.url | ||
? slice.readMoreLink.url | ||
: linkResolver('organizationnewsoverview', [slug]).href | ||
} | ||
> | ||
<Button as="span" unfocusable={true} variant="text" icon="arrowForward"> | ||
{slice.readMoreText} | ||
</Button> | ||
</LinkV2> | ||
) | ||
} | ||
|
||
interface SliceProps { | ||
slice: LatestNewsSliceSchema | ||
slug: string | ||
} | ||
|
||
export const DigitalIcelandLatestNewsSlice: React.FC< | ||
React.PropsWithChildren<SliceProps> | ||
> = ({ slice, slug }) => { | ||
const { linkResolver } = useLinkResolver() | ||
return ( | ||
<Box component="section" aria-labelledby="news-items-title"> | ||
<GridContainer> | ||
<Stack space={4}> | ||
<Box | ||
display="flex" | ||
flexDirection="row" | ||
justifyContent="spaceBetween" | ||
alignItems="center" | ||
rowGap={3} | ||
columnGap={3} | ||
> | ||
<Text | ||
id="news-items-title" | ||
variant="h2" | ||
as="h2" | ||
dataTestId="home-news" | ||
> | ||
{slice.title} | ||
</Text> | ||
<Hidden below="md"> | ||
<SeeMoreLink slice={slice} slug={slug} /> | ||
</Hidden> | ||
</Box> | ||
<Box className={styles.itemListContainer}> | ||
{slice.news.slice(0, 3).map((news) => ( | ||
<Item | ||
key={news.id} | ||
href={linkResolver('organizationnews', [slug, news.slug]).href} | ||
date={news.date} | ||
description={news.intro} | ||
imageSrc={news.image?.url ?? ''} | ||
tags={news.genericTags.map((tag) => tag.title)} | ||
title={news.title} | ||
/> | ||
))} | ||
</Box> | ||
<Hidden above="sm"> | ||
<Box display="flex" justifyContent="center"> | ||
<SeeMoreLink slice={slice} slug={slug} /> | ||
</Box> | ||
</Hidden> | ||
</Stack> | ||
</GridContainer> | ||
</Box> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
.../web/components/Organization/Slice/LatestNewsSlice/DigitalIcelandLatestNewsSlice/index.ts
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 @@ | ||
export * from './DigitalIcelandLatestNewsSlice' |
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
Oops, something went wrong.