-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: info row with tags and created info
- Loading branch information
1 parent
03410d8
commit 58e0048
Showing
8 changed files
with
97 additions
and
42 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
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,68 @@ | ||
/** @jsx jsx */ | ||
import { FC, Fragment } from 'react'; | ||
import { jsx, Box, Text } from 'theme-ui'; | ||
import { | ||
Document, | ||
getDocPath, | ||
dateToLocalString, | ||
RunConfiguration, | ||
} from '@component-controls/core'; | ||
import { Link } from '@component-controls/components'; | ||
import { TagsList } from '../TagsList'; | ||
|
||
export interface DocumentShortItemProps { | ||
/** | ||
* document to be displayed | ||
*/ | ||
doc?: Document; | ||
/** | ||
* store configuration object | ||
*/ | ||
config?: RunConfiguration; | ||
|
||
reverse?: boolean; | ||
} | ||
export const DocumentShortItem: FC<DocumentShortItemProps> = ({ | ||
doc, | ||
config, | ||
reverse, | ||
}) => { | ||
const { tags = [], date, author } = doc || {}; | ||
const dateNode = | ||
date || author ? ( | ||
<Box variant="documentitem.info.inner"> | ||
{date ? ( | ||
<Box variant="documentitem.info.date">{`created: ${dateToLocalString( | ||
date, | ||
)}`}</Box> | ||
) : ( | ||
'' | ||
)} | ||
{author && ( | ||
<Box variant="documentitem.info.author"> | ||
{date && <Text variant="documentitem.info.comma">,</Text>} | ||
<Text variant="documentitem.info.by">by</Text> | ||
<Link href={getDocPath('author', undefined, config?.pages, author)}> | ||
{author} | ||
</Link> | ||
</Box> | ||
)} | ||
</Box> | ||
) : null; | ||
const tagsNode = tags.length ? <TagsList tags={tags} /> : null; | ||
return tagsNode && dateNode ? ( | ||
<Box variant="documentitem.info.container"> | ||
{reverse ? ( | ||
<Fragment> | ||
{tagsNode} | ||
{dateNode} | ||
</Fragment> | ||
) : ( | ||
<Fragment> | ||
{dateNode} | ||
{tagsNode} | ||
</Fragment> | ||
)} | ||
</Box> | ||
) : null; | ||
}; |
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 +1,2 @@ | ||
export * from './DocumentItem'; | ||
export * from './DocumentShortItem'; |
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