@chakra-ui/icons#RepeatIcon TypeScript Examples

The following examples show how to use @chakra-ui/icons#RepeatIcon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavascriptEmbedButton.tsx    From coindrop with GNU General Public License v3.0 5 votes vote down vote up
JavascriptEmbedButton: FunctionComponent<Props> = ({ publicUrl, piggybankName }) => {
    const [customText, setCustomText] = useState(publicUrl);
    const scriptButtonHtml = `<script type="text/javascript" src="${fullBaseUrl}embed-button.js" data-id="coindrop-button" data-slug="${piggybankName}" data-customText="${customText}" ></script>`;
    const { onCopy: onCopyScript, hasCopied: hasCopiedScript } = useClipboard(scriptButtonHtml);
    const initialShuffleTextArray = [publicUrl, ...shuffleCustomTextOptions];
    const [shuffleTextArray] = useState(initialShuffleTextArray);
    const [shuffleCustomTextIndex, setShuffleCustomTextIndex] = useState(0);
    useEffect(() => {
        setCustomText(shuffleTextArray[shuffleCustomTextIndex]);
    }, [shuffleCustomTextIndex]);
    const ButtonPreview: FunctionComponent<ButtonPreviewProps> = ({ text = "coindrop.to me", isHtmlOnly = false }) => (
        <a href={`${fullBaseUrl}${piggybankName}`} target="_blank" rel="noreferrer">
            <button type="button" className={isHtmlOnly ? `${styles["coindrop-button"]} ${styles["coindrop-html-button"]}` : styles["coindrop-button"]}>
                <div className={styles["coindrop-button-content"]}>
                <div className={styles["coindrop-svg"]}>{svg}</div>
                <div>{text}</div>
                </div>
            </button>
        </a>
    );
    return (
        <Box>
            <Box textAlign="center" mt={3}>
                <ButtonPreview text={customText} />
            </Box>
            <Flex justify="center" align="center" textAlign="center" mb={3}>
                <Input
                    variant="flushed"
                    width="350px"
                    value={customText}
                    textAlign="center"
                    onChange={(e) => setCustomText(e.target.value)}
                />
            </Flex>
            <Box textAlign="center">
                <Flex justify="center" wrap="wrap">
                    <Button
                        leftIcon={<RepeatIcon />}
                        variant="outline"
                        colorScheme="green"
                        onClick={() => {
                            setShuffleCustomTextIndex(shuffleCustomTextIndex === shuffleCustomTextOptions.length - 1 ? 0 : shuffleCustomTextIndex + 1);
                        }}
                        mx={1}
                        mb={1}
                    >
                        Shake It Up
                    </Button>
                    <Button
                        leftIcon={hasCopiedScript ? <CheckIcon /> : <SourceCodeIcon />}
                        colorScheme="green"
                        mx={1}
                        mb={1}
                        onClick={onCopyScript}
                    >
                        {hasCopiedScript ? 'Copied' : 'Copy Code'}
                    </Button>
                </Flex>
                <Text fontSize="sm">For websites that support JavaScript embed</Text>
            </Box>
        </Box>
    );
}