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

Use icons as field labels in Datagrid #4848

Closed
deluan opened this issue May 25, 2020 · 5 comments
Closed

Use icons as field labels in Datagrid #4848

deluan opened this issue May 25, 2020 · 5 comments
Assignees

Comments

@deluan
Copy link

deluan commented May 25, 2020

Is your feature request related to a problem? Please describe.
I want to show an icon as a column header in Datagrid, like this:
Screen Shot 2020-05-24 at 10 00 36 PM

I can achieve this with:

label={<StarBorderIcon fontSize={'small'} className={classes.columnIcon} />}

The problem is that the FieldTitle component always tries to translate the field's label, and gives this error in the console:

Warning: Missing translation for key: "[object Object]" 
    at FieldTitle (http://localhost:4533/static/js/0.chunk.js:106580:21)
    at pure(FieldTitle) (http://localhost:4533/static/js/0.chunk.js:187826:9)
    at th
    at TableCell (http://localhost:4533/static/js/0.chunk.js:27368:28)
    at WithStyles (http://localhost:4533/static/js/0.chunk.js:41841:31)
    at DatagridHeaderCell (http://localhost:4533/static/js/0.chunk.js:131626:25)
...

Describe the solution you'd like
Maybe we could have a new property in the Field that accepts a component as label, instead of using the label itself (iconLabel?).

Describe alternatives you've considered
Can't think of anything else.

@deluan deluan changed the title Use icons as field names in Datagrid Use icons as field labels in Datagrid May 25, 2020
@fzaninotto
Copy link
Member

Definitely useful! I actually need it, too. Marking it as a feature request, and working on an implementation.

@fzaninotto fzaninotto self-assigned this May 25, 2020
@deluan
Copy link
Author

deluan commented May 25, 2020

By the way, it would be nice if the implementation aligns the icon for you. To get the correct position, I had to add the following style to the icon:

  columnIcon: {
    marginLeft: '3px',
    verticalAlign: 'text-top',
  },

@deluan
Copy link
Author

deluan commented May 25, 2020

I just though about a better solution: the FieldTitle component could check for the type of the label field, and only tries to translate it if it is a string. But that would not cater for the styling I mentioned above... :(

@fzaninotto
Copy link
Member

@deluan That's what I did, see attached PR.

@fzaninotto
Copy link
Member

Fixed by #4852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants