Skip to content

Instantly share code, notes, and snippets.

@scalvert
Last active November 15, 2016 07:15
Show Gist options
  • Save scalvert/cfeb7240b1990ac8be3e3a7e5633ed59 to your computer and use it in GitHub Desktop.
Save scalvert/cfeb7240b1990ac8be3e3a7e5633ed59 to your computer and use it in GitHub Desktop.
Sharebox
This gist demonstrates sharebox composability
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
click(...args) {
this.attrs.addPhoto();
}
});
import Ember from 'ember';
export default Ember.Component.extend({
click() {
this.attrs.preview();
}
});
import Ember from 'ember';
export default Ember.Component.extend({
click() {
this.attrs.preview();
}
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: Ember.A('share-box__bar share-box__action-bar')
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: Ember.A('share-box'),
actions: {
preview(...args) {
alert('Previewing');
},
addPhoto() {
alert('Adding photo');
},
addLink() {
alert('Adding Link');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: Ember.A('share-box__bar share-box__subaction-bar')
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: Ember.A('share-box__input'),
tagName: 'textarea'
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
click() {
alert('Adding target audience');
}
});
import Ember from 'ember';
export default Ember.Component.extend({
click() {
this.attrs.preview();
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Composable Sharebox'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.share-box {
min-height: 150px;
border: 1px solid black;
position: relative;
padding-bottom: 20px;
}
.share-box__bar {
width: 100%;
height: 20px;
}
.share-box__action-bar {
border-bottom: 1px solid black;
}
.share-box__subaction-bar {
position: absolute;
bottom: 0;
border-top: 1px solid black;
}
.share-box__input {
width: 99%;
height: 104px;
}
.share-box__button {
}
<h1>{{appName}} example</h1>
<br>
<br>
{{outlet}}
<h2>Core Sharebox</h2>
{{#share-box as |children actions|}}
{{children.actionBar}}
{{children.textArea}}
{{children.urlPreview preview=(action actions.preview "Do some core stuff") }}
{{#children.subactionBar as |buttons|}}
{{buttons.addPhoto addPhoto=(action actions.addPhoto)}}
{{buttons.addLink addLink=(action actions.addLink)}}
{{/children.subactionBar}}
{{/share-box}}
<br>
<br>
<h2>Company Sharebox</h2>
{{#share-box as |children actions|}}
{{children.actionBar}}
{{children.textArea}}
{{editable-url-preview preview=(action actions.preview "Do some company stuff") }}
{{#children.subactionBar as |buttons|}}
{{buttons.addPhoto addPhoto=(action actions.addPhoto)}}
{{buttons.addLink addLink=(action actions.addLink)}}
{{target-audience}}
{{/children.subactionBar}}
{{/share-box}}
<br>
<br>
{{yield
(hash actionBar=(component "share-action-bar") textArea=(component "share-textarea") subactionBar=(component "share-subaction-bar") urlPreview=(component "url-preview"))
(hash preview=(action "preview" "default value") addPhoto=(action "addPhoto") addLink=(action "addLink"))
}}
{{yield (hash addPhoto=(component "add-photo") addLink=(component "add-link"))}}
{
"version": "0.8.1",
"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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment