-
Notifications
You must be signed in to change notification settings - Fork 8
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 changeset-release/main
- Loading branch information
Showing
7 changed files
with
200 additions
and
43 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,6 @@ | ||
--- | ||
"@justeattakeaway/pie-thumbnail": minor | ||
"pie-storybook": minor | ||
--- | ||
|
||
[Added] - basic functionality of thumbnail component |
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
75 changes: 59 additions & 16 deletions
75
apps/pie-storybook/stories/testing/pie-thumbnail.test.stories.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 |
---|---|---|
@@ -1,34 +1,77 @@ | ||
import { html } from 'lit'; | ||
import { type Meta } from '@storybook/web-components'; | ||
|
||
import '@justeattakeaway/pie-thumbnail'; | ||
import { type ThumbnailProps } from '@justeattakeaway/pie-thumbnail'; | ||
import { type ThumbnailProps, defaultProps, variants } from '@justeattakeaway/pie-thumbnail'; | ||
|
||
import { createStory } from '../../utilities'; | ||
import { type Meta } from '@storybook/web-components'; | ||
import { createVariantStory, type TemplateFunction } from '../../utilities'; | ||
|
||
type ThumbnailStoryMeta = Meta<ThumbnailProps>; | ||
|
||
const defaultArgs: ThumbnailProps = {}; | ||
const defaultArgs: ThumbnailProps = { | ||
...defaultProps, | ||
src: 'https://www.pie.design/assets/img/jet-logo-narrow.svg', | ||
alt: 'JET logo', | ||
}; | ||
|
||
const thumbnailStoryMeta: ThumbnailStoryMeta = { | ||
title: 'Thumbnail', | ||
component: 'pie-thumbnail', | ||
argTypes: {}, | ||
args: defaultArgs, | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: '', | ||
argTypes: { | ||
variant: { | ||
description: 'Set the variant of the thumbnail.', | ||
control: 'select', | ||
options: variants, | ||
defaultValue: { | ||
summary: defaultArgs.variant, | ||
}, | ||
}, | ||
src: { | ||
description: 'Set the src attribute for the underlying image tag.', | ||
control: 'text', | ||
defaultValue: { | ||
summary: defaultArgs.src, | ||
}, | ||
}, | ||
alt: { | ||
description: 'Set the alt attribute for the underlying image tag.', | ||
control: 'text', | ||
defaultValue: { | ||
summary: defaultArgs.alt, | ||
}, | ||
}, | ||
}, | ||
args: defaultArgs, | ||
}; | ||
|
||
export default thumbnailStoryMeta; | ||
|
||
// TODO: remove the eslint-disable rule when props are added | ||
// eslint-disable-next-line no-empty-pattern | ||
const Template = ({}: ThumbnailProps) => html` | ||
<pie-thumbnail></pie-thumbnail> | ||
`; | ||
const Template: TemplateFunction<ThumbnailProps> = ({ | ||
variant, | ||
src, | ||
alt, | ||
}) => html` | ||
<pie-thumbnail | ||
variant="${variant}" | ||
src="${src}" | ||
alt="${alt}"> | ||
</pie-thumbnail>`; | ||
|
||
// Define the prop options for the matrix | ||
const sharedPropOptions = { | ||
src: ['https://www.pie.design/assets/img/jet-logo-narrow.svg'], | ||
alt: ['JET logo'], | ||
}; | ||
|
||
const defaultPropOptions = { | ||
...sharedPropOptions, | ||
variant: ['default'], | ||
}; | ||
|
||
const outlinePropOptions = { | ||
...sharedPropOptions, | ||
variant: ['outline'], | ||
}; | ||
|
||
export const Default = createStory<ThumbnailProps>(Template, defaultArgs)(); | ||
export const DefaultPropVariations = createVariantStory<ThumbnailProps>(Template, defaultPropOptions); | ||
export const OutlinePropVariations = createVariantStory<ThumbnailProps>(Template, outlinePropOptions); |
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 |
---|---|---|
@@ -1,3 +1,19 @@ | ||
// TODO - please remove the eslint disable comment below when you add props to this interface | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ThumbnailProps {} | ||
import type { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core'; | ||
|
||
export const variants = [ | ||
'default', 'outline', | ||
] as const; | ||
|
||
export interface ThumbnailProps { | ||
variant?: typeof variants[number]; | ||
src?: string; | ||
alt?: string; | ||
} | ||
|
||
export type DefaultProps = ComponentDefaultProps<ThumbnailProps, 'variant' | 'src' | 'alt'>; | ||
|
||
export const defaultProps: DefaultProps = { | ||
variant: 'default', | ||
src: '', | ||
alt: '', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
@use '@justeattakeaway/pie-css/scss' as p; | ||
.c-thumbnail { | ||
--thumbnail-size: var(--dt-spacing-g); | ||
--thumbnail-border-radius: var(--dt-radius-rounded-b); | ||
--thumbnail-bg-color: var(--dt-color-container-default); | ||
--thumbnail-border-color: transparent; | ||
|
||
box-sizing: border-box; | ||
overflow: hidden; | ||
width: var(--thumbnail-size); | ||
height: var(--thumbnail-size); | ||
border-radius: var(--thumbnail-border-radius); | ||
border: 1px solid var(--thumbnail-border-color); | ||
background-color: var(--thumbnail-bg-color); | ||
|
||
&.c-thumbnail--outline { | ||
--thumbnail-border-color: var(--dt-color-border-default); | ||
} | ||
|
||
.c-thumbnail-img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: contain; | ||
display: block; | ||
} | ||
} |
17 changes: 9 additions & 8 deletions
17
packages/components/pie-thumbnail/test/visual/pie-thumbnail.spec.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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { test } from '@playwright/test'; | ||
import percySnapshot from '@percy/playwright'; | ||
import { percyWidths } from '@justeattakeaway/pie-webc-testing/src/percy/breakpoints.ts'; | ||
import { BasePage } from '@justeattakeaway/pie-webc-testing/src/helpers/page-object/base-page.ts'; | ||
import { variants } from '../../src/defs.ts'; | ||
|
||
test.describe('PieThumbnail - Visual tests`', () => { | ||
test('should display the PieThumbnail component successfully', async ({ page }) => { | ||
const basePage = new BasePage(page, 'thumbnail--default'); | ||
variants.forEach((variant) => test(`should render all prop variations for Variant: ${variant}`, async ({ page }) => { | ||
const basePage = new BasePage(page, `thumbnail--${variant}-prop-variations`); | ||
|
||
basePage.load(); | ||
await page.waitForTimeout(2500); | ||
basePage.load(); | ||
|
||
await percySnapshot(page, 'PieThumbnail - Visual Test'); | ||
}); | ||
}); | ||
await page.waitForTimeout(5000); | ||
|
||
await percySnapshot(page, `PIE Thumbnail - Variant: ${variant}`, percyWidths); | ||
})); |