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

feat: SIP-34 card/grid views for dashboards and charts #10526

Merged
merged 19 commits into from
Aug 13, 2020

Conversation

nytai
Copy link
Member

@nytai nytai commented Aug 5, 2020

SUMMARY

  • card viewing mode for dashboards list view
  • card viewing mode for charts list view

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After:
Screen Shot 2020-08-05 at 3 48 31 PM
Screen Shot 2020-08-05 at 3 50 31 PM

TEST PLAN

  • WIP

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI (behind ENABLE_REACT_CRUD_VIEWS flag)
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@mistercrunch
Copy link
Member

mistercrunch commented Aug 5, 2020

My first impression visually (more of a note for our designers) is that we could have 4 columns in the grid, maybe even 5.

Super stoked to see this!

@nytai
Copy link
Member Author

nytai commented Aug 6, 2020

@mistercrunch the screenshots were taken on my retina laptop screen simulating 1680px width. On my 4k external monitor set to 3008px width we end up with a 5 column layout.

Screen Shot 2020-08-05 at 7 05 41 PM

Initially design specified behavior where the cards would also scale with the window up until a point but we ended up deferring that implementation until we had a better framework for responsiveness in superset.

@codecov-commenter
Copy link

codecov-commenter commented Aug 6, 2020

Codecov Report

Merging #10526 into master will decrease coverage by 4.15%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10526      +/-   ##
==========================================
- Coverage   63.60%   59.44%   -4.16%     
==========================================
  Files         763      358     -405     
  Lines       36120    22918   -13202     
  Branches     3408        0    -3408     
==========================================
- Hits        22973    13624    -9349     
+ Misses      13034     9294    -3740     
+ Partials      113        0     -113     
Flag Coverage Δ
#cypress ?
#javascript ?
#python 59.44% <ø> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/charts/api.py 73.89% <ø> (ø)
superset/views/database/mixins.py 59.64% <0.00%> (-21.06%) ⬇️
superset/db_engine_specs/mysql.py 79.16% <0.00%> (-12.33%) ⬇️
superset/tasks/slack_util.py 89.47% <0.00%> (-10.53%) ⬇️
superset/views/database/validators.py 78.94% <0.00%> (-5.27%) ⬇️
superset/views/alerts.py 66.66% <0.00%> (-4.17%) ⬇️
superset/databases/api.py 85.18% <0.00%> (-2.78%) ⬇️
superset/models/tags.py 61.20% <0.00%> (-2.76%) ⬇️
superset/common/query_context.py 82.50% <0.00%> (-2.76%) ⬇️
superset/db_engine_specs/postgres.py 97.43% <0.00%> (-2.57%) ⬇️
... and 468 more

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 ece9192...e58429e. Read the comment docs.

@nytai nytai marked this pull request as ready for review August 6, 2020 23:38
@mistercrunch
Copy link
Member

The rails look very wide, how do other tools deal with this. [off to pinterest.com ...] Looks like the rails between cards is constant, but the leftmost and rightmost rails are dynamic and the cards that fit in are centered.

}

const CardContainer = styled.div`
justify-content: space-between;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks fine when there are 3+ columns, but with 2 columns the cards look like they're pushed to the edges of the container:
Screen Shot 2020-08-07 at 11 42 57 AM

Using justify-content: space-around would space them more evenly:
Screen Shot 2020-08-07 at 11 44 40 AM

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 ended up ditching the flexbox implementation in favor of CSS grid. I really didn't like how this was sometimes happening on the last row

Screen Shot 2020-08-07 at 2 24 20 PM

Copy link

@kalimuthu123 kalimuthu123 left a comment

Choose a reason for hiding this comment

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

ya good feature go ahead


.cover-footer {
transform: translateY(36px);
transition: 0.2s ease-out;
Copy link
Member

Choose a reason for hiding this comment

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

theme.transitionTiming is 0.3 if you wanna base this on that var.

const CardCoverImg = styled.img`
display: block;
object-fit: cover;
width: 459px;
Copy link
Member

Choose a reason for hiding this comment

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

Could just be 100% width, and auto height if the card has its own width set, I 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.

Doesn't seem to like that

Screen Shot 2020-08-12 at 5 32 55 PM

th {
background: white;
Copy link
Member

Choose a reason for hiding this comment

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

theme.colors.grayscale.light5


.actions {
white-space: nowrap;
font-size: 24px;
Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm... the theme has

      xl: 21,
      xxl: 28

... I wonder if we should use one of those, and possibly adjust the value if needed. The current theme values are based on the LESS variables file, and might need to be updated to more closely match SIP-34 specs.

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, I don't think this is even necessary anymore. This is left over from the days of the font-awesome icons.

className={cx('table-cell', {
'table-cell-loader': loading,
[cell.column.size || '']: cell.column.size,
<TableContainer>
Copy link
Member

Choose a reason for hiding this comment

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

If Table is a styled table is there any need for this TableContainer to exist? Seems like those styles could just be part of the Table styles.

{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => {
let sortIcon = <Icon name="sort" />;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is easier or harder to parse ¯\_(ツ)_/¯ :
<Icon name={column.isSorted ? (column.isSortedDesc ? "sort-desc" : "sort-desc") : "sort" } />

Also, you could just set the value of sortIconName and then use it inline later in rendering, i.e. {column.canSort && <Icon name={sortIconName} />

Copy link
Member

Choose a reason for hiding this comment

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

These are just indentation changes, so sorry if I'm off target ;)

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 we're allowed nested ternaries per our eslint rules. I've already caused a bug trying to "simplify" this logic once, I'd like to avoid touching this logic again unless necessary.

`;

const CardWrapper = styled.div`
display: inline-block;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure this is needed, if the parent is a grid?

Actually, I wonder if CardWrapper is needed at all, if the key could be passed into the renderCard method.

Copy link
Member Author

@nytai nytai Aug 12, 2020

Choose a reason for hiding this comment

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

I think it's good to have a wrapper, this ensures the key is always present. I don't think the implementation of renderCard should have to know that it is responsible for adding the key prop to the resulting JSX. It's something I often forget. This also provides a wrapper div to implement additional functionality, eg bulk select. I'll remove the unnecessary styling though.

@@ -21,20 +21,28 @@ import { t } from '@superset-ui/translation';
import PropTypes from 'prop-types';
import React from 'react';
import rison from 'rison';
import { Label } from 'react-bootstrap';
Copy link
Member

Choose a reason for hiding this comment

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

Could this be the Label from src/components/Label?

Copy link
Member Author

Choose a reason for hiding this comment

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

Did that PR already get merged? I'll rebase and use that.

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Code LGTM... I ought to do some local testing with it, but I don't want to block the PR for that since it's still behind a feature flag anyway.

@nytai nytai merged commit db88cec into apache:master Aug 13, 2020
@nytai nytai deleted the tai/card-view branch August 13, 2020 21:47
@rusackas
Copy link
Member

Impacts #8976

Ofeknielsen pushed a commit to ofekisr/incubator-superset that referenced this pull request Oct 5, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants