@justeattakeaway/pie-thumbnail 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,42 @@
11
11
  {
12
12
  "kind": "javascript-module",
13
13
  "path": "src/defs.js",
14
- "declarations": [],
15
- "exports": []
14
+ "declarations": [
15
+ {
16
+ "kind": "variable",
17
+ "name": "variants",
18
+ "type": {
19
+ "text": "[\n 'default', 'outline',\n]"
20
+ },
21
+ "default": "[\n 'default', 'outline',\n]"
22
+ },
23
+ {
24
+ "kind": "variable",
25
+ "name": "defaultProps",
26
+ "type": {
27
+ "text": "DefaultProps"
28
+ },
29
+ "default": "{\n variant: 'default',\n src: '',\n alt: '',\n}"
30
+ }
31
+ ],
32
+ "exports": [
33
+ {
34
+ "kind": "js",
35
+ "name": "variants",
36
+ "declaration": {
37
+ "name": "variants",
38
+ "module": "src/defs.js"
39
+ }
40
+ },
41
+ {
42
+ "kind": "js",
43
+ "name": "defaultProps",
44
+ "declaration": {
45
+ "name": "defaultProps",
46
+ "module": "src/defs.js"
47
+ }
48
+ }
49
+ ]
16
50
  },
17
51
  {
18
52
  "kind": "javascript-module",
@@ -22,7 +56,40 @@
22
56
  "kind": "class",
23
57
  "description": "",
24
58
  "name": "PieThumbnail",
25
- "members": [],
59
+ "members": [
60
+ {
61
+ "kind": "field",
62
+ "name": "variant",
63
+ "privacy": "public",
64
+ "attribute": "variant"
65
+ },
66
+ {
67
+ "kind": "field",
68
+ "name": "src",
69
+ "privacy": "public",
70
+ "attribute": "src"
71
+ },
72
+ {
73
+ "kind": "field",
74
+ "name": "alt",
75
+ "privacy": "public",
76
+ "attribute": "alt"
77
+ }
78
+ ],
79
+ "attributes": [
80
+ {
81
+ "name": "variant",
82
+ "fieldName": "variant"
83
+ },
84
+ {
85
+ "name": "src",
86
+ "fieldName": "src"
87
+ },
88
+ {
89
+ "name": "alt",
90
+ "fieldName": "alt"
91
+ }
92
+ ],
26
93
  "superclass": {
27
94
  "name": "LitElement",
28
95
  "package": "lit"
package/dist/index.d.ts CHANGED
@@ -1,16 +1,29 @@
1
+ import type { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import type { TemplateResult } from 'lit-html';
4
5
 
6
+ export declare type DefaultProps = ComponentDefaultProps<ThumbnailProps, 'variant' | 'src' | 'alt'>;
7
+
8
+ export declare const defaultProps: DefaultProps;
9
+
5
10
  /**
6
11
  * @tagname pie-thumbnail
7
12
  */
8
13
  export declare class PieThumbnail extends LitElement implements ThumbnailProps {
14
+ variant: "default" | "outline";
15
+ src: string;
16
+ alt: string;
9
17
  render(): TemplateResult<1>;
10
18
  static styles: CSSResult;
11
19
  }
12
20
 
13
21
  export declare interface ThumbnailProps {
22
+ variant?: typeof variants[number];
23
+ src?: string;
24
+ alt?: string;
14
25
  }
15
26
 
27
+ export declare const variants: readonly ["default", "outline"];
28
+
16
29
  export { }
package/dist/index.js CHANGED
@@ -1,13 +1,55 @@
1
- import { LitElement as o, html as s, unsafeCSS as r } from "lit";
2
- import { defineCustomElement as n } from "@justeattakeaway/pie-webc-core";
3
- const i = "*,*:after,*:before{box-sizing:inherit}", l = "pie-thumbnail", e = class e extends o {
1
+ import { LitElement as m, html as h, unsafeCSS as p } from "lit";
2
+ import { validPropertyValues as v, defineCustomElement as f } from "@justeattakeaway/pie-webc-core";
3
+ import { classMap as g } from "lit/directives/class-map.js";
4
+ import { property as n } from "lit/decorators.js";
5
+ const y = [
6
+ "default",
7
+ "outline"
8
+ ], e = {
9
+ variant: "default",
10
+ src: "",
11
+ alt: ""
12
+ }, S = ".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.c-thumbnail--outline{--thumbnail-border-color: var(--dt-color-border-default)}.c-thumbnail .c-thumbnail-img{width:100%;height:100%;object-fit:contain;display:block}";
13
+ var x = Object.defineProperty, l = (d, a, i, u) => {
14
+ for (var t = void 0, o = d.length - 1, c; o >= 0; o--)
15
+ (c = d[o]) && (t = c(a, i, t) || t);
16
+ return t && x(a, i, t), t;
17
+ };
18
+ const b = "pie-thumbnail", s = class s extends m {
19
+ constructor() {
20
+ super(...arguments), this.variant = e.variant, this.src = e.src, this.alt = e.alt;
21
+ }
4
22
  render() {
5
- return s`<h1 data-test-id="pie-thumbnail">Hello world!</h1>`;
23
+ const {
24
+ variant: a,
25
+ src: i,
26
+ alt: u
27
+ } = this, t = {
28
+ "c-thumbnail": !0,
29
+ [`c-thumbnail--${a}`]: !0
30
+ };
31
+ return h`
32
+ <div data-test-id="pie-thumbnail" class="${g(t)}">
33
+ <img data-test-id="pie-thumbnail-img" src="${i}" class="c-thumbnail-img" alt="${u}">
34
+ </div>
35
+ `;
6
36
  }
7
37
  };
8
- e.styles = r(i);
9
- let t = e;
10
- n(l, t);
38
+ s.styles = p(S);
39
+ let r = s;
40
+ l([
41
+ n({ type: String }),
42
+ v(b, y, e.variant)
43
+ ], r.prototype, "variant");
44
+ l([
45
+ n({ type: String })
46
+ ], r.prototype, "src");
47
+ l([
48
+ n({ type: String })
49
+ ], r.prototype, "alt");
50
+ f(b, r);
11
51
  export {
12
- t as PieThumbnail
52
+ r as PieThumbnail,
53
+ e as defaultProps,
54
+ y as variants
13
55
  };
package/dist/react.d.ts CHANGED
@@ -1,14 +1,22 @@
1
+ import type { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import * as React_2 from 'react';
4
5
  import type { TemplateResult } from 'lit-html';
5
6
 
7
+ export declare type DefaultProps = ComponentDefaultProps<ThumbnailProps, 'variant' | 'src' | 'alt'>;
8
+
9
+ export declare const defaultProps: DefaultProps;
10
+
6
11
  export declare const PieThumbnail: React_2.ForwardRefExoticComponent<ThumbnailProps & React_2.RefAttributes<PieThumbnail_2> & ReactBaseType>;
7
12
 
8
13
  /**
9
14
  * @tagname pie-thumbnail
10
15
  */
11
16
  declare class PieThumbnail_2 extends LitElement implements ThumbnailProps {
17
+ variant: "default" | "outline";
18
+ src: string;
19
+ alt: string;
12
20
  render(): TemplateResult<1>;
13
21
  static styles: CSSResult;
14
22
  }
@@ -16,6 +24,11 @@ declare class PieThumbnail_2 extends LitElement implements ThumbnailProps {
16
24
  declare type ReactBaseType = React_2.HTMLAttributes<HTMLElement>;
17
25
 
18
26
  export declare interface ThumbnailProps {
27
+ variant?: typeof variants[number];
28
+ src?: string;
29
+ alt?: string;
19
30
  }
20
31
 
32
+ export declare const variants: readonly ["default", "outline"];
33
+
21
34
  export { }
package/dist/react.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as a } from "@lit/react";
3
- import { PieThumbnail as i } from "./index.js";
4
- const m = a({
3
+ import { PieThumbnail as t } from "./index.js";
4
+ import { defaultProps as s, variants as p } from "./index.js";
5
+ const i = a({
5
6
  displayName: "PieThumbnail",
6
- elementClass: i,
7
+ elementClass: t,
7
8
  react: e,
8
9
  tagName: "pie-thumbnail",
9
10
  events: {}
10
- }), o = m;
11
+ }), n = i;
11
12
  export {
12
- o as PieThumbnail
13
+ n as PieThumbnail,
14
+ s as defaultProps,
15
+ p as variants
13
16
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-thumbnail",
3
3
  "description": "PIE Design System Thumbnail built using Web Components",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@custom-elements-manifest/analyzer": "0.9.0",
38
38
  "@justeattakeaway/pie-components-config": "0.18.0",
39
- "@justeattakeaway/pie-css": "0.13.1",
39
+ "@justeattakeaway/pie-css": "0.14.0",
40
40
  "cem-plugin-module-file-extensions": "0.0.5"
41
41
  },
42
42
  "dependencies": {
package/src/defs.ts CHANGED
@@ -1,3 +1,19 @@
1
- // TODO - please remove the eslint disable comment below when you add props to this interface
2
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
3
- export interface ThumbnailProps {}
1
+ import type { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
+
3
+ export const variants = [
4
+ 'default', 'outline',
5
+ ] as const;
6
+
7
+ export interface ThumbnailProps {
8
+ variant?: typeof variants[number];
9
+ src?: string;
10
+ alt?: string;
11
+ }
12
+
13
+ export type DefaultProps = ComponentDefaultProps<ThumbnailProps, 'variant' | 'src' | 'alt'>;
14
+
15
+ export const defaultProps: DefaultProps = {
16
+ variant: 'default',
17
+ src: '',
18
+ alt: '',
19
+ };
package/src/index.ts CHANGED
@@ -1,8 +1,12 @@
1
- import { LitElement, html, unsafeCSS } from 'lit';
1
+ import {
2
+ LitElement, html, unsafeCSS,
3
+ } from 'lit';
2
4
 
3
- import { defineCustomElement } from '@justeattakeaway/pie-webc-core';
5
+ import { defineCustomElement, validPropertyValues } from '@justeattakeaway/pie-webc-core';
6
+ import { classMap } from 'lit/directives/class-map.js';
7
+ import { property } from 'lit/decorators.js';
8
+ import { type ThumbnailProps, defaultProps, variants } from './defs';
4
9
  import styles from './thumbnail.scss?inline';
5
- import { type ThumbnailProps } from './defs';
6
10
 
7
11
  // Valid values available to consumers
8
12
  export * from './defs';
@@ -13,8 +17,33 @@ const componentSelector = 'pie-thumbnail';
13
17
  * @tagname pie-thumbnail
14
18
  */
15
19
  export class PieThumbnail extends LitElement implements ThumbnailProps {
20
+ @property({ type: String })
21
+ @validPropertyValues(componentSelector, variants, defaultProps.variant)
22
+ public variant = defaultProps.variant;
23
+
24
+ @property({ type: String })
25
+ public src = defaultProps.src;
26
+
27
+ @property({ type: String })
28
+ public alt = defaultProps.alt;
29
+
16
30
  render () {
17
- return html`<h1 data-test-id="pie-thumbnail">Hello world!</h1>`;
31
+ const {
32
+ variant,
33
+ src,
34
+ alt,
35
+ } = this;
36
+
37
+ const wrapperClasses = {
38
+ 'c-thumbnail': true,
39
+ [`c-thumbnail--${variant}`]: true,
40
+ };
41
+
42
+ return html`
43
+ <div data-test-id="pie-thumbnail" class="${classMap(wrapperClasses)}">
44
+ <img data-test-id="pie-thumbnail-img" src="${src}" class="c-thumbnail-img" alt="${alt}">
45
+ </div>
46
+ `;
18
47
  }
19
48
 
20
49
  // Renders a `CSSResult` generated from SCSS by Vite
@@ -1 +1,25 @@
1
- @use '@justeattakeaway/pie-css/scss' as p;
1
+ .c-thumbnail {
2
+ --thumbnail-size: var(--dt-spacing-g);
3
+ --thumbnail-border-radius: var(--dt-radius-rounded-b);
4
+ --thumbnail-bg-color: var(--dt-color-container-default);
5
+ --thumbnail-border-color: transparent;
6
+
7
+ box-sizing: border-box;
8
+ overflow: hidden;
9
+ width: var(--thumbnail-size);
10
+ height: var(--thumbnail-size);
11
+ border-radius: var(--thumbnail-border-radius);
12
+ border: 1px solid var(--thumbnail-border-color);
13
+ background-color: var(--thumbnail-bg-color);
14
+
15
+ &.c-thumbnail--outline {
16
+ --thumbnail-border-color: var(--dt-color-border-default);
17
+ }
18
+
19
+ .c-thumbnail-img {
20
+ width: 100%;
21
+ height: 100%;
22
+ object-fit: contain;
23
+ display: block;
24
+ }
25
+ }