-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pie-checkbox-group): DSW-2182 component skeleton (#1570)
- Loading branch information
Showing
28 changed files
with
370 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@justeattakeaway/pie-checkbox-group": minor | ||
"@justeattakeaway/pie-webc": patch | ||
"pie-storybook": patch | ||
--- | ||
|
||
[Added] - initial pie-checkbox-group files from component generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"pie-monorepo": patch | ||
--- | ||
|
||
[Changed] - update github workflows for new pie-checkbox-group component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { html } from 'lit'; | ||
|
||
/* eslint-disable import/no-duplicates */ | ||
import '@justeattakeaway/pie-checkbox-group'; | ||
import { CheckboxGroupProps } from '@justeattakeaway/pie-checkbox-group'; | ||
/* eslint-enable import/no-duplicates */ | ||
|
||
import { type StoryMeta } from '../types'; | ||
import { createStory } from '../utilities'; | ||
|
||
type CheckboxGroupStoryMeta = StoryMeta<CheckboxGroupProps>; | ||
|
||
const defaultArgs: CheckboxGroupProps = {}; | ||
|
||
const checkboxGroupStoryMeta: CheckboxGroupStoryMeta = { | ||
title: 'Checkbox Group', | ||
component: 'pie-checkbox-group', | ||
argTypes: {}, | ||
args: defaultArgs, | ||
parameters: { | ||
design: { | ||
type: 'figma', | ||
url: '', | ||
}, | ||
}, | ||
}; | ||
|
||
export default checkboxGroupStoryMeta; | ||
|
||
// TODO: remove the eslint-disable rule when props are added | ||
// eslint-disable-next-line no-empty-pattern | ||
const Template = ({}: CheckboxGroupProps) => html` | ||
<pie-checkbox-group></pie-checkbox-group> | ||
`; | ||
|
||
export const Default = createStory<CheckboxGroupProps>(Template, defaultArgs)(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.turbo | ||
dist | ||
node_modules | ||
lit-browsers-report | ||
lit-visual-report | ||
test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<p align="center"> | ||
<img align="center" src="../../../readme_image.png" height="200" alt=""> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://www.npmjs.com/@justeattakeaway/pie-checkbox-group"> | ||
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-checkbox-group.svg"> | ||
</a> | ||
</p> | ||
|
||
# Table of Contents | ||
|
||
1. [Introduction](#pie-checkbox-group) | ||
2. [Installation](#installation) | ||
3. [Importing the component](#importing-the-component) | ||
4. [Peer Dependencies](#peer-dependencies) | ||
5. [Props](#props) | ||
6. [Contributing](#contributing) | ||
|
||
## pie-checkbox-group | ||
|
||
`pie-checkbox-group` is a Web Component built using the Lit library. | ||
|
||
This component can be easily integrated into various frontend frameworks and customized through a set of properties. | ||
|
||
|
||
## Installation | ||
|
||
To install `pie-checkbox-group` in your application, run the following on your command line: | ||
|
||
```bash | ||
# npm | ||
$ npm i @justeattakeaway/pie-checkbox-group | ||
|
||
# yarn | ||
$ yarn add @justeattakeaway/pie-checkbox-group | ||
``` | ||
|
||
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). | ||
|
||
|
||
### Importing the component | ||
|
||
#### JavaScript | ||
```js | ||
// Default – for Native JS Applications, Vue, Angular, Svelte, etc. | ||
import { PieCheckboxGroup } from '@justeattakeaway/pie-checkbox-group'; | ||
|
||
// If you don't need to reference the imported object, you can simply | ||
// import the module which registers the component as a custom element. | ||
import '@justeattakeaway/pie-checkbox-group'; | ||
``` | ||
|
||
#### React | ||
```js | ||
// React | ||
// For React, you will need to import our React-specific component build | ||
// which wraps the web component using @lit/react | ||
import { PieCheckboxGroup } from '@justeattakeaway/pie-checkbox-group/dist/react'; | ||
``` | ||
|
||
> [!NOTE] | ||
> When using the React version of the component, please make sure to also | ||
> include React as a [peer dependency](#peer-dependencies) in your project. | ||
|
||
## Peer Dependencies | ||
|
||
> [!IMPORTANT] | ||
> When using `pie-checkbox-group`, 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. | ||
|
||
## Props | ||
|
||
| Property | Type | Default | Description | | ||
|---|---|---|---| | ||
| - | - | - | - | | ||
|
||
In your markup or JSX, you can then use these to set the properties for the `pie-checkbox-group` component: | ||
|
||
```html | ||
<!-- Native HTML --> | ||
<pie-checkbox-group></pie-checkbox-group> | ||
|
||
<!-- JSX --> | ||
<PieCheckboxGroup></PieCheckboxGroup> | ||
``` | ||
|
||
## Contributing | ||
|
||
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). |
15 changes: 15 additions & 0 deletions
15
packages/components/pie-checkbox-group/custom-elements-manifest.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { moduleFileExtensionsPlugin } from 'cem-plugin-module-file-extensions'; | ||
|
||
export default { | ||
globs: [ | ||
'./src/**/!(*.css).ts', | ||
], | ||
exclude: [ | ||
'**/*.d.ts', | ||
'**/*.d.js', | ||
'**/react.ts', | ||
'**/test/**', | ||
'**/node_modules/**', | ||
], | ||
plugins: [moduleFileExtensionsPlugin()], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare module '*.scss' { | ||
const content: Record<string, string>; | ||
export default content; | ||
} | ||
|
||
declare module '*.scss?inline' { | ||
const content: Record<string, string>; | ||
export default content; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@justeattakeaway/pie-checkbox-group", | ||
"description": "PIE Design System Checkbox Group built using Web Components", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"custom-elements.json", | ||
"src", | ||
"dist", | ||
"**/*.d.ts" | ||
], | ||
"pieMetadata": { | ||
"componentStatus": "alpha" | ||
}, | ||
"scripts": { | ||
"build": "run -T vite build", | ||
"build:react-wrapper": "npx build-react-wrapper", | ||
"create:manifest": "yarn cem analyze --litelement", | ||
"lint:scripts": "run -T eslint .", | ||
"lint:scripts:fix": "yarn lint:scripts --fix", | ||
"lint:style": "run -T stylelint ./src/**/*.{css,scss}", | ||
"lint:style:fix": "yarn lint:style --fix", | ||
"watch": "run -T vite build --watch", | ||
"test": "echo \"Error: no test specified\" && exit 0", | ||
"test:ci": "yarn test", | ||
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts", | ||
"test:browsers:ci": "yarn test:browsers", | ||
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_CHECKBOX_GROUP} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts", | ||
"test:visual:ci": "yarn test:visual", | ||
"test:browsers-setup": "npx playwright-lit-setup" | ||
}, | ||
"author": "Just Eat Takeaway.com - Design System Team", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@custom-elements-manifest/analyzer": "0.9.0", | ||
"@justeattakeaway/pie-components-config": "0.16.0", | ||
"cem-plugin-module-file-extensions": "0.0.5" | ||
}, | ||
"dependencies": { | ||
"@justeattakeaway/pie-webc-core": "0.23.0" | ||
}, | ||
"volta": { | ||
"extends": "../../../package.json" | ||
}, | ||
"customElements": "custom-elements.json", | ||
"sideEffects": [ | ||
"dist/*.js" | ||
] | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/components/pie-checkbox-group/playwright-lit-visual.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineConfig } from '@sand4rt/experimental-ct-web'; | ||
import { getPlaywrightVisualConfig } from '@justeattakeaway/pie-components-config'; | ||
|
||
export default defineConfig(getPlaywrightVisualConfig()); |
4 changes: 4 additions & 0 deletions
4
packages/components/pie-checkbox-group/playwright-lit.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { defineConfig } from '@sand4rt/experimental-ct-web'; | ||
import { getPlaywrightConfig } from '@justeattakeaway/pie-components-config'; | ||
|
||
export default defineConfig(getPlaywrightConfig()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@use '@justeattakeaway/pie-css/scss' as p; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
/** | ||
* TODO: Verify if ReactBaseType can be set as a more specific React interface | ||
* Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces | ||
* Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>` | ||
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829 | ||
*/ | ||
export type ReactBaseType = React.HTMLAttributes<HTMLElement> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// TODO - please remove the eslint disable comment below when you add props to this interface | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface CheckboxGroupProps {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { LitElement, html, unsafeCSS } from 'lit'; | ||
import { RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core'; | ||
|
||
import styles from './checkbox-group.scss?inline'; | ||
import { CheckboxGroupProps } from './defs'; | ||
|
||
// Valid values available to consumers | ||
export * from './defs'; | ||
|
||
const componentSelector = 'pie-checkbox-group'; | ||
|
||
/** | ||
* @tagname pie-checkbox-group | ||
*/ | ||
export class PieCheckboxGroup extends RtlMixin(LitElement) implements CheckboxGroupProps { | ||
render () { | ||
return html`<h1 data-test-id="pie-checkbox-group">Hello world!</h1>`; | ||
} | ||
|
||
// Renders a `CSSResult` generated from SCSS by Vite | ||
static styles = unsafeCSS(styles); | ||
} | ||
|
||
defineCustomElement(componentSelector, PieCheckboxGroup); | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
[componentSelector]: PieCheckboxGroup; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/components/pie-checkbox-group/test/accessibility/pie-checkbox-group.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import { test, expect } from '@justeattakeaway/pie-webc-testing/src/playwright/webc-fixtures.ts'; | ||
import { PieCheckboxGroup, CheckboxGroupProps } from '../../src/index.ts'; | ||
|
||
test.describe('PieCheckboxGroup - Accessibility tests', () => { | ||
test('a11y - should test the PieCheckboxGroup component WCAG compliance', async ({ makeAxeBuilder, mount }) => { | ||
await mount( | ||
PieCheckboxGroup, | ||
{ | ||
props: {} as CheckboxGroupProps, | ||
}, | ||
); | ||
|
||
const results = await makeAxeBuilder().analyze(); | ||
|
||
expect(results.violations).toEqual([]); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/components/pie-checkbox-group/test/component/pie-checkbox-group.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
import { test, expect } from '@sand4rt/experimental-ct-web'; | ||
import { PieCheckboxGroup, CheckboxGroupProps } from '../../src/index.ts'; | ||
|
||
const componentSelector = '[data-test-id="pie-checkbox-group"]'; | ||
|
||
test.describe('PieCheckboxGroup - Component tests', () => { | ||
test('should render successfully', async ({ mount, page }) => { | ||
// Arrange | ||
await mount(PieCheckboxGroup, { | ||
props: {} as CheckboxGroupProps, | ||
}); | ||
|
||
// Act | ||
const checkboxGroup = page.locator(componentSelector); | ||
|
||
// Assert | ||
expect(checkboxGroup).toBeVisible(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/components/pie-checkbox-group/test/visual/pie-checkbox-group.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import { test } from '@sand4rt/experimental-ct-web'; | ||
import percySnapshot from '@percy/playwright'; | ||
import { PieCheckboxGroup, CheckboxGroupProps } from '../../src/index.ts'; | ||
|
||
test.describe('PieCheckboxGroup - Visual tests`', () => { | ||
test('should display the PieCheckboxGroup component successfully', async ({ page, mount }) => { | ||
await mount(PieCheckboxGroup, { | ||
props: {} as CheckboxGroupProps, | ||
}); | ||
|
||
await percySnapshot(page, 'PieCheckboxGroup - Visual Test'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@justeattakeaway/pie-components-config/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": ".", | ||
}, | ||
"include": ["src/**/*.ts","./declaration.d.ts", "test/**/*.ts", "playwright-lit-visual.config.ts", "playwright-lit.config.ts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import viteConfig from '@justeattakeaway/pie-components-config/vite.config'; | ||
|
||
export default viteConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@justeattakeaway/pie-checkbox-group'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@justeattakeaway/pie-checkbox-group'; |
Oops, something went wrong.