@justeattakeaway/pie-tag 0.4.1 → 0.6.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.
package/README.md CHANGED
@@ -8,18 +8,9 @@
8
8
  </a>
9
9
  </p>
10
10
 
11
- # Table of Contents
12
-
13
- 1. [Introduction](#pie-tag)
14
- 2. [Installation](#installation)
15
- 3. [Importing the component](#importing-the-component)
16
- 4. [Peer Dependencies](#peer-dependencies)
17
- 5. [Props](#props)
18
- 6. [Contributing](#contributing)
19
-
20
11
  ## pie-tag
21
12
 
22
- `pie-tag` is a Web Component built using the Lit library. A tag is a small visual element used to represent and categorize information within a user interface. 
13
+ `pie-tag` is a Web Component built using the Lit library.
23
14
 
24
15
  This component can be easily integrated into various frontend frameworks and customized through a set of properties.
25
16
 
@@ -36,79 +27,13 @@ $ npm i @justeattakeaway/pie-tag
36
27
  $ yarn add @justeattakeaway/pie-tag
37
28
  ```
38
29
 
39
- For full information on using PIE components as part of an application, check out the [Getting Started Guide](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components).
40
-
41
-
42
- ### Importing the component
43
-
44
- #### JavaScript
45
- ```js
46
- // Default – for Native JS Applications, Vue, Angular, Svelte, etc.
47
- import { PieTag } from '@justeattakeaway/pie-tag';
48
-
49
- // If you don't need to reference the imported object, you can simply
50
- // import the module which registers the component as a custom element.
51
- import '@justeattakeaway/pie-tag';
52
- ```
53
-
54
- #### React
55
- ```js
56
- // React
57
- // For React, you will need to import our React-specific component build
58
- // which wraps the web component using ​@lit/react
59
- import { PieTag } from '@justeattakeaway/pie-tag/dist/react';
60
- ```
61
-
62
- > [!NOTE]
63
- > When using the React version of the component, please make sure to also
64
- > include React as a [peer dependency](#peer-dependencies) in your project.
65
-
66
-
67
- ## Peer Dependencies
30
+ ## Documentation
68
31
 
69
- > [!IMPORTANT]
70
- > When using `pie-tag`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
32
+ Visit [Link | PIE Design System](https://pie.design/components/tag/overview) to view more information on this component.
71
33
 
34
+ ## Questions
72
35
 
73
- ## Props
74
-
75
- | Property | Type | Default | Description |
76
- |---|---|---|---|
77
- | size | `String` | `large` | Size of the tag. Can be either `large` or `small` |
78
- | variant | `String` | `neutral` | Variant of the tag, one of `variants` - `neutral-alternative`, `neutral`, `outline`, `ghost`, `blue`, `green`, `yellow`, `red`, `brand` |
79
- | isStrong | `Boolean` | `false` | If `true`, displays strong tag styles for `green`, `yellow`, `red`, `blue` and `neutral` variants'|
80
-
81
- Since the component is not interactive it doesn't have a disabled property. To give the Tag a disabled look please use `--tag-opacity` css variable. Recommended opacity level for disabled tag is 0.5.
82
-
83
- In your markup or JSX, you can then use these to set the properties for the `pie-tag` component:
84
-
85
- ```html
86
- <!-- Native HTML -->
87
- <pie-tag>Label</pie-tag>
88
-
89
- <!-- JSX -->
90
- <PieTag>Label</PieTag>
91
- ```
92
- ## Slots
93
-
94
- | Slot | Description |
95
- | Default slot | Used to pass text into the tag component. |
96
- | icon | Used to pass in an icon to the tag component. We recommend using `pie-icons-webc` for defining this icon, but this can also accept an SVG icon. |
97
-
98
- ### Using `pie-icons-webc` with `pie-tag` icon slot
99
-
100
- We recommend using `pie-icons-webc` when using the `icon` slot. Here is an example of how you would do this:
101
-
102
- ```html
103
- <!--
104
- Note that pie-tag and the icon that you want to use will need to be imported as components into your application.
105
- See the `pie-icons-webc` README for more info on importing these icons.
106
- -->
107
- <pie-tag>
108
- <icon-vegan slot="icon"></icon-vegan>
109
- Vegan
110
- </pie-tag>
111
- ```
36
+ Please head to [FAQs | PIE Design System](https://pie.design/support/contact-us/) to see our FAQs and get in touch.
112
37
 
113
38
  ## Contributing
114
39
 
@@ -96,6 +96,16 @@
96
96
  "privacy": "public",
97
97
  "default": "false",
98
98
  "attribute": "isStrong"
99
+ },
100
+ {
101
+ "kind": "field",
102
+ "name": "isDimmed",
103
+ "type": {
104
+ "text": "boolean"
105
+ },
106
+ "privacy": "public",
107
+ "default": "false",
108
+ "attribute": "isDimmed"
99
109
  }
100
110
  ],
101
111
  "attributes": [
@@ -122,6 +132,14 @@
122
132
  },
123
133
  "default": "false",
124
134
  "fieldName": "isStrong"
135
+ },
136
+ {
137
+ "name": "isDimmed",
138
+ "type": {
139
+ "text": "boolean"
140
+ },
141
+ "default": "false",
142
+ "fieldName": "isDimmed"
125
143
  }
126
144
  ],
127
145
  "superclass": {
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare class PieTag extends LitElement implements TagProps {
11
11
  variant: TagProps['variant'];
12
12
  size: TagProps['size'];
13
13
  isStrong: boolean;
14
+ isDimmed: boolean;
14
15
  render(): TemplateResult<1>;
15
16
  static styles: CSSResult;
16
17
  }
@@ -26,6 +27,10 @@ export declare interface TagProps {
26
27
  * When true, the 'green', "yellow", "red", "blue" and "neutral" variants change their styles and become bolder
27
28
  */
28
29
  isStrong?: boolean;
30
+ /**
31
+ * When `true`, lowers the tag opacity.
32
+ */
33
+ isDimmed?: boolean;
29
34
  /**
30
35
  * What size the tag should be.
31
36
  */
package/dist/index.js CHANGED
@@ -1,52 +1,57 @@
1
- import { unsafeCSS as p, LitElement as u, html as s, nothing as h } from "lit";
2
- import { property as l } from "lit/decorators.js";
3
- import { validPropertyValues as v, defineCustomElement as b } from "@justeattakeaway/pie-webc-core";
4
- const f = `.c-tag{--tag-bg-color: var(--dt-color-container-inverse);--tag-color: var(--dt-color-content-inverse);--tag-padding: 2px var(--dt-spacing-b);--tag-height: 24px;--tag-border-radius: var(--dt-radius-rounded-b);--tag-font-family: var(--dt-font-body-s-family);--tag-font-weight: var(--dt-font-body-s-weight);--tag-font-size: calc(var(--dt-font-body-s-size) * 1px);--tag-line-height: calc(var(--dt-font-body-s-line-height) * 1px);--tag-transparent-bg-color: transparent;--tag-height-large: 24px;--tag-height-small: 16px;--icon-display-override: block;--icon-size-override: 16px;display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;gap:var(--dt-spacing-a);height:var(--tag-height);padding:var(--tag-padding);border:none;border-radius:var(--tag-border-radius);background-color:var(--tag-bg-color);color:var(--tag-color);font-family:var(--tag-font-family);font-weight:var(--tag-font-weight);font-size:var(--tag-font-size);line-height:var(--tag-line-height);opacity:var(--tag-opacity, 1)}.c-tag[size=small]{--tag-height: var(--tag-height-small);--tag-padding: 0 var(--dt-spacing-a);--tag-border-radius: var(--dt-radius-rounded-a);--tag-font-size: calc(var(--dt-font-caption-size) * 1px);--tag-line-height: calc(var(--dt-font-caption-line-height) * 1px)}.c-tag[size=large]{--tag-height: var(--tag-height-large);--tag-padding: 2px var(--dt-spacing-b);--tag-border-radius: var(--dt-radius-rounded-b);--tag-font-size: calc(var(--dt-font-body-s-size) * 1px);--tag-line-height: calc(var(--dt-font-body-s-line-height) * 1px)}.c-tag[variant=neutral]{--tag-bg-color: var(--dt-color-container-strong);--tag-color: var(--dt-color-content-default)}.c-tag[variant=neutral][isStrong]{--tag-bg-color: var(--dt-color-container-inverse);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=blue]{--tag-bg-color: var(--dt-color-support-info-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=blue][isStrong]{--tag-bg-color: var(--dt-color-support-info);--tag-color: var(--dt-color-content-light)}.c-tag[variant=green]{--tag-bg-color: var(--dt-color-support-positive-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=green][isStrong]{--tag-bg-color: var(--dt-color-support-positive);--tag-color: var(--dt-color-content-light)}.c-tag[variant=yellow]{--tag-bg-color: var(--dt-color-support-warning-02);--tag-color: var(--dt-color-content-dark)}.c-tag[variant=yellow][isStrong]{--tag-bg-color: var(--dt-color-support-warning);--tag-color: var(--dt-color-content-dark)}.c-tag[variant=red]{--tag-bg-color: var(--dt-color-support-error-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=red][isStrong]{--tag-bg-color: var(--dt-color-support-error);--tag-color: var(--dt-color-content-light)}.c-tag[variant=brand]{--tag-bg-color: var(--dt-color-support-brand-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=neutral-alternative]{--tag-bg-color: var(--dt-color-container-default);--tag-color: var(--dt-color-content-default)}.c-tag[variant=outline]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default);border:1px solid var(--dt-color-border-strong)}.c-tag[variant=outline][size=small]{--tag-padding: 0 3px}.c-tag[variant=outline][size=large]{--tag-padding: 1px 7px}.c-tag[variant=ghost]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default)}::slotted(svg){display:block;height:var(--icon-size-override);width:var(--icon-size-override)}
5
- `, y = ["neutral-alternative", "neutral", "outline", "ghost", "blue", "green", "yellow", "red", "brand"], m = ["small", "large"];
6
- var z = Object.defineProperty, x = Object.getOwnPropertyDescriptor, c = (n, a, r, o) => {
7
- for (var t = o > 1 ? void 0 : o ? x(a, r) : a, g = n.length - 1, i; g >= 0; g--)
8
- (i = n[g]) && (t = (o ? i(a, r, t) : i(t)) || t);
1
+ import { unsafeCSS as p, LitElement as u, html as d, nothing as h } from "lit";
2
+ import { property as n } from "lit/decorators.js";
3
+ import { validPropertyValues as v, defineCustomElement as f } from "@justeattakeaway/pie-webc-core";
4
+ const b = `.c-tag{--tag-bg-color: var(--dt-color-container-inverse);--tag-color: var(--dt-color-content-inverse);--tag-padding: 2px var(--dt-spacing-b);--tag-height: 24px;--tag-border-radius: var(--dt-radius-rounded-b);--tag-font-family: var(--dt-font-body-s-family);--tag-font-weight: var(--dt-font-body-s-weight);--tag-font-size: calc(var(--dt-font-body-s-size) * 1px);--tag-line-height: calc(var(--dt-font-body-s-line-height) * 1px);--tag-transparent-bg-color: transparent;--tag-height-large: 24px;--tag-height-small: 16px;--icon-display-override: block;--icon-size-override: 16px;display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;gap:var(--dt-spacing-a);height:var(--tag-height);padding:var(--tag-padding);border:none;border-radius:var(--tag-border-radius);background-color:var(--tag-bg-color);color:var(--tag-color);font-family:var(--tag-font-family);font-weight:var(--tag-font-weight);font-size:var(--tag-font-size);line-height:var(--tag-line-height)}.c-tag[size=small]{--tag-height: var(--tag-height-small);--tag-padding: 0 var(--dt-spacing-a);--tag-border-radius: var(--dt-radius-rounded-a);--tag-font-size: calc(var(--dt-font-caption-size) * 1px);--tag-line-height: calc(var(--dt-font-caption-line-height) * 1px)}.c-tag[size=large]{--tag-height: var(--tag-height-large);--tag-padding: 2px var(--dt-spacing-b);--tag-border-radius: var(--dt-radius-rounded-b);--tag-font-size: calc(var(--dt-font-body-s-size) * 1px);--tag-line-height: calc(var(--dt-font-body-s-line-height) * 1px)}.c-tag[variant=neutral]{--tag-bg-color: var(--dt-color-container-strong);--tag-color: var(--dt-color-content-default)}.c-tag[variant=neutral][isStrong]{--tag-bg-color: var(--dt-color-container-inverse);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=blue]{--tag-bg-color: var(--dt-color-support-info-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=blue][isStrong]{--tag-bg-color: var(--dt-color-support-info);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=green]{--tag-bg-color: var(--dt-color-support-positive-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=green][isStrong]{--tag-bg-color: var(--dt-color-support-positive);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=yellow]{--tag-bg-color: var(--dt-color-support-warning-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=yellow][isStrong]{--tag-bg-color: var(--dt-color-support-warning);--tag-color: var(--dt-color-content-dark)}.c-tag[variant=red]{--tag-bg-color: var(--dt-color-support-error-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=red][isStrong]{--tag-bg-color: var(--dt-color-support-error);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=brand]{--tag-bg-color: var(--dt-color-support-brand-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=neutral-alternative]{--tag-bg-color: var(--dt-color-container-default);--tag-color: var(--dt-color-content-default)}.c-tag[variant=outline]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default);border:1px solid var(--dt-color-border-strong)}.c-tag[variant=outline][size=small]{--tag-padding: 0 3px}.c-tag[variant=outline][size=large]{--tag-padding: 1px 7px}.c-tag[variant=ghost]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default)}.c-tag[isDimmed]{opacity:.5}::slotted(svg){display:block;height:var(--icon-size-override);width:var(--icon-size-override)}
5
+ `, m = ["neutral-alternative", "neutral", "outline", "ghost", "blue", "green", "yellow", "red", "brand"], y = ["small", "large"];
6
+ var z = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (g, a, r, o) => {
7
+ for (var t = o > 1 ? void 0 : o ? x(a, r) : a, l = g.length - 1, c; l >= 0; l--)
8
+ (c = g[l]) && (t = (o ? c(a, r, t) : c(t)) || t);
9
9
  return o && t && z(a, r, t), t;
10
10
  };
11
- const d = "pie-tag";
11
+ const s = "pie-tag";
12
12
  class e extends u {
13
13
  constructor() {
14
- super(...arguments), this.variant = "neutral", this.size = "large", this.isStrong = !1;
14
+ super(...arguments), this.variant = "neutral", this.size = "large", this.isStrong = !1, this.isDimmed = !1;
15
15
  }
16
16
  render() {
17
17
  const {
18
18
  variant: a,
19
19
  size: r,
20
- isStrong: o
20
+ isStrong: o,
21
+ isDimmed: t
21
22
  } = this;
22
- return s`
23
+ return d`
23
24
  <div
24
25
  class="c-tag"
25
26
  variant=${a || "neutral"}
26
27
  size=${r || "large"}
27
28
  ?isStrong=${o}
29
+ ?isDimmed=${t}
28
30
  data-test-id="pie-tag"
29
31
  >
30
- ${r === "large" ? s`<slot name="icon"></slot>` : h}
32
+ ${r === "large" ? d`<slot name="icon"></slot>` : h}
31
33
  <slot></slot>
32
34
  </div>`;
33
35
  }
34
36
  }
35
- e.styles = p(f);
36
- c([
37
- l({ type: String }),
38
- v(d, y, "neutral")
37
+ e.styles = p(b);
38
+ i([
39
+ n({ type: String }),
40
+ v(s, m, "neutral")
39
41
  ], e.prototype, "variant", 2);
40
- c([
41
- l({ type: String }),
42
- v(d, m, "large")
42
+ i([
43
+ n({ type: String }),
44
+ v(s, y, "large")
43
45
  ], e.prototype, "size", 2);
44
- c([
45
- l({ type: Boolean })
46
+ i([
47
+ n({ type: Boolean })
46
48
  ], e.prototype, "isStrong", 2);
47
- b(d, e);
49
+ i([
50
+ n({ type: Boolean })
51
+ ], e.prototype, "isDimmed", 2);
52
+ f(s, e);
48
53
  export {
49
54
  e as PieTag,
50
- m as sizes,
51
- y as variants
55
+ y as sizes,
56
+ m as variants
52
57
  };
package/dist/react.d.ts CHANGED
@@ -14,6 +14,7 @@ declare class PieTag_2 extends LitElement implements TagProps {
14
14
  variant: TagProps['variant'];
15
15
  size: TagProps['size'];
16
16
  isStrong: boolean;
17
+ isDimmed: boolean;
17
18
  render(): TemplateResult<1>;
18
19
  static styles: CSSResult;
19
20
  }
@@ -31,6 +32,10 @@ export declare interface TagProps {
31
32
  * When true, the 'green', "yellow", "red", "blue" and "neutral" variants change their styles and become bolder
32
33
  */
33
34
  isStrong?: boolean;
35
+ /**
36
+ * When `true`, lowers the tag opacity.
37
+ */
38
+ isDimmed?: boolean;
34
39
  /**
35
40
  * What size the tag should be.
36
41
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-tag",
3
3
  "description": "PIE Design System Tag built using Web Components",
4
- "version": "0.4.1",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "license": "Apache-2.0",
33
33
  "devDependencies": {
34
34
  "@custom-elements-manifest/analyzer": "0.9.0",
35
- "@justeattakeaway/pie-components-config": "0.9.0",
35
+ "@justeattakeaway/pie-components-config": "0.11.0",
36
36
  "@justeattakeaway/pie-wrapper-react": "0.14.0",
37
37
  "cem-plugin-module-file-extensions": "0.0.5"
38
38
  },
package/src/defs.ts CHANGED
@@ -12,6 +12,11 @@ export interface TagProps {
12
12
  */
13
13
  isStrong?: boolean;
14
14
 
15
+ /**
16
+ * When `true`, lowers the tag opacity.
17
+ */
18
+ isDimmed?: boolean;
19
+
15
20
  /**
16
21
  * What size the tag should be.
17
22
  */
package/src/index.ts CHANGED
@@ -28,11 +28,15 @@ export class PieTag extends LitElement implements TagProps {
28
28
  @property({ type: Boolean })
29
29
  public isStrong = false;
30
30
 
31
+ @property({ type: Boolean })
32
+ public isDimmed = false;
33
+
31
34
  render () {
32
35
  const {
33
36
  variant,
34
37
  size,
35
38
  isStrong,
39
+ isDimmed,
36
40
  } = this;
37
41
  return html`
38
42
  <div
@@ -40,6 +44,7 @@ export class PieTag extends LitElement implements TagProps {
40
44
  variant=${variant || 'neutral'}
41
45
  size=${size || 'large'}
42
46
  ?isStrong=${isStrong}
47
+ ?isDimmed=${isDimmed}
43
48
  data-test-id="pie-tag"
44
49
  >
45
50
  ${size === 'large' ? html`<slot name="icon"></slot>` : nothing}
package/src/tag.scss CHANGED
@@ -39,7 +39,6 @@
39
39
  font-weight: var(--tag-font-weight);
40
40
  font-size: var(--tag-font-size);
41
41
  line-height: var(--tag-line-height);
42
- opacity: var(--tag-opacity, 1); // we don't specify --tag-opacity variable here to let consumers override a default value that we set
43
42
 
44
43
  // Size
45
44
  &[size='small'] {
@@ -75,7 +74,7 @@
75
74
 
76
75
  &[isStrong] {
77
76
  --tag-bg-color: var(--dt-color-support-info);
78
- --tag-color: var(--dt-color-content-light);
77
+ --tag-color: var(--dt-color-content-inverse);
79
78
  }
80
79
  }
81
80
 
@@ -85,13 +84,13 @@
85
84
 
86
85
  &[isStrong] {
87
86
  --tag-bg-color: var(--dt-color-support-positive);
88
- --tag-color: var(--dt-color-content-light);
87
+ --tag-color: var(--dt-color-content-inverse);
89
88
  }
90
89
  }
91
90
 
92
91
  &[variant='yellow'] {
93
92
  --tag-bg-color: var(--dt-color-support-warning-02);
94
- --tag-color: var(--dt-color-content-dark);
93
+ --tag-color: var(--dt-color-content-default);
95
94
 
96
95
  &[isStrong] {
97
96
  --tag-bg-color: var(--dt-color-support-warning);
@@ -105,7 +104,7 @@
105
104
 
106
105
  &[isStrong] {
107
106
  --tag-bg-color: var(--dt-color-support-error);
108
- --tag-color: var(--dt-color-content-light);
107
+ --tag-color: var(--dt-color-content-inverse);
109
108
  }
110
109
  }
111
110
 
@@ -137,6 +136,10 @@
137
136
  --tag-bg-color: var(--tag-transparent-bg-color);
138
137
  --tag-color: var(--dt-color-content-default);
139
138
  }
139
+
140
+ &[isDimmed] {
141
+ opacity: 0.5;
142
+ }
140
143
  }
141
144
 
142
145
  // Used to size an SVG if one is passed in (when not using the component icons)