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

CRM-20929 - Convey css classes to main page title from Angular #10711

Merged
merged 2 commits into from
Jul 21, 2017

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jul 20, 2017

ang/crmUi.js Outdated
newDocumentTitle = scope.crmDocumentTitle || $el.text(),
cls = $el.attr('class').split(' '),
classes = _.filter(cls, function(c) {
return c.indexOf('ng-') !== 0;
Copy link
Member

@totten totten Jul 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to say "sync the CSS classes, except when you shouldn't, and here's a rule-of-thumb about when you shouldn't". How confident are you in this rule-of-thumb? It seems like it would transfer over bits for other directives. (For example, crm-page-title is replicated over -- which I didn't intuitively expect.)

I don't want to block if you feel strongly about it, but it seems like it could just as easily list the sync-able classes in different attribute with less risk of accidents, eg:

<h1 crm-page-title crm-page-class="foo bar">{{ts('Hello')}}</h1>

then change $el.attr('class') to scope.crmPageClass, and you don't the filter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well crm-page-title is the class I think we should add no matter what. I started to leave the PR at just that, then got inspired to add other stuff from the class attribute, then realized there was some ng-* junk in there so stripped it out.

I don't feel strongly one way or the other about your suggestion. I'm tempted to just take it back to the simpler .addClass('crm-page-title') and be done with it, since that satisfies the use case.

@totten
Copy link
Member

totten commented Jul 21, 2017

I gave some inline feedback on design, which you can take or leave.

The behavior is not entirely obvious -- it should probably mentioned in the docblock.

From functional perspective, this worked as described on a dcase build with a custom page/page-title/class (e.g. <h1 crm-page-title class="foozball">Yo Yo</h1>).

@colemanw
Copy link
Member Author

@totten I went with the simpler approach. The fancier stuff is YAGNI.

@totten
Copy link
Member

totten commented Jul 21, 2017

Sounds good to me.

@eileenmcnaughton eileenmcnaughton merged commit b17ee8d into civicrm:master Jul 21, 2017
@eileenmcnaughton eileenmcnaughton deleted the CRM-20929 branch July 21, 2017 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants