Comments (9)
Possible uses:
// apply to all data sources
layoutController.setDataSourceOptions({
properties : {
color : 'white',
lineHeight : '48px',
textAlign : 'center'
}
});
// apply to just the left and right items
layoutController.setDataSourceOptions({
properties : {
background : 'blue'
}
}, ['leftItems', 'rightItems']);
// apply to just the title
layoutController.setDataSourceOptions({
properties : {
background : 'darkgreen'
}
}, 'title');
// apply with a function
layoutController.setDataSourceOptions({
properties : {
color : 'red'
}
}, function(key) {
// return true if the key contains an e, because yolo
// in this case: title, leftItems, rightItems
// but not: background
return key.indexOf('e') > -1;
});
from famous-flex.
Stephan, I think this would make a great contribution.
I do have some concerns about the solution. In my opinion, it is too opinionated (pun intended) and based on the premise that anything can be set using setOptions
. What if you want to add a class ('.addClass') or do something else with a renderable? Or select only the header-sections in a ListLayout?
I myself would prefer a more flexible method for enumerating the renderables in the data-source which allows me to do any arbitrary task on it. Something like this:
Simple form:
layoutController.forEach(function(renderable) {
renderable.setProperties({
backgroundColor: 'green'
});
});
Complete form:
layoutController.forEach(function(renderable, indexOrId) {
if ((indexOrId === 'leftItems') || (indexOrId === 'rightItems')) {
for (var i = 0; i < renderable.length; i++) {
renderable[i].addClass('highlight');
}
}
});
from famous-flex.
It's funny you should say that Hein because I was thinking the exact same while writing this function.
It could really be used for anything! Enumerate renderables, pass them through a validation process and invoke functions if they pass the validation.
I'll edit my things tomorrow 👍
In your last example you assume that a renderable cannot have children, which is correct. But what if the following structure takes place:
dataSource : {
dur : hur,
and : fur,
but : [
[stephan, is, extremely, sexy],
[ _while, hein, well, he, is, all_right]
]
}
In this case your example would fail as it assumes but
's child is a renderable, while in fact it's yet another array. Therefore we should definitely recursively check on the backend and only give the endpoints to the user for processing. In this case hur, fur, stephan, is, extremely, sexy, _while, hein, well, he, is, all_right
.
from famous-flex.
Well I guess you could embed an array in an array, in an object, in another object, in an array, and so on. It might even make sense to have such a dataSource layout (in some cases) and to write a layout-function for it. But I wouldn't go as far as to make a single enumeration function for it, which flattens this arbitrary structure and outputs just the renderables. You would probably also want to know the parent hierarchy..
Basically, I don't want to add an opinionated "smart" function for this, but instead provide a lower level solution which will serve all purposes and any hierarchy.
from famous-flex.
Hmm it would indeed be good to know about the parents, which a function like that would indeed remove or abstract away.
from famous-flex.
Let me know if you still want to add this feature, then I will include it in the next official release. If not, I'll might add it myself.
Also, your material design screenshot looks awesome, can't wait to see the live demo's :)
from famous-flex.
I'll make some adjustments tomorrow!
You should look into adding CLAs and Travis by the way :-) It was surprisingly easy to add to my own project and does a wonderful job.
https://www.clahub.com/ (just log in using Github and enable on a per project basis)
Example: https://www.clahub.com/agreements/StephanBijzitter/Famous-Material-Examples
Same thing for Travis really, if you scaffold your Famo.us project with Yeoman a travis config file will be auto generated (you can find it in the main directory of my examples, if you don't have it) and it works out of the box O_o
from famous-flex.
Awesome!
from famous-flex.
@StephanBijzitter 👍 on the CLAHub suggestion! Never knew it existed until now.
from famous-flex.
Related Issues (20)
- velocity limit HOT 10
- Scrollview is only partially shown (after blurring an input element, window scroll position isnt reset) HOT 9
- Pull to refresh on desktop HOT 3
- any plans to support https://github.com/Famous/engine/tree/v1.0.0? HOT 7
- Scrollview: scroll without animation HOT 3
- Invalid bower version HOT 2
- FlexScrollView - mousepad two finger scrolling doesn't work in paginated view
- LayoutController insert 0 not working HOT 6
- CollectionLayout last row just partial visible HOT 1
- WheelLayout (DatePicker) sometimes wrong number sequence HOT 7
- Possible Bug in CollectionLayout HOT 5
- Is mixed-mode really good(right) ? HOT 7
- What is the state of Famous-Flex? HOT 6
- Surface leakage issue because of Entity.register HOT 2
- Bug in DatePicker.Component.FullDay HOT 7
- SamsaraJS support
- Error: HOT 6
- Correction in documentation HOT 2
- Use famous-sizeconstraint with FlexScrollView
- Changes to LinkedListViewSequence does not get reflected in FlexScrollView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from famous-flex.