How to use the @chakra-ui/core.useClipboard function in @chakra-ui/core

To help you get started, weโ€™ve selected a few @chakra-ui/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivan-dalmet / smart-swatch / src / components / CopyJS.js View on Github external
export const CopyJS = ({ colors }) => {
  const JS = `
{${colors.map((color, i) =>
  `
  ${getColorNumber(i)}: '${color.hex()}',`
).join('')}
}`;

  const { onCopy, hasCopied } = useClipboard(JS);

  return (
    
      <button size="xs">
        {hasCopied
          ? 'Copied! JS object'
          : 'Get JS object'
        }
      </button>
    
  );
github ivan-dalmet / smart-swatch / src / components / Color.js View on Github external
export const Color = ({ color, title, isActive, ...props }) =&gt; {
  const { onCopy, hasCopied } = useClipboard(color.hex());

  return (
github ivan-dalmet / smart-swatch / src / components / CopyCSS.js View on Github external
export const CopyCSS = ({ colors }) =&gt; {
  const CSS = `
:root {${colors.map((color, i) =&gt;
  `
  --color-${getColorNumber(i)}: ${color.hex()};`
  ).join('')}
}`;
  const { onCopy, hasCopied } = useClipboard(CSS);

  return (
    
      <button size="xs">
        {hasCopied
          ? 'Copied! CSS variables'
          : 'Get CSS variables'
        }
      </button>
    
  );
github checktheroads / hyperglass / hyperglass / ui / components / CopyButton.js View on Github external
const CopyButton = ({ bg = "secondary", copyValue, ...props }) =&gt; {
  const { onCopy, hasCopied } = useClipboard(copyValue);
  return (
    
      <button size="sm">
        {hasCopied ? (
          
        ) : (
          
        )}</button>
github ivan-dalmet / smart-swatch / src / components / CopySVG.js View on Github external
const SVG = `
  <svg viewBox="0 0 200 20" height="20" width="200" xmlns="http://www.w3.org/2000/svg">
    <g fill-rule="evenodd" fill="none">
      ${colors.map((color, i) =&gt; `
        <rect x="${20 * i}" fill="${color.hex()}" height="20" width="20"></rect>
      `).join('')}
    </g>
  </svg>
  `;
  const { onCopy, hasCopied } = useClipboard(SVG);

  return (
    
      <button size="xs">
        {hasCopied
          ? 'Copied! Figma/Sketch'
          : 'Get for Figma/Sketch'
        }
      </button>
    
  );