From 2f1a76d99657bce7e011daecd7026e693b8a5575 Mon Sep 17 00:00:00 2001 From: Artur Bien Date: Thu, 16 May 2019 23:09:58 +0200 Subject: [PATCH 01/13] added createFlatBoxStyles fn for flat component styles --- src/components/TextArea/TextArea.js | 63 +++++++++++-------- src/components/TextArea/TextArea.stories.js | 37 ++++++++++- src/components/TextField/TextField.js | 59 +++++++++-------- src/components/TextField/TextField.stories.js | 41 +++++++++++- src/components/common/index.js | 11 ++++ src/components/common/themes.js | 25 ++++++-- 6 files changed, 178 insertions(+), 58 deletions(-) diff --git a/src/components/TextArea/TextArea.js b/src/components/TextArea/TextArea.js index a2a875d7..5f725471 100644 --- a/src/components/TextArea/TextArea.js +++ b/src/components/TextArea/TextArea.js @@ -2,7 +2,7 @@ import React, { useState } from "react"; import propTypes from "prop-types"; import styled from "styled-components"; -import { createDisabledTextStyles } from "../common"; +import { createDisabledTextStyles, createFlatBoxStyles } from "../common"; import { blockSizes, fontSizes, padding, fontFamily } from "../common/system"; import Cutout from "../Cutout/Cutout"; @@ -13,6 +13,11 @@ const StyledTextAreaWrapper = styled(Cutout)` background: ${({ theme, isDisabled }) => isDisabled ? theme.material : theme.canvas}; `; +const StyledFlatTextAreaWrapper = styled.div` + position: relative; + min-height: ${blockSizes.md}; + ${createFlatBoxStyles()} +`; const StyledTextArea = styled.textarea` width: 100%; height: 100%; @@ -24,50 +29,56 @@ const StyledTextArea = styled.textarea` resize: none; font-size: ${fontSizes.md}; font-family: ${fontFamily}; - color: ${({ theme, disabled }) => - disabled ? theme.inputTextDisabled : theme.inputText}; - ${props => props.disabled && createDisabledTextStyles()} + + ${({ disabled, flat }) => !flat && disabled && createDisabledTextStyles()} `; const TextArea = ({ onChange, disabled, + flat, width, height, style, className, shadow, ...otherProps -}) => ( - - - -); +}) => { + const Wrapper = flat ? StyledFlatTextAreaWrapper : StyledTextAreaWrapper; + return ( + + + + ); +}; TextArea.defaultProps = { - shadow: true + shadow: true, + flat: false }; TextArea.propTypes = { width: propTypes.oneOfType([propTypes.string, propTypes.number]), height: propTypes.oneOfType([propTypes.string, propTypes.number]), onChange: propTypes.func, disabled: propTypes.bool, + flat: propTypes.bool, className: propTypes.string, shadow: propTypes.bool }; diff --git a/src/components/TextArea/TextArea.stories.js b/src/components/TextArea/TextArea.stories.js index 62805d92..1afb3aa1 100644 --- a/src/components/TextArea/TextArea.stories.js +++ b/src/components/TextArea/TextArea.stories.js @@ -3,7 +3,7 @@ import { storiesOf } from "@storybook/react"; import { action } from "@storybook/addon-actions"; import TextArea from "./TextArea"; -import { Button } from "../"; +import { Button, Cutout } from "../"; const onChange = e => console.log(e.target.value); @@ -40,6 +40,41 @@ storiesOf("TextArea", module) )) .add("no shadow", () => (