Skip to content

Instantly share code, notes, and snippets.

@mohamedali-s-4725
Last active June 22, 2021 14:38
Show Gist options
  • Save mohamedali-s-4725/248e604a8bc5a424061c60031b74bf70 to your computer and use it in GitHub Desktop.
Save mohamedali-s-4725/248e604a8bc5a424061c60031b74bf70 to your computer and use it in GitHub Desktop.
Property dialog - POC
import Ember from 'ember';
export default Ember.Component.extend({
selected_comp_name: ''
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
willDestroyElement(){
alert( 'Component destroyed!' );
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
title: '',
tab_index: '',
custom_class:'',
custom_event: 'mouseMove'
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
tabs_and_content: [],
active_tab_index: 0,
active_obj: '',
didReceiveAttrs(){
var tab_index = this.get( 'active_tab_index' ),
total_tabs = Object.keys( this.get( 'tabs_and_content' ) ).length;
tab_index = total_tabs >= tab_index && tab_index > 0 ? tab_index : 1 ;
this.send( 'changeTab', tab_index, tab_index - 1 );
},
actions:{
changeTab( tab, index ){
var tabs_and_content = this.get( 'tabs_and_content' );
tab = typeof( tab ) === 'string' ? tab : tab - 1 ;
this.set( 'active_obj', typeof( tab ) === 'string' ? tabs_and_content.filterBy( 'tab_name', tab )[0] : tabs_and_content[ tab ] );
this.set( 'active_tab_index', index );
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
tabs_and_content: [
{ 'tab_name': 'Smileys', 'comp_name': 'tab-one', 'custom_class': '๐Ÿ˜‚' },
{ 'tab_name': 'Activity', 'comp_name': 'tab-two', 'custom_class': 'โšฝ' },
{ 'tab_name': 'Flags', 'comp_name': 'tab-three', 'custom_class': '๐ŸŽŒ' },
{ 'tab_name': 'Travel', 'comp_name': 'tab-four', 'custom_class': '๐ŸŒ‡ ' },
{ 'tab_name': 'Animals', 'comp_name': 'tab-five', 'custom_class': '๐Ÿป' }
]
});
import Ember from 'ember';
const eq = (params) => params[0] === params[1];
export default Ember.Helper.helper(eq);
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.wrapper{
border: solid 1px;
padding: 10px;
}
.title{
display: inline-block;
border: solid 1px;
cursor: pointer;
margin-bottom: 5px;
margin-top: 5px;
}
.title div{
padding: 5px 10px;
}
.title:hover{
color: green;
border: solid 2px;
margin-right: -2px;
margin-bottom: -2px;
margin-top: -2px;
}
.content{
border: solid 1px;
padding: 25px;
text-align: center;
margin: 25px;
}
.active{
color: green;
background: #DAF4EB;
}
<h1>Ember Tab's Addon </h1>
<br>
{{outlet}}
<br>
<!-- active_tab_index = default_tab -->
{{ui-tabs tabs_and_content=tabs_and_content active_tab_index=5 class='wrapper'}}
{{component selected_comp_name}}
{{yield}}
๐Ÿ™ˆ ๐Ÿ™‰ ๐Ÿ™Š ๐Ÿ’ฆ ๐Ÿ’จ ๐Ÿต ๐Ÿ’ ๐Ÿถ ๐Ÿ• ๐Ÿฉ ๐Ÿบ ๐Ÿฑ ๐Ÿˆ ๐Ÿฆ ๐Ÿฏ ๐Ÿ… ๐Ÿ† ๐Ÿด ๐ŸŽ ๐Ÿฆ„ ๐Ÿฎ ๐Ÿ‚ ๐Ÿƒ ๐Ÿ„ ๐Ÿ ๐Ÿ‘ ๐Ÿ ๐Ÿช ๐Ÿซ ๐Ÿ˜ ๐Ÿญ ๐Ÿ ๐Ÿ€ ๐Ÿ‡ ๐Ÿฟ ๐Ÿป ๐Ÿจ ๐Ÿผ ๐Ÿฆƒ ๐Ÿ” ๐Ÿ“ ๐Ÿฃ ๐Ÿค ๐Ÿฅ ๐Ÿฆ ๐Ÿง ๐Ÿ•Š ๐Ÿ‡ ๐Ÿฟ ๐Ÿป ๐Ÿจ ๐Ÿผ ๐Ÿฆƒ ๐Ÿ’
{{yield}}
๐Ÿ—ป ๐Ÿ• ๐Ÿ– ๐Ÿœ ๐Ÿ ๐Ÿž ๐ŸŸ ๐Ÿ› ๐Ÿ— ๐Ÿ˜ ๐Ÿ™ ๐Ÿš ๐Ÿ  ๐Ÿก ๐Ÿข ๐Ÿฃ ๐Ÿค ๐Ÿฅ ๐Ÿฆ ๐Ÿจ ๐Ÿฉ ๐Ÿช ๐Ÿซ ๐Ÿฌ ๐Ÿญ ๐Ÿฏ ๐Ÿฐ ๐Ÿ’’ ๐Ÿ—ผ ๐Ÿ—ฝ โ›ช ๐Ÿ•Œ ๐Ÿ• โ›ฉ ๐Ÿ•‹ โ›ฒ ๐ŸŒ ๐ŸŒƒ ๐ŸŒ† ๐ŸŒ‡ ๐Ÿ—ฝ โ›ช ๐Ÿ•Œ ๐Ÿ• โ›ฉ ๐Ÿ•‹ โ›ฒ ๐ŸŒ ๐ŸŒƒ ๐Ÿš ๐Ÿ  ๐Ÿก ๐Ÿข ๐Ÿฃ
๐Ÿ˜€ ๐Ÿ˜ ๐Ÿ˜‚ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜… ๐Ÿ˜† ๐Ÿ˜‰ ๐Ÿ˜Š ๐Ÿ˜‹ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š ๐Ÿ™‚ ๐Ÿค— ๐Ÿ˜‡ ๐Ÿค” ๐Ÿ˜ ๐Ÿ˜‘ ๐Ÿ˜ถ ๐Ÿ™„ ๐Ÿ˜ ๐Ÿ˜ฃ ๐Ÿ˜ฅ ๐Ÿ˜ฎ ๐Ÿค ๐Ÿ˜ฏ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ด ๐Ÿ˜Œ ๐Ÿ˜› ๐Ÿ˜œ ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜“ ๐Ÿ˜” ๐Ÿ˜› ๐Ÿ˜œ ๐Ÿ˜ ๐Ÿ˜’ ๐Ÿ˜’ ๐Ÿ˜“ ๐Ÿ˜” ๐Ÿ˜ ๐Ÿ˜† ๐Ÿ˜‰ ๐Ÿ˜Š ๐Ÿ˜‹ ๐Ÿ˜Ž ๐Ÿ˜˜
{{yield}}
{{yield}}
๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡จ๐Ÿ‡ฌ ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡จ๐Ÿ‡ฎ ๐Ÿ‡จ๐Ÿ‡ฐ ๐Ÿ‡จ๐Ÿ‡ฑ ๐Ÿ‡จ๐Ÿ‡ฒ ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡จ๐Ÿ‡ด ๐Ÿ‡จ๐Ÿ‡ต ๐Ÿ‡จ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡บ ๐Ÿ‡จ๐Ÿ‡ป ๐Ÿ‡จ๐Ÿ‡ผ ๐Ÿ‡จ๐Ÿ‡ฝ ๐Ÿ‡จ๐Ÿ‡พ ๐Ÿ‡จ๐Ÿ‡ฟ ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฉ๐Ÿ‡ฌ ๐Ÿ‡ฉ๐Ÿ‡ฏ ๐Ÿ‡ฉ๐Ÿ‡ฐ ๐Ÿ‡ฉ๐Ÿ‡ฒ ๐Ÿ‡ฉ๐Ÿ‡ด ๐Ÿ‡ฉ๐Ÿ‡ฟ ๐Ÿ‡ช๐Ÿ‡ฆ ๐Ÿ‡ช๐Ÿ‡จ ๐Ÿ‡ช๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡ฌ ๐Ÿ‡ช๐Ÿ‡ญ ๐Ÿ‡ช๐Ÿ‡ท ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ช๐Ÿ‡น ๐Ÿ‡ช๐Ÿ‡บ ๐Ÿ‡ซ๐Ÿ‡ฎ ๐Ÿ‡ซ๐Ÿ‡ฏ ๐Ÿ‡ซ๐Ÿ‡ฐ ๐Ÿ‡จ๐Ÿ‡ต ๐Ÿ‡จ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡บ ๐Ÿ‡จ๐Ÿ‡ป ๐Ÿ‡จ๐Ÿ‡ฐ ๐Ÿ‡จ๐Ÿ‡ฑ ๐Ÿ‡จ๐Ÿ‡ฒ ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡จ๐Ÿ‡ด ๐Ÿ‡จ๐Ÿ‡ต ๐Ÿ‡จ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡บ ๐Ÿ‡จ๐Ÿ‡ป ๐Ÿ‡จ๐Ÿ‡ผ ๐Ÿ‡จ๐Ÿ‡ฝ ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡จ๐Ÿ‡ฌ ๐Ÿ‡จ๐Ÿ‡ญ
<div {{action 'changeTab' title tab_index on='click'}}>
{{custom_class}}
{{title}}
</div>
{{yield}}
{{yield}}
๐Ÿ›€ ๐ŸŽ— ๐ŸŽŸ ๐ŸŽซ ๐ŸŽ– ๐Ÿ† ๐Ÿ… โšฝ โšพ ๐Ÿ€ ๐Ÿ ๐Ÿˆ ๐Ÿ‰ ๐ŸŽพ ๐ŸŽฑ ๐ŸŽณ ๐Ÿ ๐Ÿ‘ ๐Ÿ’ ๐Ÿ“ ๐Ÿธ โ›ณ ๐ŸŒ โ›ธ ๐ŸŽฃ ๐ŸŽฝ ๐ŸŽฟ โ›ท ๐Ÿ‚ ๐Ÿ„ ๐Ÿ‡ ๐ŸŠ โ›น ๐Ÿ‹ ๐Ÿšด ๐Ÿšต ๐ŸŽฏ ๐ŸŽฎ ๐ŸŽฒ ๐ŸŽท ๐Ÿ„ ๐Ÿ‡ ๐ŸŠ โ›น ๐Ÿ‹ ๐ŸŽ— ๐ŸŽŸ ๐ŸŽซ ๐ŸŽ– ๐Ÿ† ๐Ÿ… ๐Ÿ’ ๐Ÿ“ ๐Ÿธ
{{#each tabs_and_content as | tab_obj index |}}
{{#if (eq index active_tab_index) }}
{{tab-title title=tab_obj.tab_name class='title active' custom_class=tab_obj.custom_class}}
{{else}}
{{tab-title title=tab_obj.tab_name class='title' custom_class=tab_obj.custom_class tab_index=index}}
{{/if}}
{{/each}}
<hr>
{{tab-content selected_comp_name=active_obj.comp_name class='content'}}
{
"version": "0.10.5",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment