-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task/86 markdown description #104
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
64d095e
86 Make markdown description possible, ontology description (details …
zsoltker ec84ead
fix ellipsis && height
zsoltker bcbf46a
fix ellipsis && height
zsoltker 2277cac
Merge branch 'refs/heads/main' into task/86-markdown_description
zsoltker ae9513b
change default size to 200, use markdown component for resource cards…
zsoltker e020dde
show markdown at resources cards/details, create own details page fro…
zsoltker ecbd935
Merge branch 'refs/heads/main' into task/86-markdown_description
zsoltker 2ee586d
fix code review comments
zsoltker b40737c
fix namings
zsoltker 4e4d1a5
fix markdown props naming
zsoltker 45ec7f8
Merge branch 'refs/heads/main' into task/86-markdown_description
zsoltker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,64 @@ | ||
.gmarkdown { | ||
font-size: large; | ||
font-weight: lighter; | ||
text-align: justify; | ||
} | ||
|
||
.gmarkdown table { | ||
width: 100%; | ||
border: 1px solid black; | ||
border-collapse: collapse; | ||
margin: 20px 0; | ||
} | ||
|
||
.gmarkdown th, | ||
.gmarkdown td { | ||
border: 1px solid black; | ||
padding: 8px; | ||
text-align: left; | ||
} | ||
|
||
.gmarkdown th { | ||
background-color: #f2f2f2; | ||
font-weight: bold; | ||
} | ||
|
||
.gmarkdown tr:nth-child(even) { | ||
background-color: #f9f9f9; | ||
} | ||
|
||
.gmarkdown tr:hover { | ||
background-color: #e0e0e0; | ||
} | ||
|
||
.gmarkdown 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; | ||
} | ||
|
||
.gmarkdown code { | ||
background-color: #e8e8e8; | ||
border-radius: 4px; | ||
padding: 2px 4px; | ||
font-family: 'Courier New', Courier, monospace; | ||
} | ||
|
||
.gmarkdown pre code { | ||
background: none; | ||
color: inherit; | ||
} | ||
|
||
.card { | ||
max-height: 200px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.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,39 @@ | ||
import classNames from 'classnames'; | ||
import Markdown from 'markdown-to-jsx'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
|
||
import styles from './GMarkdown.module.css'; | ||
|
||
type GMarkdownProps = { | ||
children: React.ReactNode; | ||
isCard?: boolean; | ||
maxContentHeight?: number; | ||
}; | ||
|
||
const GMarkdown: React.FC<GMarkdownProps> = ({ isCard, maxContentHeight = 200, children }) => { | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const [isHigher, setIsHigher] = useState(false); | ||
const contentRef = useRef<HTMLDivElement | null>(null); | ||
|
||
useEffect(() => { | ||
if (contentRef.current) { | ||
const contentHeight = contentRef.current.scrollHeight; | ||
setIsHigher(contentHeight > maxContentHeight); // Adjust height as needed | ||
} | ||
}, [children]); | ||
|
||
const cardClass = isCard ? styles.card : ''; | ||
const inlineStyles = isCard && maxContentHeight ? { maxHeight: maxContentHeight } : {}; | ||
|
||
return ( | ||
<> | ||
<div className={classNames(styles.gmarkdown, cardClass)} style={inlineStyles}> | ||
<div ref={contentRef}> | ||
<Markdown>{children}</Markdown> | ||
</div> | ||
</div> | ||
{isCard && isHigher && <div className={styles.ellipsis}>...</div>} | ||
</> | ||
); | ||
}; | ||
|
||
export default GMarkdown; |
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/ResourcesDatails.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; | ||
} |
74 changes: 74 additions & 0 deletions
74
src/components/detailsPage/pages/resources/ResourcesDetailsPage.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,74 @@ | ||
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 car from '../../../../assets/car.gif'; | ||
|
||
import styles from './ResourcesDatails.module.css'; | ||
import ResourcesMainContent from './ResourcesMainContent'; | ||
|
||
export default function ResourcesDetailsPage() { | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching self descriptions:', error); | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
if (resourceId && authContext.isAuthenticated) { | ||
fetchAndSetSelfDescriptions(); | ||
} | ||
}, [resourceId, authContext.isAuthenticated]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className="newCarLoader"> | ||
<img src={car} alt="loading..." className="car"/> | ||
</div> | ||
); | ||
} | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!selfDescriptionData) { | ||
return <div>No data available.</div>; | ||
} | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<div className={styles['details-page-container']}> | ||
{isLoading ? ( | ||
<div className="newCarLoader"> | ||
<img src={car} alt="loading..." className="car"/> | ||
</div> | ||
) : ( | ||
<> | ||
<div> | ||
<ResourcesMainContent 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> | ||
</> | ||
)} | ||
devbysp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/components/detailsPage/pages/resources/ResourcesMainContent.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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be other type of files like some helpers, hooks, services, ... which will be created in the common. Therefore can you please create a 'components' folder inside the 'common' and move your markdown component and css into that. Something like
src/common/components/markdown/GMakdown.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not solved.