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

fix(ui): ensure all dashboard cards render the same size #17612

Merged
merged 4 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

1. [17490](https://github.com/influxdata/influxdb/pull/17490): `influx config -`, to switch back to previous activated configuration

### Bug Fixes

1. [17612](https://github.com/influxdata/influxdb/pull/17612): Fix card size and layout jank in dashboards index view

### UI Improvements

1. [17583](https://github.com/influxdata/influxdb/pull/17583): Update layout of Alerts page to work on all screen sizes
Expand Down
8 changes: 7 additions & 1 deletion ui/cypress/e2e/dashboardsView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,13 @@ describe('Dashboard', () => {
cy.createDashWithViewAndVar(orgID).then(() => {
cy.fixture('routes').then(({orgs}) => {
cy.visit(`${orgs}/${orgID}/dashboards`)
cy.getByTestID('dashboard-card--name').click()
cy.getByTestID('dashboard-card--name').within(() => {
// Ideally we don't need to select the clickable element within the card name.
// The testID here should be on the clickable element
// Issue created in Clockface: https://github.com/influxdata/clockface/issues/478
cy.get('.cf-resource-name--text').click()
})

cy.get('.cell--view').should('have.length', 1)
})
})
Expand Down
50 changes: 33 additions & 17 deletions ui/src/dashboards/components/DashboardsCardGrid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,53 @@
}

.dashboards-card-grid {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 150px 150px 150px;
grid-column-gap: $ix-marg-a;
grid-row-gap: $ix-marg-a;
height: 100%;

.cf-resource-card {
margin-bottom: 0;
}

.cf-resource-description {
height: 60px;
padding-bottom: $cf-marg-d;
display: grid;
grid-template-columns: minmax(100%, 1fr);
grid-auto-rows: 152px;
grid-column-gap: $cf-marg-a;
grid-row-gap: $cf-marg-a;
height: 100%;

.cf-resource-card {
margin-bottom: 0;
}

.cf-resource-card--contents {
position: relative;
}

.cf-resource-editable-name {
position: absolute;
width: 100%;

.cf-resource-name--text {
overflow: hidden;
}
text-overflow: ellipsis;
}
}

.cf-resource-description {
height: 60px;
margin-top: 22px;
overflow: hidden;
}
}

@media screen and (min-width: $cf-grid--breakpoint-sm) {
.dashboards-card-grid {
grid-template-columns: 1fr 1fr;
grid-template-columns: minmax(50%, 1fr) minmax(50%, 1fr);
}
}

@media screen and (min-width: $cf-grid--breakpoint-md) {
.dashboards-card-grid {
grid-template-columns: 1fr 1fr 1fr;
grid-template-columns: minmax(33.3333%, 1fr) minmax(33.3333%, 1fr) minmax(33.3333%, 1fr);
Copy link
Contributor

Choose a reason for hiding this comment

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

minmax is like the CSS version of the interrobang

Also, fr???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a CSS Grid thing. Stands for "fractional unit" and in this context controls how big the columns are. So 1fr 1fr 1fr means divide up into 3 even columns.

Using minmax() ensures that the columns don't exceed that size

}
}

@media screen and (min-width: $cf-grid--breakpoint-lg) {
.dashboards-card-grid {
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-columns: minmax(25%, 1fr) minmax(25%, 1fr) minmax(25%, 1fr) minmax(25%, 1fr);
}
}