Skip to content

Commit

Permalink
style: move channel table actions column to first
Browse files Browse the repository at this point in the history
this reduces potential for horizontal scrolling to get to the actions
  • Loading branch information
chrisbenincasa committed Jan 9, 2025
1 parent 13db6ec commit dedb6e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
18 changes: 6 additions & 12 deletions web/src/helpers/dayjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function betterHumanize(
const hrs = Math.floor(dur.asHours() % 24);
const mins = Math.round(dur.asMinutes() % 60);
const seconds = Math.floor(dur.asSeconds() % 60);
let builder = '';
const builder = [];

const daysStr = styleStrings[mergedOpts.style]['day'];
const hoursStr = styleStrings[mergedOpts.style]['hour'];
Expand All @@ -52,36 +52,30 @@ export function betterHumanize(
if (days >= 1) {
const d =
mergedOpts.style === 'full' ? ' ' + pluralize(daysStr, days) : daysStr;
builder += `${days}${d}`;
builder.push(`${days}${d}`);
}

if (hrs >= 1) {
const d =
mergedOpts.style === 'full' ? ' ' + pluralize(hoursStr, hrs) : hoursStr;
if (builder.length > 0 && mergedOpts.style === 'full') {
builder += ' ';
}
builder += `${hrs}${d}`;
builder.push(`${hrs}${d}`);
}

if (mins >= 1) {
const minsN = Math.round(mins);
const d =
mergedOpts.style === 'full' ? ' ' + pluralize(minStr, minsN) : minStr;
if (builder.length > 0 && mergedOpts.style === 'full') {
builder += ' ';
}
if (hrs < 1) {
const prefix = seconds > 0 && !mergedOpts.exact ? 'about ' : '';
builder += `${prefix}${padStart(minsN.toString(), 2, '0')}${d}`;
builder.push(`${prefix}${padStart(minsN.toString(), 2, '0')}${d}`);
} else {
builder += `${padStart(minsN.toString(), 2, '0')}${d}`;
builder.push(`${padStart(minsN.toString(), 2, '0')}${d}`);
}
}

if (builder.length === 0) {
return mergedOpts.style === 'short' ? '0s' : dur.humanize();
} else {
return builder;
return builder.join(' ');
}
}
13 changes: 6 additions & 7 deletions web/src/pages/channels/ChannelsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@ export default function ChannelsPage() {

const columnsNew = useMemo<MRT_ColumnDef<ChannelRow>[]>(
() => [
{
header: 'Number',
accessorKey: 'number',
minSize: 120,
size: 120,
},
{
header: 'Icon',
accessorKey: 'icon',
Expand All @@ -371,6 +365,12 @@ export default function ChannelsPage() {
enableColumnFilter: false,
enableSorting: false,
},
{
header: 'Number',
accessorKey: 'number',
minSize: 120,
size: 120,
},
{
header: 'Name',
accessorKey: 'name',
Expand Down Expand Up @@ -471,7 +471,6 @@ export default function ChannelsPage() {
visibleInShowHideMenu: false,
},
},
positionActionsColumn: 'last',
renderRowActions: renderActionCell,
onColumnVisibilityChange: (updater) => {
setColumnVisibility(updater);
Expand Down

0 comments on commit dedb6e4

Please sign in to comment.