Files
hedgedoc/frontend/src/components/editor-page/document-bar/note-info/note-info-line-updated.tsx
T
Philip Molares 1c16e25e14 feat(frontend): replace forkawesome with bootstrap icons
These icon replace fork awesome. A linter informs the user about the deprecation.

See https://github.com/hedgedoc/hedgedoc/issues/2929

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-02-24 14:31:17 +01:00

50 lines
1.8 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { useApplicationState } from '../../../../hooks/common/use-application-state'
import { UserAvatarForUsername } from '../../../common/user-avatar/user-avatar-for-username'
import { NoteInfoLine } from './note-info-line'
import type { NoteInfoTimeLineProps } from './note-info-time-line'
import { UnitalicBoldTimeFromNow } from './utils/unitalic-bold-time-from-now'
import { UnitalicBoldTrans } from './utils/unitalic-bold-trans'
import { DateTime } from 'luxon'
import React, { useMemo } from 'react'
import { Pencil as IconPencil } from 'react-bootstrap-icons'
import { Trans, useTranslation } from 'react-i18next'
/**
* Renders an info line about the last update of the current note.
*
* @param size The size in which line and user avatar should be displayed.
*/
export const NoteInfoLineUpdated: React.FC<NoteInfoTimeLineProps> = ({ size }) => {
useTranslation()
const noteUpdateTime = useApplicationState((state) => state.noteDetails.updatedAt)
const noteUpdateDateTime = useMemo(() => DateTime.fromSeconds(noteUpdateTime), [noteUpdateTime])
const noteUpdateUser = useApplicationState((state) => state.noteDetails.updateUsername)
const userBlock = useMemo(() => {
if (!noteUpdateUser) {
return <UnitalicBoldTrans i18nKey={'common.guestUser'} />
}
return (
<UserAvatarForUsername
username={noteUpdateUser}
additionalClasses={'font-style-normal bold font-weight-bold'}
size={size ? 'lg' : undefined}
/>
)
}, [noteUpdateUser, size])
return (
<NoteInfoLine icon={IconPencil} size={size}>
<Trans i18nKey={'editor.modal.documentInfo.edited'}>
{userBlock}
<UnitalicBoldTimeFromNow time={noteUpdateDateTime} />
</Trans>
</NoteInfoLine>
)
}