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

Doesn't work with flag template-only-glimmer-components #293

Open
aklkv opened this issue Aug 27, 2018 · 18 comments
Open

Doesn't work with flag template-only-glimmer-components #293

aklkv opened this issue Aug 27, 2018 · 18 comments

Comments

@aklkv
Copy link

aklkv commented Aug 27, 2018

with this add-on installed and template-only-glimmer-components turned on wrapping div is being created. It would be nice to provide an element as root to attach auto generated class to.

@aklkv
Copy link
Author

aklkv commented Aug 27, 2018

I guess I have to use tagName property in component.js

@topaxi
Copy link
Collaborator

topaxi commented Aug 27, 2018

I'm not familiar with template only components and ember-component-css, but maybe try using <div class={{styleNamespace}}></div> in your template?

@aklkv
Copy link
Author

aklkv commented Aug 27, 2018

this would generate two divs with auto generated class:
screenshot 2018-08-27 02 46 22

@aklkv
Copy link
Author

aklkv commented Aug 27, 2018

the only way I was able to get it working correctly is by doing the following:

  init() {
    this._super(...arguments);
    this.tagName = 'div';
    this.classNames =['main-navbar', 'sticky', 'navCTA'];
    this.classNameBindings = ['styleNamespace'];
  }

and result is :
screenshot 2018-08-27 02 54 39

It would be useful to have logic not to generate outer div if {{styleNamespace}} is used in the template

@aklkv
Copy link
Author

aklkv commented Aug 27, 2018

I have done I little more digging. The way template-only-glimmer-components is that if there is now component.js file in the component folder outer div will not be generated. Feather more, here it looks like if tagName is not set on component the outer div will be generated even if I am already using {{styleNamespace}} inside the component. I guess to solve it would need to add additional check if {{styleNamespace}} is present in component template.

@webark
Copy link
Owner

webark commented Aug 27, 2018

Ya. Template only components aren't currently working with this. The proposed change that is under development will be to use ahtmlbars-ast-plugin transformation and wrap the template in a let block that gives access to styleNamespace in the template.

@webark
Copy link
Owner

webark commented Aug 27, 2018

right now to do a "tagless" component with ECC, you have to set the tagName to '' in the component.js file and then use styleNamespace in the template.

@webark
Copy link
Owner

webark commented Aug 27, 2018

I know that isn't what a template-only-glimmer-components is, but until the new version is complete, that will be what you have to do.

@aklkv
Copy link
Author

aklkv commented Aug 27, 2018

@webark Thanks a lot for quick reply! Let me know if you need a hand getting this working. I would be happy to help!

@knownasilya
Copy link

What's the status on this? Since it also affects glimmer components I think as well.

@aklkv
Copy link
Author

aklkv commented Apr 9, 2019

Indeed it does, I have already asked this question in discord. But I guess it will take some time to make it forward compatible. I am more then willing to help but with some directions from maintainer

@rtablada
Copy link

Hit this today when working with Glimmer and Sparkles components. Is there any movement forward to get something working for those cases?

@rtablada
Copy link

When working with Sparkles Components you can do something like:

import Component from 'sparkles-component';
import podNames from 'ember-component-css/pod-names';

export default class ReportConfigButton extends Component {
  get styleNamespace() {
    return podNames['foo-bar'];
  }
}

Where foo-bar is the path for the current component.

I'd imagine that this is similar to what would be wanted when working with the let AST transform since at build time we have access to the current module path.

@webark
Copy link
Owner

webark commented Apr 16, 2019

ya. if you look in PR #300, you can see the template transform that does that. (i ended up just doing a string adjustment cause it’s always wrapping i don’t have to go through the complexity of a handlebars transform)

That PR is held up due to me not really loving the babel transform that adds the styleNamespace into the component js files, and considering having to manually do the imports for addons similarly to how you do the templates with importing the layout

@knownasilya
Copy link

knownasilya commented Sep 27, 2019

In Ember 3.13

with this add-on installed and template-only-glimmer-components turned on wrapping div is being created.

is no longer true, and if you disable template-only-glimmer-components classes aren't generated either

reproduction: https://github.com/knownasilya/repro-3.13-component-css-bug

@knownasilya
Copy link

Screen Shot 2019-09-27 at 12 08 55 PM

The issue from a discussion with @rwjblue

@BryanCrotaz
Copy link

import podNames from 'ember-component-css/pod-names';

This doesn't work in Ember 3.15
podNames contains:

default:
  components: "__components__dfa48"

@webark
Copy link
Owner

webark commented Dec 27, 2019

@BryanCrotaz I’m sorry that you are running into this issue. :/ I will release the new beta version soon where you should have access to the class.

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

6 participants