Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion @src/TitleInput/TitleInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import InsertDriveFile from '@material-ui/icons/InsertDriveFile';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { FaFile } from 'react-icons/fa';
import { MdInsertDriveFile } from 'react-icons/md';
import { TiDocument } from 'react-icons/ti';
import { Field, reduxForm } from 'redux-form';
import { length, required } from 'redux-form-validators';

import { FormDecorator } from '../../.storybook/decorators';
import { TitleInput } from './index';

Expand Down Expand Up @@ -90,4 +92,66 @@ storiesOf('Atoms/TitleInput', module)
)}
</div>
);
})
.add('icon', () => {
return (
<div>
<div style={{ width: '300px', display: 'inline-block' }}>
{React.createElement(
MyForm({
label: 'No icon',
placeholder: '(empty)'
})
)}
</div>

<hr />

<div style={{ width: '300px', display: 'inline-block' }}>
{React.createElement(
MyForm({
icon: <FaFile size={16} />,
label: 'Font Awesome Icons',
placeholder: '(empty)'
})
)}
</div>

<hr />

<div style={{ width: '300px', display: 'inline-block' }}>
{React.createElement(
MyForm({
icon: <MdInsertDriveFile size={16} />,
label: 'Material Icons',
placeholder: '(empty)'
})
)}
</div>

<hr />

<div style={{ width: '300px', display: 'inline-block' }}>
{React.createElement(
MyForm({
icon: <TiDocument size={16} />,
label: 'Typeicons',
placeholder: '(empty)'
})
)}
</div>

<hr />

<div style={{ width: '300px', display: 'inline-block' }}>
{React.createElement(
MyForm({
icon: <InsertDriveFile fontSize={'small'} />,
label: 'Material UI Icons',
placeholder: '(empty)'
})
)}
</div>
</div>
);
});
9 changes: 6 additions & 3 deletions @src/TitleInput/TitleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,15 @@ class TitleInput extends React.Component<ITitleInputProps, IState> {
</label>
)}
<div styleName={'input-wrapper'} style={{ height: wrapperHeight }}>
{icon && <div styleName="icon">{icon}</div>}
{icon && (
<div styleName="icon">
<div styleName="inner">{icon}</div>
</div>
)}
<textarea
className={cn(styles.textarea, {
[`${classNameInput}`]: !!classNameInput,
[styles.bold]: bold,
[styles['with-icon']]: !!icon
[styles.bold]: bold
})}
{...input}
maxLength={maxLength}
Expand Down
20 changes: 10 additions & 10 deletions @src/TitleInput/style.m.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $warning: #ffc107 !default; // hover #E0A800 or #ff8484

.input-wrapper {
box-sizing: border-box;
display: block;
display: table;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не поддерживается многими браузерами. В том числе, современными.

position: relative;
width: 100%;
&.bold {
Expand All @@ -27,14 +27,16 @@ $warning: #ffc107 !default; // hover #E0A800 or #ff8484
}

.textarea {
display: table-cell;
width: 100%;
color: $mainColor;
box-sizing: border-box;
resize: none;
overflow: hidden;
overflow-wrap: break-word;
min-height: 32px;
height: auto;
width: 100%;
//width: 100%;
margin: 1px;
padding: 4px;
font-size: 18px;
Expand All @@ -61,14 +63,12 @@ $warning: #ffc107 !default; // hover #E0A800 or #ff8484
}

.icon {
position: absolute;
left: 0;
top: 0;
* {
position: absolute;
left: 0;
top: 10px;
max-width: 16px;
display: table-cell;
vertical-align: top;
.inner {
display: table-cell;
vertical-align: middle;
height: 40px;
}
}

Expand Down
Loading