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

73 Emphasize current active sorted column #76

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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 @@ -18,13 +18,15 @@ interface ContentTypeUsagesTableProps {
tableColumns: TableColumn<ContentUsageDto>[];
rows: ContentUsageDto[];
onSortChange: (column: TableColumn<ContentUsageDto>) => void;
sortBy: keyof ContentUsageDto;
sortDirection: string;
}

const ContentTypeUsagesTable = ({
tableColumns,
rows,
onSortChange,
sortBy,
sortDirection,
}: ContentTypeUsagesTableProps) => {
const onTableRowClick = useCallback(
Expand All @@ -41,6 +43,9 @@ const ContentTypeUsagesTable = ({
[navigateTo]
);

const columnHeaderClassName = "forte-optimizely-content-usage-column";
const activeColumnHeaderClassName = `${columnHeaderClassName} forte-optimizely-content-usage-column--active`;

return (
<Table
tableLayoutAlgorithm="fixed"
Expand All @@ -53,10 +58,11 @@ const ContentTypeUsagesTable = ({
.map((column) => (
<Table.TH
colSpan={column.columnSpanWidth}
className={column.id === sortBy ? activeColumnHeaderClassName : columnHeaderClassName}
sorting={{
canSort: column.sorting,
handleSort: () => onSortChange(column),
order: sortDirection,
order: column.id === sortBy ? sortDirection : undefined,
}}
key={column.id}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function useFilteredTableData<TableDataType>({
onTableColumnChange: (column: string, visible: boolean) => void;
selectedRowsPerPage: number;
onRowsPerPageChange: (option: number) => void;
sortBy: keyof TableDataType | null;
sortDirection: SortDirection;
onSortChange: (column: TableColumn<TableDataType>) => void;
totalPages: number;
Expand Down Expand Up @@ -634,6 +635,7 @@ export function useFilteredTableData<TableDataType>({
onTableColumnChange: onColumnVisiblityChange,
selectedRowsPerPage: rowsPerPage,
onRowsPerPageChange: onRowsPerPageChange,
sortBy,
sortDirection,
onSortChange: handleTableSort,
totalPages,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import 'variables/breakpoints';

:root {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't optimizely oui using sass variables for colors? Maybe we should do the same? See node_modules\optimizely-oui\src\oui\_oui-variables.scss for reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe these colors are declared already? Please search in @optimizely\design-tokens\dist\scss\_colors.scss

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reuse as much as possible

--muted-color: #707070
--muted-color: #707070;
--brand-blue-dark: #0037ff;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
}
}

.forte-optimizely-content-usage-column {
.oui-arrow-inline--up, .oui-arrow-inline--down {
visibility: hidden;
}

&.forte-optimizely-content-usage-column--active {
color: var(--brand-blue-dark) !important;
.oui-arrow-inline--up, .oui-arrow-inline--down{
visibility: visible;
}
}
}

.oui-spinner {
margin: 30px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const ContentTypeUsageView = () => {
onClearButtonClick,
tableColumns,
onTableColumnChange,
sortBy,
sortDirection,
onSortChange,
currentPage,
Expand Down Expand Up @@ -223,6 +224,7 @@ const ContentTypeUsageView = () => {
<div className="forte-optimizely-content-usage-table-container">
<ContentTypeUsagesTable rows={rows}
tableColumns={tableColumns}
sortBy={sortBy}
sortDirection={sortDirection.toLowerCase()}
onSortChange={handleSortChange}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const ContentTypesView = () => {
onTableColumnChange,
selectedRowsPerPage,
onRowsPerPageChange,
sortBy,
sortDirection,
onSortChange,
totalPages,
Expand Down Expand Up @@ -161,6 +162,9 @@ const ContentTypesView = () => {
}
}, [response, dataLoaded]);

const columnHeaderClassName = "forte-optimizely-content-usage-column";
const activeColumnHeaderClassName = `${columnHeaderClassName} forte-optimizely-content-usage-column--active`;

return (
<Layout>
<GridContainer ref={gridContainerRef} className="forte-optimizely-content-usage-grid">
Expand Down Expand Up @@ -195,10 +199,11 @@ const ContentTypesView = () => {
.filter((column) => column.visible)
.map((column) => (
<Table.TH
className={column.id === sortBy ? activeColumnHeaderClassName : columnHeaderClassName}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When active, both classes should be added - according to BEM methodology

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using classNames package

sorting={{
canSort: true,
handleSort: () => onSortChange(column),
order: sortDirection,
order: column.id === sortBy ? sortDirection : undefined,
}}
key={column.id}
>
Expand Down