@justeattakeaway/pie-icon-button 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 +1 @@
1
- export * from './src/index'
1
+ export * from './packages/components/pie-icon-button/src/index'
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Icon Button style variants
3
+ */
4
+ export declare enum ICON_BUTTON_VARIANT {
5
+ PRIMARY = "primary",
6
+ SECONDARY = "secondary",
7
+ OUTLINE = "outline",
8
+ GHOST = "ghost",
9
+ GHOST_TERTIARY = "ghost-tertiary"
10
+ }
11
+ //# sourceMappingURL=defs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,mBAAmB;IAC3B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,cAAc,mBAAmB;CACpC"}
@@ -0,0 +1,16 @@
1
+ import { LitElement } from 'lit';
2
+ import { ICON_BUTTON_VARIANT } from './defs';
3
+ export { ICON_BUTTON_VARIANT };
4
+ declare const componentSelector = "pie-icon-button";
5
+ export declare class PieIconButton extends LitElement {
6
+ variant: ICON_BUTTON_VARIANT;
7
+ disabled: boolean;
8
+ render(): import("lit-html").TemplateResult<1>;
9
+ static styles: import("lit").CSSResult;
10
+ }
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ [componentSelector]: PieIconButton;
14
+ }
15
+ }
16
+ //# sourceMappingURL=index.d.ts.map
@@ -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;AAGlD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAI7C,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,iBAAiB,oBAAoB,CAAC;AAE5C,qBAAa,aAAc,SAAQ,UAAU;IAGrC,OAAO,EAAG,mBAAmB,CAA+B;IAG5D,QAAQ,UAAS;IAErB,MAAM;IAiBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;KACtC;CACJ"}
@@ -0,0 +1,3 @@
1
+ import { PieIconButton as PieIconButtonReact } from './index';
2
+ export declare const PieIconButton: import("@lit-labs/react").ReactWebComponent<PieIconButtonReact, {}>;
3
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG9D,eAAO,MAAM,aAAa,qEAMxB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './packages/components/pie-icon-button/src/react'
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-icon-button",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "PIE Design System Icon Button built using Web Components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/types/index.d.ts",
9
9
  "scripts": {
10
- "build": "run -T vite build",
11
- "watch": "run -T vite build --watch",
12
- "test": "echo \"Error: no test specified\" && exit 0"
10
+ "build": "yarn build:wrapper pie-icon-button && run -T vite build --config ../../../configs/pie-components-config/vite.config.js",
11
+ "watch": "run -T vite build --config ../../../configs/pie-components-config/vite.config.js --watch",
12
+ "test": "echo \"Error: no test specified\" && exit 0",
13
+ "test:ci": "yarn test"
13
14
  },
14
15
  "author": "JustEatTakeaway - Design System Web Team",
15
16
  "license": "Apache-2.0",
17
+ "dependencies": {
18
+ "@justeattakeaway/pie-webc-core": "workspace:*"
19
+ },
16
20
  "volta": {
17
21
  "extends": "../../../package.json"
18
22
  }
