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

Why has AM not taken off? #29

Open
Jakobud opened this issue Jun 8, 2017 · 5 comments
Open

Why has AM not taken off? #29

Jakobud opened this issue Jun 8, 2017 · 5 comments

Comments

@Jakobud
Copy link

Jakobud commented Jun 8, 2017

I just came across the idea of Attribute Modules today. The advantages seem very clear. I'm curious if anyone knows why AM has not taken off and why it hasn't been adopted more widely by CSS frameworks, etc. It's weird because its from 2014 but I haven't heard about it until I stumbled on it today.

As for feedback, the only way I would change AM is not having multiple values in a single attribute like:

am-Button="wide red uppercase"

While this approach is simple, its definitely more difficult to deal with when you start using JavaScript to interact with these attributes. With classes it's easy because lib's like jQuery have .addClass() and .removeClass(). It's easy to add and remove modifier classes using tools like this. But non such tools exist for custom attributes.

For example, if you are using JavaScript to dynamically change the above button from red to blue, you have to use a bunch of JavaScript to parse through the current values, remove all "color" values and then add then append blue into the attribute value.

A better solution would be for each different type of thing into it's own attribute. So instead of the above, have:

<button am-Button-size="wide" am-Button-color="red" am-Button-text="uppercase">hello</button>

This has all the power of the proposed AM solution, but it uses separation of concerns to compartmentalize each type of attribute. So now, if you need to dynamically change the color of the button, it's just $('button').attr('am-Button-color','blue');. No more parsing out values and having to remove values first, etc. It's just changing a single attribute to a new value and done.

@geelen
Copy link
Contributor

geelen commented Jun 14, 2017

That's a good idea. I'm not sure why AMCSS didn't go further, but there's a lot of different pure-CSS namespacing techniques out there, and they're all pretty interchangeable. So it's just a matter of someone releasing a CSS framework that uses it before it'd get popular.

I like your am-Button-size vs am-Button-color though. Basically, AMCSS is whatever works for you once you realise you're not limited to classnames!

@viT-1
Copy link

viT-1 commented Aug 22, 2021

@Jakobud But with modificators realised as separate custom attributes you get such vebose tag markup as BEM!

@jacobxperez
Copy link

@geelen @Jakobud @viT-1 @benschwarz I have been looking around the web about using data attributes for styling components and came across your discussion. I also came to a similar conclusion as you guys did but I think I went all the way with the idea of using data attributes instead of classes and created Rams a framework with zero classes and pure data attributes glory. I have been looking for a community that understands this stuff please let me know what you guys think about Rams, I need more feedback.

@viT-1
Copy link

viT-1 commented Nov 3, 2023

@jacobxperez I wrote iam-css documentation with samples. May be you find it useful for some ideas.

@jacobxperez
Copy link

@viT-1 Thanks I'll take a look at your work. This type of projects are great I feel like there is a lot of potential in data attributes that hasn't been tapped yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants