Skip to content

Commit

Permalink
Added support for TextArea.
Browse files Browse the repository at this point in the history
NOTE:  macOS CSS was funky, and could not fully shrink bottom border.  It's close, but I think somebody with more CSS understanding should review the playground and see if there's a better solution.
  • Loading branch information
drmikecrowe committed Feb 25, 2018
1 parent 15c92fb commit b7508c7
Show file tree
Hide file tree
Showing 11 changed files with 820 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/macOs/components/textArea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { Component } from 'react';
import { TextArea } from 'react-desktop/macOs';

export default class extends Component {
handleChange = e => console.log(e.target.value);

render() {
return (
<TextArea
label="My Input"
placeholder="My Input"
defaultValue=""
rows={5}
cols={80}
onChange={this.handleChange}
/>
);
}
}
26 changes: 26 additions & 0 deletions examples/windows/components/textArea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { Component } from 'react';
import { TextArea } from 'react-desktop/windows';

export default class extends Component {
static defaultProps = {
color: '#cc7f29',
theme: 'light'
};

handleChange = e => console.log(e.target.value);

render() {
return (
<TextArea
theme={this.props.theme}
color={this.props.color}
background
label="My Input"
placeholder="My Input"
rows={5}
cols={80}
onChange={this.handleChange}
/>
);
}
}
1 change: 1 addition & 0 deletions macOs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export {
} from './src/SegmentedControl/macOs/Item';
export { default as Text } from './src/Text/macOs';
export { default as TextInput } from './src/TextInput/macOs';
export { default as TextArea } from './src/TextArea/macOs';
export { default as TitleBar } from './src/TitleBar/macOs';
export { default as Toolbar } from './src/Toolbar/macOs';
export { default as ToolbarNav } from './src/Toolbar/macOs/Nav';
Expand Down
65 changes: 65 additions & 0 deletions src/TextArea/macOs/centerPlaceholderAnimation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import BezierEasing from '../../animation/bezierEasing';

let requestAnimationFrame;
if (typeof window !== 'undefined') {
requestAnimationFrame = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame;
}

let startTimestamp;
const duration = 350;
const easing = BezierEasing(.3,.14,0,1);

function moveLabel(timestamp, label, start, current, end, cb) {
if (start === end) return null;
if (!startTimestamp) startTimestamp = timestamp;
let progress = 1 - (timestamp - startTimestamp) / duration;
if (progress < 0) progress = 0;
progress = 1 - (easing.get(1 - progress));
if (start > end) {
current = progress * start;
} else {
current = (1 - progress) * end + start;
}

label.style.left = current + 'px';
if (start > end && current > end || start < end && current < end) {
requestAnimationFrame(timestamp => moveLabel(timestamp, label, start, current, end));
} else {
label.style.left = end + 'px';
if (cb) cb();
}
}

function animateLabel(label, start, end) {
return new Promise(resolve => {
if (requestAnimationFrame) {
requestAnimationFrame(timestamp => moveLabel(timestamp, label, start, start, end, resolve));
}
});
}

export function pullLeft(input, label) {
startTimestamp = null;
const start = label.offsetLeft;
input.style.color = 'transparent';
label.style.position = 'absolute';
setTimeout(() => {
animateLabel(label, start, 2);
setTimeout(() => input.style.color = null, 300);
}, 10);
}

export function pushCenter(input, label) {
startTimestamp = null;
label.style.position = 'relative';
const end = label.offsetLeft;
label.style.position = 'absolute';

setTimeout(() => {
animateLabel(label, 2, end)
.then(() => label.style.position = 'relative');
}, 10);
}
57 changes: 57 additions & 0 deletions src/TextArea/macOs/focusRingAnimation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { keyframes } from 'radium';

export default function (borderRadius) {
return keyframes(
{
'0%': {
opacity: '0',
borderWidth: '34px',
top: '-34px',
left: '-34px'
},
'32%': {
opacity: '0',
borderRadius: '10px',
borderWidth: '30px',
top: '-30px',
left: '-30px'
},
'50%': {
opacity: '.2',
borderWidth: '15px',
top: '-15px',
left: '-15px'
},
'80%': {
opacity: '.4',
borderWidth: '9px',
top: '-9px',
left: '-9px'
},
'90%': {
opacity: '.9',
borderWidth: '6px',
top: '-6px',
left: '-6px'
},
'100%': {
opacity: '1',
...(
borderRadius ? {
top: '-2px',
left: '-2px',
borderRadius: (parseInt(borderRadius) + 2) + 'px',
borderWidth: '2px',
boxShadow: '0 0 1px 0px rgba(125, 195, 242, .7)'
} : {
top: '-3px',
left: '-3px',
borderRadius: '4px',
borderWidth: '3px'
}
)
}
},
'text-input-focus'
);
}
Loading

0 comments on commit b7508c7

Please sign in to comment.