Skip to content

Commit

Permalink
[docs] Hide copy button on search icon dialog (#32577)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored May 3, 2022
1 parent 1829236 commit 0c5a0b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ const DialogDetails = React.memo(function DialogDetails(props) {
TransitionProps={{ onExited: () => setCopied2(false) }}
>
<Markdown
copyButtonHidden
onClick={handleClick(2)}
code={`import ${selectedIcon.importName}Icon from '@mui/icons-material/${selectedIcon.importName}';`}
language="js"
Expand Down
34 changes: 19 additions & 15 deletions docs/src/modules/components/HighlightedCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useCodeCopy } from 'docs/src/modules/utils/CodeCopy';

const HighlightedCode = React.forwardRef(function HighlightedCode(props, ref) {
const {
copyButtonHidden = false,
copyButtonProps,
code,
language,
Expand Down Expand Up @@ -50,21 +51,23 @@ const HighlightedCode = React.forwardRef(function HighlightedCode(props, ref) {
dangerouslySetInnerHTML={{ __html: renderedCode }}
/>
</pre>
<button
{...copyButtonProps}
aria-label="Copy the code"
type="button"
className="MuiCode-copy"
onClick={async () => {
setCopied(true);
await copy(code);
}}
>
{copied ? 'Copied' : 'Copy'}
<span className="MuiCode-copyKeypress">
<span>or</span> {key} + C
</span>
</button>
{!copyButtonHidden && (
<button
{...copyButtonProps}
aria-label="Copy the code"
type="button"
className="MuiCode-copy"
onClick={async () => {
setCopied(true);
await copy(code);
}}
>
{copied ? 'Copied' : 'Copy'}
<span className="MuiCode-copyKeypress">
<span>or</span> {key} + C
</span>
</button>
)}
</div>
</Component>
);
Expand All @@ -73,6 +76,7 @@ const HighlightedCode = React.forwardRef(function HighlightedCode(props, ref) {
HighlightedCode.propTypes = {
code: PropTypes.string.isRequired,
component: PropTypes.elementType,
copyButtonHidden: PropTypes.bool,
copyButtonProps: PropTypes.object,
language: PropTypes.string.isRequired,
};
Expand Down

0 comments on commit 0c5a0b0

Please sign in to comment.