@justeattakeaway/pie-button 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +6 -0
- package/README.md +52 -44
- package/dist/react.js +209 -223
- package/dist/types/packages/components/pie-button/src/defs.d.ts +25 -3
- package/dist/types/packages/components/pie-button/src/defs.d.ts.map +1 -1
- package/dist/types/packages/components/pie-button/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/defs.ts +25 -3
- package/src/index.ts +0 -1
- package/test/accessibility/pie-button.spec.ts +7 -8
- package/test/component/pie-button.spec.ts +7 -4
- package/vite.config.js +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[2:38:37 PM] @custom-elements-manifest/analyzer: Created new manifest.
|
|
2
2
|
react wrapper has been added!
|
|
3
|
-
[36mvite v4.
|
|
3
|
+
[36mvite v4.3.9 [32mbuilding for production...[36m[39m
|
|
4
4
|
transforming...
|
|
5
5
|
[32m✓[39m 28 modules transformed.
|
|
6
6
|
rendering chunks...
|
|
7
7
|
computing gzip size...
|
|
8
8
|
[2mdist/[22m[36mindex.js [39m[1m[2m 7.96 kB[22m[1m[22m[2m │ gzip: 2.10 kB[22m
|
|
9
|
-
[2mdist/[22m[36mreact.js [39m[1m[2m59.
|
|
9
|
+
[2mdist/[22m[36mreact.js [39m[1m[2m59.01 kB[22m[1m[22m[2m │ gzip: 15.91 kB[22m
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
-
[32m
|
|
13
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
12
|
+
[32m✓ built in 22.93s[39m
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 21054ms.
|
|
14
14
|
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Changed] - Updated defs to use different array type syntax ([#566](https://github.com/justeattakeaway/pie/pull/566)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
8
|
+
|
|
3
9
|
## 0.16.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -17,54 +17,71 @@
|
|
|
17
17
|
- [HTML example](#html)
|
|
18
18
|
- [Vue example (using Nuxt 3)](#vue-templates-using-nuxt-3)
|
|
19
19
|
- [React example (using Next 13)](#react-templates-using-next-13)
|
|
20
|
-
5. [
|
|
21
|
-
6. [Testing](#testing)
|
|
20
|
+
5. [Testing](#testing)
|
|
22
21
|
- [Browser Tests](#browser-tests)
|
|
23
22
|
- [Visual Tests](#visual-tests)
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
## `pie-button`
|
|
27
26
|
|
|
28
|
-
`pie-button` is a Web Component built using the Lit library. It offers a simple and accessible button component for web applications.
|
|
27
|
+
`pie-button` is a Web Component built using the Lit library. It offers a simple and accessible button component for web applications.
|
|
28
|
+
|
|
29
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
29
30
|
|
|
30
31
|
## Local development
|
|
31
32
|
|
|
32
|
-
Install dependencies
|
|
33
|
-
|
|
33
|
+
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
34
36
|
yarn
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
cd packages/components/pie-button
|
|
40
|
-
yarn build
|
|
41
|
-
```
|
|
39
|
+
To build the `pie-button` package, run the following command:
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
```bash
|
|
42
|
+
yarn build --filter=pie-button
|
|
44
43
|
```
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
yarn watch --filter=pie-button
|
|
49
|
+
|
|
50
|
+
# in a separate terminal tab, run
|
|
51
|
+
yarn dev --filter=pie-storybook
|
|
46
52
|
```
|
|
47
53
|
|
|
48
54
|
### Importing the component
|
|
49
55
|
|
|
50
56
|
```js
|
|
51
|
-
//
|
|
57
|
+
// Default – for Native JS Applications, Vue, Angular, Svelte etc.
|
|
52
58
|
import { PieButton } from '@justeattakeaway/pie-button';
|
|
53
59
|
|
|
54
|
-
//
|
|
60
|
+
// React
|
|
61
|
+
// For React, you will need to import our React specific component build
|
|
62
|
+
// Which wraps the web component using the @lit-labs/react package
|
|
55
63
|
import { PieButton } from '@justeattakeaway/pie-button/dist/react';
|
|
56
64
|
```
|
|
57
65
|
|
|
58
66
|
## Props
|
|
59
67
|
|
|
60
|
-
| Property | Type | Default | Description
|
|
61
|
-
|
|
62
|
-
| size | `String` | `medium` | Size of the button, one of `buttonSizes` |
|
|
63
|
-
| type | `String` | `submit` | Type of the button, one of `buttonTypes` |
|
|
64
|
-
| variant | `String` | `primary` | Variant of the button, one of `buttonVariants` |
|
|
65
|
-
| disabled | `Boolean` | `false` | If `true`, disables the button.
|
|
66
|
-
| isFullWidth | `Boolean` | `false` | If `true`, sets the button width to 100% of it's container.
|
|
68
|
+
| Property | Type | Default | Description |
|
|
69
|
+
|-------------|-----------|-----------------|----------------------------------------------------------------------------------------------------------------|
|
|
70
|
+
| size | `String` | `medium` | Size of the button, one of `buttonSizes` – `xsmall`, `small-expressive`, `small-productive`, `medium`, `large` |
|
|
71
|
+
| type | `String` | `submit` | Type of the button, one of `buttonTypes` – `submit`, `button`, `reset`, `menu` |
|
|
72
|
+
| variant | `String` | `primary` | Variant of the button, one of `buttonVariants`– `primary`, `secondary`, `outline`, `ghost` |
|
|
73
|
+
| disabled | `Boolean` | `false` | If `true`, disables the button. |
|
|
74
|
+
| isFullWidth | `Boolean` | `false` | If `true`, sets the button width to 100% of it's container. |
|
|
67
75
|
|
|
76
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-button` component:
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<!-- Native HTML -->
|
|
80
|
+
<pie-button size='medium' type='button' variant='primary'>Click me!</pie-button>
|
|
81
|
+
|
|
82
|
+
<!-- JSX -->
|
|
83
|
+
<PieButton size='medium' type='button' variant='primary'>Click me!</PieButton>
|
|
84
|
+
```
|
|
68
85
|
|
|
69
86
|
## Events
|
|
70
87
|
|
|
@@ -73,67 +90,58 @@ This component does not use any custom event handlers. In order to add event lis
|
|
|
73
90
|
For example, to add a click handler in various templates:
|
|
74
91
|
|
|
75
92
|
### HTML
|
|
93
|
+
|
|
76
94
|
```html
|
|
77
95
|
<!-- Other attributes omitted for clarity -->
|
|
78
96
|
<pie-button onclick="e => console.log(e)">Click me!</pie-button>
|
|
79
97
|
```
|
|
80
98
|
|
|
81
99
|
### Vue templates (using Nuxt 3)
|
|
100
|
+
|
|
82
101
|
```html
|
|
83
102
|
<!-- Other attributes omitted for clarity -->
|
|
84
103
|
<pie-button @click="handleClick">Click me!</pie-button>
|
|
85
104
|
```
|
|
86
105
|
|
|
87
106
|
### React templates (using Next 13)
|
|
107
|
+
|
|
88
108
|
```html
|
|
89
109
|
<!-- Other attributes omitted for clarity -->
|
|
90
110
|
<PieButton onClick={handleClick}>increment</PieButton>
|
|
91
111
|
|
|
92
112
|
```
|
|
93
113
|
|
|
94
|
-
## TypeScript Type Exports
|
|
95
|
-
|
|
96
|
-
For TypeScript projects, we export one interface for the button properties: `ButtonProps`. This contains three props `buttonSizes`, `buttonTypes`, and `buttonVariants`. You can import and use these types to set the corresponding property values for the `pie-button` component. This ensures better type safety and autocompletion in your project.
|
|
97
|
-
|
|
98
|
-
Here's an example of how to import and use the enums in a TypeScript project:
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
import { ButtonProps } from '@justeattakeaway/pie-button';
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
In your markup or JSX, you can then use these variables to set the properties for the pie-button component:
|
|
105
|
-
|
|
106
|
-
```html
|
|
107
|
-
<PieButton size='medium' type='button' variant='primary'>Click me!</PieButton>
|
|
108
|
-
```
|
|
109
114
|
|
|
110
115
|
## Testing
|
|
111
116
|
|
|
112
117
|
### Browser tests
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
To run the browser tests, run the following command from the root of the monorepo:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
116
122
|
yarn test:browsers --filter=pie-button
|
|
117
123
|
```
|
|
118
124
|
|
|
119
125
|
### Visual tests
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
123
130
|
yarn test:visual --filter=pie-button
|
|
124
131
|
```
|
|
125
132
|
|
|
126
133
|
Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
|
|
127
134
|
|
|
128
|
-
Setup via bash
|
|
135
|
+
#### Setup via bash
|
|
129
136
|
|
|
130
|
-
```
|
|
137
|
+
```bash
|
|
131
138
|
export PERCY_TOKEN_PIE_BUTTON=abcde
|
|
132
139
|
```
|
|
133
140
|
|
|
134
|
-
Setup via package.json
|
|
141
|
+
#### Setup via package.json
|
|
135
142
|
|
|
136
143
|
Under scripts `test:visual` replace the environment variable with the below:
|
|
137
144
|
|
|
138
|
-
```
|
|
145
|
+
```bash
|
|
139
146
|
PERCY_TOKEN_PIE_BUTTON=abcde
|
|
147
|
+
```
|