Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCastigliano committed Jul 18, 2024
1 parent 3a0659f commit 8741cb4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/elements/flip-card/flip-card-details/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `sbb-flip-card-details`, when used inside a `sbb-flip-card`, will show its contents when the card is flipped.
The `sbb-flip-card-details`, when used inside a [sbb-flip-card](/docs/elements-sbb-flip-card-sbb-flip-card--docs), will show its contents when the card is flipped.
The component's slot is implicitly set to `"details"`.

```html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export const Default: StoryObj = {
argTypes: defaultArgTypes,
};

export const ImageBelow: StoryObj = {
render: Template,
argTypes: defaultArgTypes,
args: { ...defaultArgs, imageAlignment: imageAlignment.options![1] },
};

const meta: Meta = {
decorators: [withActions as Decorator],
parameters: {
Expand Down
7 changes: 4 additions & 3 deletions src/elements/flip-card/flip-card-summary/flip-card-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { hostAttributes } from '../../core/decorators.js';

import style from './flip-card-summary.scss?lit&inline';

export type SbbFlipCardImageAlignment = 'after' | 'below';

/**
* Combined with a `sbb-flip-card`, it displays its content when the card is not flipped.
*
Expand All @@ -20,9 +22,8 @@ export class SbbFlipCardSummaryElement extends LitElement {
public static override styles: CSSResultGroup = style;

/** The position where to render the image. */
@property({ attribute: 'image-alignment', reflect: true }) public imageAlignment:
| 'after'
| 'below' = 'after';
@property({ attribute: 'image-alignment', reflect: true })
public imageAlignment: SbbFlipCardImageAlignment = 'after';

protected override render(): TemplateResult {
return html`
Expand Down
4 changes: 2 additions & 2 deletions src/elements/flip-card/flip-card-summary/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `sbb-flip-card-summary`, when used inside a `sbb-flip-card`, shows its contents when the card is not flipped.
The `sbb-flip-card-summary`, when used inside a [sbb-flip-card](/docs/elements-sbb-flip-card-sbb-flip-card--docs), shows its contents when the card is not flipped.
The component's slot is implicitly set to `"summary"`.

```html
Expand All @@ -20,7 +20,7 @@ Use the unnamed slot of `sbb-flip-card-summary` to provide a title and, optional

| Name | Attribute | Privacy | Type | Default | Description |
| ---------------- | ----------------- | ------- | --------------------------- | --------- | --------------------------------------- |
| `imageAlignment` | `image-alignment` | public | `\| 'after' \| 'below'` | `'after'` | The position where to render the image. |
| `imageAlignment` | `image-alignment` | public | `SbbFlipCardImageAlignment` | `'after'` | The position where to render the image. |

## Slots

Expand Down
20 changes: 10 additions & 10 deletions src/elements/flip-card/flip-card/flip-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import style from './flip-card.scss?lit&inline';
export class SbbFlipCardElement extends LitElement {
public static override styles: CSSResultGroup = style;

/** Returns the slotted sbb-flip-card-summary. */
public get summary(): SbbFlipCardSummaryElement {
return this.querySelector('sbb-flip-card-summary')!;
}

/** Returns the slotted sbb-flip-card-details. */
public get details(): SbbFlipCardDetailsElement {
return this.querySelector('sbb-flip-card-details')!;
}

/** Whether the card is flipped or not. */
@state() private _flipped = false;

Expand All @@ -34,16 +44,6 @@ export class SbbFlipCardElement extends LitElement {
this.details.inert = !this._flipped;
}

/** Returns the slotted sbb-flip-card-summary. */
public get summary(): SbbFlipCardSummaryElement {
return this.querySelector('sbb-flip-card-summary')!;
}

/** Returns the slotted sbb-flip-card-details. */
public get details(): SbbFlipCardDetailsElement {
return this.querySelector('sbb-flip-card-details')!;
}

protected override render(): TemplateResult {
return html`
<div class="sbb-flip-card--wrapper">
Expand Down
12 changes: 6 additions & 6 deletions src/elements/flip-card/flip-card/flip-card.visual.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { html, nothing } from 'lit';
import { html, nothing, type TemplateResult } from 'lit';

import sampleImages from '../../core/images.js';
import {
describeViewports,
visualDiffDefault,
visualDiffFocus,
} from '../../core/testing/private.js';

import './flip-card.js';
import '../flip-card-summary.js';
import '../flip-card-details.js';
import '../../title.js';
import '../../link.js';
import '../../image.js';
import type { SbbFlipCardImageAlignment } from '../flip-card-summary.js';

const content = (
title: string = 'Summary',
imageAlignment: 'after' | 'below' = 'after',
imageAlignment: SbbFlipCardImageAlignment = 'after',
longConent: boolean = false,
) =>
): TemplateResult =>
html` <sbb-flip-card-summary slot="summary" image-alignment=${imageAlignment}>
<sbb-title level="4">${title}</sbb-title>
<sbb-image
Expand Down Expand Up @@ -52,7 +52,7 @@ describe(`sbb-flip-card`, () => {
state.with(async (setup) => {
await setup.withFixture(html`
<sbb-flip-card>
${content('Summary', imageAlignment as 'after' | 'below')}
${content('Summary', imageAlignment as SbbFlipCardImageAlignment)}
</sbb-flip-card>
`);
}),
Expand Down Expand Up @@ -86,7 +86,7 @@ describe(`sbb-flip-card`, () => {
visualDiffDefault.with(async (setup) => {
await setup.withFixture(
html`<sbb-flip-card>
${content('Summary', imageAlignment as 'after' | 'below', true)}
${content('Summary', imageAlignment as SbbFlipCardImageAlignment, true)}
</sbb-flip-card>`,
);
}),
Expand Down
4 changes: 2 additions & 2 deletions src/elements/flip-card/flip-card/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The `sbb-flip-card` component displays an informative card that reveals more informations when clicked or toggled programmatically.
It's meant to be used together with `sbb-flip-card-summary` and `sbb-flip-card-details`.
It's meant to be used together with [sbb-flip-card-summary](/docs/elements-sbb-flip-card-sbb-flip-card-summary--docs) and [sbb-flip-card-details](/docs/elements-sbb-flip-card-sbb-flip-card-details--docs).

```html
<sbb-flip-card>
Expand All @@ -17,7 +17,7 @@ The component will display the content slotted in the `summary` slot in the main

## States

The `sbb-flip-card` will switch to the flipped state after the user clicks on it or after the `toggle` method is called. Once the component is flipped, it will have the attribute `data-flipped`, which is for internal use only, so it should not be set by hand.
The `sbb-flip-card` will switch to the flipped state after the user clicks on it or after the `toggle` method is called.

<!-- Auto Generated Below -->

Expand Down

0 comments on commit 8741cb4

Please sign in to comment.