|
| 1 | +import React from 'react'; |
| 2 | +import styled from 'styled-components'; |
| 3 | +import type { Complex } from '../../../types/complex'; |
| 4 | +import Button from '../../common/atoms/Button'; |
| 5 | + |
| 6 | +const CardWrapper = styled.div<{ delay: number }>` |
| 7 | + background-color: #ffffff; |
| 8 | + border-radius: 16px; |
| 9 | + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08); |
| 10 | + padding: 1.5rem; /* 24px */ |
| 11 | + display: flex; |
| 12 | + flex-direction: column; |
| 13 | + justify-content: space-between; |
| 14 | + transition: |
| 15 | + transform 0.3s ease-out, |
| 16 | + box-shadow 0.3s ease-out; |
| 17 | + opacity: 0; |
| 18 | + transform: translateY(10px); |
| 19 | + animation: fadeIn 0.5s ease-out forwards; |
| 20 | + animation-delay: ${({ delay }) => delay}s; |
| 21 | +
|
| 22 | + &:hover { |
| 23 | + transform: translateY(-6px); |
| 24 | + box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12); |
| 25 | + } |
| 26 | +
|
| 27 | + @keyframes fadeIn { |
| 28 | + to { |
| 29 | + opacity: 1; |
| 30 | + transform: translateY(0); |
| 31 | + } |
| 32 | + } |
| 33 | +`; |
| 34 | + |
| 35 | +const CategoryBadge = styled.span` |
| 36 | + display: inline-block; |
| 37 | + background-color: #e0e7ff; /* Indigo-100 like */ |
| 38 | + color: #4338ca; /* Indigo-700 like */ |
| 39 | + font-size: 0.75rem; /* 12px */ |
| 40 | + font-weight: 500; |
| 41 | + padding: 0.25rem 0.75rem; /* 4px 12px */ |
| 42 | + border-radius: 9999px; /* pill shape */ |
| 43 | + margin-bottom: 0.75rem; /* 12px */ |
| 44 | +`; |
| 45 | + |
| 46 | +const ContentText = styled.p` |
| 47 | + color: #4b5563; /* Gray-600 like */ |
| 48 | + font-size: 0.9375rem; /* 15px */ |
| 49 | + line-height: 1.6; |
| 50 | + margin-bottom: 1rem; /* 16px */ |
| 51 | + /* For line clamping */ |
| 52 | + display: -webkit-box; |
| 53 | + -webkit-line-clamp: 4; |
| 54 | + -webkit-box-orient: vertical; |
| 55 | + overflow: hidden; |
| 56 | + text-overflow: ellipsis; |
| 57 | + min-height: calc(1.6em * 4); /* Ensure space for 4 lines */ |
| 58 | +`; |
| 59 | + |
| 60 | +const MetaText = styled.p` |
| 61 | + font-size: 0.75rem; /* 12px */ |
| 62 | + color: #6b7280; /* Gray-500 like */ |
| 63 | + margin-bottom: 1rem; /* 16px */ |
| 64 | +`; |
| 65 | + |
| 66 | +const ActionsWrapper = styled.div` |
| 67 | + display: flex; |
| 68 | + gap: 0.5rem; /* 8px */ |
| 69 | + margin-top: auto; /* Pushes actions to the bottom */ |
| 70 | +`; |
| 71 | + |
| 72 | +interface ComplexCardProps { |
| 73 | + complex: Complex; |
| 74 | + onViewGoals: (id: number) => void; |
| 75 | + onEdit: (id: number) => void; |
| 76 | + onDelete: (id: number) => void; |
| 77 | + animationDelay: number; |
| 78 | +} |
| 79 | + |
| 80 | +const ComplexCard: React.FC<ComplexCardProps> = ({ |
| 81 | + complex, |
| 82 | + onViewGoals, |
| 83 | + onEdit, |
| 84 | + onDelete, |
| 85 | + animationDelay, |
| 86 | +}) => { |
| 87 | + const formatDate = (dateString: string) => { |
| 88 | + const options: Intl.DateTimeFormatOptions = { |
| 89 | + year: 'numeric', |
| 90 | + month: 'long', |
| 91 | + day: 'numeric', |
| 92 | + }; |
| 93 | + return new Date(dateString).toLocaleDateString('ja-JP', options); |
| 94 | + }; |
| 95 | + |
| 96 | + return ( |
| 97 | + <CardWrapper delay={animationDelay}> |
| 98 | + <div> |
| 99 | + <CategoryBadge>{complex.category}</CategoryBadge> |
| 100 | + <ContentText>{complex.content}</ContentText> |
| 101 | + </div> |
| 102 | + <div> |
| 103 | + <MetaText>最終更新: {formatDate(complex.updated_at)}</MetaText> |
| 104 | + <ActionsWrapper> |
| 105 | + <Button |
| 106 | + variant="primary" |
| 107 | + size="small" |
| 108 | + onClick={() => onViewGoals(complex.id)} |
| 109 | + style={{ flexGrow: 1 }} |
| 110 | + > |
| 111 | + 目標を見る/設定 |
| 112 | + </Button> |
| 113 | + <Button |
| 114 | + variant="secondary" |
| 115 | + size="small" |
| 116 | + onClick={() => onEdit(complex.id)} |
| 117 | + > |
| 118 | + 編集 |
| 119 | + </Button> |
| 120 | + <Button |
| 121 | + variant="danger" |
| 122 | + size="small" |
| 123 | + onClick={() => onDelete(complex.id)} |
| 124 | + > |
| 125 | + 削除 |
| 126 | + </Button> |
| 127 | + </ActionsWrapper> |
| 128 | + </div> |
| 129 | + </CardWrapper> |
| 130 | + ); |
| 131 | +}; |
| 132 | + |
| 133 | +export default ComplexCard; |
0 commit comments