Skip to content

Commit

Permalink
Merge pull request #89 from opendata-mvcr/feature/83-empty-term
Browse files Browse the repository at this point in the history
[#83 #84] Empty term component + meta description
  • Loading branch information
filip-kopecky authored Nov 19, 2021
2 parents d274bc1 + bf52b01 commit eeb3e29
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 26 deletions.
39 changes: 18 additions & 21 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<head>
<meta charset="utf-8"/>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico"/>
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<meta name="theme-color" content="#000000"/>
<meta name="description" content="Browsing Semantic Government Vocabulary"/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png"/>
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap"
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap"
rel="stylesheet"
/>
<title>ShowIt</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions src/assets/no_data.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/components/EmptyTerm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { Box, Typography } from "@mui/material";
import { ReactComponent as NoData } from "../assets/no_data.svg";

const EmptyTerm: React.FC = () => {
return (
<Box style={{ textAlign: "center" }} mt={4}>
<NoData style={{ maxHeight: 280, maxWidth: "80%", marginBottom: 30 }} />
<Box>
<Typography variant="h4">
Víc informací bohužel není k dispozici
</Typography>
</Box>
</Box>
);
};
export default EmptyTerm;
2 changes: 1 addition & 1 deletion src/components/Hierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Hierarchy: React.FC<HierarchyProps> = ({ term }) => {
const currIndex = term.parentTerms ? 1 : 0;
return (
<Container>
<Box py={2} mb={10} px={2} mt={4}>
<Box py={2} mb={2} px={2} mt={4}>
<Box borderLeft={4} pr={6} borderColor="primary.main">
<Box pl={4}>
<Typography variant="h5">Související pojmy</Typography>
Expand Down
17 changes: 13 additions & 4 deletions src/components/TermPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Hierarchy } from "./Hierarchy";
import useURLTerm from "../hooks/useURLTerm";
import Loader from "./Loader";
import ErrorPage from "./ErrorPage";
import EmptyTerm from "./EmptyTerm";
import { isTermEmpty } from "../utils/TermUtils";

const TermPage: React.FC = () => {
const term = useURLTerm();
Expand All @@ -18,15 +20,22 @@ const TermPage: React.FC = () => {
if (isError || !data) return <ErrorPage />;

if (isSuccess) {
return (
<Box mb={2}>
<TermHeader term={data} />
const content = isTermEmpty(data) ? (
<EmptyTerm />
) : (
<>
<TermDefinition term={data} />
<Hierarchy term={data} />
</>
);
return (
<Box>
<TermHeader term={data} />
{content}
</Box>
);
}

return <NoResults />;
};

export default TermPage;
11 changes: 11 additions & 0 deletions src/utils/TermUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TermInterface } from "../api/data/terms";

//Checks whether term consists only of information which is displayed in the header (TermPage)
export const isTermEmpty = (term: TermInterface) => {
return (
!term.parentTerms.length &&
!term.subTerms.length &&
!term.definition &&
!term.source
);
};

0 comments on commit eeb3e29

Please sign in to comment.