Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] close popins with escape #1094

Closed
wants to merge 4 commits into from
Closed
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
114 changes: 92 additions & 22 deletions src/application/popin/example/index.jsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,76 @@
const {MenuLeft} = FocusComponents.components;
const Popin = FocusComponents.application.popin.component;
const {Panel} = FocusComponents.components;

let currentLevel = 0;
const getLevel = function getLevel() {
currentLevel++;
return currentLevel;
};

const MyMenu = React.createClass({

getInitialState() {
return ({
levelPopin1: 0,
levelPopin2: 0,
levelPopin3: 0,
});
},

goHome() {
window.location.href = '#'
},
itemsBuilder() {
const self = this;
return [
{
icon:'home',
icon: 'home',
onClick() {
self.goHome();
}
},
{
icon:'notifications',
icon: 'notifications',
onClick() {
self.setState({levelPopin1:getLevel() });
self.refs.popin.togglePopin();
}
},
{
icon:'chat',
icon: 'chat',
onClick() {
self.setState({levelPopin3:getLevel() });
self.refs.thirdPopin.togglePopin();

}
}
]
},
style: {
position: 'fixed',
left:'40%',
top:'30%',
width:'576px'
left: '40%',
top: '30%',
width: '576px'
},
titleStyle: {
color: 'white',
height:' 176px',
height: ' 176px',
backgroundImage: 'url(http://media.dcentertainment.com/sites/default/files/character_bio_576_superman_0.jpg)'
},
makeTheSecondPopinPop() {
const self = this;
self.setState({levelPopin2:getLevel()});
self.refs.secondPopin.setState({dynamicPopin: 0});
return self.refs.secondPopin.togglePopin();
},
makeTheThirdPopinPop() {
const self = this;
self.setState({levelPopin3:getLevel() });
return self.refs.thirdPopin.togglePopin();
},
render() {
const {levelPopin1,levelPopin2,levelPopin3} = this.state;
return (
<div>
<MenuLeft items={this.itemsBuilder()} handleBrandClick={this.goHome}>
Expand All @@ -58,20 +81,31 @@ const MyMenu = React.createClass({
</div>
<div className="mdl-card__supporting-text" style={this.divSupportText}>
<h5>
Through this example you'll find the different possibilities you got with the Focus Popin component.
Through this example you'll find the different possibilities you got with the Focus Popin
component.
<br/><br/>
Click on <div className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"><i className="material-icons">notifications</i></div> icon to have a menu slidding popin
Click on
<div className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"><i
className="material-icons">notifications</i></div>
icon to have a menu slidding popin
<br/>
Click on <div className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"><i className="material-icons">chat</i></div> icon to have a right slidding popin
Click on
<div className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"><i
className="material-icons">chat</i></div>
icon to have a right slidding popin
<br/>
And <button className="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" onClick={this.makeTheSecondPopinPop}><b>Click here</b></button> to display a fade-in popin example.
And
<button
className="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
onClick={this.makeTheSecondPopinPop}><b>Click here</b></button>
to display a fade-in popin example.
<br/>
</h5>
</div>
</div>
<MyPopin ref='popin'/>
<SecondPopin ref='secondPopin'/>
<ThirdPopin ref='thirdPopin'/>
<MyPopin ref='popin' level={levelPopin1}/>
<SecondPopin ref='secondPopin' level={levelPopin2}/>
<ThirdPopin ref='thirdPopin' level={levelPopin3}/>
</div>
);
}
Expand All @@ -82,8 +116,9 @@ const MyPopin = React.createClass({
this.refs.popin.toggleOpen();
},
render() {
const {level}= this.props;
return (
<Popin ref='popin' size='small' type='from-menu' modal={false}>
<Popin ref='popin' size='small' type='from-menu' modal={false} level={level} >
<h2>
News
</h2>
Expand All @@ -104,24 +139,53 @@ const MyPopin = React.createClass({
});

const SecondPopin = React.createClass({

getInitialState() {
return {dynamicPopin: 0};
},
togglePopin() {
this.refs.secondPopin.toggleOpen();
},
_renderDynamicPopin(){
const colors = ['grey', 'Cornsilk', 'Gainsboro', 'LightCyan '];
const popins = Array.from(Array(this.state.dynamicPopin).keys())
.map(idx => {
const colorStyle = {backgroundColor: colors[idx % colors.length]};
const popinTile = `Popin ${idx + 1}`;
return (
<Popin key={idx} size='small' overlay={false} open={true} level={getLevel()}>
<Panel style={colorStyle} title={popinTile}>
<p>Close this popin with Escape key</p>
</Panel>
</Popin>);
});
return popins;
},
addPopup(){
this.setState({dynamicPopin: this.state.dynamicPopin + 1});
},
render() {
const {level}= this.props;
return (
<Popin ref='secondPopin' size='medium'>
<Popin ref='secondPopin' id='secondPopin' size='medium' overlay={false} level={level}>
<h2>
The Modal, The Medium and The Full !
</h2>
<br/>
<h4>
This Popin is, as described, set the default <b>type</b> named <b>full</b> it defines its animation.
<br/>
You have 3 choices which are <b>"full"</b>, <b>"from-menu"</b> and <b>"from-right"</b>. The modal <b>attribute</b> is, by default, set to true so you can click outside of the Popin to close it.
You have 3 choices which are <b>"full"</b>, <b>"from-menu"</b> and <b>"from-right"</b>. The modal
<b>attribute</b> is, by default, set to true so you can click outside of the Popin to close it.
<br/>
Check the notification icon which is in the Focus menu bar now.
<br/> <br/>
You can add as much popin as you want and close them with esc, from newer to older ones.
</h4>
<br/>
<button className="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent"
onClick={this.addPopup}><b>Click here</b></button>
{this._renderDynamicPopin()}
</Popin>
);
}
Expand All @@ -132,41 +196,47 @@ const ThirdPopin = React.createClass({
this.refs.thirdPopin.toggleOpen();
},
render() {
const {level}= this.props;
return (
<Popin ref='thirdPopin' size='small' type='from-right'>
<Popin ref='thirdPopin' size='small' type='from-right' level={level}>
<h2>
Material Design Videos
</h2>
<br/>
<center>
<b>Material design</b>
<br/>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Q8TXgCzxEnw" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Q8TXgCzxEnw" frameborder="0"
allowfullscreen></iframe>
<br/>
<br/>
</center>
<center>
<b>Making Material Design: Crafting Material</b>
<br/>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Y0UEGsvcYvk" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Y0UEGsvcYvk" frameborder="0"
allowfullscreen></iframe>
<br/>
<br/>
</center>
<center>
<b>Material Design : Palette Perfect</b>
<br/>
<iframe width="560" height="315" src="https://www.youtube.com/embed/xYkz0Ueg0L4" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/xYkz0Ueg0L4" frameborder="0"
allowfullscreen></iframe>
<br/>
<br/>
</center>
<center>
<b>Material Desing : Story</b>
<br/>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rrT6v5sOwJg" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rrT6v5sOwJg" frameborder="0"
allowfullscreen></iframe>
</center>
</Popin>
);
}
});


module.exports = MyMenu;
Loading