-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
3c30d0c
to
45867b2
Compare
Current coverage is
|
06bf501
to
747fc5f
Compare
* @ngInject | ||
*/ | ||
constructor() { | ||
/** @export {!Array<Object.<string,string>>} Initialized from the scope and transformed to |
There was a problem hiding this comment.
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.<
.
There was a problem hiding this comment.
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_() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
stripPrefix
path was wrong. It is merged with karmabasePath
and as result it was../../src/app/frontend/
. I've changedbasePath
to point to current folder as all ourconf.paths
havebasePath
in them.moduleName
was pointing to non existing variable. It was undefined and not loaded. I've changed it to be loaded withng
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.
There was a problem hiding this comment.
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
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :)
Got only two minor comments regarding stylesheets. LGTM |
PTAL. Also what do you think about trying to apply similar look to labels in deploy page. |
9f53b28
to
e14a69e
Compare
PTAL |
LGTM |
PTAL |
CC @kenmoore |
CC Ken, if you have any comments. |
@@ -49,7 +49,7 @@ function getFileList() { | |||
*/ | |||
module.exports = function(config) { | |||
let configuration = { | |||
basePath: conf.paths.base, | |||
basePath: '.', |
There was a problem hiding this comment.
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!
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. |
@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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
.
@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. |
Makes sense to me. They should not overwhelm user. I've changed it. PTAL |
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: 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? |
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. |
746e650
to
d2b0026
Compare
PTAL |
.kd-labels { | ||
background-color: $body; | ||
border-radius: $label-height / 2; | ||
color: $muted; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Looks great. I have last comment, I promise :) |
I've surrounded it with |
Awesome. Thank you. Will merge soon. |
Added common label formatting (as chips) and unified across the project.
Fixed Object listing page to match changed Backend response
This is how it looks:
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?