-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
247e8bb
commit bd644d8
Showing
19 changed files
with
493 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _AbstractComponent2 = require('./AbstractComponent'); | ||
|
||
var _AbstractComponent3 = _interopRequireDefault(_AbstractComponent2); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var Textarea = function (_AbstractComponent) { | ||
_inherits(Textarea, _AbstractComponent); | ||
|
||
function Textarea() { | ||
_classCallCheck(this, Textarea); | ||
|
||
return _possibleConstructorReturn(this, (Textarea.__proto__ || Object.getPrototypeOf(Textarea)).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Textarea, [{ | ||
key: 'getModifierObject', | ||
value: function getModifierObject() { | ||
return { | ||
size: this.props.size, | ||
view: this.props.view, | ||
color: this.props.color, | ||
disabled: this.props.disabled | ||
}; | ||
} | ||
}, { | ||
key: 'delegateEvent', | ||
value: function delegateEvent(eventName) { | ||
var _this2 = this; | ||
|
||
return function (event) { | ||
if (typeof _this2.props[eventName] === 'function') { | ||
_this2.props[eventName](event.target.value, event); | ||
} | ||
}; | ||
} | ||
}, { | ||
key: 'renderLabel', | ||
value: function renderLabel() { | ||
return this.props.label ? _react2.default.createElement( | ||
'div', | ||
{ className: this.getElementName('textarea', 'label') }, | ||
this.props.label | ||
) : null; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: this.getBlockName('textarea', this.getModifierObject()) }, | ||
this.renderLabel(), | ||
_react2.default.createElement('textarea', { | ||
name: this.props.name, | ||
placeholder: this.props.placeholder, | ||
value: this.props.value, | ||
disabled: this.props.disabled, | ||
onChange: this.delegateEvent('onChange'), | ||
onKeyDown: this.delegateEvent('onKeyDown'), | ||
onKeyUp: this.delegateEvent('onKeyUp'), | ||
onKeyPress: this.delegateEvent('onKeyPress'), | ||
onFocus: this.delegateEvent('onFocus'), | ||
onBlur: this.delegateEvent('onBlur') | ||
}) | ||
); | ||
} | ||
}]); | ||
|
||
return Textarea; | ||
}(_AbstractComponent3.default); | ||
|
||
exports.default = Textarea; |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import AbstractComponent from './AbstractComponent'; | ||
|
||
export default class Textarea extends AbstractComponent { | ||
getModifierObject() { | ||
return { | ||
size: this.props.size, | ||
view: this.props.view, | ||
color: this.props.color, | ||
disabled: this.props.disabled | ||
}; | ||
} | ||
|
||
delegateEvent(eventName) { | ||
return (event) => { | ||
if (typeof this.props[eventName] === 'function') { | ||
this.props[eventName](event.target.value, event); | ||
} | ||
}; | ||
} | ||
|
||
renderLabel() { | ||
return this.props.label ? ( | ||
<div className={this.getElementName('textarea', 'label')}>{this.props.label}</div> | ||
) : null; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className={this.getBlockName('textarea', this.getModifierObject())}> | ||
{this.renderLabel()} | ||
<textarea | ||
name={this.props.name} | ||
placeholder={this.props.placeholder} | ||
value={this.props.value} | ||
disabled={this.props.disabled} | ||
onChange={this.delegateEvent('onChange')} | ||
onKeyDown={this.delegateEvent('onKeyDown')} | ||
onKeyUp={this.delegateEvent('onKeyUp')} | ||
onKeyPress={this.delegateEvent('onKeyPress')} | ||
onFocus={this.delegateEvent('onFocus')} | ||
onBlur={this.delegateEvent('onBlur')} | ||
/> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@import "constants.styl"; | ||
|
||
textarea-size($size, $font-size) { | ||
height: $size; | ||
font-size: $font-size; | ||
} | ||
|
||
.c-textarea { | ||
textarea { | ||
textarea-size(48px, 16px); | ||
box-sizing: border-box; | ||
width: 100%; | ||
max-width: 100%; | ||
min-width: 100%; | ||
padding: 8px; | ||
background: $color-light-grey; | ||
border: 1px solid $color-grey; | ||
outline: none; | ||
&:focus { | ||
border: 1px solid $color-primary; | ||
} | ||
} | ||
&--label { | ||
font-size: 14px; | ||
color: $color-dark-grey; | ||
padding: 4px 0; | ||
} | ||
&.-size-48 textarea { | ||
input-size(48px, 16px); | ||
} | ||
&.-size-64 textarea { | ||
input-size(64px, 16px); | ||
} | ||
&.-size-128 textarea { | ||
input-size(128px, 16px); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ describe('Input', () => { | |
size="4" | ||
color="primary" | ||
view="flat" | ||
didabled | ||
disabled | ||
/> | ||
).toJSON(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import Textarea from '../../src/components/Textarea'; | ||
|
||
describe('Textarea', () => { | ||
it('should render Textarea', () => { | ||
const tree = renderer.create( | ||
<Textarea | ||
size="128" | ||
color="primary" | ||
view="flat" | ||
disabled | ||
/> | ||
).toJSON(); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.