@justeattakeaway/pie-button 0.16.0 → 0.16.1

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,18 +1,40 @@
1
1
  export interface ButtonProps {
2
+ /**
3
+ * the size of the button.
4
+ * @default medium
5
+ */
2
6
  size: 'xsmall' | 'small-expressive' | 'small-productive' | 'medium' | 'large';
7
+ /**
8
+ * The html button type to use.
9
+ * @default submit
10
+ */
3
11
  type: 'submit' | 'button' | 'reset' | 'menu';
12
+ /**
13
+ * the variant of the button.
14
+ * @default primary
15
+ */
4
16
  variant: 'primary' | 'secondary' | 'outline' | 'ghost';
17
+ /**
18
+ * If `true`, the button will be disabled.
19
+ * @default false
20
+ */
21
+ disabled: boolean;
22
+ /**
23
+ * If `true`, the button will span the full width.
24
+ * @default false
25
+ */
26
+ isFullWidth: boolean;
5
27
  }
6
28
  /**
7
29
  * Button size variants
8
30
  */
9
- export declare const buttonSizes: ButtonProps['size'][];
31
+ export declare const buttonSizes: Array<ButtonProps['size']>;
10
32
  /**
11
33
  * Button style variants
12
34
  */
13
- export declare const buttonVariants: ButtonProps['variant'][];
35
+ export declare const buttonVariants: Array<ButtonProps['variant']>;
14
36
  /**
15
37
  * Button type variants
16
38
  */
17
- export declare const buttonTypes: ButtonProps['type'][];
39
+ export declare const buttonTypes: Array<ButtonProps['type']>;
18
40
  //# sourceMappingURL=defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,QAAQ,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC9E,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7C,OAAO,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;CAC1D;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAM5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,SAAS,CAAC,EAKlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAK5C,CAAC"}
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC9E;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7C;;;OAGG;IACH,OAAO,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACvD;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAMlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAKxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAKlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAKlD,OAAO,EACH,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EACxD,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACH,KAAK,WAAW,EAChB,WAAW,EACX,WAAW,EACX,cAAc,GACjB,CAAC;AAEF,QAAA,MAAM,iBAAiB,eAAe,CAAC;AAEvC,qBAAa,SAAU,SAAQ,UAAU;IAGjC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAa;IAG5C,QAAQ,UAAS;IAGjB,WAAW,UAAS;IAExB,MAAM;IAkBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;KAClC;CACJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD,OAAO,EACH,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EACxD,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACH,KAAK,WAAW,EAChB,WAAW,EACX,WAAW,EACX,cAAc,GACjB,CAAC;AAEF,QAAA,MAAM,iBAAiB,eAAe,CAAC;AAEvC,qBAAa,SAAU,SAAQ,UAAU;IAGjC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAa;IAG5C,QAAQ,UAAS;IAGjB,WAAW,UAAS;IAExB,MAAM;IAkBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;KAClC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/defs.ts CHANGED
@@ -1,13 +1,35 @@
1
1
  export interface ButtonProps {
2
+ /**
3
+ * the size of the button.
4
+ * @default medium
5
+ */
2
6
  size: 'xsmall' | 'small-expressive' | 'small-productive' | 'medium' | 'large';
7
+ /**
8
+ * The html button type to use.
9
+ * @default submit
10
+ */
3
11
  type: 'submit' | 'button' | 'reset' | 'menu';
12
+ /**
13
+ * the variant of the button.
14
+ * @default primary
15
+ */
4
16
  variant: 'primary' | 'secondary' | 'outline' | 'ghost';
17
+ /**
18
+ * If `true`, the button will be disabled.
19
+ * @default false
20
+ */
21
+ disabled: boolean;
22
+ /**
23
+ * If `true`, the button will span the full width.
24
+ * @default false
25
+ */
26
+ isFullWidth: boolean;
5
27
  }
6
28
 
7
29
  /**
8
30
  * Button size variants
9
31
  */
