From 3909c74c00454668f1da6d4484856a1c70d78128 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 25 Aug 2022 21:21:03 -0500 Subject: [PATCH] Add new CopyableInput component, use in EmbedModal --- app/soapbox/components/copyable-input.tsx | 42 +++++++++++++++++++ app/soapbox/components/ui/button/button.tsx | 10 ++--- .../features/ui/components/embed-modal.tsx | 14 ++----- 3 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 app/soapbox/components/copyable-input.tsx diff --git a/app/soapbox/components/copyable-input.tsx b/app/soapbox/components/copyable-input.tsx new file mode 100644 index 000000000..4a42452bb --- /dev/null +++ b/app/soapbox/components/copyable-input.tsx @@ -0,0 +1,42 @@ +import React, { useRef } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import { Button, HStack, Input } from './ui'; + +interface ICopyableInput { + /** Text to be copied. */ + value?: string, +} + +/** An input with copy abilities. */ +const CopyableInput: React.FC = ({ value }) => { + const input = useRef(null); + + const selectInput = () => { + input.current?.select(); + }; + + return ( + + + + + + ); +}; + +export default CopyableInput; diff --git a/app/soapbox/components/ui/button/button.tsx b/app/soapbox/components/ui/button/button.tsx index 15826ff2d..e3ae339fc 100644 --- a/app/soapbox/components/ui/button/button.tsx +++ b/app/soapbox/components/ui/button/button.tsx @@ -1,3 +1,4 @@ +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router-dom'; @@ -12,8 +13,8 @@ interface IButton { block?: boolean, /** Elements inside the