Skip to content

Commit

Permalink
Merge branch 'main' into dsw-1624-pie-webc-docs-for-consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
leksaBoiko authored Jul 10, 2024
2 parents fc6a3d2 + ff65968 commit 6babb9c
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 54 deletions.
22 changes: 22 additions & 0 deletions .changeset/curly-mirrors-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@justeattakeaway/pie-webc-core": minor
"@justeattakeaway/pie-assistive-text": patch
"@justeattakeaway/pie-cookie-banner": patch
"@justeattakeaway/pie-notification": patch
"@justeattakeaway/pie-icon-button": patch
"@justeattakeaway/pie-checkbox": patch
"@justeattakeaway/pie-textarea": patch
"@justeattakeaway/pie-divider": patch
"@justeattakeaway/pie-spinner": patch
"@justeattakeaway/pie-button": patch
"@justeattakeaway/pie-switch": patch
"@justeattakeaway/pie-modal": patch
"@justeattakeaway/pie-card": patch
"@justeattakeaway/pie-chip": patch
"@justeattakeaway/pie-link": patch
"@justeattakeaway/pie-tag": patch
---

[Changed] - Update default props generic helper type to include all props by default
[Changed] - Naming of generic type
[Added] - JSDoc comment
4 changes: 2 additions & 2 deletions packages/components/pie-assistive-text/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['default', 'error', 'success'] as const;

Expand All @@ -9,7 +9,7 @@ export interface AssistiveTextProps {
variant?: typeof variants[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<AssistiveTextProps, 'variant'>;
export type DefaultProps = ComponentDefaultProps<AssistiveTextProps>;

export const defaultProps: DefaultProps = {
variant: 'default',
Expand Down
4 changes: 2 additions & 2 deletions packages/components/pie-button/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const sizes = ['xsmall', 'small-productive', 'small-expressive', 'medium', 'large'] as const;
export const responsiveSizes = ['productive', 'expressive'] as const;
Expand Down Expand Up @@ -101,7 +101,7 @@ export interface ButtonProps {
responsiveSize?: typeof responsiveSizes[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<ButtonProps, 'size' | 'type' | 'variant' | 'iconPlacement' | 'disabled' | 'isLoading' | 'isFullWidth' | 'isResponsive'>;
export type DefaultProps = ComponentDefaultProps<ButtonProps, 'size' | 'type' | 'variant' | 'iconPlacement' | 'disabled' | 'isFullWidth' | 'isLoading' | 'isResponsive'>;

export const defaultProps: DefaultProps = {
size: 'medium',
Expand Down
10 changes: 5 additions & 5 deletions packages/components/pie-card/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['default', 'outline', 'inverse', 'outline-inverse'] as const;
export const tags = ['a', 'button'] as const;
Expand Down Expand Up @@ -51,7 +51,7 @@ export interface CardProps {
/**
* What HTML element the card should be such as `a` or `button`.
*/
tag?: typeof tags[number];
tag?: typeof tags[number];

/**
* Sets the padding of the card. Can be either a single value or two values
Expand All @@ -61,11 +61,11 @@ export interface CardProps {
padding?: PaddingValue | `${PaddingValue},${PaddingValue}`;
}

export type DefaultProps = ComponentDefaultPropsGeneric<CardProps, 'tag' | 'variant' | 'disabled' | 'isDraggable'>;
export type DefaultProps = ComponentDefaultProps<CardProps, 'disabled' | 'variant' | 'isDraggable' | 'tag'>;

export const defaultProps: DefaultProps = {
tag: 'button',
variant: 'default',
disabled: false,
variant: 'default',
isDraggable: false,
tag: 'button',
};
9 changes: 5 additions & 4 deletions packages/components/pie-checkbox/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const statusTypes = ['default', 'success', 'error'] as const;

Expand Down Expand Up @@ -64,15 +64,16 @@ export interface CheckboxProps {
status?: typeof statusTypes[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked' | 'status'>;
export type DefaultProps = ComponentDefaultProps<CheckboxProps, keyof Omit<CheckboxProps, 'label' | 'name' | 'aria' | 'assistiveText'>>;

export const defaultProps: DefaultProps = {
// a default value for the html <input type="checkbox" /> value attribute.
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value
value: 'on',
required: false,
disabled: false,
defaultChecked: false,
indeterminate: false,
checked: false,
indeterminate: false,
required: false,
status: 'default',
};
4 changes: 2 additions & 2 deletions packages/components/pie-chip/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['default', 'outline', 'ghost'] as const;

Expand Down Expand Up @@ -43,7 +43,7 @@ export interface ChipProps {

export const ON_CHIP_CLOSE_EVENT = 'pie-chip-close';

export type DefaultProps = ComponentDefaultPropsGeneric<ChipProps, 'variant' | 'disabled' | 'isSelected' | 'isLoading' | 'isDismissible'>;
export type DefaultProps = ComponentDefaultProps<ChipProps, keyof Omit<ChipProps, 'aria'>>;

export const defaultProps: DefaultProps = {
variant: 'default',
Expand Down
5 changes: 2 additions & 3 deletions packages/components/pie-cookie-banner/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

import {
TemplateResult,
Expand Down Expand Up @@ -143,5 +143,4 @@ export interface CustomTagEnhancers {
[key: string]: (tagContent: string) => TemplateResult;
}

export type DefaultProps = ComponentDefaultPropsGeneric<CookieBannerProps, 'hasPrimaryActionsOnly' | 'defaultPreferences' | 'locale' | 'cookieStatementLink' | 'cookieTechnologiesLink'>;

export type DefaultProps = ComponentDefaultProps<CookieBannerProps>;
8 changes: 4 additions & 4 deletions packages/components/pie-divider/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['default', 'inverse'] as const;
export const orientations = ['horizontal', 'vertical'] as const;

export interface DividerProps {
/**
* What style variant the divider should be such as default or vertical.
* What style variant the divider should be such as default or inverse.
*/
variant?: typeof variants[number];
/**
* What orientation the divider should be such as horizontal or inverse.
* What orientation the divider should be such as horizontal or vertical.
*/
orientation?: typeof orientations[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<DividerProps, 'variant' | 'orientation'>;
export type DefaultProps = ComponentDefaultProps<DividerProps>;

export const defaultProps: DefaultProps = {
variant: 'default',
Expand Down
4 changes: 2 additions & 2 deletions packages/components/pie-icon-button/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const sizes = ['xsmall', 'small', 'medium', 'large'] as const;
export const variants = ['primary', 'secondary', 'outline', 'ghost',
Expand Down Expand Up @@ -27,7 +27,7 @@ export interface IconButtonProps {
isLoading?: boolean;
}

export type DefaultProps = ComponentDefaultPropsGeneric<IconButtonProps, 'size' | 'variant' | 'disabled' | 'disabled' | 'isLoading'>;
export type DefaultProps = ComponentDefaultProps<IconButtonProps>;

export const defaultProps: DefaultProps = {
size: 'medium',
Expand Down
6 changes: 3 additions & 3 deletions packages/components/pie-link/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['default', 'high-visibility', 'inverse'] as const;
export const sizes = ['small', 'medium'] as const;
Expand Down Expand Up @@ -68,16 +68,16 @@ export interface LinkProps {
type?: typeof buttonTypes[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<LinkProps, 'tag' | 'variant' | 'size' | 'underline' | 'iconPlacement' | 'isBold' | 'isStandalone' | 'hasVisited' | 'type'>;
export type DefaultProps = ComponentDefaultProps<LinkProps, keyof Omit<LinkProps, 'aria' | 'href' | 'target' | 'rel'>>;

export const defaultProps: DefaultProps = {
tag: 'a',
variant: 'default',
size: 'medium',
underline: 'default',
iconPlacement: 'leading',
isBold: false,
isStandalone: false,
hasVisited: false,
iconPlacement: 'leading',
type: 'submit',
};
18 changes: 9 additions & 9 deletions packages/components/pie-modal/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';

Expand Down Expand Up @@ -93,6 +93,11 @@ export type ModalProps = {
*/
leadingAction?: ActionProps;

/**
* The supporting action configuration for the modal.
*/
supportingAction?: ActionProps;

/*
* The position of the modal; this controls where it will appear on the page.
*/
Expand All @@ -107,11 +112,6 @@ export type ModalProps = {
* The size of the modal; this controls how wide it will appear on the page.
*/
size?: typeof sizes[number];

/**
* The supporting action configuration for the modal.
*/
supportingAction?: ActionProps;
};

/**
Expand Down Expand Up @@ -151,17 +151,17 @@ export const ON_MODAL_SUPPORTING_ACTION_CLICK = 'pie-modal-supporting-action-cli

export type ModalActionType = 'leading' | 'supporting';

export type DefaultProps = ComponentDefaultPropsGeneric<ModalProps, 'headingLevel'|'hasBackButton'|'hasStackedActions'|'isDismissible'|'isFooterPinned'|'isFullWidthBelowMid'|'isLoading'|'isOpen'|'position'|'size'>;
export type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingAction' | 'supportingAction' | 'returnFocusAfterCloseSelector'>>;

export const defaultProps: DefaultProps = {
headingLevel: 'h2',
hasBackButton: false,
hasStackedActions: false,
headingLevel: 'h2',
isOpen: false,
isDismissible: false,
isFooterPinned: true,
isFullWidthBelowMid: false,
isLoading: false,
isOpen: false,
position: 'center',
size: 'medium',
};
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ test.describe('Prop: `supportingAction`', () => {
const modal = page.locator(componentFooterSelector);
await expect.soft(modal).not.toBeVisible();

await percySnapshot(page, 'Modal displays footer');
await percySnapshot(page, 'Modal hides footer if there is no leadingAction');
});

test.describe('when prop is provided but the optional child properties of `supportingAction` are not provided', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/components/pie-notification/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['neutral', 'neutral-alternative', 'info', 'success', 'warning', 'error'] as const;
export const headingLevels = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;
Expand Down Expand Up @@ -116,15 +116,15 @@ export const ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT = `${componentSelector}-
*/
export const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT = `${componentSelector}-supporting-action-click`;

export type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
export type DefaultProps = ComponentDefaultProps<NotificationProps, keyof Omit<NotificationProps, 'heading' | 'aria' | 'leadingAction' | 'supportingAction'>>;

export const defaultProps: DefaultProps = {
isOpen: true,
variant: 'neutral',
position: 'inline-content',
isDismissible: true,
isCompact: false,
headingLevel: 'h2',
hideIcon: false,
isOpen: true,
hasStackedActions: false,
};
5 changes: 3 additions & 2 deletions packages/components/pie-spinner/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const sizes = ['xsmall', 'small', 'medium', 'large', 'xlarge'] as const;
export const variants = ['brand', 'secondary', 'inverse'] as const;
Expand All @@ -22,7 +22,8 @@ export interface SpinnerProps {
variant?: typeof variants[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<SpinnerProps, 'size' | 'variant'>;
export type DefaultProps = ComponentDefaultProps<SpinnerProps, keyof Omit<SpinnerProps, 'aria'>>;

export const defaultProps: DefaultProps = {
size: 'medium',
variant: 'brand',
Expand Down
9 changes: 5 additions & 4 deletions packages/components/pie-switch/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const labelPlacements = ['leading', 'trailing'] as const;

Expand Down Expand Up @@ -51,11 +51,12 @@ export interface SwitchProps {
*/
export const ON_SWITCH_CHANGED_EVENT = 'change';

export type DefaultProps = ComponentDefaultPropsGeneric<SwitchProps, 'labelPlacement' | 'checked' | 'required' | 'value' | 'disabled'>;
export type DefaultProps = ComponentDefaultProps<SwitchProps, keyof Omit<SwitchProps, 'aria' | 'label' | 'name'>>;

export const defaultProps: DefaultProps = {
labelPlacement: 'leading',
checked: false,
required: false,
value: 'on',
disabled: false,
value: 'on',
labelPlacement: 'leading',
};
6 changes: 3 additions & 3 deletions packages/components/pie-tag/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const variants = ['neutral-alternative', 'neutral', 'outline', 'ghost', 'blue', 'green', 'yellow', 'red', 'brand'] as const;
export const sizes = ['small', 'large'] as const;
Expand All @@ -25,11 +25,11 @@ export interface TagProps {
size?: typeof sizes[number];
}

export type DefaultProps = ComponentDefaultPropsGeneric<TagProps, 'variant' | 'size' | 'isStrong' | 'isDimmed'>;
export type DefaultProps = ComponentDefaultProps<TagProps>;

export const defaultProps: DefaultProps = {
variant: 'neutral',
size: 'large',
isStrong: false,
isDimmed: false,
size: 'large',
};
4 changes: 2 additions & 2 deletions packages/components/pie-text-input/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const types = ['text', 'number', 'password', 'url', 'email', 'tel'] as const;
export const inputModes = ['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search'] as const;
Expand Down Expand Up @@ -115,7 +115,7 @@ export interface TextInputProps {
/**
* The default values for the `TextInputProps` that are required (i.e. they have a fallback value in the component).
*/
type DefaultProps = ComponentDefaultPropsGeneric<TextInputProps, 'type' | 'value' | 'size' | 'status'>;
type DefaultProps = ComponentDefaultProps<TextInputProps, 'type' | 'value' | 'size' | 'status'>;

/**
* Default values for optional properties that have default fallback values in the component.
Expand Down
5 changes: 3 additions & 2 deletions packages/components/pie-textarea/src/defs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';

export const sizes = ['small', 'medium', 'large'] as const;

Expand All @@ -17,11 +17,12 @@ export interface TextareaProps {
/**
* The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component).
*/
type DefaultProps = ComponentDefaultPropsGeneric<TextareaProps, 'size'>;
type DefaultProps = ComponentDefaultProps<TextareaProps>;

/**
* Default values for optional properties that have default fallback values in the component.
*/
export const defaultProps: DefaultProps = {
disabled: false,
size: 'medium',
};
Loading

0 comments on commit 6babb9c

Please sign in to comment.