-
Notifications
You must be signed in to change notification settings - Fork 43
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
Using a data-attribute instead of a class? #8
Comments
Cool idea! Two things:
|
I saw that selector series approach post before I posted however I feel that the selectors may work on smaller doms but not necessarily on more complexly structured doms where you might end up with a ton of different Also thinking about the idea around a data-attr further implementing something along the lines of this could open the door for further interesting options down the line like: data-fixie="true" // enables default fixie content on this element
data-fixie="false" // temporarily disable fixie without removing the attr (for debugging perhaps?)
data-fixie="{ p:1 }" // 1 paragraph of text
data-fixie="{ w:20 }" // 20 words
data-fixie="{ s:5 }" // 5 sentences
data-fixie="{ c:300 }" // 300 characters data-fixie="{ p:1, s:2, w:3 }"
// a series of filler text:
// 1 paragraph followed by
// 2 sentences followed by
// 3 words.
// not sure why anyone would need this but hey… why not, it could be done! Anyway, I don't want to overcomplicate things with the additional options but using a data attribute would allow those things to possibly be built in easily later with full backwards compatibility to those who might still be using the default What do you think? |
Good point with the additional options. Ilteris forked with support for data-fixie (see here https://github.com/icanberk/fixie ), though I feel I would prefer to support both class and data-fixie. |
Wow, that was quick regarding the I agree with you though, I don't think the Since it's just a development plugin I don't think we'd need to worry about any overheads that might come from supporting both options. |
Quick update - https://github.com/rthprog/fixie/tree/data-fixie |
+1 to @jannisg's inline config idea. not sure how this would fit in, but generally content has a max character / word count. so maybe those config options could be maximums? |
@wayneashleyberry The way I could see this working is this: // Single Digit: (1) up to 5 words
data-fixie="{ w:5 }"
// Range: 3 - 9 words
data-fixie="{ w: [ 3,9 ] }"
// ! Exactly 5 words
data-fixie="{ w: '5!' }" The latter obviously depends on how this would be parsed, if we treat is as an I suppose one could use a range with two equal values? But in general terms, barring a decision on the Given If the type of If the type of If the type of or If the type of What are your thoughts on this type of handling? |
hey @jannisg the inline config is actually starting to feel a bit verbose to me, especially adding all of those options maybe fixie itself could have a config where you could define content lengths per element?
prefer this because it keeps the markup cleaner and allows for potentially more options :) |
@wayneashleyberry Yes, I like the idea of a central config for fixie. Though I would think that this global config would only be good for setting the defaults while element specific The simple reason being, in any given layout I may generally want each paragraph to be X many words but there will usually be exceptions to this rule where all of a sudden my document has a paragraph I need to fill that needs only half the words or twice as many… So while I agree that setting defaults is by far a better option that setting the same data setting on every single element, it should be an additional config possibility rather than the only way of setting this data. Then again you never said not to also have element specific overrides so what am I talking about :) Another option would be to create global aliases for config sets. fixie.config {
sets : {
small : { w: [ 20,40 ] },
medium : { s: [ 3,4 ] },
large : { p: [ 1,3 ] }
}
} which could then be used as: That might be quite nice too. |
haha, I totally agree with you @jannisg. you should be able to override the global config per-element. maybe selectors would be better?
|
Nice idea, though —and this is of course just my personal preference— I like being able to change the classes and markup in the dom separately to JS configurations. If I change Another potential problem with the selector bound config would be that let's say you add another Ultimately this of course comes down to personal coding styles and preferences, and to be honest I don't see a reason why we couldn't include both as options of use in the plugin… I just think the selector based approach might get a little restrictive and too dependent on your markup not changing. |
Fixie will now target child elements, but will never overwrite content. Example
will cause fixie to add content to the first It will not override the "Hello..." text. Back to the Original Example
The number of mentions of In the end, getting rid of In regards to data-fixieI like the idea, especially the ability to further add bounds on length in the future. I believe the right solution is to support both class and That said, I do believe that this update significantly reduces the number of times |
@rthprog I'm super happy with how fixie handles child elements and the new i'm mostly using it directly on elements ( but agreed, I think this thread has become more about other config options though, word counts etc |
@rthprog I think the thought behind parent element class targeting empty child elements is good, though, and this is an admittedly contrived example, would we still need a way to selectively disable empty child elements from time to time? Given this markup as an example, what would the <body class="fixie">
<div class="wrap">
<header>
<h1>
<a href="#" class="logo"><img src="logo.png" alt="" /></a>
</h1>
<nav>
<ul>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</nav>
</header>
<div class="main" role="main">
[…my content…]
</div>
<!-- Blank .push for the sticky footer, see: http://ryanfait.com/sticky-footer/ -->
<div class="push"></div>
</div>
<footer>
[…footer content…]
</footer>
</body> Would fixie fill only direct children from the selector it was applied to, so in the above example nothing would be filled? Or would fixie try to fill the empty |
@jannisg It will fill all empty child, sub child, sub sub childs and so on. So in your example all the anchors in the list will be filled also div with the class push |
@eskimoblood Right, in which case I think this is not a very robust approach… think of people using the "icon module" for example which would rely upon empty elements like this: <i class="icon icon-large icon-tweet"></i> An then use CSS to apply the correct sizing and background image (or I understand that you'd obviously use a much more fine grained approach then putting a single class on the |
Suggestion: As an alternative to |
@rthprog |
Hi!
First of all, I think this plugin is great and I can see myself using this a whole lot when developing front-end templates for various projects.
One thing I think worth discussing is the use of the
fixie
classname and how this may affect your final output on large templates.What I mean is this, you might have a lot of fixie classes on elements in your dom which is great in the development stage but when you want to move those templates into a CMS it's time to get rid of all those fixie classes.
Options I see are:
While 2 would be my go-to solution to get rid of those classes the regex could get quite complex because throughout development further classes are likely to be added to fixie elements, and it's not guaranteed that
fixie
is always the first or last class on an element.Finding and deleting via regex from all these options would create a pretty complex regex:
On line 1 we'd need to remove the
class=""
as well asfixie
the term.On line 2 we'd only remove the
fixie
term.On line 3 we'd remove the
fixie
term (including the trailing space).Suggestion: Why not use a data-attribute instead?
Using something exclusive only for use with Fixie would be much easier to match and remove or simply toggle on/off.
Now we could safely match the
data-fixie="true"
term via a regex and 'clean' ourHTML
document before handover/output/CMS integration without worrying about handing the above mentioned regex matching woes.Anyway, just some thoughts I wanted to share and see what you guys think of.
The text was updated successfully, but these errors were encountered: