-
Notifications
You must be signed in to change notification settings - Fork 0
#1076 - Egen komponent for Card i designsystemet #54
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
Draft
rebalv
wants to merge
17
commits into
main
Choose a base branch
from
1067-egen-card-komponent-i-designsystemet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
823dfd9
#1076 - feat: first simple version of card
rebalv 38c65fa
#1067 - feat: added slots for other and subtitle + new css
rebalv d045465
#1067 - feat: parameter for href clickable cards
rebalv 15816c2
#1067 - chore: avoid link lines under the text
rebalv 930c247
#1067 - chore: improved css for card
rebalv eda1755
#1067 - feat: added documentation file for card
rebalv 1c9ee31
#1067 - fix: linting
rebalv e4d3917
#1067 - feat: egne tokens for title og tekst
rebalv 3e85a17
#1067 - chore: ta i bruk tokens for titles
rebalv 539a6cf
#1067 - chore: la til mer font styling for mobil og desktop text
rebalv a5a29b1
Merge branch 'main' into 1067-egen-card-komponent-i-designsystemet
rebalv 5ef59e4
#1067 - chore: linting
rebalv 00dd855
#1067 - chore: 100% height of cards and spesific height for images
rebalv 81a79eb
#1067 - feat: separate css files for typography classes
rebalv c6d8baf
#1067 - feat: added typography classes to global styles
rebalv b03d8be
#1067 - chore: removed max width for the cards
rebalv bf2f81b
#1067 - feat: removed href and changed naming
rebalv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,41 @@ | ||
| import type { Meta, StoryObj } from '@storybook/web-components'; | ||
| import { html } from 'lit'; | ||
| import './card.js'; | ||
|
|
||
| const meta: Meta = { | ||
| title: 'Components/Card', | ||
| component: 'cx-card', | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| argTypes: { | ||
| title: { control: 'text' }, | ||
| subtitle1: { control: 'text' }, | ||
| subtitle2: { control: 'text' }, | ||
| image: { control: 'text' }, | ||
| imageAlt: { control: 'text' }, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| title: 'Title', | ||
| subtitle1: '14:00 - 16:00', | ||
| subtitle2: 'Oslo, Norway', | ||
| image: 'https://picsum.photos/500/220', | ||
| imageAlt: 'Image', | ||
| }, | ||
| render: (args) => html` | ||
| <cx-card | ||
| title="${args.title}" | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| subtitle1="${args.subtitle1}" | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| subtitle2="${args.subtitle2}" | ||
| image="${args.image}" | ||
| image-alt="${args.imageAlt}" | ||
| > | ||
| </cx-card> | ||
| `, | ||
| }; | ||
This file contains hidden or 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,203 @@ | ||
| import { LitElement, html, css } from 'lit'; | ||
| import { customElement, property } from 'lit/decorators.js'; | ||
|
|
||
| @customElement('cx-card') | ||
| export class Card extends LitElement { | ||
| static styles = css` | ||
| :host { | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| display: block; | ||
| } | ||
|
|
||
| .card { | ||
| position: relative; | ||
| height: 440px; | ||
| width: 100%; | ||
| max-width: 500px; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| border-radius: 24px; | ||
| overflow: hidden; | ||
| padding: 0; | ||
| border: none; | ||
| box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); | ||
| } | ||
|
|
||
| .card-image { | ||
| width: 100%; | ||
| height: 50%; | ||
| position: relative; | ||
| } | ||
|
|
||
| .card-image img, | ||
| .card-image ::slotted(img) { | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| width: 100%; | ||
| height: 100%; | ||
| object-fit: cover; | ||
| transition: filter 0.3s ease; | ||
| } | ||
|
|
||
| .card-image::after { | ||
| content: ""; | ||
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| mix-blend-mode: multiply; | ||
| background: var(--cx-color-background-accent-5, #4a90e2); | ||
| opacity: 0; | ||
| transition: opacity 0.3s ease; | ||
| pointer-events: none; | ||
| } | ||
|
|
||
| .card-info-wrapper { | ||
| position: absolute; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| width: 100%; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| bottom: -74px; | ||
| padding: var(--cx-spacing-6, 24px); | ||
| color: var(--cx-color-text-primary, #333); | ||
| transition: bottom 0.3s ease; | ||
| background-color: var(--cx-color-background-accent-1-soft, rgba(255, 255, 255, 0.9)); | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| .card-info { | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .card-metadata { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| color: var(--cx-color-text-less-important, #666); | ||
| gap: var(--cx-spacing-2, 8px); | ||
| margin-bottom: var(--cx-spacing-4, 16px); | ||
| } | ||
|
|
||
| .card-metadata-section { | ||
| display: inline-flex; | ||
| flex: 1 1 100%; | ||
| align-items: center; | ||
| gap: var(--cx-spacing-2, 8px); | ||
| } | ||
|
|
||
| .card-title { | ||
| display: -webkit-box; | ||
| -webkit-box-orient: vertical; | ||
| -webkit-line-clamp: 2; | ||
| line-clamp: 2; | ||
| max-height: 65px; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| min-height: 65px; | ||
| overflow: hidden; | ||
| font-size: 24px; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| font-weight: 400; | ||
| margin: 0; | ||
| line-height: 2rem; | ||
| align-content: center; | ||
| color: var(--cx-color-text-primary, #333); | ||
| } | ||
|
|
||
| .card:hover .card-image img, | ||
| .card:hover .card-image ::slotted(img) { | ||
| filter: grayscale(1); | ||
| } | ||
|
|
||
| .card:hover .card-image::after { | ||
| opacity: 1; | ||
| } | ||
|
|
||
| .card:hover .card-info-wrapper { | ||
| bottom: 0; | ||
| } | ||
|
|
||
| @media (max-width: 750px) { | ||
| .card { | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: flex-end; | ||
| width: 100%; | ||
| max-width: 343px; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| height: auto; | ||
| min-height: unset; | ||
| max-height: unset; | ||
| } | ||
|
|
||
| .card-image { | ||
| flex: 0 0 35%; | ||
| height: auto; | ||
| } | ||
|
|
||
| .card-info-wrapper { | ||
| position: relative; | ||
| width: 65%; | ||
| bottom: unset; | ||
| align-self: flex-end; | ||
| padding: var(--cx-spacing-4, 16px); | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| .card-info { | ||
| flex-direction: column-reverse; | ||
| gap: var(--cx-spacing-2, 8px); | ||
| } | ||
|
|
||
| .card-metadata-section { | ||
| font-size: 12px; | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| .card-title { | ||
| margin-top: unset; | ||
| min-height: unset; | ||
| font-size: 18px; | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| @property({ type: String, reflect: true }) | ||
| title = ''; | ||
|
|
||
| @property({ type: String, reflect: true }) | ||
| subtitle1 = ''; | ||
|
|
||
| @property({ type: String, reflect: true }) | ||
| subtitle2 = ''; | ||
|
|
||
| @property({ type: String, reflect: true }) | ||
| image = ''; | ||
|
|
||
| @property({ type: String, reflect: true }) | ||
| imageAlt = 'Card image'; | ||
|
|
||
| render() { | ||
| return html` | ||
| <div class="card"> | ||
| <div class="card-image"> | ||
| ${this.image ? html` | ||
| <img src="${this.image}" alt="${this.imageAlt}" /> | ||
| ` : html` | ||
| <slot name="image"></slot> | ||
| `} | ||
| </div> | ||
| <div class="card-info-wrapper"> | ||
|
rebalv marked this conversation as resolved.
Outdated
|
||
| <div class="card-info"> | ||
| <div class="card-metadata"> | ||
| ${this.subtitle1 ? html` | ||
| <div class="card-metadata-section"> | ||
| ${this.subtitle1} | ||
| </div> | ||
| ` : ''} | ||
| ${this.subtitle2 ? html` | ||
| <div class="card-metadata-section"> | ||
| ${this.subtitle2} | ||
| </div> | ||
| ` : ''} | ||
| </div> | ||
| ${this.title ? html`<h3 class="card-title">${this.title}</h3>` : ''} | ||
| </div> | ||
| </div> | ||
|
rebalv marked this conversation as resolved.
|
||
| </div> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'cx-card': Card; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.