Skip to content

Commit

Permalink
Merge pull request input-output-hk#2920 from input-output-hk/fix/ddw-…
Browse files Browse the repository at this point in the history
…923-stake-pool-list-table-view-adjustments
  • Loading branch information
danielmain authored Apr 22, 2022
2 parents b467468 + 9c4ff91 commit 7a97d26
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Fixes

- Fixed stake pool list styling ([PR 2920](https://github.com/input-output-hk/daedalus/pull/2920))
- Fixed PopOver overlap ([PR 2954](https://github.com/input-output-hk/daedalus/pull/2954))
- Fixed tooltip being hidden in several places ([PR-2934](https://github.com/input-output-hk/daedalus/pull/2934))
- Adjusted padding for search field in stake pools ([PR 2945](https://github.com/input-output-hk/daedalus/pull/2945))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,25 @@

.table {
border-style: hidden;
margin-bottom: -10px;
user-select: text;
width: 100%;

.thead {
background: var(--theme-bordered-box-background-color);
border-radius: 4px 4px 0 0;
box-shadow: 0 10px 10px -10px rgba(0, 0, 0, 0.2);
display: block;
margin: -20px -20px 0;
margin: -10px -20px 0;
padding: 0 20px;
position: sticky;
top: 0;
transition: box-shadow 0.1s ease-in-out;
z-index: $sticky-header-z-index;

&.stickyHeader {
box-shadow: 0 10px 10px -10px rgba(0, 0, 0, 0.2);
}

.tr {
border: 0;
display: flex;
Expand Down Expand Up @@ -145,7 +150,7 @@
}
}

.tr {
.tr:not(:last-child) {
border-bottom: 1px solid var(--theme-staking-table-border-color);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import styles from './StakePoolsTable.scss';
import StakePool from '../../../domains/StakePool';
import LoadingSpinner from '../../widgets/LoadingSpinner';
import BorderedBox from '../../widgets/BorderedBox';
import { StakePoolsTableHeaderCell } from './StakePoolsTableHeaderCell';
import {
useSortedStakePoolList,
useCreateColumns,
StakePoolsOrder,
StakePoolSortableProps,
} from './hooks';
import { StakePoolsTableHeader } from './StakePoolsTableHeader';

export const defaultTableOrdering: Record<
StakePoolSortableProps,
Expand Down Expand Up @@ -191,34 +191,14 @@ function StakePoolsTableComponent({
{sortedStakePoolList.length > 0 && (
<BorderedBox>
<div {...getTableProps()} className={styles.table}>
<div
className={styles.thead}
onMouseEnter={onTableHeaderMouseEnter}
onMouseLeave={onTableHeaderMouseLeave}
>
{headerGroups.map((headerGroup) => (
/* eslint-disable-next-line react/jsx-key */
<div
{...headerGroup.getHeaderGroupProps()}
className={styles.tr}
>
{headerGroup.headers.map((column) => (
<StakePoolsTableHeaderCell
{...column.getHeaderProps({
style: { width: undefined },
})}
stakePoolsSortBy={stakePoolsSortBy}
stakePoolsOrder={stakePoolsOrder}
onHandleSort={handleSort}
name={column.id}
key={column.id}
>
{column.render('Header')}
</StakePoolsTableHeaderCell>
))}
</div>
))}
</div>
<StakePoolsTableHeader
stakePoolsSortBy={stakePoolsSortBy}
stakePoolsOrder={stakePoolsOrder}
headerGroups={headerGroups}
onHandleSort={handleSort}
onTableHeaderMouseEnter={onTableHeaderMouseEnter}
onTableHeaderMouseLeave={onTableHeaderMouseLeave}
/>

<AutoSizer disableHeight>
{({ width }) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react';
import { observer } from 'mobx-react';
import classNames from 'classnames';
import { HeaderGroup } from 'react-table';
import { StakePoolsTableHeaderCell } from './StakePoolsTableHeaderCell';
import StakePool from '../../../domains/StakePool';
import {
useInViewPort,
StakePoolsOrder,
StakePoolSortableProps,
} from './hooks';
import styles from './StakePoolsTable.scss';

type Props = {
headerGroups: HeaderGroup<StakePool>[];
stakePoolsOrder: StakePoolsOrder;
stakePoolsSortBy: StakePoolSortableProps;
onHandleSort: (name: string) => void;
onTableHeaderMouseEnter: () => void;
onTableHeaderMouseLeave: () => void;
};

export const Component = ({
stakePoolsSortBy,
stakePoolsOrder,
headerGroups,
onHandleSort,
onTableHeaderMouseEnter,
onTableHeaderMouseLeave,
}: Props) => {
const { setTargetRef, isInViewport } = useInViewPort();

return (
<>
<div ref={setTargetRef} />
<div
className={classNames(
styles.thead,
!isInViewport && styles.stickyHeader
)}
onMouseEnter={onTableHeaderMouseEnter}
onMouseLeave={onTableHeaderMouseLeave}
>
{headerGroups.map((headerGroup) => (
/* eslint-disable-next-line react/jsx-key */
<div {...headerGroup.getHeaderGroupProps()} className={styles.tr}>
{headerGroup.headers.map((column) => (
<StakePoolsTableHeaderCell
{...column.getHeaderProps({
style: { width: undefined },
})}
stakePoolsSortBy={stakePoolsSortBy}
stakePoolsOrder={stakePoolsOrder}
onHandleSort={onHandleSort}
name={column.id}
key={column.id}
>
{column.render('Header')}
</StakePoolsTableHeaderCell>
))}
</div>
))}
</div>
</>
);
};

export const StakePoolsTableHeader = observer(Component);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { useCreateColumns } from './useCreateColumns';
export { useInViewPort } from './useInViewPort';
export {
useSortedStakePoolList,
StakePoolsOrder,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useRef, useState, useCallback } from 'react';

export const useInViewPort = () => {
const [isInViewport, setIsInViewport] = useState(true);
const targetRef = useRef(null);
const observerRef = useRef(
new IntersectionObserver((entries) => {
entries.forEach((entry) => {
setIsInViewport(entry.isIntersecting);
});
})
);

// React will call the ref callback twice. Once when the component mounts and again when it unmounts.
// https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node
const setTargetRef = useCallback((target: HTMLElement) => {
if (targetRef.current) {
observerRef.current.unobserve(targetRef.current);
}

if (target) {
observerRef.current.observe(target);
}

targetRef.current = target;
}, []);

return { isInViewport, setTargetRef };
};
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/cardano.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ export const CARDANO_THEME_OUTPUT = {
'--theme-staking-font-color-light': 'rgba(94, 96, 102, 0.7)',
'--theme-staking-font-color-lighter': 'rgba(94, 96, 102, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(32, 34, 37, 0.07)',
'--theme-staking-table-border-color': '#d2d3d3',
'--theme-staking-table-border-color': 'rgba(94, 96, 102, 0.15)',
'--theme-staking-link-color': 'rgba(28, 172, 99, 1)',
'--theme-staking-link-color-light': 'rgba(28, 172, 99, 0.7)',
'--theme-staking-progress-bar-background-color': 'rgba(32, 34, 37, 0.1)',
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/dark-blue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ export const DARK_BLUE_THEME_OUTPUT = {
'--theme-staking-font-color-light': 'rgba(233, 244, 254, 0.7)',
'--theme-staking-font-color-lighter': 'rgba(233, 244, 254, 0.5)',
'--theme-staking-table-head-background-color': '#536370',
'--theme-staking-table-border-color': '#c6cdd6',
'--theme-staking-table-border-color': 'rgba(233, 244, 254, 0.15)',
'--theme-staking-link-color': 'rgba(32, 181, 107, 1)',
'--theme-staking-link-color-light': 'rgba(32, 181, 107, 0.7)',
'--theme-staking-progress-bar-background-color': 'rgba(233, 244, 254, 0.1)',
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/dark-cardano.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ export const DARK_CARDANO_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#ffffffb3',
'--theme-staking-font-color-lighter': 'rgba(255, 255, 255, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(255, 255, 255, 0.07)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.2)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.15)',
'--theme-staking-link-color': '#1fc1c3',
'--theme-staking-link-color-light': 'rgba(31, 193, 195, 0.7)',
'--theme-staking-progress-bar-background-color':
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/flight-candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ export const FLIGHT_CANDIDATE_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#ffffffb3',
'--theme-staking-font-color-lighter': 'rgba(255, 255, 255, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(255, 255, 255, 0.07)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.2)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.15)',
'--theme-staking-link-color': '#ffb923',
'--theme-staking-link-color-light': 'rgba(255, 185, 35, 0.7)',
'--theme-staking-progress-bar-background-color':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ export const INCENTIVIZED_TESTNET_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#ffffffb3',
'--theme-staking-font-color-lighter': 'rgba(255, 255, 255, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(255, 255, 255, 0.07)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.2)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.15)',
'--theme-staking-link-color': 'rgba(246, 154, 178, 1)',
'--theme-staking-link-color-light': 'rgba(246, 154, 178, 0.7)',
'--theme-staking-progress-bar-background-color':
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/light-blue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ export const LIGHT_BLUE_THEME_OUTPUT = {
'--theme-staking-font-color-light': 'rgba(94, 96, 102, 0.7)',
'--theme-staking-font-color-lighter': 'rgba(94, 96, 102, 0.5)',
'--theme-staking-table-head-background-color': '#f1f3f5',
'--theme-staking-table-border-color': '#c6cdd6',
'--theme-staking-table-border-color': 'rgba(94, 96, 102, 0.15)',
'--theme-staking-link-color': 'rgba(41, 111, 208, 1)',
'--theme-staking-link-color-light': 'rgba(41, 111, 208, 0.7)',
'--theme-staking-progress-bar-background-color': 'rgba(52, 70, 94, 0.1)',
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/shelley-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ export const SHELLEY_TESTNET_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#ffffffb3',
'--theme-staking-font-color-lighter': 'rgba(255, 255, 255, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(255, 255, 255, 0.07)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.2)',
'--theme-staking-table-border-color': 'rgba(255, 255, 255, 0.15)',
'--theme-staking-link-color': '#898ee6',
'--theme-staking-link-color-light': 'rgba(137, 142, 230, 0.7)',
'--theme-staking-progress-bar-background-color':
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/white.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ export const WHITE_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#2d2d2db3',
'--theme-staking-font-color-lighter': 'rgba(45, 45, 45, 0.5)',
'--theme-staking-table-head-background-color': '#f9f9f9',
'--theme-staking-table-border-color': 'rgba(45, 45, 45, 0.1)',
'--theme-staking-table-border-color': 'rgba(45, 45, 45, 0.15)',
'--theme-staking-link-color': '#29b595',
'--theme-staking-link-color-light': 'rgba(41, 181, 149, 0.7)',
'--theme-staking-progress-bar-background-color': 'rgba(94, 96, 102, 0.07)',
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/themes/daedalus/yellow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ export const YELLOW_THEME_OUTPUT = {
'--theme-staking-font-color-light': '#2d2d2db3',
'--theme-staking-font-color-lighter': 'rgba(45, 45, 45, 0.5)',
'--theme-staking-table-head-background-color': 'rgba(45, 45, 45, 0.07)',
'--theme-staking-table-border-color': '#e1dac6',
'--theme-staking-table-border-color': 'rgba(45, 45, 45, 0.15)',
'--theme-staking-link-color': '#d6902f',
'--theme-staking-link-color-light': 'rgba(214, 144, 47, 0.7)',
'--theme-staking-progress-bar-background-color': 'rgba(45, 45, 45, 0.07)',
Expand Down

0 comments on commit 7a97d26

Please sign in to comment.