@popsure/dirty-swan 0.44.0 → 0.45.0-alpha
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/dist/cjs/index.js +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/button/index.d.ts +9 -4
- package/dist/cjs/lib/components/button/index.stories.d.ts +10 -2
- package/dist/esm/components/button/index.js +3 -2
- package/dist/esm/components/button/index.js.map +1 -1
- package/dist/esm/components/button/index.stories.js +16 -3
- package/dist/esm/components/button/index.stories.js.map +1 -1
- package/dist/esm/components/card/index.js.map +1 -1
- package/dist/esm/components/cards/index.js +1 -1
- package/dist/esm/components/cards/index.js.map +1 -1
- package/dist/esm/components/comparisonTable/index.js +2 -2
- package/dist/esm/components/comparisonTable/index.js.map +1 -1
- package/dist/esm/lib/components/button/index.d.ts +9 -4
- package/dist/esm/lib/components/button/index.stories.d.ts +10 -2
- package/package.json +1 -1
- package/src/lib/components/button/index.stories.tsx +26 -1
- package/src/lib/components/button/index.tsx +21 -10
- package/src/lib/components/card/index.tsx +1 -1
- package/src/lib/components/cards/infoCard/index.tsx +1 -1
- package/src/lib/components/comparisonTable/hooks/useComparisonTable.ts +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React, { ReactElement, ReactNode } from 'react';
|
|
1
|
+
import React, { ReactElement, ElementType, ComponentProps, ReactNode } from 'react';
|
|
2
2
|
declare type ButtonVariant = 'filledColor' | 'filledGray' | 'filledWhite' | 'textColor' | 'textWhite' | 'outlineWhite' | 'filledSuccess' | 'filledError';
|
|
3
|
-
declare
|
|
3
|
+
declare const buttonDefaultAs: "button";
|
|
4
|
+
declare type ButtonDefaultAsType = typeof buttonDefaultAs;
|
|
5
|
+
declare type ButtonOwnProps<E> = {
|
|
6
|
+
as?: E;
|
|
4
7
|
children: ReactNode;
|
|
5
8
|
variant?: ButtonVariant;
|
|
6
9
|
leftIcon?: ReactElement;
|
|
@@ -8,13 +11,15 @@ declare type ButtonProps = {
|
|
|
8
11
|
loading?: boolean;
|
|
9
12
|
hideLabel?: boolean;
|
|
10
13
|
} & Omit<JSX.IntrinsicElements['button'], 'children'>;
|
|
14
|
+
export declare type ButtonProps<E extends ElementType = ButtonDefaultAsType> = ButtonOwnProps<E> & Omit<ComponentProps<E>, keyof ButtonOwnProps<E>>;
|
|
11
15
|
declare const Button: React.ForwardRefExoticComponent<Pick<{
|
|
16
|
+
as?: React.ElementType<any> | undefined;
|
|
12
17
|
children: ReactNode;
|
|
13
18
|
variant?: ButtonVariant | undefined;
|
|
14
19
|
leftIcon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
15
20
|
rightIcon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
16
21
|
loading?: boolean | undefined;
|
|
17
22
|
hideLabel?: boolean | undefined;
|
|
18
|
-
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children"
|
|
23
|
+
} & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children"> & Omit<any, "className" | "form" | "slot" | "style" | "title" | "children" | "onClick" | "color" | "hidden" | "type" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "leftIcon" | "rightIcon" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "hideLabel" | keyof React.ClassAttributes<HTMLButtonElement> | "as" | "variant" | "loading">, string | number | symbol> & React.RefAttributes<"symbol" | "object" | React.ComponentClass<any, any> | React.FunctionComponent<any> | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">>;
|
|
19
24
|
export { Button };
|
|
20
|
-
export type {
|
|
25
|
+
export type { ButtonVariant };
|
|
@@ -3,14 +3,21 @@ import { ButtonProps, ButtonVariant } from '.';
|
|
|
3
3
|
declare const story: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: import("react").ForwardRefExoticComponent<Pick<{
|
|
6
|
+
as?: import("react").ElementType<any> | undefined;
|
|
6
7
|
children: import("react").ReactNode;
|
|
7
8
|
variant?: ButtonVariant | undefined;
|
|
8
9
|
leftIcon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
9
10
|
rightIcon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
10
11
|
loading?: boolean | undefined;
|
|
11
12
|
hideLabel?: boolean | undefined;
|
|
12
|
-
} & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children"
|
|
13
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children"> & Omit<any, "className" | "form" | "slot" | "style" | "title" | "children" | "onClick" | "color" | "hidden" | "type" | "value" | "onChange" | "dir" | "onBlur" | "onFocus" | "onKeyDown" | "tabIndex" | "leftIcon" | "rightIcon" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "hideLabel" | keyof import("react").ClassAttributes<HTMLButtonElement> | "as" | "variant" | "loading">, string | number | symbol> & import("react").RefAttributes<"symbol" | "object" | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noindex" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">>;
|
|
13
14
|
argTypes: {
|
|
15
|
+
as: {
|
|
16
|
+
control: {
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
14
21
|
children: {
|
|
15
22
|
control: {
|
|
16
23
|
type: string;
|
|
@@ -50,7 +57,7 @@ declare const story: {
|
|
|
50
57
|
};
|
|
51
58
|
};
|
|
52
59
|
export declare const ButtonStory: {
|
|
53
|
-
({ className, loading, children, variant, hideLabel }: ButtonProps): JSX.Element;
|
|
60
|
+
({ as, className, loading, children, variant, hideLabel }: ButtonProps): JSX.Element;
|
|
54
61
|
storyName: string;
|
|
55
62
|
};
|
|
56
63
|
export declare const ButtonVariants: ({ children, onClick }: ButtonProps) => JSX.Element;
|
|
@@ -59,4 +66,5 @@ export declare const ButtonWithIcons: ({ children, onClick }: ButtonProps) => JS
|
|
|
59
66
|
export declare const ButtonWithIconOnly: ({ children, onClick }: ButtonProps) => JSX.Element;
|
|
60
67
|
export declare const ButtonLoading: ({ children, onClick }: ButtonProps) => JSX.Element;
|
|
61
68
|
export declare const ButtonDisabled: ({ children, onClick }: ButtonProps) => JSX.Element;
|
|
69
|
+
export declare const ButtonAsOtherComponents: ({ children, as, onClick }: ButtonProps) => JSX.Element;
|
|
62
70
|
export default story;
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Button, ButtonProps, ButtonVariant } from '.';
|
|
2
|
-
import { PlusIcon, SendIcon } from '../icon';
|
|
2
|
+
import { InfoIcon, PlusIcon, SendIcon } from '../icon';
|
|
3
3
|
|
|
4
4
|
const story = {
|
|
5
5
|
title: 'JSX/Button',
|
|
6
6
|
component: Button,
|
|
7
7
|
argTypes: {
|
|
8
|
+
as: {
|
|
9
|
+
control: { type: 'text' },
|
|
10
|
+
description: 'Allow wrapper element type to be custom defined'
|
|
11
|
+
},
|
|
8
12
|
children: {
|
|
9
13
|
control: { type: 'text' },
|
|
10
14
|
defaultValue: 'Click me',
|
|
@@ -43,6 +47,7 @@ const story = {
|
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
export const ButtonStory = ({
|
|
50
|
+
as,
|
|
46
51
|
className,
|
|
47
52
|
loading = false,
|
|
48
53
|
children,
|
|
@@ -51,6 +56,7 @@ export const ButtonStory = ({
|
|
|
51
56
|
}: ButtonProps) => (
|
|
52
57
|
<div className='wmx6'>
|
|
53
58
|
<Button
|
|
59
|
+
as={as}
|
|
54
60
|
className={className}
|
|
55
61
|
loading={loading}
|
|
56
62
|
variant={variant}
|
|
@@ -191,4 +197,23 @@ export const ButtonDisabled = ({ children, onClick }: ButtonProps) => (
|
|
|
191
197
|
</Button>
|
|
192
198
|
);
|
|
193
199
|
|
|
200
|
+
export const ButtonAsOtherComponents = ({ children, as, onClick }: ButtonProps) => (
|
|
201
|
+
<div className='d-flex fd-column gap16 p24 bg-grey-200'>
|
|
202
|
+
<h3 className='p-h3'>As an anchor:</h3>
|
|
203
|
+
<Button as="a" href="https://feather-insurance.com" target="_blank">
|
|
204
|
+
{children}
|
|
205
|
+
</Button>
|
|
206
|
+
|
|
207
|
+
<h3 className='p-h3'>As a button:</h3>
|
|
208
|
+
<Button as="button" onClick={onClick}>
|
|
209
|
+
{children}
|
|
210
|
+
</Button>
|
|
211
|
+
|
|
212
|
+
<p className='p-p p-p--small fw-bold d-flex ai-center gap8 mt32'>
|
|
213
|
+
<InfoIcon />
|
|
214
|
+
Inspect elements to see the different HTML tags being rendered.
|
|
215
|
+
</p>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
|
|
194
219
|
export default story;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import React, { ReactElement, ElementType, ComponentProps, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type ButtonVariant =
|
|
5
5
|
| 'filledColor'
|
|
@@ -22,7 +22,11 @@ const buttonTypeClassNameMap: { [K in ButtonVariant]: string } = {
|
|
|
22
22
|
filledError: 'p-btn--danger',
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const buttonDefaultAs = 'button' as const
|
|
26
|
+
type ButtonDefaultAsType = typeof buttonDefaultAs;
|
|
27
|
+
|
|
28
|
+
type ButtonOwnProps<E> = {
|
|
29
|
+
as?: E;
|
|
26
30
|
children: ReactNode;
|
|
27
31
|
variant?: ButtonVariant;
|
|
28
32
|
leftIcon?: ReactElement;
|
|
@@ -31,8 +35,12 @@ type ButtonProps = {
|
|
|
31
35
|
hideLabel?: boolean;
|
|
32
36
|
} & Omit<JSX.IntrinsicElements['button'], 'children'>;
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
export type ButtonProps<E extends ElementType = ButtonDefaultAsType> = ButtonOwnProps<E> &
|
|
39
|
+
Omit<ComponentProps<E>, keyof ButtonOwnProps<E>>;
|
|
40
|
+
|
|
41
|
+
const Button = React.forwardRef(<E extends ElementType = ButtonDefaultAsType>(
|
|
35
42
|
{
|
|
43
|
+
as,
|
|
36
44
|
className,
|
|
37
45
|
loading = false,
|
|
38
46
|
children,
|
|
@@ -41,10 +49,13 @@ const Button = React.forwardRef((
|
|
|
41
49
|
rightIcon,
|
|
42
50
|
hideLabel,
|
|
43
51
|
...props
|
|
44
|
-
}: ButtonProps
|
|
45
|
-
ref?: React.ForwardedRef<
|
|
46
|
-
) =>
|
|
47
|
-
|
|
52
|
+
}: ButtonProps<E>,
|
|
53
|
+
ref?: React.ForwardedRef<E>
|
|
54
|
+
) => {
|
|
55
|
+
const ButtonTag = as || 'button';
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<ButtonTag
|
|
48
59
|
ref={ref}
|
|
49
60
|
className={classNames(
|
|
50
61
|
buttonTypeClassNameMap[variant],
|
|
@@ -92,9 +103,9 @@ const Button = React.forwardRef((
|
|
|
92
103
|
)}
|
|
93
104
|
</div>
|
|
94
105
|
) : children}
|
|
95
|
-
</
|
|
106
|
+
</ButtonTag>
|
|
96
107
|
)
|
|
97
|
-
);
|
|
108
|
+
});
|
|
98
109
|
|
|
99
110
|
export { Button };
|
|
100
|
-
export type {
|
|
111
|
+
export type { ButtonVariant };
|
|
@@ -36,7 +36,7 @@ type CardOwnProps<E extends ElementType = CardDefaultAsType> = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export type CardProps<E extends ElementType = CardDefaultAsType> = CardOwnProps<E> &
|
|
39
|
-
Omit<ComponentProps<E>, keyof CardOwnProps<E
|
|
39
|
+
Omit<ComponentProps<E>, keyof CardOwnProps<E>>;
|
|
40
40
|
|
|
41
41
|
const Card = <E extends ElementType = CardDefaultAsType>({
|
|
42
42
|
as,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import debounce from 'lodash.debounce';
|
|
2
|
-
import { useCallback, useEffect,
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ArrowValues } from '../components/TableArrows';
|
|
5
5
|
import generateId from '../../../util/generateId';
|
|
@@ -51,12 +51,12 @@ export const useComparisonTable = () => {
|
|
|
51
51
|
};
|
|
52
52
|
}, []);
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
useEffect(() => {
|
|
55
55
|
const resetHeaderWidth = () => {
|
|
56
56
|
if (headerRef.current) {
|
|
57
57
|
setHeaderWidth(headerRef.current.clientWidth);
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
|
|
61
61
|
window.addEventListener('resize', resetHeaderWidth);
|
|
62
62
|
|