This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
.githooks
__mocks__
app
components
Alert
Avatar
Button
CenteredContent
Collaborators
CopyToClipboard
Divider
DocumentList
DocumentPreview
DocumentViews
DropToImport
DropdownMenu
Editor
Empty
HelpText
Icon
Input
Input.js
index.js
Key
Labeled
Layout
LoadingIndicator
LoadingListPlaceholder
LoadingPlaceholder
Modal
PageTitle
Popover
RouteSidebarHidden
ScrollToTop
Scrollable
SlackAuthLink
Toasts
Tooltip
fonts
menus
models
scenes
static
stores
styles
types
utils
index.js
flow-typed
frontend
public
server
shared
.babelrc
.env.sample
.eslintrc
.flowconfig
.gitignore
.sequelizerc
Procfile
README.md
app.json
circle.yml
index.js
init.js
package.json
setupJest.js
webpack.config.dev.js
webpack.config.js
webpack.config.prod.js
yarn.lock
outline/app/components/Input/Input.js
2017-10-29 23:23:16 -07:00

77 lines
1.4 KiB
JavaScript

// @flow
import React from 'react';
import styled from 'styled-components';
import Flex from 'shared/components/Flex';
import { size, color } from 'shared/styles/constants';
const RealTextarea = styled.textarea`
border: 0;
flex: 1;
padding: 8px 12px;
outline: none;
background: none;
&::placeholder {
color: ${color.slate};
}
`;
const RealInput = styled.input`
border: 0;
flex: 1;
padding: 8px 12px;
outline: none;
background: none;
&::placeholder {
color: ${color.slate};
}
`;
const Wrapper = styled.div`
`;
export const Outline = styled(Flex)`
display: flex;
flex: 1;
margin: 0 0 ${size.large};
color: inherit;
border-width: 1px;
border-style: solid;
border-color: ${props => (props.hasError ? 'red' : color.slateLight)};
border-radius: 4px;
font-weight: normal;
&:focus {
border-color: ${color.slate}
}
`;
export const LabelText = styled.div`
font-weight: 500;
padding-bottom: 4px;
`;
export type Props = {
type: string,
value?: string,
label?: string,
className?: string,
};
export default function Input({ type, label, ...rest }: Props) {
const InputComponent = type === 'textarea' ? RealTextarea : RealInput;
return (
<Wrapper>
<label>
{label && <LabelText>{label}</LabelText>}
<Outline>
<InputComponent {...rest} />
</Outline>
</label>
</Wrapper>
);
}