-
Notifications
You must be signed in to change notification settings - Fork 841
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
Add tableLayout prop to EuiTable, EuiBasicTable and EuiInMemoryTable #2697
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/table/table.tsx
Outdated
} & CommonProps & | ||
TableHTMLAttributes<HTMLTableElement>; | ||
|
||
const tableLayoutToClassMap: { [tableLayout: string]: string | null } = { | ||
fixed: 'euiTable--fixed', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're not actually using this class in the CSS, but the default .euiTable
class gets the fixed layout and you're just overriding this with the auto class, you should just set this to null.
fixed: 'euiTable--fixed', | |
fixed: null, |
src/components/table/table.tsx
Outdated
@@ -5,20 +5,32 @@ import { CommonProps } from '../common'; | |||
export type Props = { | |||
compressed?: boolean; | |||
responsive?: boolean; | |||
tableLayout?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All new props in TS need a comment explaining what it is. This helps consumers via their IDE's auto-complete. Probably just duplicate what was written in the props_info
file.
src/components/table/_table.scss
Outdated
&.euiTable--auto { | ||
table-layout: auto; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, extra space here
return ( | ||
<div> | ||
<EuiSwitch | ||
label="Show auto layout" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label="Show auto layout" | |
label="Auto layout" |
<div> | ||
<p> | ||
<EuiCode>EuiBasicTable</EuiCode> has a fixed layout by default. You can | ||
change it to auto using the <EuiCode>tableLayout</EuiCode> prop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this description isn't enough to warrant an entire example in the docs? Consider beefing up this explanation or removing the example and just relying on props comments to explain the prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that a props comment is likely enough and this concept doesn't need a full example. Only alternative (which should be handled in a separate PR) would be to do something similar to EuiDataGrid
where we devote a full section to styling concerns and add an example with lots of toggles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was going to be my third suggestion, but figured it out of scope of this PR. So probably best to just remove this example for now.
@@ -95,6 +95,14 @@ export const propsInfo = { | |||
required: false, | |||
type: { name: '(criteria: #Criteria) => void' }, | |||
}, | |||
tableLayout: { | |||
description: 'Configures table layout', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to explain that it's configuring the CSS table-layout
property.
@cchaos With this I find myself in a loop: to truncate text we would need to set the cell width which would defeat the purpose of setting layout to auto in the first place? Is there any other way to look at it? I think that when the consumer wants some columns wider than others while still being able to use Auto layout ( Fixed layout ( Fixed layout with If we stick with this, I would add a note in the docs that |
I would do that, though it doesn't technically "override" truncateText, but it does inhibit it from calculating the other columns properly. This would then also warrant keeping the docs example so you can also add in this width to your example. |
@cchaos I've updated the example to look like this. Let me know what you think |
PR to simplify TypeScript type definitions and extensions: andreadelrio#5 |
TypeScript cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just had a couple more suggestions for the doc example
@@ -95,6 +95,15 @@ export const propsInfo = { | |||
required: false, | |||
type: { name: '(criteria: #Criteria) => void' }, | |||
}, | |||
tableLayout: { | |||
description: | |||
'Sets the table-layout CSS property. Note that auto tableLayout prevents truncateText from working regularly.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Sets the table-layout CSS property. Note that auto tableLayout prevents truncateText from working regularly.', | |
'Sets the table-layout CSS property. Note that auto tableLayout prevents truncateText from working properly.', |
const html = renderToHtml(Table); | ||
|
||
export const section = { | ||
title: 'A BasicTable with auto layout', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is no longer about just auto
layout but layout in general
title: 'A BasicTable with auto layout', | |
title: 'Table layout', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I think this PR satisfies the issue but pushes towards a better solution (using widths) in the docs.
Summary
This PR adds the
tableLayout
prop toEuiTable
which in turns makes it available inEuiBasicTable
andEuiInMemoryTable
. The default value isfixed
with the option to change it toauto
.I thought it'd be good to add a small example to the docs to show the new prop in action.
Fixes #461
Checklist
- [ ] Check against all themes for compatability in both light and dark modes- [ ] Checked in mobile- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes