@justeattakeaway/pie-list 0.0.31 → 0.1.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.
- package/README.md +247 -50
- package/custom-elements.json +106 -4
- package/dist/PieElement-Y2VnHR4y.js +11 -0
- package/dist/index-D4OaeeiJ.js +79 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -19
- package/dist/pie-list-item/defs.d.ts +31 -0
- package/dist/pie-list-item/defs.d.ts.map +1 -1
- package/dist/pie-list-item/index.d.ts +14 -2
- package/dist/pie-list-item/index.d.ts.map +1 -1
- package/dist/pie-list-item/index.js +7 -14
- package/dist/pie-list-item/react.js +7 -5
- package/package.json +5 -4
- package/src/index.ts +9 -1
- package/src/list.scss +6 -0
- package/src/pie-list-item/defs.ts +43 -3
- package/src/pie-list-item/index.ts +79 -4
- package/src/pie-list-item/list-item.scss +111 -0
package/README.md
CHANGED
|
@@ -1,91 +1,288 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
</p>
|
|
1
|
+
# @justeattakeaway/pie-list
|
|
2
|
+
[Source Code](https://github.com/justeattakeaway/pie/tree/main/packages/components/pie-list) | [Design Documentation](https://pie.design/components/list) | [NPM](https://www.npmjs.com/package/@justeattakeaway/pie-list)
|
|
4
3
|
|
|
5
|
-
<p
|
|
4
|
+
<p>
|
|
6
5
|
<a href="https://www.npmjs.com/@justeattakeaway/pie-list">
|
|
7
6
|
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-list.svg">
|
|
8
7
|
</a>
|
|
9
8
|
</p>
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
`@justeattakeaway/pie-list` is a Web Component built using the Lit library. It provides a simple, accessible list built from two elements: a `pie-list` container and one or more `pie-list-item` children.
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
3. [Importing the component](#importing-the-component)
|
|
16
|
-
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
-
5. [Props](#props)
|
|
18
|
-
6. [Contributing](#contributing)
|
|
12
|
+
> [!NOTE]
|
|
13
|
+
> This component is still growing. More properties, slots and sub-components will be added over time. This documentation covers what is currently supported.
|
|
19
14
|
|
|
20
|
-
##
|
|
15
|
+
## Table of Contents
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Documentation](#documentation)
|
|
19
|
+
- [Properties](#properties)
|
|
20
|
+
- [Slots](#slots)
|
|
21
|
+
- [CSS Variables](#css-variables)
|
|
22
|
+
- [Events](#events)
|
|
23
|
+
- [Accessibility](#accessibility)
|
|
24
|
+
- [Usage Examples](#usage-examples)
|
|
25
|
+
- [Usage Notes and Rules](#usage-notes-and-rules)
|
|
26
|
+
- [Questions and Support](#questions-and-support)
|
|
27
|
+
- [Contributing](#contributing)
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
## Installation
|
|
25
30
|
|
|
31
|
+
> To install any of our web components in your application, we would suggest following the [getting started guide](https://webc.pie.design/?path=/docs/introduction-getting-started--docs) to set up your project.
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
Ideally, you should install the component using the **`@justeattakeaway/pie-webc`** package, which includes all of the components. Or you can install the individual component package.
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
`pie-list` is a compound component. The `pie-list` element is the container (it applies the `list` role and renders the dividers between items), and each row is a `pie-list-item` (which applies the `listitem` role).
|
|
38
|
+
|
|
39
|
+
> [!IMPORTANT]
|
|
40
|
+
> Because `pie-list` uses the `list` role, you **must always give it an accessible name** using either `aria-label` or `aria-labelledby`. Without one, screen reader users get no context for what the list contains. See [Accessibility](#accessibility).
|
|
41
|
+
|
|
42
|
+
### Properties
|
|
43
|
+
|
|
44
|
+
#### `pie-list`
|
|
45
|
+
|
|
46
|
+
`pie-list` currently has no configurable properties. It acts as the semantic container for `pie-list-item` children.
|
|
47
|
+
|
|
48
|
+
#### `pie-list-item`
|
|
49
|
+
|
|
50
|
+
| Prop | Options | Description | Default |
|
|
51
|
+
|---|---|---|---|
|
|
52
|
+
| `primaryText` | Any string | The main text of the item, providing an overview of the content. | `undefined` |
|
|
53
|
+
| `secondaryText` | Any string | Optional additional detail, rendered on a second line beneath the primary text. | `undefined` |
|
|
54
|
+
| `metaText` | Any string | Optional supporting information about the item's context, status or attributes. Rendered as a trailing text string. **Mutually exclusive with the `trailing` slot**: if `metaText` is set, the `trailing` slot is not rendered. | `undefined` |
|
|
55
|
+
| `isCompact` | `true`, `false` | Decreases the item height to save vertical space. See the [rules](#usage-notes-and-rules) below. | `false` |
|
|
56
|
+
| `isBold` | `true`, `false` | Sets the primary text to a bold font-weight. | `false` |
|
|
57
|
+
| `hasMedia` | `true`, `false` | **Required whenever you slot a media element (e.g. `pie-thumbnail`) into the item.** Reduces the block padding so single-line media sits correctly (this padding adjustment has no effect when `secondaryText` is set, but you should still set `hasMedia`). | `false` |
|
|
58
|
+
|
|
59
|
+
### Slots
|
|
60
|
+
|
|
61
|
+
Slots are provided by `pie-list-item`.
|
|
62
|
+
|
|
63
|
+
| Slot | Description |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `leading` | Content displayed at the start of the item, before the text. Intended for a small icon or a media element (e.g. `pie-thumbnail`). If slotting `pie-thumbnail`, it MUST use `size="40"`; this is the only size that fits the list-item layout correctly. |
|
|
66
|
+
| `trailing` | Content displayed at the end of the item, after the text. Intended for a small icon, a `pie-tag`, etc. Not rendered when `metaText` is set. |
|
|
67
|
+
|
|
68
|
+
The permitted slotted elements are: a PIE WEBC icon, `pie-tag`, `pie-thumbnail`, `pie-avatar`*, `pie-switch`, and native HTML radio/checkbox inputs.
|
|
69
|
+
Some slotted content is designed with specific properties being used. So please read the entire readme to understand correct slot usage.
|
|
28
70
|
|
|
29
|
-
|
|
71
|
+
> Slotted PIE icons are always sized by `pie-list-item` (24px). Consumers cannot override this size.
|
|
30
72
|
|
|
31
|
-
|
|
32
|
-
# npm
|
|
33
|
-
$ npm i @justeattakeaway/pie-list
|
|
73
|
+
> \* `pie-avatar` is a permitted slot element but is not covered by usage examples here yet, as it is not ready for use in lists.
|
|
34
74
|
|
|
35
|
-
|
|
36
|
-
|
|
75
|
+
### CSS Variables
|
|
76
|
+
|
|
77
|
+
These custom properties can be set on a `pie-list-item` (or on `pie-list` to affect all items) to override the defaults.
|
|
78
|
+
|
|
79
|
+
| Variable | Description | Accepted values |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `--list-item-inline-padding` | Sets the inline (start and end) padding of the item. Defaults to `var(--dt-spacing-d)`. **Must be set on the `pie-list-item`** (directly or via a rule targeting it), not on `pie-list` — the default lives on the item's host, so an inherited value from `pie-list` will not override it. | Any PIE spacing token (e.g. `var(--dt-spacing-f)`) or `0` |
|
|
82
|
+
| `--list-item-alignment` | Sets the vertical alignment of the item's content. Defaults to `flex-start`. **Must be set on the `pie-list-item`** (directly or via a rule targeting it), not on `pie-list` — the default lives on the item's host, so an inherited value from `pie-list` will not override it. | Only `center` is recommended |
|
|
83
|
+
|
|
84
|
+
### Events
|
|
85
|
+
|
|
86
|
+
This component does not emit any custom events. To listen for interactions, treat slotted interactive elements like native HTML elements in your application.
|
|
87
|
+
|
|
88
|
+
## Accessibility
|
|
89
|
+
|
|
90
|
+
`pie-list` renders with `role="list"` and each `pie-list-item` with `role="listitem"`.
|
|
91
|
+
|
|
92
|
+
> [!IMPORTANT]
|
|
93
|
+
> **Always provide an accessible name for `pie-list`** via `aria-label` or `aria-labelledby`. A list with the `list` role has no inherent name, so without one a screen reader announces "list" with no indication of what it contains.
|
|
94
|
+
|
|
95
|
+
- Use **`aria-label`** when there is no visible heading for the list:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<pie-list aria-label="Payment methods">
|
|
99
|
+
<pie-list-item primaryText="Credit card"></pie-list-item>
|
|
100
|
+
<pie-list-item primaryText="PayPal"></pie-list-item>
|
|
101
|
+
</pie-list>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- Use **`aria-labelledby`** to reference a visible heading (preferred when one exists, so the visible and accessible names stay in sync):
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<h2 id="payment-methods-heading">Payment methods</h2>
|
|
108
|
+
<pie-list aria-labelledby="payment-methods-heading">
|
|
109
|
+
<pie-list-item primaryText="Credit card"></pie-list-item>
|
|
110
|
+
<pie-list-item primaryText="PayPal"></pie-list-item>
|
|
111
|
+
</pie-list>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usage Examples
|
|
115
|
+
|
|
116
|
+
**For HTML:**
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
// import as modules into a js file e.g. main.js
|
|
120
|
+
import '@justeattakeaway/pie-webc/components/list.js';
|
|
121
|
+
import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
37
122
|
```
|
|
38
123
|
|
|
39
|
-
|
|
124
|
+
A basic list with primary, secondary and meta text (note the required `aria-label`):
|
|
40
125
|
|
|
126
|
+
```html
|
|
127
|
+
<pie-list aria-label="Recent orders">
|
|
128
|
+
<pie-list-item
|
|
129
|
+
primaryText="Primary text"
|
|
130
|
+
secondaryText="Secondary text"
|
|
131
|
+
metaText="Meta text"></pie-list-item>
|
|
132
|
+
<pie-list-item
|
|
133
|
+
primaryText="Primary text"
|
|
134
|
+
secondaryText="Secondary text"></pie-list-item>
|
|
135
|
+
<pie-list-item primaryText="Primary text"></pie-list-item>
|
|
136
|
+
</pie-list>
|
|
137
|
+
<script type="module" src="/main.js"></script>
|
|
138
|
+
```
|
|
41
139
|
|
|
42
|
-
|
|
140
|
+
**Leading and trailing content (icons):**
|
|
43
141
|
|
|
44
|
-
#### JavaScript
|
|
45
142
|
```js
|
|
46
|
-
|
|
47
|
-
|
|
143
|
+
import '@justeattakeaway/pie-icons-webc/dist/IconChevronRight.js';
|
|
144
|
+
```
|
|
48
145
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
146
|
+
```html
|
|
147
|
+
<pie-list>
|
|
148
|
+
<pie-list-item primaryText="Primary text" secondaryText="Secondary text">
|
|
149
|
+
<icon-placeholder slot="leading"></icon-placeholder>
|
|
150
|
+
<icon-chevron-right slot="trailing"></icon-chevron-right>
|
|
151
|
+
</pie-list-item>
|
|
152
|
+
</pie-list>
|
|
52
153
|
```
|
|
53
154
|
|
|
54
|
-
|
|
155
|
+
**Trailing `pie-tag`:**
|
|
156
|
+
|
|
55
157
|
```js
|
|
56
|
-
|
|
57
|
-
// For React, you will need to import our React-specific component build
|
|
58
|
-
// which wraps the web component using @lit/react
|
|
59
|
-
import { PieList } from '@justeattakeaway/pie-list/dist/react';
|
|
158
|
+
import '@justeattakeaway/pie-webc/components/tag.js';
|
|
60
159
|
```
|
|
61
160
|
|
|
62
|
-
|
|
63
|
-
>
|
|
64
|
-
|
|
161
|
+
```html
|
|
162
|
+
<pie-list>
|
|
163
|
+
<pie-list-item primaryText="Primary text" secondaryText="Secondary text">
|
|
164
|
+
<pie-tag slot="trailing">Label</pie-tag>
|
|
165
|
+
</pie-list-item>
|
|
166
|
+
</pie-list>
|
|
167
|
+
```
|
|
65
168
|
|
|
169
|
+
**Meta text** (renders as trailing text; do not combine with the `trailing` slot):
|
|
66
170
|
|
|
67
|
-
|
|
171
|
+
```html
|
|
172
|
+
<pie-list>
|
|
173
|
+
<pie-list-item
|
|
174
|
+
primaryText="Primary text"
|
|
175
|
+
secondaryText="Secondary text"
|
|
176
|
+
metaText="Meta text"></pie-list-item>
|
|
177
|
+
</pie-list>
|
|
178
|
+
```
|
|
68
179
|
|
|
69
|
-
|
|
70
|
-
> When using `pie-list`, 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.
|
|
180
|
+
**Bold primary text:**
|
|
71
181
|
|
|
182
|
+
```html
|
|
183
|
+
<pie-list>
|
|
184
|
+
<pie-list-item isBold primaryText="Primary text"></pie-list-item>
|
|
185
|
+
</pie-list>
|
|
186
|
+
```
|
|
72
187
|
|
|
73
|
-
|
|
188
|
+
**Compact list** (reduced height, see [rules](#usage-notes-and-rules)):
|
|
74
189
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
190
|
+
```html
|
|
191
|
+
<pie-list>
|
|
192
|
+
<pie-list-item isCompact primaryText="Primary text">
|
|
193
|
+
<icon-chevron-right slot="trailing"></icon-chevron-right>
|
|
194
|
+
</pie-list-item>
|
|
195
|
+
<pie-list-item isCompact primaryText="Primary text">
|
|
196
|
+
<icon-chevron-right slot="trailing"></icon-chevron-right>
|
|
197
|
+
</pie-list-item>
|
|
198
|
+
</pie-list>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Media (`pie-thumbnail`) in the leading slot:**
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
import '@justeattakeaway/pie-webc/components/thumbnail.js';
|
|
205
|
+
```
|
|
78
206
|
|
|
79
|
-
|
|
207
|
+
```html
|
|
208
|
+
<!-- `hasMedia` is REQUIRED whenever you slot a thumbnail. Without it the
|
|
209
|
+
block padding will be incorrect. -->
|
|
210
|
+
<pie-list aria-label="Restaurants">
|
|
211
|
+
<pie-list-item hasMedia primaryText="Primary text">
|
|
212
|
+
<pie-thumbnail slot="leading" size="40"></pie-thumbnail>
|
|
213
|
+
</pie-list-item>
|
|
214
|
+
</pie-list>
|
|
215
|
+
|
|
216
|
+
<!-- Still set `hasMedia` when there is secondary text. The padding is unchanged
|
|
217
|
+
in this case, but you should still set it. -->
|
|
218
|
+
<pie-list aria-label="Restaurants">
|
|
219
|
+
<pie-list-item hasMedia primaryText="Primary text" secondaryText="Secondary text">
|
|
220
|
+
<pie-thumbnail slot="leading" size="40"></pie-thumbnail>
|
|
221
|
+
</pie-list-item>
|
|
222
|
+
</pie-list>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Overriding alignment and padding** (via CSS variables):
|
|
80
226
|
|
|
81
227
|
```html
|
|
82
|
-
<!--
|
|
83
|
-
|
|
228
|
+
<!-- Vertically centre the content of the items. `--list-item-alignment` must be set on the
|
|
229
|
+
`pie-list-item` (here via a rule targeting every item), not on `pie-list`. -->
|
|
230
|
+
<style>pie-list-item { --list-item-alignment: center; }</style>
|
|
231
|
+
<pie-list>
|
|
232
|
+
<pie-list-item primaryText="Primary text" secondaryText="Secondary text">
|
|
233
|
+
<icon-chevron-right slot="trailing"></icon-chevron-right>
|
|
234
|
+
</pie-list-item>
|
|
235
|
+
</pie-list>
|
|
236
|
+
|
|
237
|
+
<!-- Remove the inline padding. `--list-item-inline-padding` must be set on the `pie-list-item`
|
|
238
|
+
(its default lives on the item's host, so a value on `pie-list` will not override it). -->
|
|
239
|
+
<pie-list>
|
|
240
|
+
<pie-list-item style="--list-item-inline-padding: 0;" primaryText="Primary text"></pie-list-item>
|
|
241
|
+
</pie-list>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**For Native JS Applications, Vue, Angular, Svelte etc.:**
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
// Vue templates (using Nuxt 3)
|
|
248
|
+
import '@justeattakeaway/pie-webc/components/list.js';
|
|
249
|
+
import '@justeattakeaway/pie-webc/components/list-item.js';
|
|
84
250
|
|
|
85
|
-
|
|
86
|
-
<
|
|
251
|
+
<pie-list>
|
|
252
|
+
<pie-list-item primaryText="Primary text" secondaryText="Secondary text"></pie-list-item>
|
|
253
|
+
</pie-list>
|
|
87
254
|
```
|
|
88
255
|
|
|
256
|
+
**For React Applications:**
|
|
257
|
+
|
|
258
|
+
```jsx
|
|
259
|
+
import { PieList } from '@justeattakeaway/pie-webc/react/list.js';
|
|
260
|
+
import { PieListItem } from '@justeattakeaway/pie-webc/react/list-item.js';
|
|
261
|
+
|
|
262
|
+
<PieList>
|
|
263
|
+
<PieListItem primaryText="Primary text" secondaryText="Secondary text">
|
|
264
|
+
<PieThumbnail slot="leading" size={40} />
|
|
265
|
+
</PieListItem>
|
|
266
|
+
</PieList>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Usage Notes and Rules
|
|
270
|
+
|
|
271
|
+
To keep lists consistent and correct, follow these rules:
|
|
272
|
+
|
|
273
|
+
- **Always give `pie-list` an accessible name** with `aria-label` or `aria-labelledby` (use `aria-labelledby` when a visible heading exists). This is required for screen reader users to understand the list. See [Accessibility](#accessibility).
|
|
274
|
+
- **Provide `primaryText`** on every `pie-list-item`; it is the item's main line of content.
|
|
275
|
+
- **`metaText` and the `trailing` slot are mutually exclusive.** If `metaText` is set, any `trailing` slot content is ignored. Choose one.
|
|
276
|
+
- **Slotted `pie-thumbnail` must use `size="40"`.** This is the only size that fits the list-item layout correctly.
|
|
277
|
+
- **Always set `hasMedia` when slotting media** (`pie-thumbnail`, and `pie-avatar` in future), whether or not the item has `secondaryText`. This guarantees the item has the correct block padding.
|
|
278
|
+
- **Do not combine `isCompact` with `secondaryText` or with slotted media.** Compact items are single-line and too short for these.
|
|
279
|
+
- **Only use `center` for `--list-item-alignment`.** Other values are not supported.
|
|
280
|
+
- **`pie-avatar` is not yet ready** for use in lists. Prefer `pie-thumbnail` for media for now.
|
|
281
|
+
|
|
282
|
+
## Questions and Support
|
|
283
|
+
|
|
284
|
+
If you work at Just Eat Takeaway.com, please contact us on **#help-designsystem**. Otherwise, please raise an issue on [Github](https://github.com/justeattakeaway/pie/issues).
|
|
285
|
+
|
|
89
286
|
## Contributing
|
|
90
287
|
|
|
91
|
-
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
|
288
|
+
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
package/custom-elements.json
CHANGED
|
@@ -65,8 +65,26 @@
|
|
|
65
65
|
{
|
|
66
66
|
"kind": "javascript-module",
|
|
67
67
|
"path": "src/pie-list-item/defs.js",
|
|
68
|
-
"declarations": [
|
|
69
|
-
|
|
68
|
+
"declarations": [
|
|
69
|
+
{
|
|
70
|
+
"kind": "variable",
|
|
71
|
+
"name": "defaultProps",
|
|
72
|
+
"type": {
|
|
73
|
+
"text": "DefaultProps"
|
|
74
|
+
},
|
|
75
|
+
"default": "{ isCompact: false, isBold: false, hasMedia: false, }"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"exports": [
|
|
79
|
+
{
|
|
80
|
+
"kind": "js",
|
|
81
|
+
"name": "defaultProps",
|
|
82
|
+
"declaration": {
|
|
83
|
+
"name": "defaultProps",
|
|
84
|
+
"module": "src/pie-list-item/defs.js"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
70
88
|
},
|
|
71
89
|
{
|
|
72
90
|
"kind": "javascript-module",
|
|
@@ -76,9 +94,93 @@
|
|
|
76
94
|
"kind": "class",
|
|
77
95
|
"description": "",
|
|
78
96
|
"name": "PieListItem",
|
|
97
|
+
"members": [
|
|
98
|
+
{
|
|
99
|
+
"kind": "field",
|
|
100
|
+
"name": "primaryText",
|
|
101
|
+
"type": {
|
|
102
|
+
"text": "ListItemProps['primaryText']"
|
|
103
|
+
},
|
|
104
|
+
"attribute": "primaryText"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"kind": "field",
|
|
108
|
+
"name": "secondaryText",
|
|
109
|
+
"type": {
|
|
110
|
+
"text": "ListItemProps['secondaryText']"
|
|
111
|
+
},
|
|
112
|
+
"attribute": "secondaryText"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"kind": "field",
|
|
116
|
+
"name": "metaText",
|
|
117
|
+
"type": {
|
|
118
|
+
"text": "ListItemProps['metaText']"
|
|
119
|
+
},
|
|
120
|
+
"attribute": "metaText"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"kind": "field",
|
|
124
|
+
"name": "isCompact",
|
|
125
|
+
"attribute": "isCompact"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"kind": "field",
|
|
129
|
+
"name": "isBold",
|
|
130
|
+
"attribute": "isBold"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"kind": "field",
|
|
134
|
+
"name": "hasMedia",
|
|
135
|
+
"attribute": "hasMedia"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"kind": "method",
|
|
139
|
+
"name": "_renderSecondaryText"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"kind": "method",
|
|
143
|
+
"name": "_renderTrailingContent"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"attributes": [
|
|
147
|
+
{
|
|
148
|
+
"name": "primaryText",
|
|
149
|
+
"type": {
|
|
150
|
+
"text": "ListItemProps['primaryText']"
|
|
151
|
+
},
|
|
152
|
+
"fieldName": "primaryText"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "secondaryText",
|
|
156
|
+
"type": {
|
|
157
|
+
"text": "ListItemProps['secondaryText']"
|
|
158
|
+
},
|
|
159
|
+
"fieldName": "secondaryText"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "metaText",
|
|
163
|
+
"type": {
|
|
164
|
+
"text": "ListItemProps['metaText']"
|
|
165
|
+
},
|
|
166
|
+
"fieldName": "metaText"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "isCompact",
|
|
170
|
+
"fieldName": "isCompact"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "isBold",
|
|
174
|
+
"fieldName": "isBold"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "hasMedia",
|
|
178
|
+
"fieldName": "hasMedia"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
79
181
|
"superclass": {
|
|
80
|
-
"name": "
|
|
81
|
-
"package": "
|
|
182
|
+
"name": "PieElement",
|
|
183
|
+
"package": "@justeattakeaway/pie-webc-core/src/internals/PieElement"
|
|
82
184
|
},
|
|
83
185
|
"tagName": "pie-list-item",
|
|
84
186
|
"customElement": true
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { unsafeCSS as p, html as o, nothing as g } from "lit";
|
|
2
|
+
import { property as n } from "lit/decorators.js";
|
|
3
|
+
import { safeCustomElement as h } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import { P as f } from "./PieElement-Y2VnHR4y.js";
|
|
5
|
+
import { classMap as y } from "lit/directives/class-map.js";
|
|
6
|
+
const m = {
|
|
7
|
+
isCompact: !1,
|
|
8
|
+
isBold: !1,
|
|
9
|
+
hasMedia: !1
|
|
10
|
+
}, v = "*,*:after,*:before{box-sizing:inherit}:host{--list-item-inline-padding: var(--dt-spacing-d);--list-item-alignment: flex-start;display:block}.c-listItem-container{--list-item-block-padding: var(--dt-spacing-d);--list-item-block-end-padding: calc(var(--list-item-block-padding) - var(--list-item-size-modifier));padding-inline-start:var(--list-item-inline-padding);padding-inline-end:var(--list-item-inline-padding);padding-block-start:var(--list-item-block-padding);padding-block-end:var(--list-item-block-end-padding, var(--list-item-block-padding));display:flex;align-items:var(--list-item-alignment);gap:var(--dt-spacing-c);min-height:56px;border-bottom:var(--list-item-border-override, none)}.c-listItem-container:has(.c-listItem-secondaryText){align-items:var(--list-item-alignment);min-height:76px}.c-listItem-container.is-compact{--list-item-block-padding: var(--dt-spacing-c);--list-item-alignment: center;align-items:var(--list-item-alignment);min-height:48px}.c-listItem-container.has-media:has(.c-listItem-primaryText:only-child){--list-item-block-padding: var(--dt-spacing-b)}.c-listItem-text{flex:1}slot[name=trailing]::slotted(*),.c-listItem-metaText{padding-inline-start:var(--dt-spacing-a)}.c-listItem-leading,slot[name=leading],.c-listItem-trailing,slot[name=trailing]{display:contents}.c-listItem-text>*{display:block}.c-listItem-trailing{margin-inline-start:auto}.c-listItem-metaText{display:block;max-width:33.3333333333%}::slotted(.c-pieIcon){--icon-size-override: 24px }.c-listItem-primaryText{font-family:var(--dt-font-body-l-family);font-weight:var(--dt-font-body-l-weight);font-size:calc(var(--dt-font-body-l-size) * 1px);line-height:calc(var(--dt-font-body-l-line-height) * 1px);color:var(--dt-color-content-default)}.c-listItem-container.is-bold .c-listItem-primaryText{font-family:var(--dt-font-body-strong-l-family);font-weight:var(--dt-font-body-strong-l-weight);font-size:calc(var(--dt-font-body-strong-l-size) * 1px);line-height:calc(var(--dt-font-body-strong-l-line-height) * 1px)}.c-listItem-secondaryText,.c-listItem-metaText{font-family:var(--dt-font-body-s-family);font-weight:var(--dt-font-body-s-weight);font-size:calc(var(--dt-font-body-s-size) * 1px);line-height:calc(var(--dt-font-body-s-line-height) * 1px);color:var(--dt-color-content-subdued)}";
|
|
11
|
+
var b = Object.defineProperty, x = Object.getOwnPropertyDescriptor, a = (t, s, r, l) => {
|
|
12
|
+
for (var e = l > 1 ? void 0 : l ? x(s, r) : s, d = t.length - 1, c; d >= 0; d--)
|
|
13
|
+
(c = t[d]) && (e = (l ? c(s, r, e) : c(e)) || e);
|
|
14
|
+
return l && e && b(s, r, e), e;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends f {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.isCompact = m.isCompact, this.isBold = m.isBold, this.hasMedia = m.hasMedia;
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "listitem");
|
|
22
|
+
}
|
|
23
|
+
_renderSecondaryText() {
|
|
24
|
+
const { secondaryText: t } = this;
|
|
25
|
+
return t ? o`<span class="c-listItem-secondaryText">${t}</span>` : g;
|
|
26
|
+
}
|
|
27
|
+
// metaText is another form of trailing content. The component can only ever display either slotted trailing content or the metaText string
|
|
28
|
+
_renderTrailingContent() {
|
|
29
|
+
const { metaText: t } = this;
|
|
30
|
+
return t ? o`<span class="c-listItem-metaText c-listItem-trailing">${t}</span>` : o`<div class="c-listItem-trailing"><slot name="trailing"></slot></div>`;
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
const { primaryText: t } = this, s = {
|
|
34
|
+
"c-listItem-container": !0,
|
|
35
|
+
"is-compact": this.isCompact,
|
|
36
|
+
"is-bold": this.isBold,
|
|
37
|
+
"has-media": this.hasMedia
|
|
38
|
+
};
|
|
39
|
+
return o`
|
|
40
|
+
<div class=${y(s)}>
|
|
41
|
+
<div class="c-listItem-leading">
|
|
42
|
+
<slot name="leading"></slot>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div class="c-listItem-text">
|
|
46
|
+
<span class="c-listItem-primaryText">${t}</span>
|
|
47
|
+
${this._renderSecondaryText()}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
${this._renderTrailingContent()}
|
|
51
|
+
</div>`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
i.styles = p(v);
|
|
55
|
+
a([
|
|
56
|
+
n({ type: String })
|
|
57
|
+
], i.prototype, "primaryText", 2);
|
|
58
|
+
a([
|
|
59
|
+
n({ type: String })
|
|
60
|
+
], i.prototype, "secondaryText", 2);
|
|
61
|
+
a([
|
|
62
|
+
n({ type: String })
|
|
63
|
+
], i.prototype, "metaText", 2);
|
|
64
|
+
a([
|
|
65
|
+
n({ type: Boolean })
|
|
66
|
+
], i.prototype, "isCompact", 2);
|
|
67
|
+
a([
|
|
68
|
+
n({ type: Boolean })
|
|
69
|
+
], i.prototype, "isBold", 2);
|
|
70
|
+
a([
|
|
71
|
+
n({ type: Boolean })
|
|
72
|
+
], i.prototype, "hasMedia", 2);
|
|
73
|
+
i = a([
|
|
74
|
+
h("pie-list-item")
|
|
75
|
+
], i);
|
|
76
|
+
export {
|
|
77
|
+
i as P,
|
|
78
|
+
m as d
|
|
79
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare const PieList_base: import('@justeattakeaway/pie-webc-core').GenericCons
|
|
|
7
7
|
* @tagname pie-list
|
|
8
8
|
*/
|
|
9
9
|
export declare class PieList extends PieList_base implements ListProps {
|
|
10
|
+
connectedCallback(): void;
|
|
10
11
|
render(): import('lit-html').TemplateResult<1>;
|
|
11
12
|
static styles: import('lit').CSSResult;
|
|
12
13
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AAIrF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGxC,cAAc,QAAQ,CAAC;AAEvB,QAAA,MAAM,iBAAiB,aAAa,CAAC;;AAErC;;GAEG;AACH,qBACa,OAAQ,SAAQ,YAAqB,YAAW,SAAS;IAClE,MAAM;IAKN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAChC;CACJ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AAIrF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGxC,cAAc,QAAQ,CAAC;AAEvB,QAAA,MAAM,iBAAiB,aAAa,CAAC;;AAErC;;GAEG;AACH,qBACa,OAAQ,SAAQ,YAAqB,YAAW,SAAS;IAClE,iBAAiB,IAAK,IAAI;IAQ1B,MAAM;IAKN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAChC;CACJ"}
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
e
|
|
9
|
-
let r = e;
|
|
10
|
-
const u = "*,*:after,*:before{box-sizing:inherit}:host{display:block}";
|
|
11
|
-
var b = Object.getOwnPropertyDescriptor, m = (l, o, p, a) => {
|
|
12
|
-
for (var t = a > 1 ? void 0 : a ? b(o, p) : o, s = l.length - 1, n; s >= 0; s--)
|
|
13
|
-
(n = l[s]) && (t = n(t) || t);
|
|
14
|
-
return t;
|
|
1
|
+
import { html as a, unsafeCSS as d } from "lit";
|
|
2
|
+
import { P as m } from "./PieElement-Y2VnHR4y.js";
|
|
3
|
+
import { RtlMixin as c, safeCustomElement as f } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
const p = "*,*:after,*:before{box-sizing:inherit}:host{display:block}:host ::slotted(*:nth-last-child(n+2)){--list-item-size-modifier: 1px;--list-item-border-override: var(--list-item-size-modifier) solid var(--dt-color-divider-default)}";
|
|
5
|
+
var h = Object.getOwnPropertyDescriptor, b = (r, s, n, l) => {
|
|
6
|
+
for (var e = l > 1 ? void 0 : l ? h(s, n) : s, t = r.length - 1, o; t >= 0; t--)
|
|
7
|
+
(o = r[t]) && (e = o(e) || e);
|
|
8
|
+
return e;
|
|
15
9
|
};
|
|
16
|
-
let i = class extends c(
|
|
10
|
+
let i = class extends c(m) {
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "list");
|
|
13
|
+
}
|
|
17
14
|
render() {
|
|
18
|
-
return
|
|
15
|
+
return a`<slot></slot>`;
|
|
19
16
|
}
|
|
20
17
|
};
|
|
21
|
-
i.styles =
|
|
22
|
-
i =
|
|
23
|
-
|
|
18
|
+
i.styles = d(p);
|
|
19
|
+
i = b([
|
|
20
|
+
f("pie-list")
|
|
24
21
|
], i);
|
|
25
22
|
export {
|
|
26
23
|
i as PieList
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
export interface ListItemProps {
|
|
3
|
+
/**
|
|
4
|
+
* **Required:** Provides an overview of the content.
|
|
5
|
+
*/
|
|
6
|
+
primaryText?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Provides optional additional detail.
|
|
9
|
+
*/
|
|
10
|
+
secondaryText?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Provides further optional information about the context, status or attributes of the primary content.
|
|
13
|
+
*/
|
|
14
|
+
metaText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The height of the component is decreased to reduce the vertical space, and used when space needs to be saved.
|
|
17
|
+
*
|
|
18
|
+
* **Note**: Do not use if you require secondary text, or if you want to slot a pie-avatar, pie-thumbnail or Icon with Background component into the list item.
|
|
19
|
+
*/
|
|
20
|
+
isCompact?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Sets the primary text to use a bold font-weight.
|
|
23
|
+
*/
|
|
24
|
+
isBold?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Reduces the block padding to suit larger slotted media (such as a pie-thumbnail).
|
|
27
|
+
*
|
|
28
|
+
* **Note**: This has no effect when `secondaryText` is set, and should not be combined with `isCompact`.
|
|
29
|
+
*/
|
|
30
|
+
hasMedia?: boolean;
|
|
2
31
|
}
|
|
32
|
+
export type DefaultProps = ComponentDefaultProps<ListItemProps, keyof Omit<ListItemProps, 'primaryText' | 'secondaryText' | 'metaText'>>;
|
|
33
|
+
export declare const defaultProps: DefaultProps;
|
|
3
34
|
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/defs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC;AAEzI,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAC"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nothing } from 'lit';
|
|
2
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
2
3
|
import { ListItemProps } from './defs';
|
|
3
4
|
declare const componentSelector = "pie-list-item";
|
|
4
5
|
/**
|
|
5
6
|
* @tagname pie-list-item
|
|
6
7
|
*/
|
|
7
|
-
export declare class PieListItem extends
|
|
8
|
+
export declare class PieListItem extends PieElement implements ListItemProps {
|
|
9
|
+
primaryText: ListItemProps['primaryText'];
|
|
10
|
+
secondaryText: ListItemProps['secondaryText'];
|
|
11
|
+
metaText: ListItemProps['metaText'];
|
|
12
|
+
isCompact: boolean;
|
|
13
|
+
isBold: boolean;
|
|
14
|
+
hasMedia: boolean;
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
_renderSecondaryText(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
17
|
+
_renderTrailingContent(): import('lit-html').TemplateResult<1>;
|
|
18
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
19
|
+
static styles: import('lit').CSSResult;
|
|
8
20
|
}
|
|
9
21
|
declare global {
|
|
10
22
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pie-list-item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAa,MAAM,KAAK,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AAErF,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,QAAQ,CAAC;AAG1D,QAAA,MAAM,iBAAiB,kBAAkB,CAAC;AAE1C;;GAEG;AACH,qBACa,WAAY,SAAQ,UAAW,YAAW,aAAa;IAE5D,WAAW,EAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAG3C,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAG9C,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAGpC,SAAS,UAA0B;IAGnC,MAAM,UAAuB;IAG7B,QAAQ,UAAyB;IAErC,iBAAiB;IAQjB,oBAAoB;IAUpB,sBAAsB;IAStB,MAAM;IA0BN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAAC;KACpC;CACJ"}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
let l = class extends p {
|
|
9
|
-
// component logic
|
|
10
|
-
};
|
|
11
|
-
l = f([
|
|
12
|
-
n("pie-list-item")
|
|
13
|
-
], l);
|
|
1
|
+
import "lit";
|
|
2
|
+
import "lit/decorators.js";
|
|
3
|
+
import "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import "../PieElement-Y2VnHR4y.js";
|
|
5
|
+
import "lit/directives/class-map.js";
|
|
6
|
+
import { P as s } from "../index-D4OaeeiJ.js";
|
|
14
7
|
export {
|
|
15
|
-
|
|
8
|
+
s as PieListItem
|
|
16
9
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as t } from "@lit/react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { P as m } from "../index-D4OaeeiJ.js";
|
|
4
|
+
import { d as c } from "../index-D4OaeeiJ.js";
|
|
5
|
+
const i = t({
|
|
5
6
|
displayName: "PieListItem",
|
|
6
|
-
elementClass:
|
|
7
|
+
elementClass: m,
|
|
7
8
|
react: e,
|
|
8
9
|
tagName: "pie-list-item",
|
|
9
10
|
events: {}
|
|
10
|
-
}),
|
|
11
|
+
}), a = i;
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
+
a as PieListItem,
|
|
14
|
+
c as defaultProps
|
|
13
15
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-list",
|
|
3
3
|
"description": "PIE Design System List built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@justeattakeaway/pie-components-config": "0.21.3",
|
|
41
|
-
"@justeattakeaway/pie-css": "1.
|
|
41
|
+
"@justeattakeaway/pie-css": "1.3.0",
|
|
42
42
|
"@justeattakeaway/pie-monorepo-utils": "0.9.6"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@justeattakeaway/pie-webc-core": "
|
|
45
|
+
"@justeattakeaway/pie-webc-core": "16.0.0"
|
|
46
46
|
},
|
|
47
47
|
"customElements": "custom-elements.json",
|
|
48
48
|
"sideEffects": [
|
|
49
|
-
"dist/*.js"
|
|
49
|
+
"dist/*.js",
|
|
50
|
+
"dist/**/*.js"
|
|
50
51
|
]
|
|
51
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,16 @@ const componentSelector = 'pie-list';
|
|
|
15
15
|
*/
|
|
16
16
|
@safeCustomElement('pie-list')
|
|
17
17
|
export class PieList extends RtlMixin(PieElement) implements ListProps {
|
|
18
|
+
connectedCallback (): void {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
|
|
21
|
+
if (!this.hasAttribute('role')) {
|
|
22
|
+
this.setAttribute('role', 'list');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
render () {
|
|
19
|
-
return html`<
|
|
27
|
+
return html`<slot></slot>`;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
// Renders a `CSSResult` generated from SCSS by Vite
|
package/src/list.scss
CHANGED
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
5
|
+
|
|
6
|
+
::slotted(*:nth-last-child(n+2)) {
|
|
7
|
+
// This allows list-items following other list-items to have 1px stripped off of their padding to account for the added border.
|
|
8
|
+
--list-item-size-modifier: 1px;
|
|
9
|
+
--list-item-border-override: var(--list-item-size-modifier) solid var(--dt-color-divider-default);
|
|
10
|
+
}
|
|
5
11
|
}
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface ListItemProps {
|
|
1
|
+
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
3
|
+
export interface ListItemProps {
|
|
4
|
+
/**
|
|
5
|
+
* **Required:** Provides an overview of the content.
|
|
6
|
+
*/
|
|
7
|
+
primaryText?: string,
|
|
8
|
+
/**
|
|
9
|
+
* Provides optional additional detail.
|
|
10
|
+
*/
|
|
11
|
+
secondaryText?: string,
|
|
12
|
+
/**
|
|
13
|
+
* Provides further optional information about the context, status or attributes of the primary content.
|
|
14
|
+
*/
|
|
15
|
+
metaText?: string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The height of the component is decreased to reduce the vertical space, and used when space needs to be saved.
|
|
19
|
+
*
|
|
20
|
+
* **Note**: Do not use if you require secondary text, or if you want to slot a pie-avatar, pie-thumbnail or Icon with Background component into the list item.
|
|
21
|
+
*/
|
|
22
|
+
isCompact?: boolean
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the primary text to use a bold font-weight.
|
|
26
|
+
*/
|
|
27
|
+
isBold?: boolean
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reduces the block padding to suit larger slotted media (such as a pie-thumbnail).
|
|
31
|
+
*
|
|
32
|
+
* **Note**: This has no effect when `secondaryText` is set, and should not be combined with `isCompact`.
|
|
33
|
+
*/
|
|
34
|
+
hasMedia?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DefaultProps = ComponentDefaultProps<ListItemProps, keyof Omit<ListItemProps, 'primaryText' | 'secondaryText' | 'metaText'>>;
|
|
38
|
+
|
|
39
|
+
export const defaultProps: DefaultProps = {
|
|
40
|
+
isCompact: false,
|
|
41
|
+
isBold: false,
|
|
42
|
+
hasMedia: false,
|
|
43
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { html, nothing, unsafeCSS } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
2
3
|
import { safeCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
3
|
-
import {
|
|
4
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { type ListItemProps, defaultProps } from './defs';
|
|
7
|
+
import styles from './list-item.scss?inline';
|
|
4
8
|
|
|
5
9
|
const componentSelector = 'pie-list-item';
|
|
6
10
|
|
|
@@ -8,8 +12,79 @@ const componentSelector = 'pie-list-item';
|
|
|
8
12
|
* @tagname pie-list-item
|
|
9
13
|
*/
|
|
10
14
|
@safeCustomElement('pie-list-item')
|
|
11
|
-
export class PieListItem extends
|
|
12
|
-
|
|
15
|
+
export class PieListItem extends PieElement implements ListItemProps {
|
|
16
|
+
@property({ type: String })
|
|
17
|
+
primaryText!: ListItemProps['primaryText'];
|
|
18
|
+
|
|
19
|
+
@property({ type: String })
|
|
20
|
+
secondaryText: ListItemProps['secondaryText'];
|
|
21
|
+
|
|
22
|
+
@property({ type: String })
|
|
23
|
+
metaText: ListItemProps['metaText'];
|
|
24
|
+
|
|
25
|
+
@property({ type: Boolean })
|
|
26
|
+
isCompact = defaultProps.isCompact;
|
|
27
|
+
|
|
28
|
+
@property({ type: Boolean })
|
|
29
|
+
isBold = defaultProps.isBold;
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean })
|
|
32
|
+
hasMedia = defaultProps.hasMedia;
|
|
33
|
+
|
|
34
|
+
connectedCallback () {
|
|
35
|
+
super.connectedCallback();
|
|
36
|
+
|
|
37
|
+
if (!this.hasAttribute('role')) {
|
|
38
|
+
this.setAttribute('role', 'listitem');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_renderSecondaryText () {
|
|
43
|
+
const { secondaryText } = this;
|
|
44
|
+
if (secondaryText) {
|
|
45
|
+
return html`<span class="c-listItem-secondaryText">${secondaryText}</span>`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return nothing;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// metaText is another form of trailing content. The component can only ever display either slotted trailing content or the metaText string
|
|
52
|
+
_renderTrailingContent () {
|
|
53
|
+
const { metaText } = this;
|
|
54
|
+
if (metaText) {
|
|
55
|
+
return html`<span class="c-listItem-metaText c-listItem-trailing">${metaText}</span>`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return html`<div class="c-listItem-trailing"><slot name="trailing"></slot></div>`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
render () {
|
|
62
|
+
const { primaryText } = this;
|
|
63
|
+
|
|
64
|
+
const containerClasses = {
|
|
65
|
+
'c-listItem-container': true,
|
|
66
|
+
'is-compact': this.isCompact,
|
|
67
|
+
'is-bold': this.isBold,
|
|
68
|
+
'has-media': this.hasMedia,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return html`
|
|
72
|
+
<div class=${classMap(containerClasses)}>
|
|
73
|
+
<div class="c-listItem-leading">
|
|
74
|
+
<slot name="leading"></slot>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="c-listItem-text">
|
|
78
|
+
<span class="c-listItem-primaryText">${primaryText}</span>
|
|
79
|
+
${this._renderSecondaryText()}
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
${this._renderTrailingContent()}
|
|
83
|
+
</div>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
87
|
+
static styles = unsafeCSS(styles);
|
|
13
88
|
}
|
|
14
89
|
|
|
15
90
|
declare global {
|
|
@@ -1 +1,112 @@
|
|
|
1
1
|
@use '@justeattakeaway/pie-css/scss' as p;
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
// Defined on the host so consumers can override them directly (a declaration on the element
|
|
5
|
+
// takes precedence over these defaults). Setting them on `pie-list` does not work, since the
|
|
6
|
+
// host declaration wins over a value inherited from an ancestor.
|
|
7
|
+
--list-item-inline-padding: var(--dt-spacing-d);
|
|
8
|
+
--list-item-alignment: flex-start;
|
|
9
|
+
|
|
10
|
+
// Using contents to remove the host from the box model so that the internal container element fully acts as the component shell
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Using an internal container div rather than applying directly to the host due to safari and firefox compat issues
|
|
15
|
+
.c-listItem-container {
|
|
16
|
+
--list-item-block-padding: var(--dt-spacing-d);
|
|
17
|
+
|
|
18
|
+
// The list component will add a border to each list-item that follows another. This ensures the height accounts for the added border.
|
|
19
|
+
--list-item-block-end-padding: calc(var(--list-item-block-padding) - var(--list-item-size-modifier));
|
|
20
|
+
|
|
21
|
+
padding-inline-start: var(--list-item-inline-padding);
|
|
22
|
+
padding-inline-end: var(--list-item-inline-padding);
|
|
23
|
+
|
|
24
|
+
padding-block-start: var(--list-item-block-padding);
|
|
25
|
+
padding-block-end: var(--list-item-block-end-padding, var(--list-item-block-padding));
|
|
26
|
+
|
|
27
|
+
// Layout
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: var(--list-item-alignment);
|
|
30
|
+
gap: var(--dt-spacing-c);
|
|
31
|
+
min-height: 56px;
|
|
32
|
+
border-bottom: var(--list-item-border-override, none);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Two lines of text (primary + secondary) need top-alignment so leading/trailing
|
|
36
|
+
// content sits level with the first line, not centred across both lines.
|
|
37
|
+
.c-listItem-container:has(.c-listItem-secondaryText) {
|
|
38
|
+
align-items: var(--list-item-alignment);
|
|
39
|
+
min-height: 76px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.c-listItem-container.is-compact {
|
|
43
|
+
--list-item-block-padding: var(--dt-spacing-c);
|
|
44
|
+
|
|
45
|
+
// Compact items are centre-aligned.
|
|
46
|
+
--list-item-alignment: center;
|
|
47
|
+
align-items: var(--list-item-alignment);
|
|
48
|
+
min-height: 48px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Larger slotted media (e.g. pie-thumbnail) reduces the block padding, but only
|
|
52
|
+
// when the primary text stands alone (`:only-child` == no secondary text). With
|
|
53
|
+
// secondary text the default padding is kept so two lines of text sit correctly.
|
|
54
|
+
.c-listItem-container.has-media:has(.c-listItem-primaryText:only-child) {
|
|
55
|
+
--list-item-block-padding: var(--dt-spacing-b);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.c-listItem-text {
|
|
59
|
+
flex: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
slot[name="trailing"]::slotted(*),
|
|
63
|
+
.c-listItem-metaText {
|
|
64
|
+
// Add a tiny bit of padding to the flex gap to make up 16px total
|
|
65
|
+
padding-inline-start: var(--dt-spacing-a);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Ensures that empty slots do not create a flex-gap in the container.
|
|
69
|
+
.c-listItem-leading, slot[name="leading"],
|
|
70
|
+
.c-listItem-trailing, slot[name="trailing"] {
|
|
71
|
+
display: contents;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Vertically stack the text items
|
|
75
|
+
.c-listItem-text > * {
|
|
76
|
+
display: block;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Flush trailing content to the end of the list-item
|
|
80
|
+
.c-listItem-trailing {
|
|
81
|
+
margin-inline-start: auto;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.c-listItem-metaText {
|
|
85
|
+
display: block;
|
|
86
|
+
max-width: calc(100% / 3);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
::slotted(.c-pieIcon) {
|
|
90
|
+
--icon-size-override: 24px
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// typography
|
|
94
|
+
|
|
95
|
+
.c-listItem-primaryText {
|
|
96
|
+
@include p.font-theme('font-body-l');
|
|
97
|
+
color: var(--dt-color-content-default);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.c-listItem-container.is-bold .c-listItem-primaryText {
|
|
101
|
+
@include p.font-theme('font-body-strong-l');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.c-listItem-secondaryText {
|
|
105
|
+
@include p.font-theme('font-body-s');
|
|
106
|
+
color: var(--dt-color-content-subdued);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.c-listItem-metaText {
|
|
110
|
+
@include p.font-theme('font-body-s');
|
|
111
|
+
color: var(--dt-color-content-subdued);
|
|
112
|
+
}
|