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

table consumes css attributes from theme #1235

Merged
merged 2 commits into from
Feb 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const getPercentageValue = (value: number) => {
};

export const PctProgressCell = ({ column, columnMap, row }: TableCellProps) => {
if (row[0] === 0) {
console.log({ row });
}
const value = row[columnMap[column.name]];

const percentageValue = getPercentageValue(value);
Expand Down
38 changes: 24 additions & 14 deletions vuu-ui/packages/vuu-table/src/Row.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,33 @@
white-space: nowrap;
}

.vuuTableRow-even {
--row-background: var(--row-background-even);
}
.vuuTableRow-proxy {
visibility: hidden;
}

.vuuTableRow-highlighted {
background-color: var(--vuu-color-gray-10);
}
.vuuTableRow-even {
--row-background: var(--row-background-even);
}

.vuuTableRow-highlighted {
background-color: var(--salt-selectable-background-hover);
}

.vuuTableRow-selected,
.vuuTableRow-selectedEnd {
/* background-color: rgb(133,133,137,.16); */
background-color: rgb(235,235,236);
}

.vuuTableRow-selected,
.vuuTableRow-selectedEnd {
--row-borderColor: var(--salt-separable-secondary-borderColor);
background-color: var(--salt-selectable-background-selected);
}

.vuuTable-zebra {
.vuuTableRow-even.vuuTableRow-selected,
.vuuTableRow-even.vuuTableRow-selectedEnd {
/** thisis really where we want a darken function */
background-color: var(--vuu-color-gray-07);

}
}

.vuuTableRow-selectedStart {
--vuu-selection-decorator-left-radius: 5px 0 0 0;
Expand Down Expand Up @@ -90,9 +103,6 @@
--vuu-selection-decorator-bg: white;
}

.vuuTableRow-selectedStart.vuuTableRow-selectedEnd {

}

.vuuTableRow-selectedStart .vuuTableRow-selectionDecorator:before,
.vuuTableRow-selectedEnd .vuuTableRow-selectionDecorator:before {
Expand Down
25 changes: 24 additions & 1 deletion vuu-ui/packages/vuu-table/src/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
RowSelected,
} from "@finos/vuu-utils";
import cx from "clsx";
import { CSSProperties, memo, MouseEvent, useCallback } from "react";
import {
CSSProperties,
forwardRef,
memo,
MouseEvent,
useCallback,
} from "react";
import { TableCell, TableGroupCell } from "./table-cell";