package/src/defs.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Icon Button style variants
3
+ */
4
+ export enum ICON_BUTTON_VARIANT {
5
+ PRIMARY = 'primary',
6
+ SECONDARY = 'secondary',
7
+ OUTLINE = 'outline',
8
+ GHOST = 'ghost',
9
+ GHOST_TERTIARY = 'ghost-tertiary',
10
+ }
@@ -0,0 +1,122 @@
1
+ :host {
2
+ --btn-border-radius: var(--dt-radius-rounded-e);
3
+
4
+ // The base values are set to the size default, which is for the medium button size
5
+ --btn-height: 48px;
6
+ --btn-width: var(--btn-height);
7
+
8
+ // The following values set to default background and color
9
+ // currently this sets the primary button styles
10
+ --btn-bg-color: var(--dt-color-interactive-brand);
11
+ --btn-icon-fill: var(--dt-color-content-interactive-primary);
12
+ --btn-focus: var(--dt-color-focus-outer);
13
+ }
14
+
15
+ @mixin button-interactive-states($bg-color) {
16
+ & .o-iconBtn:hover:not(:disabled) {
17
+ background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-hover-01)));
18
+ }
19
+
20
+ & .o-iconBtn:active:not(:disabled) {
21
+ background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-active-01)));
22
+ }
23
+ }
24
+
25
+ // Base button styles
26
+ .o-iconBtn {
27
+ min-block-size: var(--btn-height);
28
+ aspect-ratio: 1 / 1;
29
+
30
+ @supports not (aspect-ratio: 1 / 1) {
31
+ min-inline-size: var(--btn-width);
32
+ }
33
+
34
+ border: none;
35
+ border-radius: var(--btn-border-radius);
36
+ outline: none;
37
+ background-color: var(--btn-bg-color);
38
+ cursor: pointer;
39
+ user-select: none;
40
+
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+
45
+ &:focus-visible {
46
+ // TODO - Need to update to use the latest focus styling
47
+ outline: 2px solid var(--btn-focus);
48
+ }
49
+
50
+ svg {
51
+ height: 24.5px;
52
+ width: 24.5px;
53
+ }
54
+
55
+ svg, path {
56
+ fill: var(--btn-icon-fill);
57
+ }
58
+ }
59
+
60
+ // Variants
61
+ :host([variant='primary']) {
62
+ @include button-interactive-states('--dt-color-interactive-brand');
63
+ }
64
+
65
+ :host([variant='secondary']) {
66
+ --btn-bg-color: var(--dt-color-interactive-secondary);
67
+ --btn-icon-fill: var(--dt-color-content-interactive-secondary);
68
+
69
+ @include button-interactive-states('--dt-color-interactive-secondary');
70
+ }
71
+
72
+ :host([variant='outline']) {
73
+ --btn-bg-color: var(--dt-color-container-default);
74
+ --btn-icon-fill: var(--dt-color-content-interactive-brand);
75
+
76
+ & .o-iconBtn {
77
+ border: 1px solid var(--dt-color-border-strong);
78
+ }
79
+
80
+ @include button-interactive-states('--dt-color-container-default');
81
+ }
82
+
83
+ :host([variant='ghost']) {
84
+ --btn-bg-color: var(--dt-color-container-default);
85
+ --btn-icon-fill: var(--dt-color-content-interactive-brand);
86
+
87
+ @include button-interactive-states('--dt-color-container-default');
88
+ }
89
+
90
+ :host([variant='ghost-tertiary']) {
91
+ --btn-bg-color: var(--dt-color-container-default);
92
+ --btn-icon-fill: var(--dt-color-content-interactive-tertiary);
93
+
94
+ @include button-interactive-states('--dt-color-container-default');
95
+ }
96
+
97
+ :host([disabled]) {
98
+ --btn-bg-color: var(--dt-color-disabled-01);
99
+ --btn-icon-fill: var(--dt-color-content-disabled);
100
+
101
+ & .o-iconBtn {
102
+ border: 1px solid var(--dt-color-disabled-01);
103
+ cursor: not-allowed;
104
+ }
105
+ }
106
+
107
+ :host([disabled][variant='outline']) {
108
+ & .o-iconBtn {
109
+ outline: none;
110
+ }
111
+ }
112
+
113
+ :host([disabled][variant='ghost']),
114
+ :host([disabled][variant='ghost-tertiary']) {
115
+ --btn-bg-color: transparent;
116
+ --btn-icon-fill: var(--dt-color-content-default);
117
+
118
+ & .o-iconBtn {
119
+ outline: none;
120
+ border: none;
121
+ }
122
+ }
package/src/index.ts CHANGED
@@ -1,20 +1,46 @@
1
- import { LitElement, html } from 'lit'; // eslint-disable-line import/no-extraneous-dependencies
2
- import { customElement } from 'lit/decorators.js'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import { LitElement, html, unsafeCSS } from 'lit'; // eslint-disable-line import/no-extraneous-dependencies
2
+ import { property } from 'lit/decorators.js'; // eslint-disable-line import/no-extraneous-dependencies
3
+ import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
4
+ import { ICON_BUTTON_VARIANT } from './defs';
5
+ import styles from './iconButton.scss?inline';
6
+
7
+ // Valid values available to consumers
8
+ export { ICON_BUTTON_VARIANT };
9
+
10
+ const componentSelector = 'pie-icon-button';
3
11
 
