-
Notifications
You must be signed in to change notification settings - Fork 7
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 #111 from indexnetwork/sources
new item models & default questions
- Loading branch information
Showing
20 changed files
with
429 additions
and
84 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
104 changes: 104 additions & 0 deletions
104
web-app/src/components/site/index-details/DefaultIndexItem/index.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,104 @@ | ||
import Button from "components/base/Button"; | ||
import IconContextMenu from "components/base/Icon/IconContextMenu"; | ||
import Text from "components/base/Text"; | ||
import Col from "components/layout/base/Grid/Col"; | ||
import FlexRow from "components/layout/base/Grid/FlexRow"; | ||
import IndexDetailItemPopup from "components/site/popup/IndexDetailItemPopup"; | ||
import { useBreakpoint } from "hooks/useBreakpoint"; | ||
import { useRole } from "hooks/useRole"; | ||
import moment from "moment"; | ||
import React from "react"; | ||
import sanitize from "sanitize-html"; | ||
import { DefaultIndexNodeItem } from "types/entity"; | ||
import { BREAKPOINTS } from "utils/constants"; | ||
import cm from "./style.module.scss"; | ||
|
||
// TODO: data prop will be Index object | ||
export interface DefaultIndexItemProps { | ||
item: DefaultIndexNodeItem; | ||
onChange?(val: DefaultIndexNodeItem[]): void; | ||
search?: boolean; | ||
handleRemove?(): void; | ||
} | ||
|
||
const DefaultIndexItem: React.FC<DefaultIndexItemProps> = ({ | ||
item, | ||
search = false, | ||
handleRemove, | ||
}) => { | ||
const breakpoint = useBreakpoint(BREAKPOINTS, true); | ||
const { node } = item; | ||
|
||
const { isCreator } = useRole(); | ||
|
||
return ( | ||
<div className="index-detail-list-item-wrapper"> | ||
<FlexRow className="index-detail-list-item py-3"> | ||
<Col xs={12}> | ||
<FlexRow wrap={false}> | ||
<Col className="idxflex-grow-1"> | ||
<img | ||
className="mr-3" | ||
src={"/images/ic_default_index_item.svg"} | ||
alt="favicon" | ||
width={16} | ||
height={16} | ||
onError={(e: React.SyntheticEvent<HTMLImageElement, Event>) => { | ||
const target = e.target as HTMLImageElement; | ||
target.onerror = null; // Prevents infinite loop in case fallback image also fails | ||
target.src = "/images/globe.svg"; | ||
}} | ||
style={{ | ||
verticalAlign: "middle", | ||
}} | ||
/> | ||
<Text | ||
className={cm.title} | ||
fontWeight={700} | ||
dangerouslySetInnerHTML={{ | ||
__html: sanitize(node?.id as string), | ||
}} | ||
></Text> | ||
</Col> | ||
{!search && isCreator ? ( | ||
<Col className="idxflex-shrink-0 index-detail-list-item-buttons ml-3"> | ||
<FlexRow> | ||
<Col></Col> | ||
<Col> | ||
<IndexDetailItemPopup onDelete={handleRemove}> | ||
<Button size="xs" iconButton theme="clear" borderless> | ||
<IconContextMenu /> | ||
</Button> | ||
</IndexDetailItemPopup> | ||
</Col> | ||
</FlexRow> | ||
</Col> | ||
) : ( | ||
<Col className="idxflex-shrink-0 index-detail-list-item-buttons ml-3"> | ||
<FlexRow> | ||
<Col></Col> | ||
<Col> | ||
<IndexDetailItemPopup onDelete={handleRemove} /> | ||
</Col> | ||
</FlexRow> | ||
</Col> | ||
)} | ||
</FlexRow> | ||
</Col> | ||
<Col xs={12} className="mt-2"> | ||
<Text size="md" theme="gray5"> | ||
{item.type} | ||
{" • "} | ||
</Text> | ||
|
||
<Text size="md" theme="gray5"> | ||
{node?.updatedAt | ||
? `Updated ${moment(new Date(node.updatedAt)).fromNow()}` | ||
: ""} | ||
</Text> | ||
</Col> | ||
</FlexRow> | ||
</div> | ||
); | ||
}; | ||
export default DefaultIndexItem; |
4 changes: 4 additions & 0 deletions
4
web-app/src/components/site/index-details/DefaultIndexItem/style.module.scss
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,4 @@ | ||
.title { | ||
font-family: "Freizeit" !important; | ||
font-size: 16px; | ||
} |
141 changes: 141 additions & 0 deletions
141
web-app/src/components/site/index-details/IndexIndexItem/index.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,141 @@ | ||
import Button from "components/base/Button"; | ||
import IconContextMenu from "components/base/Icon/IconContextMenu"; | ||
import Text from "components/base/Text"; | ||
import Col from "components/layout/base/Grid/Col"; | ||
import FlexRow from "components/layout/base/Grid/FlexRow"; | ||
import IndexDetailItemPopup from "components/site/popup/IndexDetailItemPopup"; | ||
import { useBreakpoint } from "hooks/useBreakpoint"; | ||
import { useRole } from "hooks/useRole"; | ||
import moment from "moment"; | ||
import React from "react"; | ||
import sanitize from "sanitize-html"; | ||
import { IndexIndexNodeItem } from "types/entity"; | ||
import { BREAKPOINTS } from "utils/constants"; | ||
import cm from "./style.module.scss"; | ||
|
||
// TODO: data prop will be Index object | ||
export interface IndexIndexItemProps { | ||
item: IndexIndexNodeItem; | ||
onChange?(val: IndexIndexNodeItem[]): void; | ||
search?: boolean; | ||
handleRemove?(): void; | ||
} | ||
|
||
const IndexIndexItem: React.FC<IndexIndexItemProps> = ({ | ||
item, | ||
search = false, | ||
handleRemove, | ||
}) => { | ||
const breakpoint = useBreakpoint(BREAKPOINTS, true); | ||
const { node } = item; | ||
|
||
const { isCreator } = useRole(); | ||
|
||
return ( | ||
<div className="index-detail-list-item-wrapper"> | ||
<FlexRow className="index-detail-list-item py-3"> | ||
<Col xs={12}> | ||
<FlexRow wrap={false}> | ||
<Col className="idxflex-grow-1"> | ||
<img | ||
className="mr-3" | ||
src={node?.logo || "/images/ic_index_item.svg"} | ||
alt="favicon" | ||
width={16} | ||
height={16} | ||
onError={(e: React.SyntheticEvent<HTMLImageElement, Event>) => { | ||
const target = e.target as HTMLImageElement; | ||
target.onerror = null; // Prevents infinite loop in case fallback image also fails | ||
target.src = "/images/globe.svg"; | ||
}} | ||
style={{ | ||
verticalAlign: "middle", | ||
}} | ||
/> | ||
<a | ||
target="_blank" | ||
rel="noreferrer" | ||
href={`${window.location.origin}/${node?.id}`} | ||
> | ||
<Text | ||
className={cm.title} | ||
fontWeight={700} | ||
dangerouslySetInnerHTML={{ | ||
__html: sanitize(node?.title as string), | ||
}} | ||
></Text> | ||
{/* dangerouslySetInnerHTML={{ __html: sanitize((node.highlight && item.highlight["link.title"]) ? item.highlight["link.title"] : node?.title as string) }}></Text> */} | ||
</a> | ||
</Col> | ||
{!search && isCreator ? ( | ||
<Col className="idxflex-shrink-0 index-detail-list-item-buttons ml-3"> | ||
<FlexRow> | ||
<Col></Col> | ||
<Col> | ||
<IndexDetailItemPopup onDelete={handleRemove}> | ||
<Button size="xs" iconButton theme="clear" borderless> | ||
<IconContextMenu /> | ||
</Button> | ||
</IndexDetailItemPopup> | ||
</Col> | ||
</FlexRow> | ||
</Col> | ||
) : ( | ||
<Col className="idxflex-shrink-0 index-detail-list-item-buttons ml-3"> | ||
<FlexRow> | ||
<Col></Col> | ||
<Col> | ||
<IndexDetailItemPopup onDelete={handleRemove}> | ||
{/* <Button size="xs" iconButton theme="clear" borderless> | ||
<IconContextMenu /> | ||
</Button> */} | ||
</IndexDetailItemPopup> | ||
</Col> | ||
</FlexRow> | ||
</Col> | ||
)} | ||
</FlexRow> | ||
</Col> | ||
<Col xs={12} className="mt-2"> | ||
<Text size="md" theme="gray5"> | ||
{node?.updatedAt | ||
? `Updated ${moment(new Date(node.updatedAt)).fromNow()}` | ||
: ""} | ||
</Text> | ||
</Col> | ||
{/* { | ||
search && node.highlight && node.highlight["link.content"] && ( | ||
<Col className="mt-5"> | ||
<Text className="listItem" theme="secondary" dangerouslySetInnerHTML={{ __html: sanitize(item.highlight["link.content"]) }}></Text> | ||
</Col> | ||
) | ||
} */} | ||
{ | ||
<Col xs={12} className="idxflex idxflex-gap-3 idxflex-wrap mt-3"> | ||
{/* { | ||
node?.tags?.map((t, ind) => ( | ||
<TagIndexDetailItem | ||
key={ind} | ||
text={t} | ||
removable | ||
onRemove={handleRemoveTag} | ||
/>)) | ||
} */} | ||
{/* { | ||
<TagIndexDetailItem | ||
theme="clear" | ||
text="" | ||
placeholder="New Tag" | ||
editable={true} | ||
inputActive | ||
// onEdit={handleNewTagEdit} | ||
// onBlur={handleToggleNewTag} | ||
/> | ||
} */} | ||
</Col> | ||
} | ||
</FlexRow> | ||
</div> | ||
); | ||
}; | ||
export default IndexIndexItem; |
4 changes: 4 additions & 0 deletions
4
web-app/src/components/site/index-details/IndexIndexItem/style.module.scss
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,4 @@ | ||
.title { | ||
font-family: "Freizeit" !important; | ||
font-size: 16px; | ||
} |
Oops, something went wrong.