import "./Row.css";
Expand All @@ -37,6 +43,23 @@ export interface RowProps {
const { IDX, IS_EXPANDED, SELECTED } = metadataKeys;
const classBase = "vuuTableRow";

// A dummy Table Row rendered once and not visible. We measure this to
// determine height of Row(s) and monitor it for size changes (in
// case of runtime density switch). This allows ListItem height to
// be controlled purely through CSS.
export const RowProxy = forwardRef<HTMLDivElement, { height?: number }>(
function RowProxy({ height }, forwardedRef) {
return (
<div
aria-hidden
className={cx(classBase, `${classBase}-proxy`)}
ref={forwardedRef}
style={{ height }}
/>
);
}
);

// export const Row = memo(
export const Row = memo(
({
Expand Down
13 changes: 3 additions & 10 deletions vuu-ui/packages/vuu-table/src/Table.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
}

.vuuTable-colLines {
--cell-borderColor: var(--salt-separable-tertiary-borderColor);
--cell-borderColor: var(--salt-separable-tertiary-borderColor);
}

.vuuTable-rowLines {
--row-borderColor: var(--salt-separable-tertiary-borderColor);
}

.vuuTable-highlight .vuuTableRow:hover {
background-color: var(--vuu-color-pink-10-fade-20);
--row-borderColor: var(--salt-separable-tertiary-borderColor);
}

.vuuTable-scrollbarContainer {
--scroll-content-width: 1100px;
border-bottom: none !important;
border-top: none !important;
border-left: solid 1px var(--salt-container-primary-borderColor);
Expand Down Expand Up @@ -98,7 +93,6 @@
width: var(--content-width);
margin: 0;
border: none;
background-color: #fff;
border-collapse: separate;
border-spacing: 0;
}
Expand Down Expand Up @@ -136,14 +130,13 @@


.sizer-cell {
background-color: green !important;
border: none !important;
height: 0px;
}

.vuuDraggable-vuuTable {
--header-height: 25px;
--vuuTableHeaderCell-background: var(--vuu-color-gray-25);
--vuuTableHeaderCell-background: var(--salt-container-secondary-background);
}
.vuuDraggable-vuuTable {
--row-height: 25px;
Expand Down
19 changes: 15 additions & 4 deletions vuu-ui/packages/vuu-table/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ import {
FC,
ForwardedRef,
forwardRef,
RefCallback,
RefObject,
useCallback,
useRef,
useState,
} from "react";
import { Row as DefaultRow, RowProps } from "./Row";
import { Row as DefaultRow, RowProps, RowProxy } from "./Row";
import { TableHeader } from "./table-header/TableHeader";
import { useTable } from "./useTable";

Expand Down Expand Up @@ -140,14 +142,15 @@ const TableCore = ({
onSelect,
onSelectionChange,
renderBufferSize = 5,
rowHeight = 20,
rowHeight,
scrollingApiRef,
selectionModel = "extended",
showColumnHeaders = true,
headerHeight = showColumnHeaders ? 25 : 0,
size,
}: TableProps & {
}: Omit<TableProps, "rowHeight"> & {
containerRef: RefObject<HTMLDivElement>;
rowHeight: number;
size: MeasuredSize;
}) => {
const id = useId(idProp);
Expand Down Expand Up @@ -304,7 +307,7 @@ export const Table = forwardRef(function TableNext(
onSelect,
onSelectionChange,
renderBufferSize,
rowHeight,
rowHeight = 20,
scrollingApiRef,
selectionModel,
showColumnHeaders,
Expand All @@ -318,6 +321,12 @@ export const Table = forwardRef(function TableNext(

const [size, setSize] = useState<MeasuredSize>();

const rowHeightProxyRef = useCallback<RefCallback<HTMLDivElement>>((el) => {
console.log(`row proxy `, {
el,
});
}, []);

if (config === undefined) {
throw Error(
"vuu Table requires config prop. Minimum config is list of Column Descriptors"
Expand All @@ -335,6 +344,8 @@ export const Table = forwardRef(function TableNext(
onResize={setSize}
ref={useForkRef(containerRef, forwardedRef)}
>
<RowProxy ref={rowHeightProxyRef} height={rowHeight} />

{size ? (
<TableCore
Row={Row}
Expand Down
3 changes: 3 additions & 0 deletions vuu-ui/packages/vuu-theme/css/foundations/color.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
--vuu-color-pink-10-fade-20: rgba(234, 120, 128, .2); /* #F37880 */


--vuu-color-gray-02: rgb(235, 235, 236); /* #EBEBEC */
--vuu-color-gray-03: rgb(237, 237, 237); /* #EDEDED */
--vuu-color-gray-05: rgb(222, 222, 222); /* #DEDEDE */
--vuu-color-gray-07: rgb(226, 226, 227); /* #E2E2E3 */
--vuu-color-gray-10: rgb(228, 227, 231); /* #E4E3E7 */
--vuu-color-gray-20: rgb(245, 242, 248); /* #F5F2F8 */
--vuu-color-gray-25: rgb(244, 244, 244) ; /* #F4F4F4 */
Expand All @@ -34,6 +36,7 @@
--vuu-color-gray-50: rgb(96, 100, 119); /* #606477 */
--vuu-color-gray-80: rgb(21, 23, 27); /* #15171B */


--vuu-color-green-50: rgb(102, 174, 90); /* #66AE5A */
--vuu-color-green-60: rgb(36, 137, 19); /* #248913 */
--vuu-color-green-60-fade-30: rgba(36, 137, 19, .3); /* #248913 */
Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-theme/css/palette/interact.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--salt-palette-interact-background: transparent;
--salt-palette-interact-background-blurSelected: var(--salt-color-gray-30);
--salt-palette-interact-background-hover: var(--vuu-color-gray-10);
--salt-palette-interact-background-active: var(--vuu-color-blue-40);
--salt-palette-interact-background-active: var(--vuu-color-gray-02);
--salt-palette-interact-background-disabled: var(--vuu-color-gray-35);
--salt-palette-interact-background-activeDisabled: var(--salt-color-blue-30-fade-background);
--salt-palette-interact-border: var(--vuu-color-gray-45);
Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-theme/css/palette/neutral.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--salt-palette-neutral-secondary-foreground: var(--salt-color-gray-200);
--salt-palette-neutral-secondary-foreground-disabled: var(--salt-color-gray-200-fade-foreground);
--salt-palette-neutral-backdrop: var(--salt-color-white-fade-backdrop);
--salt-palette-neutral-secondary-separator: var(--salt-color-black-fade-separatorOpacity-secondary);
--salt-palette-neutral-secondary-separator: var(--vuu-color-gray-05);
--salt-palette-neutral-tertiary-separator: var(--vuu-color-gray-03);
}

Expand Down
6 changes: 3 additions & 3 deletions vuu-ui/packages/vuu-ui-controls/src/list/useListHeight.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MeasuredSize } from "@finos/vuu-ui-controls";
import { useCallback, useMemo, useRef, useState } from "react";
import { RefCallback, useCallback, useMemo, useRef, useState } from "react";
import { HeightOnly, ResizeHandler, useResizeObserver } from "../common-hooks";

export interface ListHeightHookProps {
Expand All @@ -17,7 +17,7 @@ export interface HeightHookResult {
contentHeight: number;
listClientHeight?: number;
listItemHeight: number;
rowHeightProxyRef: (el: HTMLDivElement | null) => void;
rowHeightProxyRef: RefCallback<HTMLDivElement>;
}

const getContentHeight = (
Expand Down Expand Up @@ -101,7 +101,7 @@ export const useListHeight = ({
}
}, []);

const rowHeightProxyRef = useCallback((el: HTMLDivElement | null) => {
const rowHeightProxyRef = useCallback<RefCallback<HTMLDivElement>>((el) => {
proxyItemRef.current = el;
forceUpdate({});
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { FilterTableFeatureProps } from "./VuuFilterTableFeature";
const NO_CONFIG: FilterTableConfig = {};

const defaultTableConfig: Partial<TableConfig> = {
columnDefaultWidth: 130,
rowSeparators: true,
zebraStripes: true,
};
Expand Down
Loading