Skip to content

Commit

Permalink
[docs] Update example w/ truncation to include new multiline feature
Browse files Browse the repository at this point in the history
+ fix default starting valign - should be middle, not top
  • Loading branch information
cee-chen committed Oct 4, 2023
1 parent d3ec396 commit 81a3b34
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src-docs/src/views/tables/auto/auto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ const columns: Array<EuiTableFieldDataColumnType<User>> = [
{
field: 'jobTitle',
name: 'Job title',
truncateText: true,
},
{
field: 'address',
name: 'Address',
truncateText: true,
truncateText: { lines: 2 },
},
];

Expand Down Expand Up @@ -147,11 +148,12 @@ const alignButtons: EuiButtonGroupOptionProps[] = [

export default () => {
const [tableLayout, setTableLayout] = useState('tableLayoutFixed');
const [vAlign, setVAlign] = useState('columnVAlignTop');
const [vAlign, setVAlign] = useState('columnVAlignMiddle');
const [align, setAlign] = useState('columnAlignLeft');

const onTableLayoutChange = (id: string, value: string) => {
setTableLayout(id);
columns[4].width = value === 'custom' ? '100px' : undefined;
columns[5].width = value === 'custom' ? '20%' : undefined;
};

Expand All @@ -169,14 +171,16 @@ export default () => {

switch (tableLayout) {
case 'tableLayoutFixed':
callOutText = 'Address has truncateText set to true';
callOutText =
'Job title has truncateText set to true. Address is set to { lines: 2 }';
break;
case 'tableLayoutAuto':
callOutText =
'Address has truncateText set to true which is not applied since tableLayout is set to auto';
'Job title will not wrap or truncate since tableLayout is set to auto. Address will truncate if necessary';
break;
case 'tableLayoutCustom':
callOutText = 'Address has truncateText set to true and width set to 20%';
callOutText =
'Job title has a custom column width of 100px. Address has a custom column width of 20%';
break;
}

Expand Down

0 comments on commit 81a3b34

Please sign in to comment.