Skip to content

Commit

Permalink
fix(button): incorrect ts margin type definitions
Browse files Browse the repository at this point in the history
remove margin type definitions
remove onClick type definition that is not available in the propTypes
add documentation for type definitions

Fixes #3727
  • Loading branch information
grabkowski committed May 6, 2021
1 parent 78b33d5 commit fb055df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/button/button.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Button.propTypes = {
subtext: PropTypes.string,
/** Ref to be forwarded */
forwardRef: PropTypes.object,
/** Button types for legacy theme: "primary" | "secondary" */
/** [Legacy] Button types for legacy theme: "primary" | "secondary" */
as: PropTypes.oneOf(OptionsHelper.themesBinary),
/** Used to transform button into anchor */
href: PropTypes.string,
Expand Down
49 changes: 30 additions & 19 deletions src/components/button/button.d.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import * as React from "react";
import { SpacingProps } from "../../utils/helpers/options-helper";
import { IconTypes, ButtonTypes } from "../../utils/helpers/options-helper/options-helper";
import { SpaceProps } from "styled-system";
import * as OptionsHelper from "../../utils/helpers/options-helper/options-helper";

export interface ButtonProps extends SpacingProps {
as?: ButtonTypes;
buttonType?: ButtonTypes;
export interface ButtonProps extends SpaceProps {
/** Prop to specify the aria-label text.
* Only to be used in Button when only an icon is rendered.
* This is required to comply with WCAG 4.1.2 - Buttons must have discernible text
*/
"aria-label"?: string;
/** [Legacy] Button types for legacy theme: "primary" | "secondary" */
as?: OptionsHelper.ButtonTypes;
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
buttonType?: OptionsHelper.ButtonTypes;
/** The text the button displays */
children?: React.ReactNode;
/** Apply disabled state to the button */
disabled?: boolean;
/** Apply destructive style to the button */
destructive?: boolean;
/** Ref to be forwarded */
forwardRef?: () => void;
/** Apply fullWidth style to the button */
fullWidth?: boolean;
/** Margin bottom, given number will be multiplied by base spacing unit (8) */
mb?: 0 | 1 | 2 | 3 | 4 | 5 | 7;
/** Margin left, any valid CSS value */
ml?: string;
size?: "small" | "medium" | "large";
iconPosition?: "before" | "after";
iconType?: IconTypes;
subtext?: string;
children?: React.ReactNode;
/** Used to transform button into anchor */
href?: string;
forwardRef?: () => void;
onClick?: (
event: React.MouseEvent<HTMLButtonElement | HTMLLinkElement>,
) => void;
noWrap?: boolean;
/** Defines an Icon position related to the children: "before" | "after" */
iconPosition?: "before" | "after";
/** Provides a tooltip message when the icon is hovered. */
iconTooltipMessage?: string;
/** Provides positioning when the tooltip is displayed. */
iconTooltipPosition?: string;
/** Defines an Icon type within the button */
iconType?: OptionsHelper.IconTypes;
/** If provided, the text inside a button will not wrap */
noWrap?: boolean;
/** Assigns a size to the button: "small" | "medium" | "large" */
size?: "small" | "medium" | "large";
/** Second text child, renders under main text, only when size is "large" */
subtext?: string;
}

declare const Button: React.ComponentType<
Expand Down

0 comments on commit fb055df

Please sign in to comment.