Browse Source
Added ListItem and changed StoryList ot use it, reorganized StoryMenu, added scrollbar styling, added moment dependency
1.0
Added ListItem and changed StoryList ot use it, reorganized StoryMenu, added scrollbar styling, added moment dependency
1.0
Gisle Aune
6 years ago
11 changed files with 171 additions and 16 deletions
-
5rpdata-ui/package-lock.json
-
1rpdata-ui/package.json
-
22rpdata-ui/src/colors.css
-
2rpdata-ui/src/common/Background.js
-
66rpdata-ui/src/common/List.js
-
50rpdata-ui/src/common/css/List.css
-
1rpdata-ui/src/common/css/Menu.css
-
22rpdata-ui/src/index.css
-
4rpdata-ui/src/routes/story/StoryList.js
-
6rpdata-ui/src/routes/story/StoryMenu.js
-
6rpdata-ui/src/routes/story/StoryRoot.js
@ -0,0 +1,66 @@ |
|||||
|
import React, { Component } from "react" |
||||
|
import { Link } from "react-router-dom" |
||||
|
import moment from "moment" |
||||
|
|
||||
|
import "./css/List.css" |
||||
|
|
||||
|
export default class List extends Component { |
||||
|
render() { |
||||
|
return ( |
||||
|
<table className="List" cellSpacing="0px"> |
||||
|
<tbody> |
||||
|
{this.props.children} |
||||
|
</tbody> |
||||
|
</table> |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export function Item({link, name, icon, author, description, tags, fictionalDate, createdDate}) { |
||||
|
return [ |
||||
|
<tr className="ListItem color-primary"> |
||||
|
<td className="icon color-highlight-primary">{icon}</td> |
||||
|
<td className="content color-primary color-highlight-dark"> |
||||
|
<div className="title"> |
||||
|
<Link className="color-primary" to={link}>{name}</Link> |
||||
|
</div> |
||||
|
<div className="description color-text">{description}</div> |
||||
|
<div className="meta"> |
||||
|
<ItemMeta key="D2" kind="date" value={createdDate} /> |
||||
|
<ItemMeta key="D1" kind="date" value={fictionalDate} /> |
||||
|
<ItemMeta key="T" kind="tag" value={tags[0] || null} /> |
||||
|
<ItemMeta key="A" kind="author" value={author} /> |
||||
|
</div> |
||||
|
</td> |
||||
|
</tr>, |
||||
|
<tr className="ListItem-spacer"> |
||||
|
<td></td> |
||||
|
</tr> |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
function ItemMeta({kind, value, className}) { |
||||
|
// Hide empty fields
|
||||
|
if (value == null || value == "") { |
||||
|
return null |
||||
|
} |
||||
|
|
||||
|
switch (kind) { |
||||
|
case "date": { |
||||
|
const m = moment(value) |
||||
|
if (m.year() < 2) { |
||||
|
return null |
||||
|
} |
||||
|
|
||||
|
return <div className="date color-menu">{m.format("MMM D, YYYY")}</div> |
||||
|
} |
||||
|
|
||||
|
case "tag": { |
||||
|
return <div className={`tag color-tag-${value.kind.toLowerCase()}`}>{value.name}</div> |
||||
|
} |
||||
|
|
||||
|
case "author": { |
||||
|
return <div className="author color-menu">{value}</div> |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
.List { |
||||
|
padding: 1em 1ch; |
||||
|
width: 100%; |
||||
|
max-width: 90ch; |
||||
|
margin: auto; |
||||
|
margin-top: 0.75em; |
||||
|
} |
||||
|
|
||||
|
.ListItem { |
||||
|
user-select: none; |
||||
|
outline: 0.05px solid; |
||||
|
} |
||||
|
.ListItem td.icon { |
||||
|
font-size: 2.75em; |
||||
|
text-align: center; |
||||
|
width: 2.5ch; |
||||
|
outline: 0.05px solid; |
||||
|
margin: 0; |
||||
|
} |
||||
|
.ListItem td.content { |
||||
|
padding: 0.25em; |
||||
|
padding-bottom: 0.33em; |
||||
|
margin: 0; |
||||
|
} |
||||
|
.ListItem td.content .title { |
||||
|
padding: 0.25em 1ch; |
||||
|
} |
||||
|
.ListItem td.content a { |
||||
|
font-size: 1.333em; |
||||
|
} |
||||
|
.ListItem td.content a:hover { |
||||
|
color: white; |
||||
|
} |
||||
|
.ListItem td.content .description { |
||||
|
margin: 0 1ch; |
||||
|
} |
||||
|
.ListItem td.content p { |
||||
|
margin: 0; |
||||
|
} |
||||
|
.ListItem td.content .meta { |
||||
|
|
||||
|
} |
||||
|
.ListItem td.content .meta > div { |
||||
|
display: inline-block; |
||||
|
padding: 0.25em 1ch; |
||||
|
} |
||||
|
|
||||
|
.ListItem-spacer td { |
||||
|
height: 0.75em; |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue