@justeattakeaway/pie-modal 0.2.0 → 0.4.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.
@@ -1,11 +1,14 @@
1
- vite v4.2.1 building for production...
1
+ [11:48:53] @custom-elements-manifest/analyzer: Created new manifest.
2
+ react wrapper has been added!
3
+ vite v4.2.3 building for production...
2
4
  transforming...
3
- ✓ 5 modules transformed.
5
+ ✓ 27 modules transformed.
4
6
  rendering chunks...
5
7
  computing gzip size...
6
- dist/index.js 1.78 kB │ gzip: 0.81 kB
7
- 
8
- [vite:dts] Start generate declaration files...
9
- ✓ built in 23.66s
10
- [vite:dts] Declaration files built in 23401ms.
11
- 
8
+ dist/index.js 5.93 kB │ gzip: 2.06 kB
9
+ dist/react.js 59.15 kB │ gzip: 15.95 kB
10
+
11
+ [vite:dts] Start generate declaration files...
12
+ ✓ built in 5.82s
13
+ [vite:dts] Declaration files built in 5339ms.
14
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @justeattakeaway/pie-modal
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Added] - `heading` and `headingLevel` props to the modal component ([#530](https://github.com/justeattakeaway/pie/pull/530)) by [@raoufswe](https://github.com/raoufswe)
8
+
9
+ - [Added] - Modal heading added to component ([#513](https://github.com/justeattakeaway/pie/pull/513)) by [@fernandofranca](https://github.com/fernandofranca)
10
+
11
+ [Added] - Basic styling for modal default state
12
+
13
+ - [Changed] - moved pie-webc-core dependency to devDependencies in each component ([#499](https://github.com/justeattakeaway/pie/pull/499)) by [@jamieomaguire](https://github.com/jamieomaguire)
14
+
15
+ - [Added] - Additional notes on visual tests and environment variables ([#525](https://github.com/justeattakeaway/pie/pull/525)) by [@jamieomaguire](https://github.com/jamieomaguire)
16
+
17
+ - [Added] prop to control modal open & close state ([#527](https://github.com/justeattakeaway/pie/pull/527)) by [@kevinrodrigues](https://github.com/kevinrodrigues)
18
+
19
+ - [Added] Read me percy config examples ([#529](https://github.com/justeattakeaway/pie/pull/529)) by [@kevinrodrigues](https://github.com/kevinrodrigues)
20
+
21
+ ### Patch Changes
22
+
23
+ - [Fixed] - PieModal CSS by adding logical property ([#521](https://github.com/justeattakeaway/pie/pull/521)) by [@fernandofranca](https://github.com/fernandofranca)
24
+
25
+ ## 0.3.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [Changed] - Build script to include generating react wrapper ([#426](https://github.com/justeattakeaway/pie/pull/426)) by [@LTurns](https://github.com/LTurns)
30
+
31
+ ### Patch Changes
32
+
33
+ - [Added] - Missing `test:ci` scripts to package.json ([#492](https://github.com/justeattakeaway/pie/pull/492)) by [@siggerzz](https://github.com/siggerzz)
34
+
35
+ - [Updated] - components to use the shared configurations ([#487](https://github.com/justeattakeaway/pie/pull/487)) by [@fernandofranca](https://github.com/fernandofranca)
36
+
37
+ - Updated dependencies [[`090354733`](https://github.com/justeattakeaway/pie/commit/090354733f24f0aa52ce287db7f8d13648414150)]:
38
+ - @justeattakeaway/pie-webc-core@0.2.0
39
+
3
40
  ## 0.2.0
4
41
 
5
42
  ### Minor Changes
package/README.md CHANGED
@@ -8,6 +8,13 @@
8
8
  </a>
9
9
  </p>
10
10
 
11
+ # Table of Contents
12
+
13
+ 1. [Introduction](#pie-modal)
14
+ 2. [Local Development](#local-development)
15
+ 3. [Importing the component](#importing-the-component)
16
+ 4. [Props](#props)
17
+
11
18
  # pie-modal
12
19
 
13
20
  This modal is a Web Component built using Lit.
@@ -29,3 +36,46 @@ Compile and watch for changes (auto-compiles `dist` on save)
29
36
  ```
30
37
  yarn watch
31
38
  ```
39
+
40
+ ### Importing the component
41
+
42
+ ```javascript
43
+ // default
44
+ import { PieModal } from '@justeattakeaway/pie-button';
45
+
46
+ // react
47
+ import { PieModal } from '@justeattakeaway/pie-button/dist/react';
48
+ ```
49
+
50
+ ## Props
51
+
52
+ | Property | Type | Default | Description |
53
+ |----------|-----------|---------|-------------------------------------------------|
54
+ | isOpen | `Boolean` | `false` | Controls if the modal element is open or closed |
55
+ | heading* | `String` | - | Sets the heading of the modal |
56
+ | headingLevel | `String` | `h2` | Allows you to set the heading tag (from `h1` to `h6`) |
57
+
58
+
59
+ ## Testing
60
+
61
+ ### Visual tests
62
+
63
+ Run at the root of the monorepo:
64
+ ```
65
+ yarn test:visual --filter=pie-modal
66
+ ```
67
+
68
+ Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
69
+
70
+ ### Setup via bash:
71
+
72
+ ```
73
+ export PERCY_TOKEN_PIE_MODAL=abcde
74
+ ```
75
+
76
+ ### Setup via package.json:
77
+
78
+ Under scripts `test:visual` replace the environment variable with the below:
79
+
80
+ ```
81
+ PERCY_TOKEN_PIE_MODAL=abcde
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- import { html as p, LitElement as f } from "lit";
2
- import { customElement as u } from "lit/decorators.js";
3
- import { property as m } from "lit/decorators/property.js";
4
- var v = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, c = (i, e, s, t) => {
5
- for (var r = t > 1 ? void 0 : t ? _(e, s) : e, o = i.length - 1, l; o >= 0; o--)
6
- (l = i[o]) && (r = (t ? l(e, s, r) : l(r)) || r);
7
- return t && r && v(e, s, r), r;
1
+ import { unsafeCSS as m, LitElement as u, html as f } from "lit";
2
+ import { unsafeStatic as b, html as $ } from "lit/static-html.js";
3
+ import { property as d } from "lit/decorators.js";
4
+ import { property as y } from "lit/decorators/property.js";
5
+ var w = Object.defineProperty, P = Object.getOwnPropertyDescriptor, O = (n, r, o, t) => {
6
+ for (var e = t > 1 ? void 0 : t ? P(r, o) : r, s = n.length - 1, i; s >= 0; s--)
7
+ (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
8
+ return t && e && w(r, o, e), e;
8
9
  };
9
- const d = (i) => {
10
- class e extends i {
10
+ const _ = (n) => {
11
+ class r extends n {
11
12
  constructor() {
12
13
  super(...arguments), this.dir = "";
13
14
  }
@@ -25,27 +26,115 @@ const d = (i) => {
25
26
  return this.dir === "ltr" ? !1 : this.dir === "rtl" || ((t = window == null ? void 0 : window.getComputedStyle(this)) == null ? void 0 : t.direction) === "rtl";
26
27
  }
27
28
  }
28
- return c([
29
- m({ type: String })
30
- ], e.prototype, "dir", 2), e;
31
- };
32
- var a = Object.defineProperty, P = Object.getOwnPropertyDescriptor, h = (i, e, s, t) => {
33
- for (var r = t > 1 ? void 0 : t ? P(e, s) : e, o = i.length - 1, l; o >= 0; o--)
34
- (l = i[o]) && (r = (t ? l(e, s, r) : l(r)) || r);
35
- return t && r && a(e, s, r), r;
29
+ return O([
30
+ y({ type: String })
31
+ ], r.prototype, "dir", 2), r;
32
+ }, x = (n, r, o) => function(t, e) {
33
+ const s = `#${e}`;
34
+ Object.defineProperty(t, e, {
35
+ get() {
36
+ return this[s];
37
+ },
38
+ set(i) {
39
+ const h = this[s];
40
+ r.includes(i) ? this[s] = i : (console.error(
41
+ `<${n}> Invalid value "${i}" provided for property "${e}".`,
42
+ `Must be one of: ${r.join(" | ")}.`,
43
+ `Falling back to default value: "${o}"`
44
+ ), this[s] = o), this.requestUpdate(e, h);
45
+ }
46
+ });
47
+ }, C = (n) => function(r, o) {
48
+ const t = `#${o}`;
49
+ Object.defineProperty(r, o, {
50
+ get() {
51
+ return this[t];
52
+ },
53
+ set(e) {
54
+ const s = this[t];
55
+ (e == null || e === "") && console.error(`<${n}> Missing required attribute "${o}"`), this[t] = e, this.requestUpdate(o, s);
56
+ }
57
+ });
58
+ }, j = `.c-webComponentTestWrapper{padding-block:var(--dt-spacing-c);padding-inline:var(--dt-spacing-e);font-family:var(--dt-font-interactive-m-family);font-size:calc(var(--dt-font-size-20) * 1px);border:1px solid var(--dt-color-background-dark);display:grid;grid-template-columns:1fr 1fr}.c-webComponentTestWrapper-label{margin-block:var(--dt-spacing-c)}.c-webComponentTestWrapper-slot{padding:var(--dt-spacing-c);border:1px dashed var(--dt-color-background-dark);grid-column:1/3;margin-block-start:var(--dt-spacing-c)}
59
+ `;
60
+ var T = Object.defineProperty, W = Object.getOwnPropertyDescriptor, z = (n, r, o, t) => {
61
+ for (var e = t > 1 ? void 0 : t ? W(r, o) : r, s = n.length - 1, i; s >= 0; s--)
62
+ (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
63
+ return t && e && T(r, o, e), e;
36
64
  };
37
- let n = class extends d(f) {
65
+ class l extends u {
66
+ constructor() {
67
+ super(...arguments), this.propKeyValues = "";
68
+ }
69
+ // Renders a string such as 'size: small, isFullWidth: true'
70
+ // as HTML such as:
71
+ // <p class="c-webComponentTestWrapper-label"><b>size</b>: <code>small</code></p>
72
+ // <p class="c-webComponentTestWrapper-label"><b>isFullWidth</b>: <code>true</code></p>
73
+ _renderPropKeyValues() {
74
+ return this.propKeyValues.split(",").map((r) => {
75
+ const [o, t] = r.split(":");
76
+ return f`<p class="c-webComponentTestWrapper-label"><b>${o}</b>: <code>${t}</code></p>`;
77
+ });
78
+ }
38
79
  // eslint-disable-next-line class-methods-use-this
39
80
  render() {
40
- return p`
41
- <div>This is the Pie Modal
42
- <slot></slot>
81
+ return f`
82
+ <div class="c-webComponentTestWrapper">
83
+ ${this._renderPropKeyValues()}
84
+ <div class="c-webComponentTestWrapper-slot">
85
+ <slot></slot>
86
+ </div>
43
87
  </div>`;
44
88
  }
89
+ }
90
+ l.styles = m(j);
91
+ z([
92
+ d({ type: String })
93
+ ], l.prototype, "propKeyValues", 2);
94
+ const v = "web-component-test-wrapper";
95
+ customElements.get(v) || customElements.define(v, l);
96
+ const q = `.c-modal{border-radius:var(--dt-radius-rounded-d);border:none;font-family:var(--dt-font-interactive-m-family);background-color:var(--dt-color-container-default);padding:0;inline-size:600px;box-shadow:var(--dt-elevation-04)}.c-modal .c-modal-heading{font-size:calc(var(--dt-font-heading-m-size--wide) * 1px);line-height:calc(var(--dt-font-heading-m-line-height--wide) * 1px);font-weight:var(--dt-font-heading-m-weight);margin:0;padding-block:var(--dt-spacing-e) var(--dt-spacing-d);padding-inline:var(--dt-spacing-e)}.c-modal .c-modal-contentWrapper{font-size:calc(var(--dt-font-size-16) * 1px);line-height:calc(var(--dt-font-size-16-line-height) * 1px);font-weight:var(--dt-font-weight-regular);padding-block:var(--dt-spacing-a) var(--dt-spacing-e);padding-inline:var(--dt-spacing-e)}
97
+ `;
98
+ var p = /* @__PURE__ */ ((n) => (n.H1 = "h1", n.H2 = "h2", n.H3 = "h3", n.H4 = "h4", n.H5 = "h5", n.H6 = "h6", n))(p || {}), M = Object.defineProperty, S = Object.getOwnPropertyDescriptor, c = (n, r, o, t) => {
99
+ for (var e = t > 1 ? void 0 : t ? S(r, o) : r, s = n.length - 1, i; s >= 0; s--)
100
+ (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
101
+ return t && e && M(r, o, e), e;
45
102
  };
46
- n = h([
47
- u("pie-modal")
48
- ], n);
103
+ const g = "pie-modal";
104
+ class a extends _(u) {
105
+ constructor() {
106
+ super(...arguments), this.isOpen = !1, this.headingLevel = p.H2;
107
+ }
108
+ render() {
109
+ const {
110
+ isOpen: r,
111
+ heading: o,
112
+ headingLevel: t
113
+ } = this, e = b(t);
114
+ return $`
115
+ <dialog class="c-modal" ?open="${r}">
116
+ <${e} class="c-modal-heading">${o}</${e}>
117
+ <div class="c-modal-contentWrapper">
118
+ <slot></slot>
119
+ </div>
120
+ </dialog>
121
+ `;
122
+ }
123
+ }
124
+ a.styles = m(q);
125
+ c([
126
+ d({ type: Boolean })
127
+ ], a.prototype, "isOpen", 2);
128
+ c([
129
+ d({ type: String }),
130
+ C(g)
131
+ ], a.prototype, "heading", 2);
132
+ c([
133
+ d(),
134
+ x(g, Object.values(p), p.H2)
135
+ ], a.prototype, "headingLevel", 2);
136
+ customElements.define(g, a);
49
137
  export {
50
- n as PieModal
138
+ p as HEADING_LEVELS,
139
+ a as PieModal
51
140
  };