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

news-widget #1786

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
2 changes: 2 additions & 0 deletions apps/core-lib-dev/src/app/app.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import '@sebgroup/green-core/components/menu-button/index.js'
import '@sebgroup/green-core/components/segmented-control/index.js'

import '../components/header'
import '../components/news-widget'

import './chlorophyll.scss'
import './form-validation.element'
import './datepicker.element'
Expand Down
1 change: 1 addition & 0 deletions apps/core-lib-dev/src/app/dashboard/dashboard.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class CardExample extends LitElement {
<gds-card>[CONTENT GOES HERE]</gds-card>
<gds-card>[CONTENT GOES HERE]</gds-card>
</gds-grid>
<tp-news-widget></tp-news-widget>
</gds-flex>
`
}
Expand Down
Binary file added apps/core-lib-dev/src/assets/image 23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions apps/core-lib-dev/src/components/news-widget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { LitElement } from 'lit'
import { customElement } from 'lit/decorators.js'

import { html } from '@sebgroup/green-core/scoping'

import '@sebgroup/green-core/components/theme/index.js'
import '@sebgroup/green-core/components/card/index.js'
import '@sebgroup/green-core/components/flex/index.js'
import '@sebgroup/green-core/components/grid/index.js'
import '@sebgroup/green-core/components/img/index.js'
import '@sebgroup/green-core/components/mask/index.js'
import '@sebgroup/green-core/components/text/index.js'

import img from '../assets/image 23.png'

type News = {
img: string
heading: string
body: string
button: string
}

const heading = 'Inspiration och annat'

const newsItems: News[] = [
{
img,
heading: 'Nu sänker vi bolåneräntan!',
body: `Den 8 november sänker vi våra bolåne­­räntor för flera bindnings­­tider. Den rörliga 3-månaders­­räntan sänks med 0,50 procent­enheter.`,
button: 'Read article',
},
{
img,
heading: 'Nu sänker vi bolåneräntan!',
body: `Den 8 november sänker vi våra bolåne­­räntor för flera bindnings­­tider. Den rörliga 3-månaders­­räntan sänks med 0,50 procent­enheter.`,
button: 'Read article',
},
{
img,
heading: 'Nu sänker vi bolåneräntan!',
body: `Den 8 november sänker vi våra bolåne­­räntor för flera bindnings­­tider. Den rörliga 3-månaders­­räntan sänks med 0,50 procent­enheter.`,
button: 'Read article',
},
]

@customElement('tp-news-widget')
export class TpNewsWidget extends LitElement {
connectedCallback() {
super.connectedCallback()
}

render() {
return html` <gds-theme>
<gds-flex flex-direction="column" gap="l">
<gds-text tag="h2" font-size="heading-m">${heading}</gds-text>
<gds-grid columns="1; s{2} m{3}" gap="m">
${newsItems.map(
(item) =>
html`<gds-card
border="4xs/primary"
border-radius="xs"
overflow="hidden"
padding="0"
variant="tertiary"
>
<gds-flex position="relative" height="100%">
<gds-img
src="${item.img}"
object-fit="cover"
aspect-ratio="1/1"
></gds-img>
<gds-mask
mask-image="top"
backdrop-filter="blur(20px)"
position="absolute"
>
<gds-flex
flex-direction="column"
justify-content="flex-end"
padding="l"
gap="l"
height="100%"
>
<gds-flex flex-direction="column" gap="xs">
<gds-text tag="h3" font-size="heading-s"
>${item.heading}</gds-text
>
<gds-text font-size="detail-m">${item.body}</gds-text>
</gds-flex>
<div>
<gds-button size="medium">${item.button}</gds-button>
</div>
</gds-flex>
</gds-mask>
</gds-flex>
</gds-card>`,
)}
</gds-grid>
</gds-flex>
</gds-theme>`
}
}
Loading