scinote-web/app/javascript/packs/shared/navigation/components/ActivityElement.jsx

55 lines
1.2 KiB
React
Raw Normal View History

2017-08-02 23:27:05 +08:00
import React from "react";
import PropTypes from "prop-types";
2017-08-22 19:20:06 +08:00
import Moment from "react-moment";
import styled from "styled-components";
import {
WHITE_COLOR,
COLOR_CONCRETE,
BORDER_GRAY_COLOR
} from "../../../app/constants/colors";
const StyledLi = styled.li`
border-radius: .25em;
margin-bottom: 1em;
background-color: ${WHITE_COLOR};
border: 1px solid ${COLOR_CONCRETE};
`;
const TimeSpan = styled.span`
min-width: 150px;
display: table-cell;
vertical-align: middle;
border-top-left-radius: .25em;
border-bottom-left-radius: .25em;
border: 3px solid ${BORDER_GRAY_COLOR};
background-color: ${BORDER_GRAY_COLOR};
padding-left: 10px;
padding-right: 10px;
vertical-align: top;
`;
const TextSpan = styled.span`
display: table-cell;
padding: 3px 10px;
text-align: justify;
`
2017-08-02 23:27:05 +08:00
2017-08-07 19:51:22 +08:00
const ActivityElement = ({ activity }) =>
2017-08-22 19:20:06 +08:00
<StyledLi>
<TimeSpan>
<Moment format="HH.mm">
{activity.created_at}
</Moment>
</TimeSpan>
<TextSpan dangerouslySetInnerHTML={{ __html: activity.message }} />
</StyledLi>;
2017-08-02 23:27:05 +08:00
ActivityElement.propTypes = {
activity: PropTypes.shape({
message: PropTypes.string.isRequired,
created_at: PropTypes.string.isRequired
2017-08-22 19:20:06 +08:00
}).isRequired
2017-08-02 23:27:05 +08:00
};
export default ActivityElement;