Skip to content

Commit

Permalink
Add Empty Search to CertificatesList
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-slobodian committed Jun 26, 2024
1 parent e83a963 commit 72dd59f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/components/certificates-list/CertificatesList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ export const Empty: Story = {
certificates: [],
},
};

export const EmptySearch: Story = {
args: {
certificates: [],
highlightedText: "test",
},
};
32 changes: 30 additions & 2 deletions src/components/certificates-list/CertificatesList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ComponentProps, useState } from "react";
import { useTranslation } from "react-i18next";
import { Trans, useTranslation } from "react-i18next";
import clsx from "clsx";
import {
Button,
Expand All @@ -15,7 +15,7 @@ import {
TableHeader,
TableRow,
} from "../table";
import CertificatesIcon from "../../icons/certificates.svg?react";

import { CertificateTypeLabel } from "../certificate-type-label";
import { Date } from "../date";
import { CertificateName } from "../certificate-name";
Expand All @@ -29,6 +29,8 @@ import { CertificateProps } from "../../types";

import DeleteIcon from "../../icons/delete.svg?react";
import DownloadIcon from "../../icons/download-20.svg?react";
import CertificatesIcon from "../../icons/certificates.svg?react";
import SearchIcon from "../../icons/search-120.svg?react";

import styles from "./styles/index.module.scss";

Expand Down Expand Up @@ -69,6 +71,32 @@ export const CertificatesList: React.FunctionComponent<

const [currentRow, setCurrentRow] = useState<string>();

if (highlightedText && !certificates?.length && !loading) {
return (
<div className={clsx(styles.empty_list, styles.empty_search_list)}>
<div className={styles.empty_search_list_icon}>
<SearchIcon />
</div>
<Typography variant="b2" color="gray-9">
<Trans
i18nKey="certificates.list.empty-search-text"
values={{ text: highlightedText }}
components={[
<Typography
className={styles.empty_list_search_text}
variant="b2"
color="black"
component="span"
>
{0}
</Typography>,
]}
/>
</Typography>
</div>
);
}

if (!certificates?.length && !loading) {
return (
<div className={styles.empty_list}>
Expand Down
17 changes: 17 additions & 0 deletions src/components/certificates-list/styles/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
border: solid var(--pv-color-gray-4);
border-width: 1px 1px 0 1px;
background-color: var(--pv-color-white);
text-align: center;

.empty_list_icon {
width: 180px;
Expand All @@ -92,6 +93,22 @@
}
}

.empty_search_list {
gap: var(--pv-size-base-4);

.empty_search_list_icon {
width: 120px;
height: 120px;
display: flex;
align-items: center;
justify-content: center;
}

.empty_list_search_text {
word-break: break-all;
}
}

.skeleton_tr {
.skeleton_td {
border-bottom: none;
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"delete": "Delete certificate",
"download": "Download certificate"
},
"empty-text": "There are no certificates yet."
"empty-text": "There are no certificates yet.",
"empty-search-text": "There are no results for <0>{{text}}</0>"
},
"dialog": {
"create": {
Expand Down
3 changes: 3 additions & 0 deletions src/icons/search-120.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72dd59f

Please sign in to comment.