import React, { useState, useContext } from 'react'; import { Card, Accordion, Col, AccordionContext, useAccordionToggle } from 'react-bootstrap'; import styled from 'styled-components'; const Text = styled(Card.Body)` & .WRAP { display: inline-block; text-overflow: ellipsis; width: 100%; white-space: initial; } ` function Notice({ card_index, title, date, content }) { function ContextAwareToggle({ children, eventKey, callback }) { const currentEventKey = useContext(AccordionContext); const decoratedOnClick = useAccordionToggle( eventKey, () => callback && callback(eventKey), ); const isCurrentEventKey = currentEventKey === eventKey; return (
{children}
); } function dateForm(day) { const post_day = new Date(day); let year = post_day.getFullYear(); let month = post_day.getMonth() + 1; let date = post_day.getDate(); month = month < 10 ? '0' + month : month; date = date < 10 ? '0' + date : date; const new_date = year + "-" + month + "-" + date; return new_date } return ( {title} {dateForm(date)} {content.split("\n").map((i, key) => { return
{i}
; })}
) } export default Notice;