mountain_view icon indicating copy to clipboard operation
mountain_view copied to clipboard

False creation messages for invalid component name

Open snuggs opened this issue 8 years ago • 4 comments

First let me say awesome job with Mountain View. The principles of componentizing the web are amazing. I have also been working on conventions very similar on a front end library. I must say there was 💯 overlap in methodologies and this is now a tool I am teaching the NYC ruby community on how to build server side rendered components. One of your contributors @robcole put me up on it and it was 😍 at first sight.

Please check out the snuggsi library when you get a chance. https://github.com/devpunks/snuggsi as there is a 1 to 1 mapping to bring mountain view to client side components. Even was able to map properties to properties and thinking about building a mountain_view_snuggsi gem after some discussion with @brandondees

https://jsfiddle.net/snuggs/3zwkj9wg

That said I made the mistake of naming a component sticky-header instead of sticky_header as @angelocordon recommended to me. The operation completed as success however no component lib created. I feel should throw a warning (least path to resistance) or create a lib with hyphens. Although i'd love the latter of the two as this would abide by the Custom Elements Specification within the browser platform. But i think this would be difficult because... Ruby.

Thanks for making such a great tool!

Peace! capture d ecran 2017-08-01 a 12 17 39

snuggs avatar Aug 01 '17 16:08 snuggs

@snuggs the components are optional as per their docs , which is fine because I haven't always had a need for it.

Including a component class is optional

I just manually create them <component_name>_component.rb inside the component's folder.

angelocordon avatar Aug 02 '17 04:08 angelocordon

I think if anything, it would be nice to include a flag when creating a component though or set it through some sort of config?

rails g mountain_view:component sticky_header --include component_class --skip javascript

Not 100% sure on that one, but would love to hear thoughts on it.

angelocordon avatar Aug 02 '17 04:08 angelocordon

@angelocordon I'm down to take a crack at it if @kitop is open to PRs in interest of your suggestion.

snuggs avatar Aug 02 '17 07:08 snuggs

@snuggs Thanks for the kind words!!! It really means a lot.

Regarding the - yeah, that's a tricky case... Ruby convention is tipically to not use - anywhere, so probably a warning is OK. Trying to work around it, as you said, may mean going against the language a bit. If - are really needed, maybe there can be a translation layer at some point to abide the Web Components Custom Elements spec.

@angelocordon suggestion looks great! (Thanks @angelocordon for chiming in!)

I'm 100% down for both improvemets if you wanna work on a PR @snuggs. Thanks again!! :)

kitop avatar Aug 02 '17 12:08 kitop