Skip to content

feat: header functionality for the list view #806

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

Merged
merged 8 commits into from
May 4, 2021

Conversation

itssharmasandeep
Copy link
Contributor

Description

Header functionality for the list view

Testing

Local testing done

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Screenshot 2021-04-30 at 12 34 48 PM

@itssharmasandeep itssharmasandeep requested a review from a team as a code owner April 30, 2021 07:06
@itssharmasandeep itssharmasandeep changed the title feat: Header functionality for the list view feat: header functionality for the list view Apr 30, 2021
@codecov
Copy link

codecov bot commented Apr 30, 2021

Codecov Report

Merging #806 (add59cf) into main (5f7770f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #806   +/-   ##
=======================================
  Coverage   85.42%   85.43%           
=======================================
  Files         792      792           
  Lines       16197    16198    +1     
  Branches     2070     2070           
=======================================
+ Hits        13837    13838    +1     
  Misses       2329     2329           
  Partials       31       31           
Impacted Files Coverage Δ
...ts/components/src/list-view/list-view.component.ts 100.00% <100.00%> (ø)
projects/components/src/public-api.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f7770f...add59cf. Read the comment docs.

@@ -7,6 +7,33 @@
display: flex;
flex-direction: column;

.header {
flex: 0 0 auto;
Copy link
Contributor

Choose a reason for hiding this comment

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

flex: 0 0 auto; you probably don't need this if you are setting a fixed width/height

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will check for it.

@github-actions

This comment has been minimized.


.header-key {
flex: 1 1 auto;
font-weight: 600;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a mixin that we can use here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was looking for it but could not find.
I will check more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please have a look

text-transform: uppercase;
}
.header-key:nth-child(1) {
width: 40%;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in sync with the data row. Why not use css grids? we can define a fixed column widths that both header and data row can share

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can refactor this whole css file using css grid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the change, please have a look!!

@@ -6,6 +6,11 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="list-view">
<div *ngIf="this.headerKeys && this.headerKeys.length === 2" class="header">
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: class="header-row"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!!

@@ -18,6 +23,9 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
`
})
export class ListViewComponent {
@Input()
public headerKeys?: [string, string];
Copy link
Contributor

Choose a reason for hiding this comment

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

ListViewRecord also has key and value properties. So, instead of headerKeys should we have two properties: keyHeaderLabel: string and 'valueHeaderLabel: string`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we can have that, But instead of making these two different inputs, we can just create and interface with these two attributes and use that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, like 'headerLabel?: ListHeaderLabel;'

Interface ListHeaderLabel { key: string; value: string;}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess, interface ListHeader { keyLabel: string; valueLabel: string} this would be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. This is fine too!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

.list-view {
height: 100%;
width: 100%;
overflow: auto;
display: flex;
flex-direction: column;

.header-row {
@include grid-view();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work isolating column width as variables.

I think you can just add these grid properties to list-view class. No need to add it in both header and data row with flex column in list view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!!

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I was thinking more like this

.list-view{
  height: 100%;
  width: 100%;
  overflow: auto;
  width: 100%;
  padding: 8px 0;
  display: grid;
  grid-template-columns: $key-width $value-width;
  align-content: center;
  
  
  .header-key-label{}
  
  .header-value-label{}
  
  .data-key{}
  
  .data-value{} 
}

Is this something we can do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we'll have to put some styles twice like

  1. Header shadow and background
  2. Alternate background for data row and column etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if needed for this, we can take this as follow up work.
I am merging changes for now.

@github-actions

This comment has been minimized.

width: 100%;
word-break: break-word;
padding: 8px 0;
& > * {
Copy link
Contributor

Choose a reason for hiding this comment

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

list-view could have a huge number of children. In such cases, this does us more harm than good. We should use a class name here instead of the wildcard.

@github-actions

This comment has been minimized.

Copy link
Contributor

@arjunlalb arjunlalb left a comment

Choose a reason for hiding this comment

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

LGTM.

@github-actions

This comment has been minimized.

@itssharmasandeep itssharmasandeep merged commit b892acd into main May 4, 2021
@itssharmasandeep itssharmasandeep deleted the list-view-header branch May 4, 2021 06:40
@github-actions
Copy link

github-actions bot commented May 4, 2021

Unit Test Results

    4 files  ±0  250 suites  ±0   16m 17s ⏱️ + 2m 26s
897 tests ±0  897 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
903 runs  ±0  903 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit b892acd. ± Comparison against base commit 5f7770f.

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.

3 participants