Fix table sort icon
This commit is contained in:
parent
8894bce406
commit
ef4b0810cc
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@codex-storage/marketplace-ui-components",
|
"name": "@codex-storage/marketplace-ui-components",
|
||||||
"version": "0.0.38",
|
"version": "0.0.39",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@codex-storage/marketplace-ui-components",
|
"name": "@codex-storage/marketplace-ui-components",
|
||||||
"version": "0.0.38",
|
"version": "0.0.39",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lucide-react": "^0.453.0"
|
"lucide-react": "^0.453.0"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/codex-storage/codex-marketplace-ui-components"
|
"url": "https://github.com/codex-storage/codex-marketplace-ui-components"
|
||||||
},
|
},
|
||||||
"version": "0.0.38",
|
"version": "0.0.39",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepack": "npm run build",
|
"prepack": "npm run build",
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<svg
|
||||||
|
width="20"
|
||||||
|
height="10"
|
||||||
|
viewBox="0 0 20 10"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<g clipPath="url(#clip0_326_785)">
|
||||||
|
<path
|
||||||
|
d="M14.1666 7.91667L9.99992 3.75L5.83325 7.91667H14.1666ZM14.1666 12.0833L9.99992 16.25L5.83325 12.0833H14.1666Z"
|
||||||
|
fill="#969696"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_326_785">
|
||||||
|
<rect width="20" height="10" fill="white" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 436 B |
|
@ -0,0 +1,19 @@
|
||||||
|
<svg
|
||||||
|
width="20"
|
||||||
|
height="10"
|
||||||
|
viewBox="0 0 20 10"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<g clipPath="url(#clip0_326_787)">
|
||||||
|
<path
|
||||||
|
d="M14.1666 -2.08333L9.99992 -6.25L5.83325 -2.08333H14.1666ZM14.1666 2.08333L9.99992 6.25L5.83325 2.08333H14.1666Z"
|
||||||
|
fill="#969696"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_326_787">
|
||||||
|
<rect width="20" height="10" fill="white" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 438 B |
|
@ -1,5 +0,0 @@
|
||||||
.sort-icon {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0;
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import "./SortIcon.css";
|
|
||||||
|
|
||||||
export function SortIcon() {
|
|
||||||
return (
|
|
||||||
<span className="sort-icon">
|
|
||||||
<svg
|
|
||||||
width="20"
|
|
||||||
height="10"
|
|
||||||
viewBox="0 0 20 10"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<g clipPath="url(#clip0_326_785)">
|
|
||||||
<path
|
|
||||||
d="M14.1666 7.91667L9.99992 3.75L5.83325 7.91667H14.1666ZM14.1666 12.0833L9.99992 16.25L5.83325 12.0833H14.1666Z"
|
|
||||||
fill="#969696"
|
|
||||||
/>
|
|
||||||
</g>
|
|
||||||
<defs>
|
|
||||||
<clipPath id="clip0_326_785">
|
|
||||||
<rect width="20" height="10" fill="white" />
|
|
||||||
</clipPath>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
<svg
|
|
||||||
width="20"
|
|
||||||
height="10"
|
|
||||||
viewBox="0 0 20 10"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<g clipPath="url(#clip0_326_787)">
|
|
||||||
<path
|
|
||||||
d="M14.1666 -2.08333L9.99992 -6.25L5.83325 -2.08333H14.1666ZM14.1666 2.08333L9.99992 6.25L5.83325 2.08333H14.1666Z"
|
|
||||||
fill="#969696"
|
|
||||||
/>
|
|
||||||
</g>
|
|
||||||
<defs>
|
|
||||||
<clipPath id="clip0_326_787">
|
|
||||||
<rect width="20" height="10" fill="white" />
|
|
||||||
</clipPath>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,14 +1,9 @@
|
||||||
import "./table.css";
|
import "./table.css";
|
||||||
import {
|
import { Fragment, ReactElement, ReactNode, useEffect, useState } from "react";
|
||||||
ComponentType,
|
|
||||||
Fragment,
|
|
||||||
ReactElement,
|
|
||||||
ReactNode,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import { classnames } from "../utils/classnames";
|
import { classnames } from "../utils/classnames";
|
||||||
import { attributes } from "../utils/attributes";
|
import { attributes } from "../utils/attributes";
|
||||||
|
import AscIcon from "../../assets/icons/asc.svg?react";
|
||||||
|
import DescIcon from "../../assets/icons/desc.svg?react";
|
||||||
|
|
||||||
export type TabSortState = "asc" | "desc" | null;
|
export type TabSortState = "asc" | "desc" | null;
|
||||||
|
|
||||||
|
@ -29,8 +24,6 @@ type Props = {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|
||||||
rows: ReactElement<RowProps, typeof Row>[];
|
rows: ReactElement<RowProps, typeof Row>[];
|
||||||
|
|
||||||
SortIcon: ComponentType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextState = (state: "asc" | "desc" | null) =>
|
const nextState = (state: "asc" | "desc" | null) =>
|
||||||
|
@ -39,7 +32,6 @@ const nextState = (state: "asc" | "desc" | null) =>
|
||||||
export function Table({
|
export function Table({
|
||||||
headers,
|
headers,
|
||||||
rows,
|
rows,
|
||||||
SortIcon,
|
|
||||||
defaultSortIndex = -1,
|
defaultSortIndex = -1,
|
||||||
className = "",
|
className = "",
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
@ -92,7 +84,11 @@ export function Table({
|
||||||
? {
|
? {
|
||||||
role: "button",
|
role: "button",
|
||||||
"aria-sort":
|
"aria-sort":
|
||||||
state === "asc" ? "ascending" : "descending",
|
state === "asc"
|
||||||
|
? "ascending"
|
||||||
|
: state == null
|
||||||
|
? ""
|
||||||
|
: "descending",
|
||||||
}
|
}
|
||||||
: {}
|
: {}
|
||||||
)}
|
)}
|
||||||
|
@ -104,7 +100,12 @@ export function Table({
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<span>{name}</span>
|
<span>{name}</span>
|
||||||
{sort && <SortIcon />}
|
{sort && (
|
||||||
|
<span className="sort-icon">
|
||||||
|
<AscIcon />
|
||||||
|
<DescIcon />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #232323;
|
background-color: #232323;
|
||||||
|
|
||||||
|
.sort-icon {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&[role="button"] {
|
&[role="button"] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ export const Sort: Story = {
|
||||||
]}
|
]}
|
||||||
></Row>,
|
></Row>,
|
||||||
],
|
],
|
||||||
headers: [["id"], ["title"], ["other", () => {}], ["actions"]],
|
headers: [["id"], ["title", () => {}], ["other", () => {}], ["actions"]],
|
||||||
defaultSortIndex: 2,
|
defaultSortIndex: 2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue