diff --git a/types/wordpress__components/card/body/index.d.ts b/types/wordpress__components/card/body/index.d.ts new file mode 100644 index 0000000000..5fa967c7c4 --- /dev/null +++ b/types/wordpress__components/card/body/index.d.ts @@ -0,0 +1,22 @@ +import Card from '..'; +import { StyledComponent } from '@emotion/styled'; + +declare namespace CardFooter { + interface Props { + /** + * `className` of the container. + */ + className?: string; + + /** + * Add visual shading style. + */ + isShady?: boolean; + + size?: Card.CardSize; + } +} + +declare const CardFooter: StyledComponent; + +export default CardFooter; diff --git a/types/wordpress__components/card/divider/index.d.ts b/types/wordpress__components/card/divider/index.d.ts new file mode 100644 index 0000000000..5b38317bbf --- /dev/null +++ b/types/wordpress__components/card/divider/index.d.ts @@ -0,0 +1,18 @@ +import { ComponentProps } from '@wordpress/element'; +import { HorizontalRule } from '../../primitives'; +import { StyledComponent } from '@emotion/styled'; + +declare namespace CardDivider { + interface Props { + /** + * `className` of the container. + */ + className?: string; + + children?: never; + } +} + +declare const CardDivider: StyledComponent, CardDivider.Props, {}>; + +export default CardDivider; diff --git a/types/wordpress__components/card/footer/index.d.ts b/types/wordpress__components/card/footer/index.d.ts new file mode 100644 index 0000000000..56ebfe5406 --- /dev/null +++ b/types/wordpress__components/card/footer/index.d.ts @@ -0,0 +1,27 @@ +import Card from '..'; +import { StyledComponent } from '@emotion/styled'; + +declare namespace CardFooter { + interface Props { + /** + * `className` of the container. + */ + className?: string; + + /** + * Renders a borderless card. + */ + isBorderless?: boolean; + + /** + * Add visual shading style. + */ + isShady?: boolean; + + size?: Card.CardSize; + } +} + +declare const CardFooter: StyledComponent; + +export default CardFooter; diff --git a/types/wordpress__components/card/header/index.d.ts b/types/wordpress__components/card/header/index.d.ts new file mode 100644 index 0000000000..6d84b89379 --- /dev/null +++ b/types/wordpress__components/card/header/index.d.ts @@ -0,0 +1,27 @@ +import Card from '..'; +import { StyledComponent } from '@emotion/styled'; + +declare namespace CardHeader { + interface Props { + /** + * `className` of the container. + */ + className?: string; + + /** + * Renders a borderless card. + */ + isBorderless?: boolean; + + /** + * Add visual shading style. + */ + isShady?: boolean; + + size?: Card.CardSize; + } +} + +declare const CardHeader: StyledComponent; + +export default CardHeader; diff --git a/types/wordpress__components/card/index.d.ts b/types/wordpress__components/card/index.d.ts new file mode 100644 index 0000000000..88481e297f --- /dev/null +++ b/types/wordpress__components/card/index.d.ts @@ -0,0 +1,32 @@ +import { StyledComponent } from '@emotion/styled'; + +declare namespace Card { + type CardSize = 'large' | 'medium' | 'small' | 'extraSmall'; + interface Props { + /** + * `className` of the container. + */ + className?: string; + + /** + * Renders a borderless card. + */ + isBorderless?: boolean; + + /** + * Renders an elevated card. + */ + isElevated?: boolean; + + /** + * Determines the amount of padding within the card. + * + * @defaultValue "medium" + */ + size?: CardSize; + } +} + +declare const Card: StyledComponent; + +export default Card; diff --git a/types/wordpress__components/card/media/index.d.ts b/types/wordpress__components/card/media/index.d.ts new file mode 100644 index 0000000000..3c93157bd0 --- /dev/null +++ b/types/wordpress__components/card/media/index.d.ts @@ -0,0 +1,14 @@ +import { StyledComponent } from '@emotion/styled'; + +declare namespace CardMedia { + interface Props { + /** + * `className` of the container. + */ + className?: string; + } +} + +declare const CardMedia: StyledComponent; + +export default CardMedia; diff --git a/types/wordpress__components/index.d.ts b/types/wordpress__components/index.d.ts index 076ee71a49..9746b628dd 100644 --- a/types/wordpress__components/index.d.ts +++ b/types/wordpress__components/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for @wordpress/components 8.2 +// Type definitions for @wordpress/components 8.5 // Project: https://github.com/WordPress/gutenberg/tree/master/packages/components/README.md // Definitions by: Derek Sifford // Jon Surrell @@ -15,6 +15,12 @@ export { default as Autocomplete } from './autocomplete'; export { default as BaseControl } from './base-control'; export { default as Button } from './button'; export { default as ButtonGroup } from './button-group'; +export { default as Card } from './card'; +export { default as CardBody } from './card/body'; +export { default as CardDivider } from './card/divider'; +export { default as CardFooter } from './card/footer'; +export { default as CardHeader } from './card/header'; +export { default as CardMedia } from './card/media'; export { default as CheckboxControl } from './checkbox-control'; export { default as ClipboardButton } from './clipboard-button'; export { default as ColorIndicator } from './color-indicator'; diff --git a/types/wordpress__components/package.json b/types/wordpress__components/package.json index 7a05588147..db1b90ea47 100644 --- a/types/wordpress__components/package.json +++ b/types/wordpress__components/package.json @@ -1,6 +1,7 @@ { "private": true, "dependencies": { + "@emotion/styled": "^10.0.0", "re-resizable": "^4.7.1" } } diff --git a/types/wordpress__components/wordpress__components-tests.tsx b/types/wordpress__components/wordpress__components-tests.tsx index 71ebca3621..105fe2b364 100644 --- a/types/wordpress__components/wordpress__components-tests.tsx +++ b/types/wordpress__components/wordpress__components-tests.tsx @@ -87,6 +87,41 @@ interface MyCompleteOption { ; +// +// card +// +I'm a card!; + + I'm a card with props! +; + +// Card is
by default, autoFocus prop is not allowed +// $ExpectError +`div` can't have autoFocus :(; + +// `withComponent` renders a `button` +const ButtonCard = C.Card.withComponent('button'); +`button` _can_ have autoFocus :D; + + + Hello world! +; + + + Hello world! +; + + + Hello world! +; + +// Divider has no children or props except className +// $ExpectError +Hello world!; +// $ExpectError +; +; + // // checkbox-control //