-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix console errors and improve form validation
- Loading branch information
Showing
33 changed files
with
363 additions
and
206 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
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 |
---|---|---|
@@ -1,27 +1,41 @@ | ||
import { properties, Resource, useArray } from '@tomic/react'; | ||
import React from 'react'; | ||
import { Resource, useResource } from '@tomic/react'; | ||
import { Detail } from './Detail'; | ||
import { getIconForClass } from '../views/FolderPage/iconMap'; | ||
import { InlineFormattedResourceList } from './InlineFormattedResourceList'; | ||
|
||
type Props = { | ||
type ClassDetailProps = { | ||
resource: Resource; | ||
}; | ||
|
||
/** Renders the is-a Class for some resource */ | ||
export function ClassDetail({ resource }: Props): JSX.Element { | ||
const [classes] = useArray(resource, properties.isA); | ||
export const ClassDetail: React.FC<ClassDetailProps> = ({ resource }) => { | ||
if (resource.getClasses().length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{classes && ( | ||
<Detail> | ||
<> | ||
{'is a '} | ||
{getIconForClass(classes[0])} | ||
<InlineFormattedResourceList subjects={classes} /> | ||
</> | ||
</Detail> | ||
)} | ||
</> | ||
<Detail> | ||
<InlineFormattedResourceList | ||
subjects={resource.getClasses()} | ||
RenderComp={ClassItem} | ||
/> | ||
</Detail> | ||
); | ||
}; | ||
|
||
interface ClassItemProps { | ||
subject: string; | ||
} | ||
|
||
const ClassItem = ({ subject }: ClassItemProps): JSX.Element => { | ||
const classResource = useResource(subject); | ||
const Icon = getIconForClass(subject); | ||
|
||
return ( | ||
<Detail> | ||
<Icon /> | ||
{classResource.title} | ||
</Detail> | ||
); | ||
}; |
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
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
Oops, something went wrong.