Skip to content

Commit

Permalink
Fix/sphere (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimakorzhovnik authored Dec 14, 2024
1 parent ee73e69 commit a4d07d1
Show file tree
Hide file tree
Showing 82 changed files with 2,282 additions and 1,911 deletions.
10 changes: 10 additions & 0 deletions src/components/ArrowToggle/ArrowToggle.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.btnOpenIconArrowImg {
width: 14px;
height: 14px;
object-fit: contain;
transition: 0.5s;

&Open {
transform: rotate(90deg);
}
}
17 changes: 17 additions & 0 deletions src/components/ArrowToggle/ArrowToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import arrowImg from 'images/Line22.svg';
import cx from 'classnames';
import styles from './ArrowToggle.module.scss';

function ArrowToggle({ isOpen }: { isOpen: boolean }) {
return (
<img
alt="img-ArrowToggle"
src={arrowImg}
className={cx(styles.btnOpenIconArrowImg, {
[styles.btnOpenIconArrowImgOpen]: isOpen,
})}
/>
);
}

export default ArrowToggle;
5 changes: 2 additions & 3 deletions src/components/MusicalAddress/MusicalAddress.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useMemo, useState, useCallback } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { Link } from 'react-router-dom';
import { Tooltip } from 'src/components';
import styles from './MusicalAddress.module.scss';
import {
DICTIONARY_ABC,
Expand All @@ -8,9 +10,6 @@ import {
makeSound,
cutAddress,
} from './utils';
import { Link } from 'react-router-dom';
import { Tooltip } from 'src/components';
import Pill from '../Pill/Pill';

const classNames = require('classnames');

Expand Down
4 changes: 4 additions & 0 deletions src/components/Table/Table.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
&.selectable tbody tr {
cursor: pointer;
}

&.hideHeader thead {
display: none;
}
}

// .resizer {
Expand Down
198 changes: 105 additions & 93 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import {
useReactTable,
Column,
ColumnDef,
getCoreRowModel,
flexRender,
getSortedRowModel,
InitialTableState,
SortingState,
TableOptions,
SortingOptions,
} from '@tanstack/react-table';

import { useEffect, useState, useCallback } from 'react';
import cx from 'classnames';
import { sessionStorageKeys } from 'src/constants/sessionStorageKeys';
import styles from './Table.module.scss';
import Loader2 from '../ui/Loader2';
import NoItems from '../ui/noItems';
import { useEffect, useState, useCallback } from 'react';
import cx from 'classnames';
import Triangle from '../atoms/Triangle/Triangle';
import { sessionStorageKeys } from 'src/constants/sessionStorageKeys';
import { tableIDs } from './tableIDs';

const storage = sessionStorage;
Expand Down Expand Up @@ -53,6 +51,8 @@ export type Props<T extends object> = {

// maybe temporary
enableSorting?: boolean;
hideHeader?: boolean;
hideBody?: boolean;
};

function Table<T extends object>({
Expand All @@ -64,6 +64,8 @@ function Table<T extends object>({
initialState,
id,
enableSorting = true,
hideHeader = false,
hideBody = false,
}: Props<T>) {
const [selected, setSelected] = useState<string | null>(null);

Expand Down Expand Up @@ -118,36 +120,39 @@ function Table<T extends object>({
})}
style={style}
>
<thead>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<th
key={header.id}
className={cx({
[styles.sortable]: header.column.getCanSort(),
})}
colSpan={header.colSpan}
style={{
width: header.column.getSize(),
}}
onClick={header.column.getToggleSortingHandler()}
>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
&nbsp;
{header.column.getCanSort() && (
<Triangle
disabled={!header.column.getIsSorted()}
direction={
header.column.getIsSorted() === 'desc' ? 'down' : 'up'
}
/>
)}
{/* <div
{!hideHeader && (
<thead className={cx({ [styles.hideHeader]: hideHeader })}>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<th
key={header.id}
className={cx({
[styles.sortable]: header.column.getCanSort(),
})}
colSpan={header.colSpan}
style={{
width: header.column.getSize(),
}}
onClick={header.column.getToggleSortingHandler()}
>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
&nbsp;
{header.column.getCanSort() && (
<Triangle
disabled={!header.column.getIsSorted()}
direction={
header.column.getIsSorted() === 'desc'
? 'down'
: 'up'
}
/>
)}
{/* <div
{...{
onDoubleClick: () => header.column.resetSize(),
onMouseDown: header.getResizeHandler(),
Expand All @@ -157,69 +162,76 @@ function Table<T extends object>({
}`,
}}
/> */}
</th>
);
})}
</tr>
))}
</thead>

<tbody>
{table.getRowModel().rows.map((row) => {
return (
<tr
key={row.id}
data-id={row.id}
className={cx({ [styles.rowSelected]: row.id === selected })}
onClick={(e) => {
// TODO: move to tbody

if (!onSelect) {
return;
}

if (
['a', 'button', 'input'].includes(
(e.target as any).tagName.toLowerCase()
)
) {
return;
}

const id = e.currentTarget.getAttribute('data-id');

if (id === selected) {
setSelected(null);
onSelect(null);
return;
}

setSelected(id);
onSelect(id);
}}
>
{row.getVisibleCells().map((cell) => {
return (
<td
key={cell.id}
style={{
width: cell.column.getSize(),
}}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
</td>
</th>
);
})}
</tr>
);
})}
</tbody>
))}
</thead>
)}

{!hideBody && (
<tbody>
{table.getRowModel().rows.map((row) => {
return (
<tr
key={row.id}
data-id={row.id}
className={cx({ [styles.rowSelected]: row.id === selected })}
onClick={(e) => {
// TODO: move to tbody

if (!onSelect) {
return;
}

if (
['a', 'button', 'input'].includes(
(e.target as any).tagName.toLowerCase()
)
) {
return;
}

const id = e.currentTarget.getAttribute('data-id');

if (id === selected) {
setSelected(null);
onSelect(null);
return;
}

setSelected(id);
onSelect(id);
}}
>
{row.getVisibleCells().map((cell) => {
return (
<td
key={cell.id}
style={{
width: cell.column.getSize(),
}}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
</td>
);
})}
</tr>
);
})}
</tbody>
)}
</table>

{isLoading ? <Loader2 /> : !data.length && <NoItems text="No data" />}
{hideBody ? null : isLoading ? (
<Loader2 />
) : (
!data.length && <NoItems text="No data" />
)}
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function Account({
}

if (address?.includes(BECH32_PREFIX_VALOPER)) {
return `/network/bostrom/hero/${address}`;
return routes.hero.getLink(address);
}

if (moniker) {
Expand Down
3 changes: 1 addition & 2 deletions src/components/formatNumber/formatNumber.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Pane } from '@cybercongress/gravity';
import { getDecimal } from '../../utils/utils';
import { formatNumber } from '../../utils/search/utils';
import { formatNumber, getDecimal } from '../../utils/utils';

function FormatNumber({ number, fontSizeDecimal, currency, ...props }) {
return (
Expand Down
3 changes: 0 additions & 3 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import {
TransactionSubmitted,
Confirmed,
StartStageSearchActionBar,
Delegate,
ActionBarSend,
RewardsDelegators,
ReDelegate,
TransactionError,
ActionBarContentText,
ConnectAddress,
Expand Down Expand Up @@ -63,7 +61,6 @@ export {
TransactionSubmitted,
Confirmed,
StartStageSearchActionBar,
Delegate,
ActionBarSend,
RewardsDelegators,
ReDelegate,
Expand Down
Loading

0 comments on commit a4d07d1

Please sign in to comment.