4
- @customElement('pie-icon-button')
5
12
  export class PieIconButton extends LitElement {
6
- // eslint-disable-next-line class-methods-use-this
13
+ @property()
14
+ @validPropertyValues(componentSelector, Object.values(ICON_BUTTON_VARIANT), ICON_BUTTON_VARIANT.PRIMARY)
15
+ variant : ICON_BUTTON_VARIANT = ICON_BUTTON_VARIANT.PRIMARY;
16
+
17
+ @property({ type: Boolean })
18
+ disabled = false;
19
+
7
20
  render () {
21
+ const {
22
+ disabled,
23
+ } = this;
24
+
25
+ // The inline SVG is temporary until we have a proper icon integration
8
26
  return html`
9
- <button>
10
- I am a pie-icon-button
11
- <slot></slot>
27
+ <button
28
+ class="o-iconBtn"
29
+ ?disabled=${disabled}>
30
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
31
+ <path d="M11.8676 3.20496L8.0001 7.07248L4.13258 3.20496L3.20508 4.13246L7.0726 7.99998L3.20508 11.8675L4.13258 12.795L8.0001 8.92748L11.8676 12.795L12.7951 11.8675L8.92761 7.99998L12.7951 4.13246L11.8676 3.20496Z" fill="#242E30"/>
32
+ </svg>
12
33
  </button>`;
13
34
  }
35
+
36
+ // Renders a `CSSResult` generated from SCSS by Vite
37
+ static styles = unsafeCSS(styles);
14
38
  }
15
39
 
40
+ customElements.define(componentSelector, PieIconButton);
41
+
16
42
  declare global {
17
43
  interface HTMLElementTagNameMap {
18
- 'pie-icon-button': PieIconButton;
44
+ [componentSelector]: PieIconButton;
19
45
  }
20
46
  }
package/tsconfig.json CHANGED
@@ -1,30 +1,8 @@
1
1
  {
2
+ "extends": "../../../configs/pie-components-config/tsconfig.json",
2
3
  "compilerOptions": {
3
- "target": "ES6",
4
- "module": "ES2022",
5
- "lib": ["es2020", "DOM", "DOM.Iterable"],
6
- "declaration": true,
7
- "declarationMap": true,
8
- "sourceMap": true,
9
- "inlineSources": true,
10
- "outDir": "./compiled",
11
- "baseUrl": ".",
12
- "paths": {
13
- "@/*": ["./src/*"]
14
- },
15
- "rootDir": ".",
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "noImplicitReturns": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noImplicitAny": true,
22
- "noImplicitThis": true,
23
- "moduleResolution": "node",
24
- "allowSyntheticDefaultImports": true,
25
- "experimentalDecorators": true,
26
- "forceConsistentCasingInFileNames": true
4
+ "baseUrl": ".",
5
+ "rootDir": ".",
27
6
  },
28
7
  "include": ["src/**/*.ts","./declaration.d.ts", "test/**/*.ts"],
29
- "exclude": []
30
8
  }
package/vite.config.js CHANGED
@@ -6,8 +6,10 @@ import dts from 'vite-plugin-dts';
6
6
  export default defineConfig({
7
7
  build: {
8
8
  lib: {
9
- entry: 'src/index.ts',
10
- fileName: 'index',
9
+ entry: {
10
+ index: 'src/index.ts',
11
+ react: 'src/react.ts',
12
+ },
11
13
  formats: ['es'],
12
14
  },
13
15
  rollupOptions: {
@@ -1,10 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class PieIconButton extends LitElement {
3
- render(): import("lit-html").TemplateResult<1>;
4
- }
5
- declare global {
6
- interface HTMLElementTagNameMap {
7
- 'pie-icon-button': PieIconButton;
8
- }
9
- }
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAGvC,qBACa,aAAc,SAAQ,UAAU;IAEzC,MAAM;CAOT;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,iBAAiB,EAAE,aAAa,CAAC;KACpC;CACJ"}