-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from GAIA-X4PLC-AAD/task/86-markdown_description
Task/86 markdown description
- Loading branch information
Showing
12 changed files
with
303 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.markdown { | ||
font-size: large; | ||
font-weight: lighter; | ||
text-align: justify; | ||
} | ||
|
||
.markdown table { | ||
width: 100%; | ||
border: 1px solid black; | ||
border-collapse: collapse; | ||
margin: 20px 0; | ||
} | ||
|
||
.markdown th, | ||
.markdown td { | ||
border: 1px solid black; | ||
padding: 8px; | ||
text-align: left; | ||
} | ||
|
||
.markdown th { | ||
background-color: #f2f2f2; | ||
font-weight: bold; | ||
} | ||
|
||
.markdown tr:nth-child(even) { | ||
background-color: #f9f9f9; | ||
} | ||
|
||
.markdown tr:hover { | ||
background-color: #e0e0e0; | ||
} | ||
|
||
.markdown pre { | ||
background-color: #f5f5f5; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
padding: 10px; | ||
overflow-x: auto; | ||
font-family: 'Courier New', Courier, monospace; | ||
white-space: pre-wrap; | ||
} | ||
|
||
.markdown code { | ||
background-color: #e8e8e8; | ||
border-radius: 4px; | ||
padding: 2px 4px; | ||
font-family: 'Courier New', Courier, monospace; | ||
} | ||
|
||
.markdown pre code { | ||
background: none; | ||
color: inherit; | ||
} | ||
|
||
.item-card .markdown { | ||
max-height: 200px; | ||
overflow: hidden; | ||
} | ||
|
||
.ellipsis { | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import MarkdownToJSX from 'markdown-to-jsx'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import './Markdown.css' | ||
|
||
type MarkdownProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const Markdown: React.FC<MarkdownProps> = ({ children }) => { | ||
const [isTruncated, setIsTruncated] = useState(false); | ||
const contentRef = useRef<HTMLDivElement | null>(null); | ||
|
||
useEffect(() => { | ||
const checkTruncation = () => { | ||
if (contentRef.current) { | ||
setIsTruncated(contentRef.current.scrollHeight > contentRef.current.clientHeight + 1); | ||
} | ||
} | ||
|
||
checkTruncation(); | ||
|
||
}, [children]); | ||
|
||
return ( | ||
<> | ||
<div ref={contentRef} className='markdown'> | ||
<MarkdownToJSX>{children}</MarkdownToJSX> | ||
</div> | ||
{isTruncated && <div className='ellipsis'>...</div>} | ||
</> | ||
); | ||
}; | ||
|
||
export default Markdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/components/detailsPage/pages/resources/ResourceDatails.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.details-page-container { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
width: auto; | ||
} | ||
|
||
.new-car-loader { | ||
display: flex; | ||
justify-content: center; | ||
} |
62 changes: 62 additions & 0 deletions
62
src/components/detailsPage/pages/resources/ResourceDetailsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import MapCard from 'components/cards/MapCard'; | ||
import SidebarCard from 'components/cards/SidebarCard'; | ||
import { AuthContext } from 'context/AuthContextProvider'; | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { CypherQueryApiService as cypherQuery } from 'services/cypherQueryApiService'; | ||
|
||
import LoadingIndicator from '../../../loading_view/LoadingIndicator'; | ||
import NoContent from '../../../nocontent/NoContent'; | ||
|
||
import styles from './ResourceDatails.module.css'; | ||
import ResourceMainContent from './ResourceMainContent'; | ||
|
||
export default function ResourceDetailsPage() { | ||
const authContext = useContext(AuthContext); | ||
const [selfDescriptionData, setSelfDescriptionData] = useState(null); | ||
const { resourceId } = useParams(); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
const fetchAndSetSelfDescriptions = async () => { | ||
try { | ||
const response = await cypherQuery.getOneSelfDescriptions(resourceId); | ||
console.log('Fetched data: ', response); | ||
if (response) { | ||
setSelfDescriptionData(response); | ||
} | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
if (resourceId && authContext.isAuthenticated) { | ||
fetchAndSetSelfDescriptions(); | ||
} | ||
}, [resourceId, authContext.isAuthenticated]); | ||
|
||
return ( | ||
<div className={styles['details-page-container']}> | ||
<LoadingIndicator visible={isLoading}/> | ||
{!isLoading && ( | ||
<> | ||
<NoContent message={'No data available.'} visible={!selfDescriptionData}/> | ||
{selfDescriptionData && ( | ||
<> | ||
<div> | ||
<ResourceMainContent cardData={selfDescriptionData}/> | ||
</div> | ||
<div> | ||
<MapCard/> | ||
<SidebarCard | ||
title="Offered by" | ||
subtitle="3D Mapping Solutions GmbH" | ||
text="We offer high-precision 3D map data of roads and urban environments for applications in autonomous driving, robotics, urban planning and navigation systems." | ||
/> | ||
</div> | ||
</>)} | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/components/detailsPage/pages/resources/ResourceMainContent.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.details-card-container { | ||
box-shadow: 10px 15px 20px rgba(0, 0, 0, 0.25); | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1; | ||
align-items: flex-start; | ||
padding: 30px; | ||
width: 90%; | ||
background-color: white; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
border-radius: 10px; | ||
} | ||
|
||
.details-grid-container { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); /* Creates two columns of equal width */ | ||
margin-top: 20px; /* Optional: Adds some space above the grid */ | ||
justify-items: stretch; | ||
align-items: start; | ||
} |
Oops, something went wrong.