Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the optimized table dark mode friendly #29

Merged
merged 2 commits into from
Jul 7, 2023
Merged
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
14 changes: 12 additions & 2 deletions src/renderer/components/OptimizeTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import styles from './styles.module.css';

interface OptimizeTableProps {
data: unknown[][];
headers: { name: string; initialSize: number; resizable?: boolean }[];
headers: {
name: string;
initialSize: number;
resizable?: boolean;
icon?: ReactElement;
}[];
renderCell: (y: number, x: number) => ReactElement;
rowHeight: number;
renderAhead: number;
Expand Down Expand Up @@ -235,7 +240,7 @@ export default function OptimizeTable({
return (
<div
ref={containerRef}
className={styles.tableContainer}
className={`${styles.tableContainer} scroll`}
onScroll={onScroll}
>
<div
Expand All @@ -256,6 +261,11 @@ export default function OptimizeTable({
<tr>
{headers.map((header, idx) => (
<th key={header.name}>
{header.icon && (
<div className={styles.tableHeaderIcon}>
{header.icon}
</div>
)}
<div className={styles.tableCellContent}>{header.name}</div>
{header.resizable && (
<ResizeHandler idx={idx} onResize={onHeaderResize} />
Expand Down
13 changes: 11 additions & 2 deletions src/renderer/components/OptimizeTable/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@
.tableContainer th {
position: sticky;
top: 0;
background: #fff;
user-select: none;
padding: 0px 10px;
height: 35px;
line-height: 35px;
background: var(--color-surface);
text-align: left;
display: flex;
flex-direction: row;
}

.tableHeaderIcon {
margin-right: 5px;
display: flex;
align-items: center;
}

.resizer {
Expand All @@ -50,7 +59,7 @@
bottom: 0;
width: 3px;
cursor: col-resize;
background: #800;
background: var(--color-critical);
opacity: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useContextMenu } from 'renderer/contexts/ContextMenuProvider';
import { useQueryResultChange } from 'renderer/contexts/QueryResultChangeProvider';
import { useTableCellManager } from './TableCellManager';
import OptimizeTable from 'renderer/components/OptimizeTable';
import Icon from 'renderer/components/Icon';

interface QueryResultTableProps {
result: QueryResult;
Expand Down Expand Up @@ -86,7 +87,9 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
return result.headers.map((header, idx) => ({
name: header.name || '',
resizable: true,
// icon: header?.schema?.primaryKey ? <Icon.GreenKey /> : undefined,
icon: header?.schema?.primaryKey ? (
<Icon.GreenKey size="sm" />
) : undefined,
initialSize: Math.max(
header.name.length * 10,
getInitialSizeByHeaderType(idx, header)
Expand All @@ -110,8 +113,6 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
[data, updatableTables, page, pageSize]
);

console.log(headerMemo, result.rows);

return (
<div className={styles.container} onContextMenu={handleContextMenu}>
<OptimizeTable
Expand Down