utopia-ui/src/Components/Templates/DateUserInfo.tsx
Anton Tranelis 9e6bcf1846
fix(source): update tailwind and daisyui (#196)
* removed daisy from config

* removed tw-elements artefact

* removed comments from tailwind config

* removed safelist

* migrated to tailwind4 and daisyui5

* deleted tailwind.config.js which is not eeded anymore

* 3.0.79

* version number

* fixed broken layouts

* more fixing

* more layout fixing

* tested theming

* small fixes

* adapt snapshots to changes

* package.json: add unit test update script

* more ui refactoring & theme controller

* ui improvements

* package-lock.json

* fix linting

* fixed tabs

* fix linting

* fixed typing

---------

Co-authored-by: mahula <lenzmath@posteo.de>
2025-04-25 16:03:42 +02:00

32 lines
1.1 KiB
TypeScript

import { useState } from 'react'
import { timeAgo } from '#utils/TimeAgo'
import type { Item } from '#types/Item'
export const DateUserInfo = ({ item }: { item: Item }) => {
const [infoExpanded, setInfoExpanded] = useState<boolean>(false)
return (
<div
className='tw:flex tw:-mb-1 tw:flex-row tw:mr-2 tw:-mt-2'
onClick={(e) => e.stopPropagation()}
>
{infoExpanded ? (
<p
className={'tw:italic tw:min-h-[21px] tw:my-0! tw:text-gray-500'}
onClick={() => setInfoExpanded(false)}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
>{`${item.date_updated && item.date_updated !== item.date_created ? 'updated' : 'posted'} ${item.user_created?.first_name ? `by ${item.user_created.first_name}` : ''} ${item.date_updated ? timeAgo(item.date_updated) : timeAgo(item.date_created!)}`}</p>
) : (
<p
className='tw:my-0! tw:min-h-[21px] tw:font-bold tw:cursor-pointer tw:text-gray-500'
onClick={() => setInfoExpanded(true)}
>
</p>
)}
<div className='tw:grow '></div>
</div>
)
}