10
- export const buttonSizes: ButtonProps['size'][] = [
32
+ export const buttonSizes: Array<ButtonProps['size']> = [
11
33
  'xsmall',
12
34
  'small-expressive',
13
35
  'small-productive',
@@ -18,7 +40,7 @@ export const buttonSizes: ButtonProps['size'][] = [
18
40
  /**
19
41
  * Button style variants
20
42
  */
21
- export const buttonVariants: ButtonProps['variant'][] = [
43
+ export const buttonVariants: Array<ButtonProps['variant']> = [
22
44
  'primary',
23
45
  'secondary',
24
46
  'outline',
@@ -28,7 +50,7 @@ export const buttonVariants: ButtonProps['variant'][] = [
28
50
  /**
29
51
  * Button type variants
30
52
  */
31
- export const buttonTypes: ButtonProps['type'][] = [
53
+ export const buttonTypes: Array<ButtonProps['type']> = [
32
54
  'submit',
33
55
  'button',
34
56
  'reset',
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
3
  import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
4
-
5
4
  import styles from './button.scss?inline';
6
5
  import {
7
6
  ButtonProps, buttonSizes, buttonTypes, buttonVariants,
@@ -1,9 +1,8 @@
1
1
  import { test, expect } from '@sand4rt/experimental-ct-web';
2
2
  import AxeBuilder from '@axe-core/playwright';
3
- import {
4
- PropObject, Combination, getAllPropCombinations, splitCombinationsByPropertyValue,
5
- } from '@justeattakeaway/pie-webc-core/src/test-helpers/get-all-prop-combos.ts';
6
- import { PieButton } from '@/index.ts';
3
+ import { getAllPropCombinations, splitCombinationsByPropertyValue } from '@justeattakeaway/pie-webc-core/src/test-helpers/get-all-prop-combos.ts';
4
+ import { PropObject, WebComponentPropValues } from '@justeattakeaway/pie-webc-core/src/test-helpers/defs.ts';
5
+ import { PieButton } from '@/index';
7
6
  import { buttonSizes, buttonVariants } from '@/defs';
8
7
 
9
8
  const props: PropObject = {
@@ -14,12 +13,12 @@ const props: PropObject = {
14
13
  disabled: [true, false],
15
14
  };
16
15
 
17
- const componentPropsMatrix : Combination[] = getAllPropCombinations(props);
18
- const componentPropsMatrixByVariant: Record<string, Combination[]> = splitCombinationsByPropertyValue(componentPropsMatrix, 'variant');
16
+ const componentPropsMatrix : WebComponentPropValues[] = getAllPropCombinations(props);
17
+ const componentPropsMatrixByVariant: Record<string, WebComponentPropValues[]> = splitCombinationsByPropertyValue(componentPropsMatrix, 'variant');
19
18
  const componentVariants: string[] = Object.keys(componentPropsMatrixByVariant);
20
19
 
21
20
  componentVariants.forEach((variant) => test(`Render all prop variations for Variant: ${variant}`, async ({ page, mount }) => {
22
- await Promise.all(componentPropsMatrixByVariant[variant].map(async (combo: Combination) => {
21
+ await Promise.all(componentPropsMatrixByVariant[variant].map(async (combo: WebComponentPropValues) => {
23
22
  await mount(
24
23
  PieButton,
25
24
  {
@@ -31,7 +30,7 @@ componentVariants.forEach((variant) => test(`Render all prop variations for Vari
31
30
  );
32
31
  }));
33
32
 
34
- const results = await new AxeBuilder.default({ page })
33
+ const results = await new AxeBuilder({ page })
35
34
  .withTags(['wcag21a', 'wcag21aa', 'wcag143', 'cat.color', 'cat.aria'])
36
35
  .disableRules(['color-contrast', 'color-contrast-enhanced'])
37
36
  .analyze();
@@ -1,5 +1,11 @@
1
1
  import { test, expect } from '@sand4rt/experimental-ct-web';
2
2
  import { PieButton } from '@/index';
3
+ import { ButtonProps } from '@/index';
4
+
5
+ const props: ButtonProps = {
6
+ size: 'large',
7
+ variant: 'primary',
8
+ }
3
9
 
4
10
  test('should correctly work with native click events', async ({ mount }) => {
5
11
  const messages: string[] = [];
@@ -7,10 +13,7 @@ test('should correctly work with native click events', async ({ mount }) => {
7
13
  const component = await mount(
8
14
  PieButton,
9
15
  {
10
- props: {
11
- size: 'large',
12
- variant: 'primary',
13
- },
16
+ props,
14
17
  slots: {
15
18
  default: 'Click me!',
16
19
  },
package/vite.config.js CHANGED
@@ -1,3 +1,3 @@
1
- import viteConfig from '@justeattakeaway/pie-components-config/vite.config'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import viteConfig from '@justeattakeaway/pie-components-config/vite.config';
2
2
 
3
3
  export default viteConfig;