Skip to content

Commit

Permalink
feat: Add TypeScript types for <Overlay>, <OverlayTrigger>, <Tooltip>…
Browse files Browse the repository at this point in the history
…, <IconButton> (#3100)

* feat: add typings for <Overlay> and <OverlayTrigger>

* feat: add typings for <Tooltip>

* feat: add typings for <IconButton>

* chore: typing cleanups for <Chip> code

* feat: slightly more detailed types for <Chip/ChipIcon> - per review
  • Loading branch information
bradenmacdonald authored and PKulkoRaccoonGang committed Dec 4, 2024
1 parent a66080b commit d9925a7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/Chip/ChipIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { STYLE_VARIANTS } from './constants';
export type ChipIconProps = {
className: string,
src: React.ComponentType,
onClick?: KeyboardEventHandler & MouseEventHandler,
alt?: string,
variant: string,
variant: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS],
disabled?: boolean,
} & (
// Either _both_ onClick and alt are provided, or neither is:
Expand Down
32 changes: 27 additions & 5 deletions src/IconButton/__snapshots__/IconButton.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,33 @@ exports[`<IconButton /> renders with deprecated props 1`] = `
<span
className="btn-icon__icon-container"
>
<span
aria-hidden={true}
className="btn-icon__icon"
id="Icon1"
/>
<svg
aria-hidden="true"
className="svg-inline--fa fa-InfoOutlineIcon btn-icon__icon"
data-icon="InfoOutlineIcon"
data-prefix="pgn"
focusable="false"
role="img"
style={{}}
viewBox="0 0 function SvgInfoOutline(props) {
return /*#__PURE__*/React.createElement("svg", _extends({
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, props), /*#__PURE__*/React.createElement("path", {
d: "M11 7h2v2h-2V7Zm0 4h2v6h-2v-6Zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Z",
fill: "currentColor"
}));
} undefined"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill="currentColor"
style={{}}
/>
</svg>
</span>
</button>
`;
Expand Down
2 changes: 1 addition & 1 deletion src/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { type Placement } from 'react-bootstrap/Overlay';
import Icon from '../Icon';
import { OverlayTrigger } from '../Overlay';
import Tooltip from '../Tooltip';
import Icon from '../Icon';

interface Props extends React.HTMLAttributes<HTMLButtonElement> {
iconAs?: React.ComponentType<any>,
Expand Down

0 comments on commit d9925a7

Please sign in to comment.