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

1560 table header improvements #1579

Merged
merged 5 commits into from
Nov 21, 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
5 changes: 5 additions & 0 deletions .changeset/smart-pans-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@orchestrator-ui/orchestrator-ui-components': minor
---

1560 Table Header: for narrow columns, moving the sort icons as much as possible to the right
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ export const WfoTableDataRows = <T extends object>({
onRowClick,
className,
}: WfoTableDataRowsProps<T>) => {
const { cellStyle, rowStyle, dataRowStyle, clickableStyle, setWidth } =
useWithOrchestratorTheme(getWfoTableStyles);
const {
cellStyle,
cellContentStyle,
rowStyle,
dataRowStyle,
clickableStyle,
setWidth,
} = useWithOrchestratorTheme(getWfoTableStyles);

const sortedVisibleColumns = getSortedVisibleColumns(
columnConfig,
Expand Down Expand Up @@ -70,7 +76,7 @@ export const WfoTableDataRows = <T extends object>({
setWidth(columnConfig.width),
]}
>
<div>
<div css={cellContentStyle}>
{columnConfig.renderControl(row)}
</div>
</td>
Expand All @@ -91,7 +97,7 @@ export const WfoTableDataRows = <T extends object>({
setWidth(columnConfig.width),
]}
>
<div>
<div css={cellContentStyle}>
<WfoDataCell
customTooltip={columnConfig.renderTooltip?.(
result,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC } from 'react';

import { useOrchestratorTheme } from '@/hooks';
import { WfoArrowNarrowDown, WfoArrowNarrowUp, WfoArrowsUpDown } from '@/icons';
import { WfoArrowDown, WfoArrowUp, WfoArrowsUpDown } from '@/icons';
import { SortOrder } from '@/types';

import { SORTABLE_ICON_CLASS } from './styles';
Expand All @@ -18,6 +18,8 @@ export const WfoSortDirectionIcon: FC<WfoSortDirectionIconProps> = ({
if (!sortDirection) {
return (
<WfoArrowsUpDown
height={16}
width={16}
className={SORTABLE_ICON_CLASS}
css={{ visibility: 'hidden' }}
color={theme.colors.subduedText}
Expand All @@ -26,16 +28,8 @@ export const WfoSortDirectionIcon: FC<WfoSortDirectionIconProps> = ({
}

return sortDirection === SortOrder.ASC ? (
<WfoArrowNarrowUp
color={theme.colors.subduedText}
height={24}
width={24}
/>
<WfoArrowUp color={theme.colors.subduedText} />
) : (
<WfoArrowNarrowDown
color={theme.colors.subduedText}
height={24}
width={24}
/>
<WfoArrowDown color={theme.colors.subduedText} />
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const getWfoBasicTableStyles = ({ theme }: WfoTheme) => {
});

const sortButtonStyle = css({
paddingLeft: theme.size.xxs,
display: 'flex',
flex: '0 0 auto',
alignItems: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const getWfoTableStyles = ({ theme }: WfoTheme) => {
});

const headerCellStyle = css({
paddingRight: 0,
[`&:hover`]: {
[`.${SORTABLE_ICON_CLASS}`]: {
visibility: 'visible',
Expand All @@ -100,6 +101,10 @@ export const getWfoTableStyles = ({ theme }: WfoTheme) => {
verticalAlign: 'middle',
});

const cellContentStyle = css({
display: 'inline-block',
});

const emptyTableMessageStyle = css({
textAlign: 'center',
});
Expand Down Expand Up @@ -127,6 +132,7 @@ export const getWfoTableStyles = ({ theme }: WfoTheme) => {
expandedRowStyle,
headerCellStyle,
cellStyle,
cellContentStyle,
emptyTableMessageStyle,
clickableStyle,
setWidth,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions packages/orchestrator-ui-components/src/icons/WfoArrowNarrowUp.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { FC } from 'react';

import { WfoIconProps } from '@/icons/WfoIconProps';

import { withWfoHeroIconsWrapper } from './WfoHeroIconsWrapper';

export const WfoArrowDownSvg: FC<WfoIconProps> = ({
width = 12,
height = 14,
color = 'currentColor',
}) => (
<svg
width={width}
height={height}
viewBox="4 3 12 14"
fill={color}
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M10 3a.75.75 0 0 1 .75.75v10.638l3.96-4.158a.75.75 0 1 1 1.08 1.04l-5.25 5.5a.75.75 0 0 1-1.08 0l-5.25-5.5a.75.75 0 1 1 1.08-1.04l3.96 4.158V3.75A.75.75 0 0 1 10 3Z"
clipRule="evenodd"
/>
</svg>
);

export const WfoArrowDown = withWfoHeroIconsWrapper(WfoArrowDownSvg);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { FC } from 'react';

import { WfoIconProps } from '@/icons/WfoIconProps';

import { withWfoHeroIconsWrapper } from './WfoHeroIconsWrapper';

export const WfoArrowUpSvg: FC<WfoIconProps> = ({
width = 12,
height = 14,
color = 'currentColor',
}) => (
<svg
width={width}
height={height}
viewBox="4 3 12 14"
fill={color}
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M10 17a.75.75 0 0 1-.75-.75V5.612L5.29 9.77a.75.75 0 0 1-1.08-1.04l5.25-5.5a.75.75 0 0 1 1.08 0l5.25 5.5a.75.75 0 1 1-1.08 1.04l-3.96-4.158V16.25A.75.75 0 0 1 10 17Z"
clipRule="evenodd"
/>
</svg>
);

export const WfoArrowUp = withWfoHeroIconsWrapper(WfoArrowUpSvg);
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { withWfoHeroIconsWrapper } from './WfoHeroIconsWrapper';
const WfoArrowsUpDownSvg: FC<WfoIconProps> = ({
width = 20,
height = 20,
color = '#000000',
color = 'currentColor',
}) => (
<svg
width={width}
height={height}
viewBox="0 0 24 24"
viewBox="2 2 20 20"
fill={color}
xmlns="http://www.w3.org/2000/svg"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC, ReactElement } from 'react';

import { useOrchestratorTheme } from '@/hooks';
import { WfoIconProps } from '@/icons';

export type WfoHeroIconsWrapperProps = {
Expand All @@ -11,24 +10,18 @@ export type WfoHeroIconsWrapperProps = {
export const WfoHeroIconsWrapper: FC<WfoHeroIconsWrapperProps> = ({
children,
className,
}) => {
const { theme } = useOrchestratorTheme();

return (
<div
className={className}
css={{
marginLeft: theme.size.xs,
marginRight: theme.size.xs,
display: 'flex',
alignItems: 'center',
height: '100%',
}}
>
{children}
</div>
);
};
}) => (
<div
className={className}
css={{
display: 'flex',
alignItems: 'center',
height: '100%',
}}
>
{children}
</div>
);

export const withWfoHeroIconsWrapper = (Icon: FC<WfoIconProps>) => {
const wfoHeroIconsWrapperWithIcon = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './WfoHeroIconsWrapper';

export * from './WfoArrowDown';
export * from './WfoArrowsUpDown';
export * from './WfoArrowUp';
export * from './WfoWrench';
2 changes: 0 additions & 2 deletions packages/orchestrator-ui-components/src/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export * from './WfoChevronUp';
export * from './WfoBoltFill';
export * from './WfoBoltSlashFill';
export * from './WfoCubeSolid';
export * from './WfoArrowNarrowDown';
export * from './WfoRefresh';
export * from './WfoArrowNarrowUp';
export * from './WfoMinusCircleFill';
export * from './WfoPlayCircle';
export * from './WfoSearchStrikethrough';
Expand Down
Loading