/**
 * Copyright 2021 Gravitational Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Flex, Text } from 'shared/components';

const LicenseTextArea = React.forwardRef((props, ref) => {
  const {text, ...styles} = props;
  return (
    <Flex bg="grey.50" alignItems="start" style={{borderRadius: "6px"}} {...styles} >
      <StyledCmd ref={ref} typography="body2" px="3" py="3" color="text.onLight">{text}</StyledCmd>
    </Flex>
  )
})

const StyledCmd = styled(Text)`
  font-family: ${({theme})=> theme.fonts.mono};
  word-break: break-all;
  word-wrap: break-word;
  border-radius: 6px;
  white-space: pre;
  word-break: break-all;
  word-wrap: break-word;
`;

LicenseTextArea.propTypes = {
  ...Flex.propTypes,
  cmd: PropTypes.string
}

export default LicenseTextArea;