@justeattakeaway/pie-divider 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.
@@ -1,14 +1,14 @@
1
- [9:04:00 AM] @custom-elements-manifest/analyzer: Created new manifest.
1
+ [2:03:48 PM] @custom-elements-manifest/analyzer: Created new manifest.
2
2
  react wrapper has been added!
3
3
  vite v4.3.9 building for production...
4
4
  transforming...
5
- ✓ 12 modules transformed.
5
+ ✓ 22 modules transformed.
6
6
  rendering chunks...
7
7
  computing gzip size...
8
- dist/index.js  0.28 kB │ gzip: 0.22 kB
9
- dist/react.js 58.95 kB │ gzip: 15.89 kB
8
+ dist/index.js  2.04 kB │ gzip: 0.94 kB
9
+ dist/react.js 59.02 kB │ gzip: 15.91 kB
10
10
  
11
11
  [vite:dts] Start generate declaration files...
12
- ✓ built in 11.55s
13
- [vite:dts] Declaration files built in 10706ms.
12
+ ✓ built in 45.92s
13
+ [vite:dts] Declaration files built in 43220ms.
14
14
  
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @justeattakeaway/pie-divider
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Added] pie divider component ([#704](https://github.com/justeattakeaway/pie/pull/704)) by [@raoufswe](https://github.com/raoufswe)
8
+
9
+ - [Changed] - skip visual tests ([#709](https://github.com/justeattakeaway/pie/pull/709)) by [@raoufswe](https://github.com/raoufswe)
10
+
11
+ - [Changed] extend ts config using relative paths ([#704](https://github.com/justeattakeaway/pie/pull/704)) by [@raoufswe](https://github.com/raoufswe)
12
+
3
13
  ## 0.1.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -59,16 +59,17 @@ import { PieDivider } from '@justeattakeaway/pie-divider/dist/react';
59
59
 
60
60
  | Property | Type | Default | Description |
61
61
  |---|---|---|---|
62
- | - | - | - | - |
62
+ | variant | `String` | `default` | Variant of the divider, one of variants – default, inverse |
63
+ | orientation | `String` | `horizontal` | Orientation of the divider, one of – horizontal, vertical |
63
64
 
64
65
  In your markup or JSX, you can then use these to set the properties for the `pie-divider` component:
65
66
 
66
67
  ```html
67
68
  <!-- Native HTML -->
68
- <pie-divider></pie-divider>
69
+ <pie-divider />
69
70
 
70
71
  <!-- JSX -->
71
- <PieDivider></PieDivider>
72
+ <PieDivider />
72
73
  ```
73
74
 
74
75
  ## Testing
package/dist/index.js CHANGED
@@ -1,12 +1,57 @@
1
- import { unsafeCSS as t, LitElement as i, html as s } from "lit";
2
- const r = "", d = "pie-divider";
3
- class e extends i {
1
+ import { unsafeCSS as u, LitElement as f, html as g } from "lit";
2
+ import { property as c } from "lit/decorators.js";
3
+ import "lit/decorators/property.js";
4
+ const l = (n, i, r) => function(e, t) {
5
+ const o = `#${t}`;
6
+ Object.defineProperty(e, t, {
7
+ get() {
8
+ return this[o];
9
+ },
10
+ set(s) {
11
+ const p = this[o];
12
+ i.includes(s) ? this[o] = s : (console.error(
13
+ `<${n}> Invalid value "${s}" provided for property "${t}".`,
14
+ `Must be one of: ${i.join(" | ")}.`,
15
+ `Falling back to default value: "${r}"`
16
+ ), this[o] = r), this.requestUpdate(t, p);
17
+ }
18
+ });
19
+ }, m = `.c-divider{--divider-bg-color: var(--dt-color-divider-default);--divider-width: 100%;--divider-height: 1px;margin:0;border:0;width:var(--divider-width);height:var(--divider-height);background-color:var(--divider-bg-color)}.c-divider[variant=inverse]{--divider-bg-color: var(--dt-color-divider-inverse)}.c-divider[orientation=vertical]{--divider-width: 1px;--divider-height: 100%}
20
+ `, b = ["default", "inverse"], P = ["horizontal", "vertical"];
21
+ var $ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, h = (n, i, r, d) => {
22
+ for (var e = d > 1 ? void 0 : d ? y(i, r) : i, t = n.length - 1, o; t >= 0; t--)
23
+ (o = n[t]) && (e = (d ? o(i, r, e) : o(e)) || e);
24
+ return d && e && $(i, r, e), e;
25
+ };
26
+ const v = "pie-divider";
27
+ class a extends f {
28
+ constructor() {
29
+ super(...arguments), this.variant = "default", this.orientation = "horizontal";
30
+ }
4
31
  render() {
5
- return s`<h1 data-test-id="pie-divider">Hello world!</h1>`;
32
+ const { variant: i, orientation: r } = this;
33
+ return g`
34
+ <hr
35
+ data-test-id="pie-divider"
36
+ aria-hidden="true"
37
+ class="c-divider"
38
+ variant=${i}
39
+ orientation=${r}
40
+ />`;
6
41
  }
7
42
  }
8
- e.styles = t(r);
9
- customElements.define(d, e);
43
+ a.styles = u(m);
44
+ h([
45
+ c({ type: String }),
46
+ l(v, b, "default")
47
+ ], a.prototype, "variant", 2);
48
+ h([
49
+ c({ type: String }),
50
+ l(v, P, "horizontal")
51
+ ], a.prototype, "orientation", 2);
52
+ customElements.define(v, a);
10
53
  export {
11
- e as PieDivider
54
+ a as PieDivider,
55
+ P as orientations,
56
+ b as variants
12
57
  };
package/dist/react.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { PieDivider as Nr } from "./index.js";
2
2
  import "lit";
3
+ import "lit/decorators.js";
4
+ import "lit/decorators/property.js";
3
5
  function Fr(g, c) {
4
6
  for (var U = 0; U < c.length; U++) {
5
7
  const T = c[U];
@@ -1577,7 +1579,7 @@ function zr(g = window.React, c, U, T, A) {
1577
1579
  const J = k.forwardRef((D, P) => F(H, { ...D, _$Gl: P }, D == null ? void 0 : D.children));
1578
1580
  return J.displayName = H.displayName, J;
1579
1581
  }
1580
- const qr = zr({
1582
+ const Kr = zr({
1581
1583
  displayName: "PieDivider",
1582
1584
  elementClass: Nr,
1583
1585
  react: Vr,
@@ -1585,5 +1587,5 @@ const qr = zr({
1585
1587
  events: {}
1586
1588
  });
1587
1589
  export {
1588
- qr as PieDivider
1590
+ Kr as PieDivider
1589
1591
  };
@@ -1 +1 @@
1
- export * from './src/index'
1
+ export * from './packages/components/pie-divider/src/index'
@@ -0,0 +1,13 @@
1
+ export declare const variants: readonly ["default", "inverse"];
2
+ export declare const orientations: readonly ["horizontal", "vertical"];
3
+ export interface DividerProps {
4
+ /**
5
+ * What style variant the divider should be such as default or vertical.
6
+ */
7
+ variant: typeof variants[number];
8
+ /**
9
+ * What orientation the divider should be such as horizontal or inverse.
10
+ */
11
+ orientation: typeof orientations[number];
12
+ }
13
+ //# sourceMappingURL=defs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,iCAAkC,CAAC;AACxD,eAAO,MAAM,YAAY,qCAAsC,CAAC;AAEhE,MAAM,WAAW,YAAY;IAC1B;;QAEI;IACJ,OAAO,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC;;OAEG;IACJ,WAAW,EAAE,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;CAC3C"}
@@ -1,8 +1,10 @@
1
1
  import { LitElement } from 'lit';
2
- import { DividerProps } from './defs';
3
- export { type DividerProps, };
2
+ import { DividerProps, variants, orientations } from './defs';
3
+ export { type DividerProps, variants, orientations, };
4
4
  declare const componentSelector = "pie-divider";
5
5
  export declare class PieDivider extends LitElement implements DividerProps {
6
+ variant: DividerProps['variant'];
7
+ orientation: DividerProps['orientation'];
6
8
  render(): import("lit-html").TemplateResult<1>;
7
9
  static styles: import("lit").CSSResult;
8
10
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG9D,OAAO,EACH,KAAK,YAAY,EACjB,QAAQ,EACR,YAAY,GACf,CAAC;AAEF,QAAA,MAAM,iBAAiB,gBAAgB,CAAC;AAExC,qBAAa,UAAW,SAAQ,UAAW,YAAW,YAAY;IAGvD,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAa;IAI7C,WAAW,EAAG,YAAY,CAAC,aAAa,CAAC,CAAgB;IAEhE,MAAM;IAcN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;KACnC;CACJ"}
@@ -1 +1 @@
1
- export * from './src/react'
1
+ export * from './packages/components/pie-divider/src/react'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-divider",
3
3
  "description": "PIE Design System Divider 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",
@@ -34,6 +34,7 @@
34
34
  /* basic styles to center align components and give them some spacing */
35
35
  #root {
36
36
  padding: 1em;
37
+ min-height: 300px;
37
38
  }
38
39
 
39
40
  #root > * {
package/src/defs.ts CHANGED
@@ -1,3 +1,13 @@
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 DividerProps {}
1
+ export const variants = ['default', 'inverse'] as const;
2
+ export const orientations = ['horizontal', 'vertical'] as const;
3
+
4
+ export interface DividerProps {
5
+ /**
6
+ * What style variant the divider should be such as default or vertical.
7
+ */
8
+ variant: typeof variants[number];
9
+ /**
10
+ * What orientation the divider should be such as horizontal or inverse.
11
+ */
12
+ orientation: typeof orientations[number];
13
+ }
package/src/divider.scss CHANGED
@@ -1 +1,30 @@
1
1
  @use '@justeattakeaway/pie-css/scss' as p;
2
+
3
+ .c-divider {
4
+ --divider-bg-color: var(--dt-color-divider-default);
5
+ --divider-width: 100%;
6
+ --divider-height: 1px;
7
+
8
+ margin: 0;
9
+ border: 0;
10
+ width: var(--divider-width);
11
+ height: var(--divider-height);
12
+ background-color: var(--divider-bg-color);
13
+
14
+ &[variant='default'] {
15
+ /* Same as default styles */
16
+ }
17
+
18
+ &[variant='inverse'] {
19
+ --divider-bg-color: var(--dt-color-divider-inverse);
20
+ }
21
+
22
+ &[orientation='horizontal'] {
23
+ /* Same as default styles */
24
+ }
25
+
26
+ &[orientation='vertical'] {
27
+ --divider-width: 1px;
28
+ --divider-height: 100%;
29
+ }
30
+ }
package/src/index.ts CHANGED
@@ -1,18 +1,38 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
-
2
+ import { property } from 'lit/decorators.js';
3
+ import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
3
4
  import styles from './divider.scss?inline';
4
- import { DividerProps } from './defs';
5
+ import { DividerProps, variants, orientations } from './defs';
5
6
 
6
7
  // Valid values available to consumers
7
8
  export {
8
9
  type DividerProps,
10
+ variants,
11
+ orientations,
9
12
  };
10
13
 
11
14
  const componentSelector = 'pie-divider';
12
15
 
13
16
  export class PieDivider extends LitElement implements DividerProps {
17
+ @property({ type: String })
18
+ @validPropertyValues(componentSelector, variants, 'default')
19
+ public variant: DividerProps['variant'] = 'default';
20
+
21
+ @property({ type: String })
22
+ @validPropertyValues(componentSelector, orientations, 'horizontal')
23
+ public orientation : DividerProps['orientation'] = 'horizontal';
24
+
14
25
  render () {
15
- return html`<h1 data-test-id="pie-divider">Hello world!</h1>`;
26
+ const { variant, orientation } = this;
27
+
28
+ return html`
29
+ <hr
30
+ data-test-id="pie-divider"
31
+ aria-hidden="true"
32
+ class="c-divider"
33
+ variant=${variant}
34
+ orientation=${orientation}
35
+ />`;
16
36
  }
17
37
 
18
38
  // Renders a `CSSResult` generated from SCSS by Vite
@@ -1,14 +1,50 @@
1
1
 
2
2
  import { test } from '@sand4rt/experimental-ct-web';
3
3
  import percySnapshot from '@percy/playwright';
4
- import { PieDivider, DividerProps } from '@/index';
4
+ import type {
5
+ PropObject, WebComponentPropValues, WebComponentTestInput,
6
+ } from '@justeattakeaway/pie-webc-testing/src/helpers/defs.ts';
7
+ import {
8
+ getAllPropCombinations, splitCombinationsByPropertyValue,
9
+ } from '@justeattakeaway/pie-webc-testing/src/helpers/get-all-prop-combos.ts';
10
+ import {
11
+ createTestWebComponent,
12
+ } from '@justeattakeaway/pie-webc-testing/src/helpers/rendering.ts';
13
+ import {
14
+ WebComponentTestWrapper,
15
+ } from '@justeattakeaway/pie-webc-testing/src/helpers/components/web-component-test-wrapper/WebComponentTestWrapper.ts';
16
+ import { variants, orientations } from '@/defs';
17
+ import { PieDivider } from '@/index';
5
18
 
6
- test.describe('PieDivider - Visual tests`', () => {
7
- test('should display the PieDivider component successfully', async ({ page, mount }) => {
8
- await mount(PieDivider, {
9
- props: {} as DividerProps,
10
- });
19
+ const props: PropObject = {
20
+ variant: variants,
21
+ orientation: orientations,
22
+ };
11
23
 
12
- await percySnapshot(page, 'PieDivider - Visual Test');
24
+ const renderTestPieDivider = (propVals: WebComponentPropValues) => `<pie-divider variant="${propVals.variant}" orientation="${propVals.orientation}" />`;
25
+
26
+ const componentPropsMatrix : WebComponentPropValues[] = getAllPropCombinations(props);
27
+ const componentPropsMatrixByVariant: Record<string, WebComponentPropValues[]> = splitCombinationsByPropertyValue(componentPropsMatrix, 'variant');
28
+ const componentVariants: string[] = Object.keys(componentPropsMatrixByVariant);
29
+
30
+ test.beforeEach(async ({ page, mount }) => {
31
+ await mount(PieDivider, {});
32
+ await page.evaluate(() => {
33
+ const element : Element | null = document.querySelector('pie-divider');
34
+ element?.remove();
13
35
  });
14
36
  });
37
+
38
+ componentVariants.forEach((variant) => test(`Render all prop variations for Variant: ${variant}`, async ({ page, mount }) => {
39
+ await Promise.all(componentPropsMatrixByVariant[variant].map(async (combo: WebComponentPropValues) => {
40
+ const testComponent: WebComponentTestInput = createTestWebComponent(combo, renderTestPieDivider);
41
+ const propKeyValues = `orientation: ${testComponent.propValues.orientation}}`;
42
+
43
+ await mount(
44
+ WebComponentTestWrapper,
45
+ { props: { propKeyValues, darkMode: variant === 'inverse' } },
46
+ );
47
+ }));
48
+
49
+ await percySnapshot(page, `PIE Divider - Variant: ${variant}`);
50
+ }));
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@justeattakeaway/pie-components-config/tsconfig.json",
2
+ "extends": "../../../configs/pie-components-config/tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "baseUrl": ".",
5
5
  "rootDir": ".",
@@ -1,3 +0,0 @@
1
- export interface DividerProps {
2
- }
3
- //# sourceMappingURL=defs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EACH,KAAK,YAAY,GACpB,CAAC;AAEF,QAAA,MAAM,iBAAiB,gBAAgB,CAAC;AAExC,qBAAa,UAAW,SAAQ,UAAW,YAAW,YAAY;IAC9D,MAAM;IAKN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;KACnC;CACJ"}