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

Added common label formatting (as chips) and unified across the project. #223

Merged
merged 1 commit into from
Jan 8, 2016

Conversation

floreks
Copy link
Member

@floreks floreks commented Jan 5, 2016

This is how it looks:

zrzut ekranu z 2016-01-05 17-29-05

zrzut ekranu z 2016-01-05 17-29-11

I've changed default chips styling to fit application style. I think that similar look can be applied to deploy page labels if needed. Only 1 key/value input row would be left and all added labels would be displayed below as list of chips.

@bryk @maciaszczykm what do you think?

@floreks floreks force-pushed the label-format branch 2 times, most recently from 3c30d0c to 45867b2 Compare January 7, 2016 08:40
@codecov-io
Copy link

Current coverage is 76.06%

Merging #223 into master will increase coverage by +0.61% as of d1b50a8

@@            master    #223   diff @@
======================================
  Files           54      56     +2
  Stmts          493     493       
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit            372     375     +3
  Partial          0       0       
+ Missed         121     118     -3

Review entire Coverage Diff as of d1b50a8

Powered by Codecov. Updated on successful CI builds.

@floreks floreks force-pushed the label-format branch 2 times, most recently from 06bf501 to 747fc5f Compare January 7, 2016 09:22
* @ngInject
*/
constructor() {
/** @export {!Array<Object.<string,string>>} Initialized from the scope and transformed to
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the dot: Object.<.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

* @return {!Array<Object.<string,string>>}
* @private
*/
transformLabels_() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you dont need the transformation. In md-chip-template you should have $chip and $index variables. Please verify.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason why I'm doing this is because md-chips needs array and what we get from backend is 1 object with lots of properties like {app: 'name', version: 'v1'}. I'm transforming object into array and md-chips iterates over this array.

It's based on this demo:
https://material.angularjs.org/latest/demo/chips

Copy link
Contributor

Choose a reason for hiding this comment

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

How about using static chips, as at the bottom of the demo list: https://material.angularjs.org/latest/demo/chips ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason I'm pushing this is the fact that this logic is not needed and non trivial. I.e., the controller is initialized with labels of type Foo which are then converted to type Bar. Meaning that labels are of two types, depending on when you look at them.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was not as easy as I thought. I've had to fix karma ng-html2js configuration. It was not working. There were 2 issues:

  1. stripPrefix path was wrong. It is merged with karma basePath and as result it was ../../src/app/frontend/. I've changed basePath to point to current folder as all our conf.paths have basePath in them.
  2. moduleName was pointing to non existing variable. It was undefined and not loaded. I've changed it to be loaded with ng module so it doesn't have to be mocked manually while writing tests.

Additionally in order to make md-chips work without additional label transformation I've had to use workaround. There are issues reported with making ng-repeat and md-chips work.

angular/material#3482
angular/material#2829

Last thing is that even after fixing karma and compiling directive it didn't show any md-chip in html code. It looks like another issue with md-chips directive. I've only checked if outer loop works and x md-chips tags are rendered.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if you have seen above comment because it's hidden. Can you confirm? @bryk

@bryk
Copy link
Contributor

bryk commented Jan 7, 2016

Looks really nice. I've got a few comments on style. PTAL.

border-radius: 0;
font-size: $caption-font-size-base;
height: $caption-font-size-base + 6;
line-height: $caption-font-size-base + 6;
Copy link
Member

Choose a reason for hiding this comment

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

This value (+ 6) repeats, can we export it to variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

How should it be called because I don't know. This is something like custom margin that we have in other files without extracting to variable.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about local variable, which will show, that these values are somehow connected (equal). However, it's not mandatory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. It can be refactored later when some appropriate name is proposed. Feel free to change it later in some PR. :)

@maciaszczykm
Copy link
Member

Got only two minor comments regarding stylesheets. LGTM

@floreks
Copy link
Member Author

floreks commented Jan 7, 2016

PTAL.

Also what do you think about trying to apply similar look to labels in deploy page.

@floreks floreks force-pushed the label-format branch 2 times, most recently from 9f53b28 to e14a69e Compare January 7, 2016 10:26
@bryk
Copy link
Contributor

bryk commented Jan 7, 2016

PTAL

@maciaszczykm
Copy link
Member

LGTM

@floreks
Copy link
Member Author

floreks commented Jan 7, 2016

PTAL

@bryk
Copy link
Contributor

bryk commented Jan 7, 2016

CC @kenmoore

@bryk
Copy link
Contributor

bryk commented Jan 7, 2016

CC Ken, if you have any comments.

@@ -49,7 +49,7 @@ function getFileList() {
*/
module.exports = function(config) {
let configuration = {
basePath: conf.paths.base,
basePath: '.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you a lot for fixing this!

@bryk
Copy link
Contributor

bryk commented Jan 8, 2016

Sorry for long review, but I'm experimenting with look and feel. I've a couple of questions/notes.

The problem I see is that the labels are too prominent and eye-catching. They are, kind of, secondary element of a card, yet they are bold and very visible. So I've attempted to make them less prominent. What I did is I reverted to rounded edges. And changed background to the same body has. Also, changed space between key and value to =.

Take a look and tell me what you think.

selection_007

@bryk
Copy link
Contributor

bryk commented Jan 8, 2016

@maciaszczykm @floreks See my previous comment.

@@ -26,7 +27,8 @@ $replicasetdetails-table-cell: #777;

.kd-replicasetdetail-sidebar {
background-color: $replicasetdetails-sidebar-bg;
min-width: 315px;
max-width: $replicasetdetails-sidebar-width;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this caused a bug:
selection_008

Copy link
Member Author

Choose a reason for hiding this comment

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

Ops actually I've set $replicasetdetails-sidebar-width variable to 315 instead of 315px.

@maciaszczykm
Copy link
Member

@bryk I agree, that your proposal should be used. It's true, that bold label names were more visible than different (and more important) parts of view.

@floreks
Copy link
Member Author

floreks commented Jan 8, 2016

Makes sense to me. They should not overwhelm user. I've changed it. PTAL

@bryk
Copy link
Contributor

bryk commented Jan 8, 2016

I did pre-merge verification of this and found troubling issues. Basically, md-chips is not designed for our use case. It is designed to work on input elements. Static chips work pretty bad, and even the docs say that this component is likely to change.

First thing I noticed is that every md-chips load asynchronously. See that in serve:prod the page does not load in one shot. Instead, the page loads and then chips load after a short while. Please test it out. I did an investigation in chrome and see what's happening:
selection_009
See more at: https://github.com/angular/material/blob/d1b7f79e92beced635190d23c307435aabcde9c5/src/components/chips/js/chipsDirective.js#L316

How about just styling our class to look like chips? In my tests it is actually less code and less CSS than current solution.

The template:

<div ng-repeat="(key, value) in ::labelsCtrl.labels">
  <div class="kd-labels-chip">
    {{key}}={{value}}
  </div>
</div>

CSS copied and adjusted from chips.

What do you think?

@floreks
Copy link
Member Author

floreks commented Jan 8, 2016

Definitely. I didn't notice that. Anyway loading chips async does not fit our use case. I agree. Styling this to look as a chip should not be a problem. I'll change this. Thanks for taking a closer look at this.

@floreks floreks force-pushed the label-format branch 3 times, most recently from 746e650 to d2b0026 Compare January 8, 2016 12:47
@floreks
Copy link
Member Author

floreks commented Jan 8, 2016

PTAL

.kd-labels {
background-color: $body;
border-radius: $label-height / 2;
color: $muted;
Copy link
Contributor

Choose a reason for hiding this comment

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

You made the color $muted. How about removing color attribute here and just use default. $muted over $body is very hard to read. Normal over $body is easier to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about this. Pure black seemed a bit too distracting comparing to the label background. Font color has to be set anyway because it will be overriden by other components if it's not set. Maybe something in the middle like #444?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you omit color here it would be application default. Which is not full black, but dark grey.

md-content.md-default-theme, md-content {
    color: rgba(0,0,0,0.87);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but f.e. if I remove color at all from css then on replica set list page it will be black and on replica set details gray, because it inherits from more detailed classes like kd-replicasetdetail-sidebar-subline

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can you take something darker from variables.scss? Or define there a variable for rgba(0,0,0,0.87). Or apply md-content class.

@bryk
Copy link
Contributor

bryk commented Jan 8, 2016

Looks great. I have last comment, I promise :)

@floreks
Copy link
Member Author

floreks commented Jan 8, 2016

I've surrounded it with md-content and rgba(0,0,0,0.87) color is inherited. PTAL

@bryk
Copy link
Contributor

bryk commented Jan 8, 2016

Awesome. Thank you. Will merge soon.

bryk added a commit that referenced this pull request Jan 8, 2016
Added common label formatting (as chips) and unified across the project.
@bryk bryk merged commit d1ac65e into kubernetes:master Jan 8, 2016
@bryk bryk deleted the label-format branch January 8, 2016 14:35
anvithks pushed a commit to anvithks/k8s-dashboard that referenced this pull request Apr 10, 2020
Fixed Object listing page to match changed Backend response
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

Successfully merging this pull request may close these issues.

5 participants