Commit 686ae912 authored by Andrey Azov's avatar Andrey Azov
Browse files

Add ShadedInput and ShadedTextarea

parent bccf53c4
Pipeline #177922 passed with stages
in 2 minutes and 29 seconds
@import 'src/styles/common';
.input {
display: inline-block;
width: 100%;
......@@ -7,3 +9,9 @@
outline: none;
}
}
.shadedInput {
box-shadow: inset 2px 2px 4px -2px $dark-grey;
border: none;
padding: 4px;
}
/**
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* 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 classNames from 'classnames';
import Input, { Props as InputProps } from './Input';
import styles from './Input.scss';
const ShadedInput = (props: InputProps) => {
const { className, ...otherProps } = props;
const inputClasses = classNames(styles.shadedInput, className);
return <Input className={inputClasses} {...otherProps} />;
};
export default ShadedInput;
/**
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* 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 classNames from 'classnames';
import Textarea, { Props as TextareaProps } from './Textarea';
import styles from './Textarea.scss';
const ShadedTextarea = (props: TextareaProps) => {
const { className, ...otherProps } = props;
const inputClasses = classNames(styles.shadedTextarea, className);
return <Textarea className={inputClasses} {...otherProps} />;
};
export default ShadedTextarea;
@import 'src/styles/common';
.textarea {
border: none;
padding: 7px;
......@@ -12,3 +14,9 @@
.disableResize {
resize: none;
}
.shadedTextarea {
box-shadow: inset 2px 2px 4px -2px $dark-grey;
border: none;
padding: 4px;
}
......@@ -36,7 +36,7 @@ type PropsForRespondingWithData = {
type OnChangeProps = PropsForRespondingWithEvents | PropsForRespondingWithData;
type Props = {
export type Props = {
value: string | number;
id?: string;
name?: string;
......@@ -50,7 +50,9 @@ type Props = {
} & OnChangeProps;
const Textarea = (props: Props) => {
const eventHandler = (eventName: string) => (
const eventHandler =
(eventName: string) =>
(
e:
| React.ChangeEvent<HTMLTextAreaElement>
| React.FocusEvent<HTMLTextAreaElement>
......
.wrapper {
max-width: 500px;
}
.customizedInput {
color: rosybrown;
font-size: 36px;
......
......@@ -17,6 +17,7 @@
import React, { useState } from 'react';
import Input from 'src/shared/components/input/Input';
import ShadedInput from 'src/shared/components/input/ShadedInput';
import styles from './Input.stories.scss';
......@@ -34,7 +35,7 @@ const Wrapper = (props: any) => {
};
return (
<div>
<div className={styles.wrapper}>
<Input value={value} {...otherProps} onChange={onChange} />
</div>
);
......@@ -64,6 +65,12 @@ export const FocusAndBlurStory = (args: DefaultArgs) => (
FocusAndBlurStory.storyName = 'handling focus and blur';
export const ShadedInputStory = (args: DefaultArgs) => (
<Wrapper input={ShadedInput} placeholder="Enter something..." {...args} />
);
ShadedInputStory.storyName = 'shaded input';
export const CustomInputStory = (args: DefaultArgs) => (
<Wrapper
input={Input}
......
......@@ -17,6 +17,7 @@
import React, { useState } from 'react';
import Textarea from 'src/shared/components/textarea/Textarea';
import ShadedTextarea from 'src/shared/components/textarea/ShadedTextarea';
import styles from './Textarea.stories.scss';
......@@ -67,6 +68,17 @@ export const FocusBlurStory = (args: DefaultArgs) => (
FocusBlurStory.storyName = 'with onFocus and onBlur';
export const ShadedTextareaStory = (args: DefaultArgs) => (
<Wrapper
textarea={ShadedTextarea}
placeholder="Enter something..."
onFocus={args.onFocus()}
onBlur={args.onBlur()}
/>
);
ShadedTextareaStory.storyName = 'shaded textarea';
export const CustomStyledStory = () => (
<Wrapper
textarea={Textarea}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment