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

Add copy to clipboard icon #1200

Conversation

survivant
Copy link
Contributor

Description

I added the copy to clipboard feature

image

image

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

<>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<CopyToClipboard text={snippet} onCopy={() => toast.success('Copied to clipboard!')}>
<FontAwesomeIcon icon={faCopy} style={{ cursor: 'pointer' }} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on contributing.md file Bruno is using Tabler icons, so probably should be replaced with Tabler icon to not mix icons from different collections.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

@martinsefcik
Copy link
Contributor

What do you think about the following styling?

Recording.2023-12-13.004345.mp4

@survivant
Copy link
Contributor Author

I'm not really a react dev, so I have know idea how to do it. It's true that I never changed the layout theme.

@martinsefcik
Copy link
Contributor

I just slightly modified CodeView component to:

    <StyledWrapper>
      <CopyToClipboard className="copy-to-clipboard" text={snippet} onCopy={() => toast.success('Copied to clipboard!')}>
        <IconCopy size={20} strokeWidth={1.5}/>
      </CopyToClipboard>
      <CodeEditor
        readOnly
        value={snippet}
        font={get(preferences, 'font.codeFont', 'default')}
        theme={storedTheme}
        mode={lang}
      />
    </StyledWrapper>

introduced new StyledWrapper for that component:

import styled from 'styled-components';

const StyledWrapper = styled.div`
  position: relative;

  .copy-to-clipboard {
    position: absolute;
    cursor: pointer;
    top: 10px;
    right: 10px;
    z-index: 10;
    opacity: 0.5;

    &:hover {
      opacity: 1;
    }
  }
`;

export default StyledWrapper;

@survivant
Copy link
Contributor Author

@martinsefcik Thanks a lot for the help. It's really appreciated.

@helloanoop helloanoop merged commit ee2d7a1 into usebruno:main Dec 14, 2023
2 checks passed
@helloanoop
Copy link
Contributor

Thank you so much @survivant @martinsefcik !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants