Skip to content

Commit

Permalink
Merge pull request #387 from cheeaun/main
Browse files Browse the repository at this point in the history
Update from main
  • Loading branch information
cheeaun authored Jan 8, 2024
2 parents 32c53b8 + 96387c8 commit dbef125
Show file tree
Hide file tree
Showing 16 changed files with 382 additions and 122 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ These are self-hosted by other wonderful folks.
- [phanpy.vmst.io](https://phanpy.vmst.io/) by [@vmstan@vmst.io](https://vmst.io/@vmstan)
- [phanpy.gotosocial.social](https://phanpy.gotosocial.social/) by [@admin@gotosocial.social](https://gotosocial.social/@admin)
- [phanpy.bauxite.tech](https://phanpy.bauxite.tech) by [@b4ux1t3@hachyderm.io](https://hachyderm.io/@b4ux1t3)
- [phanpy.hear-me.social](https://phanpy.hear-me.social) by [@admin@hear-me.social](https://hear-me.social/@admin)

> Note: Add yours by creating a pull request.
Expand Down
18 changes: 13 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dayjs": "~1.11.10",
"dayjs-twitter": "~0.5.0",
"fast-blurhash": "~1.1.2",
"fast-deep-equal": "~3.1.3",
"fast-equals": "~5.0.1",
"idb-keyval": "~6.2.1",
"just-debounce-it": "~3.2.0",
"lz-string": "~1.5.0",
Expand Down
98 changes: 87 additions & 11 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,10 @@ a[href^='http'][rel*='nofollow']:visited:not(:has(div)) {
list-style: none;
}
.timeline.contextual > li .replies > .replies-summary {
padding: 8px;
--summary-padding: 8px;
padding: var(--summary-padding);
background-color: var(--bg-faded-color);
display: inline-block;
display: inline-flex;
border-radius: 8px;
cursor: pointer;
text-transform: uppercase;
Expand All @@ -559,27 +560,82 @@ a[href^='http'][rel*='nofollow']:visited:not(:has(div)) {
box-shadow: 0 0 0 2px var(--bg-color);
position: relative;
list-style: none;
white-space: nowrap;
gap: 8px;
align-items: center;
margin-right: calc(44px + 8px);

b {
font-weight: 500;
color: var(--text-color);
}

.avatars {
flex-shrink: 0;
transition: opacity 0.3s ease;

.avatar {
transition: transform 0.3s ease;

&:not(:first-child) {
margin: 0 0 0 -4px;
}
}
}

.replies-counts {
/* flex-grow: 1; */

> * {
display: inline-block;
}
}

.replies-summary-chevron {
transition: transform 0.3s ease;
}

.replies-parent-link {
position: absolute;
right: 4px;
height: 100%;
z-index: 2;
font-size: 16px;
font-weight: bold;
align-self: stretch;
text-decoration: none;
display: flex;
align-items: center;
padding: var(--summary-padding) calc(var(--summary-padding) * 2);
transform: translateX(100%);
margin: calc(-1 * var(--summary-padding)) calc(-1 * var(--summary-padding))
calc(-1 * var(--summary-padding)) 0;
border-radius: 8px;
background-color: var(--link-bg-color);

&:is(:hover, :focus) {
color: var(--link-text-color);
box-shadow: inset 0 0 0 2px var(--link-faded-color);
}

&:active {
background-color: var(--link-faded-color);
}
}
}
.timeline.contextual > li .replies > .replies-summary::-webkit-details-marker {
display: none;
}
.timeline.contextual > li .replies > .replies-summary > * {
vertical-align: middle;
}
.timeline.contextual > li .replies > .replies-summary .avatars {
margin-right: 8px;

> *:not(:first-child) {
margin: 0 0 0 -4px;
}
}
.timeline.contextual > li .replies > .replies-summary:active,
.timeline.contextual
> li
.replies
> .replies-summary
.timeline.contextual
> li
.replies
> .replies-summary:active,
.timeline.contextual > li .replies[open] > .replies-summary {
color: var(--text-color);
background-color: var(--comment-line-color);
Expand All @@ -591,6 +647,18 @@ a[href^='http'][rel*='nofollow']:visited:not(:has(div)) {
}
.timeline.contextual > li .replies[open] > .replies-summary {
border-bottom-left-radius: 0;

.avatars {
opacity: 0.5;

.avatar {
transform: rotate(-15deg);
}
}

.replies-summary-chevron {
transform: rotate(180deg);
}
}
.timeline.contextual > li .replies .replies-summary[hidden] {
display: none;
Expand Down Expand Up @@ -763,6 +831,11 @@ a[href^='http'][rel*='nofollow']:visited:not(:has(div)) {
border-top-right-radius: 0;
border-top: 0;
background-size: 100% 16px;

&:has(.status-pre-meta) {
/* 20px = icon of the pre-meta */
background-size: 100% calc(16px + 20px);
}
}
.timeline:not(.flat)
> li:is(.timeline-item-container-middle, .timeline-item-container-end)
Expand Down Expand Up @@ -2187,6 +2260,9 @@ ul.link-list li a .icon {
.header-grid {
background-color: var(--bg-blur-color);
}
#columns > .deck-container > .timeline-deck {
content-visibility: auto;
}
#columns .header-grid input {
pointer-events: none;
}
Expand Down
16 changes: 13 additions & 3 deletions src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './compose.css';

import '@github/text-expander-element';
import { MenuItem } from '@szhsin/react-menu';
import equal from 'fast-deep-equal';
import { deepEqual } from 'fast-equals';
import { forwardRef } from 'preact/compat';
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
Expand Down Expand Up @@ -502,7 +502,10 @@ function Compose({
mediaAttachments,
},
};
if (!equal(backgroundDraft, prevBackgroundDraft.current) && !canClose()) {
if (
!deepEqual(backgroundDraft, prevBackgroundDraft.current) &&
!canClose()
) {
console.debug('not equal', backgroundDraft, prevBackgroundDraft.current);
db.drafts
.set(key, {
Expand Down Expand Up @@ -1838,10 +1841,17 @@ function MediaAttachment({
method: 'POST',
body,
}).then((r) => r.json());
if (response.error) {
throw new Error(response.error);
}
setDescription(response.description);
} catch (e) {
console.error(e);
showToast('Failed to generate description');
showToast(
`Failed to generate description${
e?.message ? `: ${e.message}` : ''
}`,
);
} finally {
setUIState('default');
toastRef.current?.hideToast?.();
Expand Down
27 changes: 27 additions & 0 deletions src/components/embed-modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.embed-modal-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
pointer-events: none;

.top-controls {
padding: 16px;
display: flex;
gap: 8px;
justify-content: space-between;
pointer-events: auto;
}

.embed-content {
flex-grow: 1;
display: flex;
align-items: center;
justify-content: center;

iframe {
pointer-events: auto;
max-width: 100%;
}
}
}
28 changes: 28 additions & 0 deletions src/components/embed-modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import './embed-modal.css';

import Icon from './icon';

function EmbedModal({ html, url, onClose = () => {} }) {
return (
<div class="embed-modal-container">
<div class="top-controls">
<button type="button" class="light" onClick={() => onClose()}>
<Icon icon="x" />
</button>
{url && (
<a
href={url}
target="_blank"
rel="noopener noreferrer"
class="button plain"
>
<span>Open link</span> <Icon icon="external" />
</a>
)}
</div>
<div class="embed-content" dangerouslySetInnerHTML={{ __html: html }} />
</div>
);
}

export default EmbedModal;
16 changes: 16 additions & 0 deletions src/components/modals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import states from '../utils/states';
import AccountSheet from './account-sheet';
import Compose from './compose';
import Drafts from './drafts';
import EmbedModal from './embed-modal';
import GenericAccounts from './generic-accounts';
import MediaAltModal from './media-alt-modal';
import MediaModal from './media-modal';
Expand Down Expand Up @@ -200,6 +201,21 @@ export default function Modals() {
/>
</Modal>
)}
{!!snapStates.showEmbedModal && (
<Modal
onClose={() => {
states.showEmbedModal = false;
}}
>
<EmbedModal
html={snapStates.showEmbedModal.html}
url={snapStates.showEmbedModal.url}
onClose={() => {
states.showEmbedModal = false;
}}
/>
</Modal>
)}
</>
);
}
Loading

0 comments on commit dbef125

Please sign in to comment.