Skip to content

Commit

Permalink
Merge kernel and icon columns
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed May 6, 2024
1 parent 47fb10d commit 6077109
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
74 changes: 34 additions & 40 deletions src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,50 +122,44 @@ export function KernelTable(props: {
);

const availableColumns: Table.IColumn<IKernelItem>[] = [
{
id: 'icon',
label: trans.__('Icon'),
renderCell: (row: IKernelItem) => (
<div
className="jp-LauncherCard-icon"
onClick={() => props.onClick(row)}
>
{row.kernelIconUrl ? (
<img
src={row.kernelIconUrl}
className="jp-Launcher-kernelIcon"
alt={row.label}
/>
) : (
<div className="jp-LauncherCard-noKernelIcon">
{row.label[0].toUpperCase()}
</div>
)}
</div>
),
sort: (a: IKernelItem, b: IKernelItem) =>
a.command.localeCompare(b.command)
},
{
id: 'kernel',
label: trans.__('Kernel'),
renderCell: (row: IKernelItem) => (
<span
className={KERNEL_ITEM_CLASS}
onClick={event => {
props.onClick(row);
event.stopPropagation();
}}
onKeyDown={event => {
// TODO memoize func defs for perf
if (event.key === 'Enter') {
row.execute();
}
}}
tabIndex={0}
>
{row.label}
</span>
<>
<span
className="jp-LauncherCard-icon"
onClick={() => props.onClick(row)}
>
{row.kernelIconUrl ? (
<img
src={row.kernelIconUrl}
className="jp-Launcher-kernelIcon"
alt={row.label}
/>
) : (
<div className="jp-LauncherCard-noKernelIcon">
{row.label[0].toUpperCase()}
</div>
)}
</span>
<span
className={KERNEL_ITEM_CLASS}
onClick={event => {
props.onClick(row);
event.stopPropagation();
}}
onKeyDown={event => {
// TODO memoize func defs for perf
if (event.key === 'Enter') {
row.execute();
}
}}
tabIndex={0}
>
{row.label}
</span>
</>
),
sort: (a: IKernelItem, b: IKernelItem) => a.label.localeCompare(b.label)
},
Expand Down
10 changes: 10 additions & 0 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,20 @@

.jp-NewLauncher-table .jp-LauncherCard-noKernelIcon {
font-size: var(--jp-icon-size);
line-height: var(--jp-icon-size);
}

.jp-NewLauncher-table .jp-LauncherCard-icon {
height: var(--jp-icon-size);
width: var(--jp-icon-size);
display: inline-block;
}

.jp-TableKernelItem {
display: inline-block;
line-height: var(--jp-icon-size);
vertical-align: top;
padding-left: 4px;
}

.jp-NewLauncher-table th[data-id='icon'],
Expand Down

0 comments on commit 6077109

Please sign in to comment.