Skip to content

Commit

Permalink
Merge pull request #176 from georgetown-cset/99-adjust-column-width-b…
Browse files Browse the repository at this point in the history
…ehavior

Adjust widths of the list view columns
  • Loading branch information
jmelot authored Nov 7, 2023
2 parents a1fcdae + 34375fc commit 8dacb27
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
5 changes: 3 additions & 2 deletions web/gui-v2/src/components/ListViewTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,12 @@ const ListViewTable = ({
switch ( colDef.type ) {
case 'companyName':
case 'dropdown':
// Set a minimum width for the dropdown menu (not the column)
let dropdownWidth;
if ( colDef?.minWidth ) {
if ( colDef?.dropdownWidth ) {
dropdownWidth = css`
.MuiPaper-root {
min-width: ${colDef.minWidth}px;
min-width: ${colDef.dropdownWidth}px;
}
`;
}
Expand Down
38 changes: 25 additions & 13 deletions web/gui-v2/src/static_data/table_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ const styles = {
width: 100%;
}
`,
sliderColumn: css`
min-width: 100px;
width: 120px;
};

.MuiButtonBase-root {
width: 100%;
}
`,
const columnWidth = (width, isSlider=false) => {
if ( isSlider ) {
return css`
min-width: ${width}px;
width: ${width}px;
.MuiButtonBase-root {
width: 100%;
}
`;
} else {
return css`
min-width: ${width}px;
`;
}
};

/**
Expand Down Expand Up @@ -86,7 +95,7 @@ const styles = {
*/
const generateSliderColDef = (dataKey, dataSubkey, extractFn, formatFn) => {
return {
css: styles.sliderColumn,
css: columnWidth(120, true),
dataKey,
dataSubkey,
extract: extractFn ?? ((_val, row) => {
Expand All @@ -105,7 +114,7 @@ const columnDefinitions = [
{
title: "Company",
key: "name",
css: styles.name,
css: [styles.name, columnWidth(200)],
format: (name, row) => (
<a
target="_blank"
Expand All @@ -115,29 +124,32 @@ const columnDefinitions = [
</a>
),
initialCol: true,
minWidth: 240,
dropdownWidth: 240,
sortable: true,
type: 'companyName',
},
{
title: "Country",
key: "country",
css: columnWidth(120),
initialCol: true,
minWidth: 180,
dropdownWidth: 180,
type: 'dropdown',
},
{
title: "Region",
key: "continent",
css: columnWidth(100),
initialCol: false,
minWidth: 170,
dropdownWidth: 170,
type: 'dropdown',
},
{
title: "Stage",
key: "stage",
css: columnWidth(80),
initialCol: false,
minWidth: 120,
dropdownWidth: 120,
type: 'dropdown',
},
{
Expand Down

0 comments on commit 8dacb27

Please sign in to comment.