Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/visualizations-react/stories/Table/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const columns: Column[] = [
options: {
display: (title: string) => `${title.toUpperCase()}`,
},
size: 'medium',
},
{
title: 'Price',
Expand All @@ -24,6 +25,7 @@ export const columns: Column[] = [
title: 'Content',
key: 'content',
dataFormat: 'long-text',
size: 'large',
},
{
title: 'Published date',
Expand Down
28 changes: 22 additions & 6 deletions packages/visualizations/src/components/Table/Cell/Cell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
export let rawValue: unknown;
export let column: Column;
const defautSize = 'fit-content';
$: ({ dataFormat, options = {} } = column);
$: ({ dataFormat, options = {}, size } = column);
$: columnSizeClass = size ? `table-column-size--${size}` : `table-column-size--${defautSize}`;
</script>

<!-- To display a format value, rawValue must be different from undefined or null -->
<td class={`table-data--${dataFormat}`}>
<td class={`table-data--${dataFormat} ${columnSizeClass}`}>
{#if isValidRawValue(rawValue)}
<svelte:component this={Format[dataFormat]} {rawValue} {...options} />
{/if}
Expand All @@ -24,23 +26,37 @@
text-align: right;
}
/* to be improved in the formatting story */
:global(.ods-dataviz--default td.table-data--long-text > span),
:global(.ods-dataviz--default td.table-data--long-text),
:global(.ods-dataviz--default td.table-data--short-text),
:global(.ods-dataviz--default td.table-data--url) {
text-overflow: ellipsis;
overflow: hidden;
width: max-content;
min-width: 40px;
max-width: 240px;
}
:global(.ods-dataviz--default td.table-data--long-text > span) {
:global(.ods-dataviz--default td.table-data--long-text > span),
:global(.ods-dataviz--default td.table-data--geo > div) {
Copy link
Contributor

Choose a reason for hiding this comment

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

image

Geo labels are no longer vertically centered

Are we sure we want to display geo labels on 3 lines?

display: -webkit-box;
-webkit-line-clamp: 3;
line-clamp: 3;
-webkit-box-orient: vertical;
white-space: pre-wrap;
width: max-content;
max-width: 100%;
overflow: hidden;
}
:global(.ods-dataviz--default td.table-data--number) {
text-align: right;
}
td.table-column-size--large {
max-width: 400px;
}
td.table-column-size--medium {
max-width: 200px;
}
td.table-column-size--small {
max-width: 100px;
}
td.table-column-size--fit-content {
max-width: none;
}
</style>
1 change: 1 addition & 0 deletions packages/visualizations/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type BaseColumn = {
desc: string;
};
onClick?: () => void;
size?: 'large' | 'medium' | 'small' | 'fit-content';
Copy link
Contributor

Choose a reason for hiding this comment

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

If this option is not used at all for a table.
There is not difference between using a short-text and a long-text column.

image

Long texts no longer break on new line as there is no default max-width.

I agree with the comment made by @etienneburdet that default max-width should be set for some column types

};

export type ShortTextColumn = BaseColumn & {
Expand Down