Skip to content

Commit

Permalink
vertically tighter note layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalmi committed Jul 26, 2023
1 parent c502178 commit fb51316
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/js/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Props = {
children: JSX.Element | JSX.Element[];
};

const Dropdown = ({ children }: Props) => {
const Dropdown = ({ children, small }: Props) => {

Check failure on line 10 in src/js/components/Dropdown.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'small' does not exist on type 'Props'.

Check failure on line 10 in src/js/components/Dropdown.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'small' does not exist on type 'Props'.
const [open, setOpen] = useState(false);

const toggle = (e: MouseEvent, newOpenState: boolean) => {
Expand Down Expand Up @@ -44,7 +44,9 @@ const Dropdown = ({ children }: Props) => {
onMouseEnter={(e) => toggle(e, true)}
onMouseLeave={(e) => toggle(e, false)}
>
<button className="dropbtn btn btn-circle btn-ghost text-neutral-500"></button>
<button className={`dropbtn btn btn-circle ${small && 'btn-sm'} btn-ghost text-neutral-500`}>
</button>
<Show when={open}>
<div className="absolute z-10 p-2 flex flex-col gap-2 right-0 w-56 rounded-md shadow-lg bg-black border-neutral-500 border-2">
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/events/EventDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const EventDropdown = (props: EventDropdownProps) => {

return (
<div>
<Dropdown>
<Dropdown small>

Check failure on line 107 in src/js/components/events/EventDropdown.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ children: Element[]; small: true; }' is not assignable to type 'IntrinsicAttributes & Props'.

Check failure on line 107 in src/js/components/events/EventDropdown.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ children: Element[]; small: true; }' is not assignable to type 'IntrinsicAttributes & Props'.
<Copy className="btn btn-sm" key={`${id!}copy_link`} text={t('copy_link')} copyStr={url} />
<Copy
className="btn btn-sm"
Expand Down
35 changes: 21 additions & 14 deletions src/js/components/events/note/Author.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import Name from '../../user/Name';
import EventDropdown from '../EventDropdown';

import Avatar from './Avatar';
import ReplyingToUsers from './ReplyingToUsers';

const Author = ({ event, fullWidth, isQuote, standalone, setTranslatedText }) => {
const Author = ({ event, fullWidth, isQuote, standalone, setTranslatedText, isQuoting }) => {
const { time, dateStr, timeStr } = useMemo(() => {
const t = new Date(event.created_at * 1000);
const dStr = t.toLocaleString(window.navigator.language, {
Expand All @@ -29,19 +30,25 @@ const Author = ({ event, fullWidth, isQuote, standalone, setTranslatedText }) =>
<Show when={fullWidth}>
<Avatar event={event} isQuote={isQuote} standalone={standalone} />
</Show>
<a href={`/${Key.toNostrBech32Address(event.pubkey, 'npub')}`} className="font-bold">
<Name pub={event.pubkey} />
</a>
<small>
{'· '}
<a
href={`/${Key.toNostrBech32Address(event.id, 'note')}`}
className="tooltip text-neutral-500"
data-tip={`${dateStr} ${timeStr}`}
>
{time && Helpers.getRelativeTimeText(time)}
</a>
</small>
<div className="flex flex-col">
<div>
<a href={`/${Key.toNostrBech32Address(event.pubkey, 'npub')}`} className="font-bold">
<Name pub={event.pubkey} />
</a>
<small>
{'· '}
<a
href={`/${Key.toNostrBech32Address(event.id, 'note')}`}
className="tooltip text-neutral-500"
data-tip={`${dateStr} ${timeStr}`}
>
{time && Helpers.getRelativeTimeText(time)}
</a>
</small>
</div>

<ReplyingToUsers event={event} isQuoting={isQuoting} />
</div>
<Show when={!isQuote}>
<div className="flex-1 flex items-center justify-end">
<EventDropdown id={event.id} event={event} onTranslate={setTranslatedText} />
Expand Down
5 changes: 2 additions & 3 deletions src/js/components/events/note/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Reactions from '../buttons/ReactionButtons';

import Author from './Author';
import Helmet from './Helmet';
import ReplyingToUsers from './ReplyingToUsers';

let loadReactions = true;
let showLikes = true;
Expand Down Expand Up @@ -99,18 +98,18 @@ const Content = ({ standalone, isQuote, fullWidth, isQuoting, asInlineQuote, eve
standalone={standalone}
event={event}
isQuote={isQuote}
isQuoting={isQuoting}
fullWidth={fullWidth}
setTranslatedText={setTranslatedText}
/>
<ReplyingToUsers event={event} isQuoting={isQuoting} />
<Show when={standalone}>
<Helmet name={name} text={text} attachments={attachments} />
</Show>
<Show when={meta.torrentId}>
<Torrent torrentId={meta.torrentId} autopause={!standalone} />
</Show>
<Show when={text?.length > 0}>
<div className={`preformatted-wrap py-2 ${emojiOnly && 'text-2xl'}`}>
<div className={`preformatted-wrap pb-1 ${emojiOnly && 'text-2xl'}`}>
{text}
<Show when={translatedText}>
<p>
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/events/note/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Note = ({
}

const className = useMemo(() => {
const classNames = ['msg'];
const classNames = [] as string[];

if (standalone) {
classNames.push('standalone');
Expand Down

0 comments on commit fb51316

Please sign in to comment.