Skip to content

Commit f4c8a1d

Browse files
committed
Adjust icon-button props and prepare 2.4.0
1 parent 692025e commit f4c8a1d

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22

3+
4+
## 2.4.0
5+
6+
- [feature] add `tooltipTextSize` option to copy-button.
7+
- [fix] rename `themeTooltip` option to `tooltipColoring` to match convention.
8+
39
## 2.3.1
410

511
- [bug] Fix layout bug introduced in copy-button changes where wrapper was given `inline-block`

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mapbox/mr-ui",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "UI components for Mapbox projects",
55
"main": "index.js",
66
"homepage": "./",

src/components/copy-button/copy-button.test.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ describe('CopyButton', () => {
3838
className: 'px6 py6 btn btn--purple btn--stroke',
3939
focusTrapPaused: true,
4040
block: true,
41-
tooltipTheme: 'dark',
41+
tooltipColoring: 'dark',
42+
tooltipTextSize: 'none',
4243
children: (
4344
<span>A custom child in place of the visual button</span>
4445
),
4546
passthroughProps: {
4647
'data-testid': 'foo'
4748
}
48-
};
49+
} as const;
4950

5051
test('renders as expected', () => {
5152
const { baseElement } = render(<CopyButton {...props} />)

src/components/copy-button/copy-button.tsx

+20-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ interface Props {
1414
block?: boolean;
1515
focusTrapPaused?: boolean;
1616
className?: string;
17-
themeTooltip?: 'light' | 'dark';
17+
tooltipColoring?: 'light' | 'dark';
18+
tooltipTextSize?: 'xs' | 's' | 'none';
1819
children?: ReactNode;
1920
passthroughProps?: HTMLAttributes<HTMLButtonElement>;
2021
}
@@ -34,7 +35,8 @@ export default function CopyButton({
3435
focusTrapPaused,
3536
className = 'btn btn--xs py3 px3 round',
3637
children,
37-
themeTooltip = 'light',
38+
tooltipColoring = 'light',
39+
tooltipTextSize = 's',
3840
passthroughProps
3941
}: Props): ReactElement {
4042
const [clipboard, setClipboard] = useState(null);
@@ -110,6 +112,13 @@ export default function CopyButton({
110112
<Icon name={iconName} />
111113
</button>
112114

115+
let popoverContent: ReactNode = 'Copied!';
116+
if (tooltipTextSize !== 'none') {
117+
popoverContent = (
118+
<div className={`txt-${tooltipTextSize}`}>{popoverContent}</div>
119+
);
120+
}
121+
113122
// data-clipboard-text and the container ref are used by clipboard.js
114123
// to copy text. Note that this wont have as nice a failure mode.
115124
return (
@@ -122,9 +131,9 @@ export default function CopyButton({
122131
onClick={handleCopyButtonClick}
123132
>
124133
<Popover
125-
content={<div className="txt-s">Copied!</div>}
134+
content={popoverContent}
126135
active={showingFeedback}
127-
coloring={themeTooltip}
136+
coloring={tooltipColoring}
128137
placement="top"
129138
alignment="center"
130139
hideWhenAnchorIsOffscreen={true}
@@ -133,7 +142,8 @@ export default function CopyButton({
133142
<div>
134143
<Tooltip
135144
disabled={showingFeedback}
136-
coloring={themeTooltip}
145+
coloring={tooltipColoring}
146+
textSize={tooltipTextSize}
137147
content="Copy"
138148
>
139149
{body}
@@ -181,7 +191,11 @@ CopyButton.propTypes = {
181191
/**
182192
* Either `'light'` or `'dark'`. This value is passed as the `coloring` prop found in Tooltip and Popover.
183193
*/
184-
themeTooltip: PropTypes.oneOf(['light', 'dark']),
194+
tooltipColoring: PropTypes.oneOf(['light', 'dark']),
195+
/**
196+
* `'xs'` (extra small), `'s'` (small), or `'none'` (no size class).
197+
*/
198+
tooltipTextSize: PropTypes.oneOf(['xs', 's', 'none']),
185199
/** Optional content to represent the button. */
186200
children: PropTypes.node
187201
};

src/components/copy-button/examples/copy-button-c.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CopyButton from '../copy-button';
77
export default function Example() {
88
return (
99
<div className="inline-block">
10-
<CopyButton themeTooltip="dark" text="Some copy from the custom element">
10+
<CopyButton tooltipColoring="dark" tooltipTextSize="xs" text="Some copy from the custom element">
1111
<button className="w240 btn">Just a custom element</button>
1212
</CopyButton>
1313
</div>

0 commit comments

Comments
 (0)