diff --git a/packages/react/src/components/Card/CardWrap.js b/packages/react/src/components/Card/CardWrap.js index 863a5d58..b2a46766 100644 --- a/packages/react/src/components/Card/CardWrap.js +++ b/packages/react/src/components/Card/CardWrap.js @@ -78,29 +78,34 @@ const Element = styled('a')( contrast && (!color || !backgroundColor) && hoverStyle ) -const CardWrap = forwardRef(({ href, rel, target, ...restProps }, ref) => { - const { - state: { backgroundColor, color, title }, - props: { size: $cardSize } - } = useContext(GlobalContext) - - return createElement(Element, { - ...(restProps.as === 'a' ? { href, rel, target } : undefined), - ...restProps, - backgroundColor, - $cardSize, - color, - ref, - title - }) -}) +const CardWrap = forwardRef( + ( + { + href, + rel = 'noopener noreferrer', + target = '_blank', + as = 'a', + ...restProps + }, + ref + ) => { + const { + state: { backgroundColor, color, title }, + props: { size: $cardSize } + } = useContext(GlobalContext) + + return createElement(Element, { + ...(as === 'a' ? { href, rel, target } : undefined), + ...restProps, + backgroundColor, + $cardSize, + color, + ref, + title + }) + } +) CardWrap.displayName = 'CardWrap' -CardWrap.defaultProps = { - as: 'a', - rel: 'noopener noreferrer', - target: '_blank' -} - export default CardWrap diff --git a/packages/react/src/index.js b/packages/react/src/index.js index 6fdb78a2..2b4f012f 100644 --- a/packages/react/src/index.js +++ b/packages/react/src/index.js @@ -209,25 +209,40 @@ microlink.io/${error.code.toLowerCase()} ) } -const Microlink = props => ( - {otherProps => } +const Microlink = ({ + className = '', + apiKey = undefined, + autoPlay = true, + controls = true, + direction = 'ltr', + lazy = true, + loop = true, + media = ['iframe', 'video', 'audio', 'image', 'logo'], + fetchData = true, + muted = true, + playsInline = true, + size = 'normal', + ...props +}) => ( + + {otherProps => } + ) -Microlink.defaultProps = { - className: '', - apiKey: undefined, - autoPlay: true, - controls: true, - direction: 'ltr', - lazy: true, - loop: true, - media: ['iframe', 'video', 'audio', 'image', 'logo'], - fetchData: true, - muted: true, - playsInline: true, - size: 'normal' -} - Microlink.propTypes = { apiKey: PropTypes.string, autoPlay: PropTypes.bool, diff --git a/packages/react/test/snapshots/build.mjs.md b/packages/react/test/snapshots/build.mjs.md index 2264e9ae..684ce733 100644 --- a/packages/react/test/snapshots/build.mjs.md +++ b/packages/react/test/snapshots/build.mjs.md @@ -10,22 +10,7 @@ Generated by [AVA](https://avajs.dev). `{␊ fetchFromApi: [Getter],␊ - default: [Function: Microlink] {␊ - defaultProps: {␊ - className: '',␊ - apiKey: undefined,␊ - autoPlay: true,␊ - controls: true,␊ - direction: 'ltr',␊ - lazy: true,␊ - loop: true,␊ - media: [Array],␊ - fetchData: true,␊ - muted: true,␊ - playsInline: true,␊ - size: 'normal'␊ - }␊ - },␊ + default: [Function: Microlink],␊ getApiUrl: [Function: getApiUrl],␊ imageProxy: [Function: imageProxy]␊ }` @@ -35,22 +20,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `[Module: null prototype] {␊ - default: [Function: Microlink] {␊ - defaultProps: {␊ - className: '',␊ - apiKey: undefined,␊ - autoPlay: true,␊ - controls: true,␊ - direction: 'ltr',␊ - lazy: true,␊ - loop: true,␊ - media: [Array],␊ - fetchData: true,␊ - muted: true,␊ - playsInline: true,␊ - size: 'normal'␊ - }␊ - },␊ + default: [Function: Microlink],␊ fetchFromApi: [AsyncFunction: fetchFromApi],␊ getApiUrl: [Function: getApiUrl],␊ imageProxy: [Function: imageProxy]␊ diff --git a/packages/react/test/snapshots/build.mjs.snap b/packages/react/test/snapshots/build.mjs.snap index 2e4c9284..a3380034 100644 Binary files a/packages/react/test/snapshots/build.mjs.snap and b/packages/react/test/snapshots/build.mjs.snap differ