Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CodeSnippet): add feedbackTimeout prop, z-index fix #8171

Merged
merged 6 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
.#{$prefix}--copy-btn__feedback {
@include tooltip--content('icon');

z-index: 3;
tw15egan marked this conversation as resolved.
Show resolved Hide resolved
display: none;
box-sizing: content-box;
margin: auto;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/globals/scss/_tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@mixin tooltip--content($tooltip-type: 'icon') {
@include box-shadow;

z-index: z('floating');
width: max-content;
min-width: rem(24px);
max-width: rem(208px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ Map {
"feedback": Object {
"type": "string",
},
"feedbackTimeout": Object {
"type": "number",
},
"hideCopyButton": Object {
"type": "bool",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const props = () => ({
),
disabled: boolean('Disabled (disabled)', false),
light: boolean('Light variant (light)', false),
feedback: text('Feedback text', 'Copied to clipboard'),
feedback: text('Feedback text (feedback)', 'Copied to clipboard'),
feedbackTimeout: number('Feedback text timout (feedbackTimeout)', 2000),
showMoreText: text('Text for "show more" button', 'Show more'),
showLessText: text('Text for "show less" button', 'Show less'),
hideCopyButton: boolean('Hide copy button (hideCopyButton)', false),
Expand Down
10 changes: 9 additions & 1 deletion packages/react/src/components/CodeSnippet/CodeSnippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function CodeSnippet({
children,
disabled,
feedback,
feedbackTimeout,
onClick,
ariaLabel,
copyLabel, //TODO: Merge this prop to `ariaLabel` in `v11`
Expand Down Expand Up @@ -165,7 +166,8 @@ function CodeSnippet({
aria-label={copyLabel || ariaLabel}
aria-describedby={uid}
className={codeSnippetClasses}
feedback={feedback}>
feedback={feedback}
feedbackTimeout={feedbackTimeout}>
<code id={uid}>{children}</code>
</Copy>
);
Expand Down Expand Up @@ -221,6 +223,7 @@ function CodeSnippet({
disabled={disabled}
onClick={handleCopyClick}
feedback={feedback}
feedbackTimeout={feedbackTimeout}
iconDescription={copyButtonDescription}
/>
)}
Expand Down Expand Up @@ -284,6 +287,11 @@ CodeSnippet.propTypes = {
*/
feedback: PropTypes.string,

/**
* Specify the time it takes for the feedback message to timeout
*/
feedbackTimeout: PropTypes.number,

/**
* Specify whether or not a copy button should be used/rendered.
*/
Expand Down