-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
export interface CommentsProps extends React.HTMLProps<HTMLDivElement> { | ||
} | ||
declare const Comments: { | ||
({ children, ...rest }: CommentsProps): React.JSX.Element; | ||
Input: ({ onSubmit, ...rest }: import("./components/CommentInput").CommentInput) => React.JSX.Element; | ||
Item: ({ inbound, text, className, createdAt, createdBy, onDelete, ...rest }: import("./components/CommentItem").CommentItemProps) => React.JSX.Element; | ||
}; | ||
export default Comments; | ||
//# sourceMappingURL=Comments.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
export interface CommentsProps extends React.HTMLProps<HTMLDivElement> { | ||
} | ||
declare const Comments: { | ||
({ children, ...rest }: CommentsProps): React.JSX.Element; | ||
Item: ({ inbound, text, className, ...rest }: import("./components/CommentItem").CommentItemProps) => React.JSX.Element; | ||
}; | ||
export default Comments; | ||
//# sourceMappingURL=Commets.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import { FormControlProps } from 'react-bootstrap'; | ||
export interface CommentInput extends FormControlProps { | ||
onSubmit: () => void; | ||
} | ||
declare const CommentInput: ({ onSubmit, ...rest }: CommentInput) => React.JSX.Element; | ||
export default CommentInput; | ||
//# sourceMappingURL=CommentInput.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
export interface CommentItemProps extends React.HTMLProps<HTMLDivElement> { | ||
inbound: boolean; | ||
text: string; | ||
createdBy: string; | ||
createdAt: Date; | ||
onDelete: () => void; | ||
} | ||
declare const CommentItem: ({ inbound, text, className, createdAt, createdBy, onDelete, ...rest }: CommentItemProps) => React.JSX.Element; | ||
export default CommentItem; | ||
//# sourceMappingURL=CommentItem.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,3 +189,7 @@ i.toast-icon { | |
} | ||
} | ||
} | ||
|
||
.cursor-pointer{ | ||
cursor: pointer; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import CommentItem from './components/CommentItem'; | ||
import CommentInput from './components/CommentInput'; | ||
|
||
export interface CommentsProps extends React.HTMLProps<HTMLDivElement> {} | ||
|
||
const Comments = ({ children, ...rest }: CommentsProps) => { | ||
return <div {...rest}>{children}</div>; | ||
}; | ||
|
||
Comments.Input = CommentInput; | ||
Comments.Item = CommentItem; | ||
|
||
export default Comments; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Button from 'components/button/Button'; | ||
import Subtitle from 'components/subtitle/Subtitle'; | ||
import React from 'react'; | ||
import { Form, FormControlProps } from 'react-bootstrap'; | ||
|
||
export interface CommentInput extends FormControlProps { | ||
onSubmit: () => void; | ||
} | ||
|
||
const CommentInput = ({ onSubmit, ...rest }: CommentInput) => { | ||
return ( | ||
<div> | ||
<Subtitle text="Comments:" className="mb-2" /> | ||
<Form.Control as="textarea" placeholder="Leave a comment..." {...rest} /> | ||
|
||
<div className="d-flex justify-content-end mt-2"> | ||
<Button onClick={onSubmit}>Comment</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CommentInput; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
export interface CommentItemProps extends React.HTMLProps<HTMLDivElement> { | ||
inbound: boolean; | ||
text: string; | ||
createdBy: string; | ||
createdAt: Date; | ||
onDelete: () => void; | ||
} | ||
|
||
const CommentItem = ({ | ||
inbound, | ||
text, | ||
className, | ||
createdAt, | ||
createdBy, | ||
onDelete, | ||
...rest | ||
}: CommentItemProps) => { | ||
const itemClass = classNames( | ||
className, | ||
'w-75 border rounded p-3 mt-3', | ||
inbound ? 'bg-secondary' : 'text-white bg-primary' | ||
); | ||
|
||
const localeFormat = new Intl.DateTimeFormat('default', { | ||
dateStyle: 'short', | ||
timeStyle: 'short', | ||
}); | ||
|
||
return ( | ||
<div | ||
className={classNames( | ||
'd-flex', | ||
inbound ? 'justify-content-start' : 'justify-content-end' | ||
)} | ||
> | ||
<div className={itemClass} {...rest}> | ||
{text} | ||
|
||
<div className="d-flex justify-content-between mt-2 opacity-75"> | ||
<span>From: {createdBy}</span> | ||
|
||
<div> | ||
<span className={classNames(!inbound ? 'me-2' : null)}> | ||
{localeFormat.format(createdAt)} | ||
</span> | ||
|
||
{!inbound ? ( | ||
<span | ||
className="text-decoration-underline cursor-pointer" | ||
onClick={onDelete} | ||
> | ||
Delete | ||
</span> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CommentItem; |