@justeattakeaway/pie-button 0.4.0 → 0.5.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,7 +1,7 @@
1
- @justeattakeaway/pie-button:build: cache hit, replaying output 4b675d127813f9f5
1
+ @justeattakeaway/pie-button:build: cache hit, replaying output 21df156a0b013060
2
2
  @justeattakeaway/pie-button:build: vite v4.0.4 building for production...
3
3
  @justeattakeaway/pie-button:build: transforming...
4
4
  @justeattakeaway/pie-button:build: ✓ 4 modules transformed.
5
5
  @justeattakeaway/pie-button:build: rendering chunks...
6
6
  @justeattakeaway/pie-button:build: computing gzip size...
7
- @justeattakeaway/pie-button:build: dist/pie-button.js 6.70 kB │ gzip: 2.18 kB
7
+ @justeattakeaway/pie-button:build: dist/pie-button.js 2.73 kB │ gzip: 1.29 kB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Changed] - Bring button styles into the component ([#178](https://github.com/justeattakeaway/pie/pull/178)) by [@xander-marjoram](https://github.com/xander-marjoram)
8
+
9
+ - [Added] - Size property to pie-button component ([#178](https://github.com/justeattakeaway/pie/pull/178)) by [@xander-marjoram](https://github.com/xander-marjoram)
10
+
11
+ - [Removed] - index.html file in favour of Storybook ([#178](https://github.com/justeattakeaway/pie/pull/178)) by [@xander-marjoram](https://github.com/xander-marjoram)
12
+
3
13
  ## 0.4.0
4
14
 
5
15
  ### Minor Changes
package/declaration.d.ts CHANGED
@@ -3,7 +3,6 @@ declare module '*.scss' {
3
3
  export default content;
4
4
  }
5
5
 
6
-
7
6
  declare module '*.scss?inline' {
8
7
  const content: Record<string, string>;
9
8
  export default content;
@@ -1,59 +1,65 @@
1
- import { unsafeCSS as u, LitElement as g, html as f } from "lit";
2
- import { classMap as m } from "lit/directives/class-map.js";
3
- import { property as c, customElement as h } from "lit/decorators.js";
4
- const v = `@charset "UTF-8";.o-btn--icon{background-color:transparent;background-repeat:no-repeat;border:0;direction:ltr;display:block;overflow:hidden;text-align:left;text-indent:-999em}.o-btn--icon br{display:none}@keyframes skeleton-gradient{0%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(359deg)}}.c-spinner-wrapper{position:absolute;right:0}.c-spinner{border:3px solid #f36805;border-top:3px solid rgba(243,109,0,.2);border-right:3px solid rgba(243,109,0,.2)}.c-spinner{margin-right:20px;border-radius:50%;animation:spin 1s linear 0s infinite;width:20px;height:20px}.c-spinner{margin:0 auto;position:absolute;left:calc(50% - 10px);top:calc(50% - 10px)}.o-btn{display:inline-block;vertical-align:middle;font-size:20px;font-size:1.25rem;line-height:1.4;cursor:pointer;margin:0;padding:10px 24px;text-align:center;font-weight:700;background-color:#f36805;border-radius:50rem;border:1px solid transparent;user-select:none;color:#fff;text-decoration:none}.o-btn:focus{box-shadow:0 0 0 2px #4996fd}.o-btn:hover{background-color:#df5f05}.o-btn:active{background-color:#b74e04}.o-btn:hover:not(.o-btn--link),.o-btn:active:not(.o-btn--link){outline:0}.o-btn,.o-btn:hover,.o-btn:active,.o-btn:focus,.o-btn:visited{text-decoration:none}p+.o-btn{margin-top:16px}.o-btn .note{display:none}@media (min-width: 48em){.o-btn .note{display:block}}.o-btn[type=submit]{margin-top:16px}.o-btn--primary{background-color:#f36805}.o-btn--primary,.o-btn--primary:link,.o-btn--primary:visited{color:#fff}.o-btn--primary:hover,.o-btn--primary:active,.o-btn--primary:focus{color:#fff}.o-btn--primary:hover{background-color:#df5f05}.o-btn--primary:active,.o-btn--primary.o-btn--loading{background-color:#b74e04}.o-btn--primary .c-spinner{border:3px solid #fff;border-top:3px solid rgba(255,255,255,.35);border-right:3px solid rgba(255,255,255,.35)}.o-btn--primary.o-btn--sizeSmall,.o-btn--primary.o-btn--sizeXSmall{background-color:#262626}.o-btn--primary.o-btn--sizeSmall:hover,.o-btn--primary.o-btn--sizeXSmall:hover{background-color:#3a3a3a}.o-btn--primary.o-btn--sizeSmall:active,.o-btn--primary.o-btn--sizeSmall.o-btn--loading,.o-btn--primary.o-btn--sizeXSmall:active,.o-btn--primary.o-btn--sizeXSmall.o-btn--loading{background-color:#595959}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--secondary:hover,.o-btn--secondary:active,.o-btn--secondary:focus{color:#242e30}.o-btn--secondary:hover{background-color:#ede9e5}.o-btn--secondary:active,.o-btn--secondary.o-btn--loading{background-color:#dcd4cd}.o-btn--secondary .c-spinner{border:3px solid #242e30;border-top:3px solid rgba(36,46,48,.35);border-right:3px solid rgba(36,46,48,.35)}.o-btn--outline{background-color:transparent;color:#303d3f;border-color:#efedea}.o-btn--outline:hover,.o-btn--outline:active,.o-btn--outline:focus{color:#303d3f}.o-btn--outline:hover{background-color:#f5f5f5}.o-btn--outline:active,.o-btn--outline.o-btn--loading{background-color:#e0e0e0}.o-btn--outline .c-spinner{border:3px solid #303d3f;border-top:3px solid rgba(48,61,63,.35);border-right:3px solid rgba(48,61,63,.35)}.o-btn--ghost{background-color:transparent;color:#242e30}.o-btn--ghost:hover,.o-btn--ghost:active,.o-btn--ghost:focus{color:#242e30}.o-btn--ghost:hover{background-color:#f5f5f5}.o-btn--ghost:active,.o-btn--ghost.o-btn--loading{background-color:#e0e0e0}.o-btn--ghost .c-spinner{border:3px solid #242e30;border-top:3px solid rgba(36,46,48,.35);border-right:3px solid rgba(36,46,48,.35)}.o-btn--sizeLarge{padding:14px 24px}.o-btn--sizeSmall{font-size:16px;font-size:1rem;line-height:1.5;padding:8px 16px}.o-btn--sizeXSmall{font-size:14px;font-size:.875rem;line-height:1.43;padding:6px 8px}.o-btn--icon{background-color:transparent;padding:0}.o-btn--icon:hover{background-color:transparent}input[type=submit].o-btn--block,input[type=reset].o-btn--block,input[type=button].o-btn--block{width:100%}.o-btn--fullWidth{display:block;width:100%}.o-btn--fullWidth+.o-btn--fullWidth{margin-top:8px}.o-btn--disabled,.o-btn.disabled,.o-btn.is-disabled,.o-btn[disabled]{cursor:not-allowed;color:#8c999b}.o-btn--disabled,.o-btn--disabled:hover,.o-btn.disabled,.o-btn.disabled:hover,.o-btn.is-disabled,.o-btn.is-disabled:hover,.o-btn[disabled],.o-btn[disabled]:hover{background-color:#efedea;color:#8c999b}.o-btn--disabled.o-btn--link,.o-btn.disabled.o-btn--link,.o-btn.is-disabled.o-btn--link,.o-btn[disabled].o-btn--link{background-color:transparent}.o-btn--link{border:0;background-color:transparent;padding:0;margin:0;color:#242e30;font-weight:700;text-decoration:underline}.o-btn--link:hover{cursor:pointer;color:#1b2324;background-color:transparent}.o-btn--link:active,.o-btn--link:focus{color:#0a0c0d;background-color:transparent}.o-btn--link .c-spinner{border:3px solid #242e30;border-top:3px solid rgba(36,46,48,.35);border-right:3px solid rgba(36,46,48,.35)}
5
- `, p = (o, r) => function(t, e) {
6
- const n = `_${e}`;
7
- Object.defineProperty(t, e, {
1
+ import { unsafeCSS as d, LitElement as m, html as h } from "lit";
2
+ import { classMap as x } from "lit/directives/class-map.js";
3
+ import { property as b, customElement as g } from "lit/decorators.js";
4
+ const v = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;font-weight:700}.o-btn--xsmall{padding:6px 8px;min-height:32px;font-size:14px;line-height:20px}.o-btn--small{padding:8px 16px;min-height:40px;font-size:19px;line-height:28px}.o-btn--medium{padding:10px 24px;min-height:48px;font-size:20px;line-height:28px}.o-btn--large{padding:14px 24px;min-height:56px;font-size:20px;line-height:28px}.o-btn--primary{background-color:#f36805;color:#fff}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--outline{border:1px solid #dbd9d7;background-color:#fff;color:#303d3f}.o-btn--ghost{background-color:#fff;color:#242e30}
5
+ `, f = (t, r) => function(e, n) {
6
+ const o = `_${n}`;
7
+ Object.defineProperty(e, n, {
8
8
  get() {
9
- return t[n];
9
+ return e[o];
10
10
  },
11
11
  set(i) {
12
- const b = t[n];
13
- o.includes(i) ? t[n] = i : (console.error(
14
- `[pie-button] Invalid value "${i}" provided for property "${e}".`,
15
- `Must be one of: ${o.join(" | ")}.`,
12
+ const p = e[o];
13
+ t.includes(i) ? e[o] = i : (console.error(
14
+ `[pie-button] Invalid value "${i}" provided for property "${n}".`,
15
+ `Must be one of: ${t.join(" | ")}.`,
16
16
  `Falling back to default value: "${r}"`
17
- ), t[n] = r), this.requestUpdate(e, b);
17
+ ), e[o] = r), this.requestUpdate(n, p);
18
18
  }
19
19
  });
20
20
  };
21
- var l = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.OUTLINE = "outline", o.GHOST = "ghost", o))(l || {}), d = /* @__PURE__ */ ((o) => (o.SUBMIT = "submit", o.BUTTON = "button", o.RESET = "reset", o.MENU = "menu", o))(d || {}), y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, s = (o, r, t, e) => {
22
- for (var n = e > 1 ? void 0 : e ? x(r, t) : r, i = o.length - 1, b; i >= 0; i--)
23
- (b = o[i]) && (n = (e ? b(r, t, n) : b(n)) || n);
24
- return e && n && y(r, t, n), n;
21
+ var l = /* @__PURE__ */ ((t) => (t.XSMALL = "xsmall", t.SMALL = "small", t.MEDIUM = "medium", t.LARGE = "large", t))(l || {}), a = /* @__PURE__ */ ((t) => (t.SUBMIT = "submit", t.BUTTON = "button", t.RESET = "reset", t.MENU = "menu", t))(a || {}), u = /* @__PURE__ */ ((t) => (t.PRIMARY = "primary", t.SECONDARY = "secondary", t.OUTLINE = "outline", t.GHOST = "ghost", t))(u || {}), M = Object.defineProperty, y = Object.getOwnPropertyDescriptor, c = (t, r, e, n) => {
22
+ for (var o = n > 1 ? void 0 : n ? y(r, e) : r, i = t.length - 1, p; i >= 0; i--)
23
+ (p = t[i]) && (o = (n ? p(r, e, o) : p(o)) || o);
24
+ return n && o && M(r, e, o), o;
25
25
  };
26
- let a = class extends g {
26
+ let s = class extends m {
27
27
  constructor() {
28
- super(...arguments), this.type = d.SUBMIT, this.variant = l.PRIMARY;
28
+ super(...arguments), this.size = l.MEDIUM, this.type = a.SUBMIT, this.variant = u.PRIMARY;
29
29
  }
30
30
  render() {
31
- const { type: o, variant: r } = this, t = m({
32
- ["o-btn"]: !0,
33
- [`o-btn--${r}`]: r
34
- });
35
- return f`
31
+ const { size: t, type: r, variant: e } = this, n = {
32
+ "o-btn": !0,
33
+ [`o-btn--${t}`]: t,
34
+ [`o-btn--${e}`]: e
35
+ };
36
+ return h`
36
37
  <button
37
- class="${t}"
38
- type=${o}>
38
+ class=${x(n)}
39
+ type=${r}>
39
40
  I'm a PIE button
40
41
  </button>`;
41
42
  }
42
43
  };
43
- a.styles = u(v);
44
- s([
45
- c(),
46
- p(Object.values(d), d.SUBMIT)
47
- ], a.prototype, "type", 2);
48
- s([
49
- c(),
50
- p(Object.values(l), l.PRIMARY)
51
- ], a.prototype, "variant", 2);
52
- a = s([
53
- h("pie-button")
54
- ], a);
44
+ s.styles = d(v);
45
+ c([
46
+ b(),
47
+ f(Object.values(l), l.MEDIUM)
48
+ ], s.prototype, "size", 2);
49
+ c([
50
+ b(),
51
+ f(Object.values(a), a.SUBMIT)
52
+ ], s.prototype, "type", 2);
53
+ c([
54
+ b(),
55
+ f(Object.values(u), u.PRIMARY)
56
+ ], s.prototype, "variant", 2);
57
+ s = c([
58
+ g("pie-button")
59
+ ], s);
55
60
  export {
56
- d as BUTTON_TYPE,
57
- l as BUTTON_VARIANT,
58
- a as PieButton
61
+ l as BUTTON_SIZE,
62
+ a as BUTTON_TYPE,
63
+ u as BUTTON_VARIANT,
64
+ s as PieButton
59
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/pie-button.js",
package/src/button.scss CHANGED
@@ -1,3 +1,60 @@
1
- @use '@justeat/fozzie/src/scss/fozzie' as f;
1
+ @use '@justeat/pie-design-tokens/dist/jet.scss' as dt;
2
2
 
3
- @include f.buttons();
3
+ .o-btn {
4
+ border-radius: dt.$radius-rounded-e;
5
+ border: none;
6
+ font-family: dt.$font-interactive-m-family;
7
+ font-weight: dt.$font-interactive-m-weight;
8
+ }
9
+
10
+ // TODO - Use latest design tokens for font size and line height
11
+ // once fozzie has been updated to handle them.
12
+
13
+ .o-btn--xsmall {
14
+ padding: 6px dt.$spacing-b;
15
+ min-height: 32px;
16
+ font-size: 14px;
17
+ line-height: 20px;
18
+ }
19
+
20
+ .o-btn--small {
21
+ padding: 8px dt.$spacing-d;
22
+ min-height: 40px;
23
+ font-size: 19px;
24
+ line-height: 28px;
25
+ }
26
+
27
+ .o-btn--medium {
28
+ padding: 10px dt.$spacing-e;
29
+ min-height: 48px;
30
+ font-size: 20px;
31
+ line-height: 28px;
32
+ }
33
+
34
+ .o-btn--large {
35
+ padding: 14px dt.$spacing-e;
36
+ min-height: 56px;
37
+ font-size: 20px;
38
+ line-height: 28px;
39
+ }
40
+
41
+ .o-btn--primary {
42
+ background-color: dt.$color-interactive-brand;
43
+ color: dt.$color-content-interactive-primary;
44
+ }
45
+
46
+ .o-btn--secondary {
47
+ background-color: dt.$color-interactive-secondary;
48
+ color: dt.$color-content-interactive-secondary;
49
+ }
50
+
51
+ .o-btn--outline {
52
+ border: 1px solid dt.$color-border-strong;
53
+ background-color: dt.$color-container-default;
54
+ color: dt.$color-content-interactive-tertiary;
55
+ }
56
+
57
+ .o-btn--ghost {
58
+ background-color: dt.$color-container-default;
59
+ color: dt.$color-content-link;
60
+ }
package/src/defs.ts CHANGED
@@ -1,49 +1,29 @@
1
1
  /**
2
- * Button style variants
2
+ * Button size variants
3
3
  */
4
- export enum BUTTON_VARIANT {
5
- /**
6
- * Primary button.
7
- */
8
- PRIMARY = 'primary',
9
-
10
- /**
11
- * Secondary button.
12
- */
13
- SECONDARY = 'secondary',
14
-
15
- /**
16
- * Outline button.
17
- */
18
- OUTLINE = 'outline',
19
-
20
- /**
21
- * Ghost button.
22
- */
23
- GHOST = 'ghost'
4
+ export enum BUTTON_SIZE {
5
+ XSMALL = 'xsmall',
6
+ SMALL = 'small',
7
+ MEDIUM = 'medium',
8
+ LARGE = 'large'
24
9
  }
25
10
 
26
11
  /**
27
12
  * Button style variants
28
13
  */
29
14
  export enum BUTTON_TYPE {
30
- /**
31
- * Submit button.
32
- */
33
15
  SUBMIT = 'submit',
34
-
35
- /**
36
- * Standard button.
37
- */
38
16
  BUTTON = 'button',
39
-
40
- /**
41
- * Reset button.
42
- */
43
17
  RESET = 'reset',
44
-
45
- /**
46
- * Menu button.
47
- */
48
18
  MENU = 'menu'
49
19
  }
20
+
21
+ /**
22
+ * Button style variants
23
+ */
24
+ export enum BUTTON_VARIANT {
25
+ PRIMARY = 'primary',
26
+ SECONDARY = 'secondary',
27
+ OUTLINE = 'outline',
28
+ GHOST = 'ghost'
29
+ }
package/src/index.ts CHANGED
@@ -4,38 +4,37 @@ import { customElement, property } from 'lit/decorators.js';
4
4
 
5
5
  import styles from './button.scss?inline';
6
6
  import { validPropertyValues } from './decorators';
7
- import { BUTTON_TYPE, BUTTON_VARIANT } from './defs';
7
+ import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
8
8
 
9
9
  // Valid values available to consumers
10
- export { BUTTON_TYPE, BUTTON_VARIANT };
10
+ export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
11
11
 
12
12
  @customElement('pie-button')
13
13
  export class PieButton extends LitElement {
14
- /**
15
- * The Button type to use
16
- */
14
+ @property()
15
+ @validPropertyValues(Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
16
+ size : BUTTON_SIZE = BUTTON_SIZE.MEDIUM;
17
+
17
18
  @property()
18
19
  @validPropertyValues(Object.values(BUTTON_TYPE), BUTTON_TYPE.SUBMIT)
19
20
  type : BUTTON_TYPE = BUTTON_TYPE.SUBMIT;
20
21
 
21
- /**
22
- * The Button style variant to use
23
- */
24
22
  @property()
25
23
  @validPropertyValues(Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
26
24
  variant : BUTTON_VARIANT = BUTTON_VARIANT.PRIMARY;
27
25
 
28
26
  render () {
29
- const { type, variant } = this;
27
+ const { size, type, variant } = this;
30
28
 
31
- const classes = classMap({
32
- ['o-btn']: true,
29
+ const classes = {
30
+ 'o-btn': true,
31
+ [`o-btn--${size}`]: size,
33
32
  [`o-btn--${variant}`]: variant
34
- });
33
+ };
35
34
 
36
35
  return html`
37
36
  <button
38
- class="${classes}"
37
+ class=${classMap(classes)}
39
38
  type=${type}>
40
39
  I'm a PIE button
41
40
  </button>`;
package/index.html DELETED
@@ -1,55 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="stylesheet" href="https://unpkg.com/@justeat/pie-design-tokens@latest/dist/jet.css">
8
- <link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2"
9
- as="font" type="font/woff2" crossorigin>
10
- <style>
11
- @font-face {
12
- font-family: JETSansDigital;
13
- src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2') format("woff2"),
14
- url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff') format("woff");
15
- font-weight: 400;
16
- font-display: swap;
17
- }
18
-
19
- body {
20
- font-feature-settings: "tnum";
21
- /* Enable tabular numbers */
22
- }
23
- </style>
24
- <script type="module" src="/src/index.ts"></script>
25
- </head>
26
-
27
- <body>
28
- <!-- This is a temporary file for testing until Storybook is in place -->
29
- <!-- Run `yarn dev` to serve this file -->
30
- <pie-button type="button" variant="primary" />
31
-
32
- <script>
33
- (function () {
34
- var boldFontUrls = 'url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2") format("woff2"), url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/ JETSansDigital-Bold-optimised.woff") format("woff")';
35
- var extraboldFontUrls = 'url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2") format("woff2"), url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/ JETSansDigital-ExtraBold-optimised.woff") format("woff")';
36
-
37
- if ('fonts' in document) {
38
- var bold = new FontFace('JETSansDigital', boldFontUrls, { weight: '700' });
39
- var extrabold = new FontFace('JETSansDigital', extraboldFontUrls, { weight: '800' });
40
-
41
- Promise.all([bold.load(), extrabold.load()])
42
- .then(function (fonts) {
43
- fonts.forEach(function (font) {
44
- document.fonts.add(font);
45
- });
46
- })
47
- .then(function () {
48
- document.documentElement.classList.add('webfonts-loaded');
49
- });
50
- }
51
- })();
52
- </script>
53
- </body>
54
-
55
- </html>