Skip to content

Conversation

@vbersch
Copy link
Contributor

@vbersch vbersch commented Jan 30, 2020

No description provided.

@vbersch vbersch changed the title feat(AnalyticalTable): add experimental feature to determin column widths based on content feat(AnalyticalTable): add experimental feature to determine column widths based on content Jan 30, 2020

export const defaultTable = () => {
const renderTable = () => {
// const innerData = generateData(200);
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove

Suggested change
// const innerData = generateData(200);

@vbersch vbersch requested a review from Lukas742 January 30, 2020 13:56
const dataTree = generateData(20, true);

export const defaultTable = () => {
const renderTable = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please export this story again and remove the new export you have creating? having these nested component demos is breaking our storybook:
image


const makeEntry = () => ({
name: getRandomName(),
longColumn: 'Really really long column content... don´t crop please',
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the long column to the treeTableData as well? otherwise this column is always empty. Or change the columns for the treeTable back to the old config.


const classes = useStyles({ rowHeight: props.rowHeight });
const [internalRows, setInternalRows] = useState([]);
const [hiddenColumns, setHiddenColumns] = useState([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this shadow on the hidden columns? can't we just call useDynamicColumnWidths after useTable and use the columns from the tableState?

} = props;

const classes = useStyles({ rowHeight: props.rowHeight });
const [internalRows, setInternalRows] = useState([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need that? why not using the rows from the table direclty?

const updateTableClientWidth = useCallback(() => {
requestAnimationFrame(() => {
if (tableRef.current) {
setTableClientHeight(tableRef.current.clientWidth);
Copy link
Contributor

Choose a reason for hiding this comment

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

clientHeight === clientWidth?

charLength < 15 ? Math.sqrt(charLength * 1500) : 8 * charLength;
const approximateContentPxFromCharLength = (charLength) => 8 * charLength;

export const useDynamicColumnWidths = (scaleWidthMode, columns, rows, totalWidth, hiddenColumns, setColumnWidth) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we run this as a tableHook? just the our useXYZStyle hooks? then we would have access to all table data like columns, row, width, hidden columns, etc...

@vbersch vbersch requested a review from MarcusNotheis February 3, 2020 11:30
Copy link
Contributor

@MarcusNotheis MarcusNotheis left a comment

Choose a reason for hiding this comment

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

There are two code snippets that can be removed in my opinion.
Could you please run prettier on these files before merging? looks like the pre-commit hook did not run.
Other than that looks good 🚢

export const defaultTable = () => {
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
{' '}
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can remove that line?

} = props;

const classes = useStyles({ rowHeight: props.rowHeight });
// const [tableClientWidth, setTableClientWidth] = useState(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed?

@vbersch vbersch merged commit 88a98ce into master Feb 4, 2020
@vbersch vbersch deleted the feat/experimental-dynamic-table-widths branch February 4, 2020 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants