Git Product home page Git Product logo

smart-data-table's Introduction

Smart Data Table

Under Development A wrapper for fixed-data-table with Material Design and smart things like responding to container width and height, automatically parsing columns, translating strings, and coercing values.

Features

This "smart" wrapper for fixed-data-table tries to be smart about how to display data with some opinionated defaults. Uses some components from material-ui It avoids managing state in most cases, designed to be used in a wrapper that will add hooks to configuration like columns to display and column resizing and pass new props. Not all these features are implemented yet.

  • First opinion: no horizontal scrolling. It will only show a subset of columns based on how many will fit in the width available and minimum column width.
  • Parse json or geojson and automatically create columns based on unique keys, including nested values.
  • Allow configuration of column order, displayed columns, blacklisted columns (columns that should never display), and column priority (i.e. which columns should be kept as screen size reduces e.g. you have columns ['a','b','c', 'd']`` and you want aandd` to display on smaller screens)
  • Integrate with react-intl to translate column keys to strings and cell contents.
  • Coerce dates (JSON has no date datatype) and localize with formatjs.
  • UI to change which columns are displayed - no state: needs plugin hook to respond to changes and pass new props.
  • UI for column sorting - managed as state
  • UI for column resizing (provided by fixed-data-table) - not managed as state, wrapper should add hook and pass column widths.
  • Checkboxes to select multiple rows - no state, wrapper should respond to selection, maintain state of selected rows, and add custom action buttons. This may be better as state and action buttons managed within this component?

Try it out

git clone https://github.com/digidem/smart-data-table.git

npm install

npm start

Visit http://localhost:9966/

Roadmap

  • Make responsive with dynamic height and width from container height and width
  • Style as Material Design
  • Add column sort
  • Add dropdown menus to change columns
  • Add checkboxes to each row
  • Allow row selection & select all
  • Add contextual action buttons on column selection

Collaboration

Please check out this issues and join the discussion about how to design this, and feel free to jump in with pull requests. Please assign an issue to yourself if you are going to start working on something, so others know, and remove your assignment if you stop working.

smart-data-table's People

Contributors

gmaclennan avatar

Stargazers

Matthew Downs avatar Ryan Hamblin avatar Venelin avatar

Watchers

Rob Heittman avatar  avatar Alison Heittman avatar James Cloos avatar Carl Scott avatar  avatar Venelin avatar  avatar  avatar

smart-data-table's Issues

Localization

How best to handle internationalization? This is not just for translation but for translating key values to human readable strings, from both column headings and cell contents which are values rather than human-readable sentences.

Probably best is pass translations as a prop, and then use custom cell and header renderers to parse strings. Can default to at least converting _ to space and changing to sentence case if no translation exists.

Row selection

Each row should have a checkbox allowing multiple rows to be selected, and a checkbox in the header to select all rows. We should add contextual buttons for actions on selected rows:

We can handle row select as state, with callbacks for each action button. We could maybe have some default actions that could be turned on and off by props.

Column sorting

Clicking a column header should sort, following these guidelines / style.

This can be handled by internal state - there is no need to save this in app state.

We need to make a shallow copy of this.props.rows to avoid mutating that when we sort.

Column configuration

We try to be smart about how many columns to show. Right now which columns are shown is completely arbitrary, but can be configured, see get-column-nodes.jsx#L18-L54.

We could be smarter, making some reasonable guesses about which columns should be shown and which order (date field first?).

Column widths are all currently set to the same using flexGrow, we could be smarter about this setting some kind of auto-width. Rendering all the rows to calculate width would not be scalable, but we could use number of characters to approximate relative column widths. Parsing a long array of JSON objects for string lengths should not take too long.

What is the best API for column configuration? Right now it is different arrays: columnOrder, columnPriority, columnBlacklist. Maybe better to have a single array of objects to configure columns?

Column priority is not currently implemented. The idea is that given columns ['a','b','c', 'd'] which all show on a larger display, we might want ['a','c', 'd'] on tablets and ['a', 'd'] on mobile. Maybe we only need to sign a numeric priority to each column, rather than using an array that assigns a priority to each one? Maybe too much work for now.

Column selection

We display a subset of columns based on screen set. Each column should be configurable via a drop-down that shows a list of hidden columns that you can switch to.

Currently this dropdown is rendered with DropDownMenu but it would be better to bring up the menu via an edit icon and keep the column header click for sorting:

The menu is currently mainly hidden because of overflow: hidden set on fixed-data-table. We need to render via a portal to escape this.

Probably easiest would be to render a material-ui Menu on a button click into a portal and overlaid.

The table itself should not handle a state change, but instead fire an event handler "onColumnChanged" and the wrapper component should update props accordingly. This allows us to manage this state within application config, so that when we return to the table view we keep the column configuration.

Icons for image and location

Would be nice to show an icon on each row to indicate if the record has an image and/or a location. Need to think of a UI for this, maybe buttons at the start of the row like this and this. Need to figure out how to parse row data to guess if there is an image and/or location.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.