Skip to content

Commit

Permalink
Merge pull request #472 from cheeaun/main
Browse files Browse the repository at this point in the history
Update from main
  • Loading branch information
cheeaun authored Mar 28, 2024
2 parents 8fc5e10 + 671d2c9 commit ecd308c
Show file tree
Hide file tree
Showing 18 changed files with 309 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ a[href^='http'][rel*='nofollow']:visited:not(:has(div)) {
video,
img,
audio {
min-height: 88px; /* for extreme dimensions */
min-height: var(--pointer-min-dimension); /* for extreme dimensions */
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/cloak-mode.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ body.cloak,
.account-block,
.catchup-filters .filter-author *,
.post-peek-html *,
.post-peek-content > * {
.post-peek-content > *,
.request-notifications-account * {
text-decoration-thickness: 1.1em;
text-decoration-line: line-through;
/* text-rendering: optimizeSpeed; */
Expand Down Expand Up @@ -51,7 +52,8 @@ body.cloak,
.cloak {
.media-container figcaption,
.media-container figcaption > *,
.catchup-filters .filter-author * {
.catchup-filters .filter-author *,
.request-notifications-account * {
color: var(--text-color) !important;
}
}
55 changes: 55 additions & 0 deletions src/components/account-info.css
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,58 @@
}
}
}

.handle-info {
.handle-handle {
display: inline-block;
margin-block: 5px;

b {
font-weight: 600;
padding: 2px 4px;
border-radius: 4px;
display: inline-block;
box-shadow: 0 0 0 5px var(--bg-blur-color);

&.handle-username {
color: var(--orange-fg-color);
background-color: var(--orange-bg-color);
}

&.handle-server {
color: var(--purple-fg-color);
background-color: var(--purple-bg-color);
}
}
}

.handle-at {
display: inline-block;
margin-inline: -3px;
position: relative;
z-index: 1;
}

.handle-legend {
margin-top: 0.25em;
}

.handle-legend-icon {
overflow: hidden;
display: inline-block;
width: 14px;
height: 14px;
border: 4px solid transparent;
border-radius: 8px;
background-clip: padding-box;

&.username {
background-color: var(--orange-fg-color);
border-color: var(--orange-bg-color);
}
&.server {
background-color: var(--purple-fg-color);
border-color: var(--purple-bg-color);
}
}
}
79 changes: 72 additions & 7 deletions src/components/account-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,55 @@ function AccountInfo({
/>
)}
<header>
<AccountBlock
account={info}
instance={instance}
avatarSize="xxxl"
external={standalone}
internal={!standalone}
/>
{standalone ? (
<Menu2
shift={
window.matchMedia('(min-width: calc(40em))').matches
? 114
: 64
}
menuButton={
<div>
<AccountBlock
account={info}
instance={instance}
avatarSize="xxxl"
onClick={() => {}}
/>
</div>
}
>
<div class="szh-menu__header">
<AccountHandleInfo acct={acct} instance={instance} />
</div>
<MenuItem
onClick={() => {
const handle = `@${acct}`;
try {
navigator.clipboard.writeText(handle);
showToast('Handle copied');
} catch (e) {
console.error(e);
showToast('Unable to copy handle');
}
}}
>
<Icon icon="link" />
<span>Copy handle</span>
</MenuItem>
<MenuItem href={url} target="_blank">
<Icon icon="external" />
<span>Go to original profile page</span>
</MenuItem>
</Menu2>
) : (
<AccountBlock
account={info}
instance={instance}
avatarSize="xxxl"
internal
/>
)}
</header>
<div class="faux-header-bg" aria-hidden="true" />
<main>
Expand Down Expand Up @@ -2000,4 +2042,27 @@ function FieldsAttributesRow({ name, value, disabled, index: i }) {
);
}

function AccountHandleInfo({ acct, instance }) {
// acct = username or username@server
let [username, server] = acct.split('@');
if (!server) server = instance;
return (
<div class="handle-info">
<span class="handle-handle">
<b class="handle-username">{username}</b>
<span class="handle-at">@</span>
<b class="handle-server">{server}</b>
</span>
<div class="handle-legend">
<span class="ib">
<span class="handle-legend-icon username" /> username
</span>{' '}
<span class="ib">
<span class="handle-legend-icon server" /> server domain name
</span>
</div>
</div>
);
}

export default AccountInfo;
2 changes: 2 additions & 0 deletions src/components/compose-button.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useHotkeys } from 'react-hotkeys-hook';

import openCompose from '../utils/open-compose';
import openOSK from '../utils/open-osk';
import states from '../utils/states';

import Icon from './icon';
Expand All @@ -14,6 +15,7 @@ export default function ComposeButton() {
states.showCompose = true;
}
} else {
openOSK();
states.showCompose = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function Compose({
setVisibility(visibility);
setLanguage(language || presf.postingDefaultLanguage || DEFAULT_LANG);
setSensitive(sensitive);
setPoll(composablePoll);
if (composablePoll) setPoll(composablePoll);
setMediaAttachments(mediaAttachments);
setUIState('default');
} catch (e) {
Expand Down
10 changes: 8 additions & 2 deletions src/components/intl-segmenter-suspense.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { shouldPolyfill } from '@formatjs/intl-segmenter/should-polyfill';
import { Suspense } from 'preact/compat';
import { useEffect, useState } from 'preact/hooks';

import Loader from './loader';

const supportsIntlSegmenter = !shouldPolyfill();

export default function IntlSegmenterSuspense({ children }) {
if (supportsIntlSegmenter) {
return <Suspense>{children}</Suspense>;
return <Suspense fallback={<Loader />}>{children}</Suspense>;
}

const [polyfillLoaded, setPolyfillLoaded] = useState(false);
Expand All @@ -17,5 +19,9 @@ export default function IntlSegmenterSuspense({ children }) {
})();
}, []);

return polyfillLoaded && <Suspense>{children}</Suspense>;
return polyfillLoaded ? (
<Suspense fallback={<Loader />}>{children}</Suspense>
) : (
<Loader />
);
}
4 changes: 4 additions & 0 deletions src/components/nav-menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@
.sparkle-icon {
animation: sparkle-icon 0.3s ease-in-out infinite alternate;
}

.nav-submenu {
max-width: 14em;
}
11 changes: 7 additions & 4 deletions src/components/nav-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ function NavMenu(props) {

const [currentAccount, moreThanOneAccount] = useMemo(() => {
const accounts = store.local.getJSON('accounts') || [];
const acc = accounts.find(
(account) => account.info.id === store.session.get('currentAccount'),
);
const acc =
accounts.find(
(account) => account.info.id === store.session.get('currentAccount'),
) || accounts[0];
return [acc, accounts.length > 1];
}, []);

Expand Down Expand Up @@ -147,7 +148,7 @@ function NavMenu(props) {
}}
{...props}
overflow="auto"
viewScroll="close"
// viewScroll="close"
position="anchor"
align="center"
boundingBoxPadding={boundingBoxPadding}
Expand Down Expand Up @@ -209,6 +210,7 @@ function NavMenu(props) {
)}
{lists?.length > 0 ? (
<SubMenu
menuClassName="nav-submenu"
overflow="auto"
gap={-8}
label={
Expand Down Expand Up @@ -243,6 +245,7 @@ function NavMenu(props) {
<Icon icon="bookmark" size="l" /> <span>Bookmarks</span>
</MenuLink>
<SubMenu
menuClassName="nav-submenu"
overflow="auto"
gap={-8}
label={
Expand Down
3 changes: 2 additions & 1 deletion src/components/notification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Fragment } from 'preact';
import { memo } from 'preact/compat';

import shortenNumber from '../utils/shorten-number';
import states from '../utils/states';
import states, { statusKey } from '../utils/states';
import store from '../utils/store';
import useTruncated from '../utils/useTruncated';

Expand Down Expand Up @@ -228,6 +228,7 @@ function Notification({
accounts: _accounts,
showReactions: type === 'favourite+reblog',
excludeRelationshipAttrs: type === 'follow' ? ['followedBy'] : [],
postID: statusKey(actualStatusID, instance),
};
};

Expand Down
28 changes: 15 additions & 13 deletions src/components/status.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
padding: 2px;
vertical-align: top;
text-transform: uppercase;
text-shadow: 0 1px var(--bg-color);
/* text-shadow: 0 1px var(--bg-color); */

&:hover {
color: var(--text-color);
Expand Down Expand Up @@ -623,26 +623,26 @@
.spoiler-media-button
),
~ .card .meta-container {
/* filter: blur(5px) invert(0.5);
image-rendering: crisp-edges;
image-rendering: pixelated; */
opacity: 0.2;
text-decoration-thickness: 1.5em;
text-decoration-line: line-through;
/* text-rendering: optimizeSpeed; */
pointer-events: none;
user-select: none;
/* contain: layout; */
/* transform: scale(0.97);
transition: transform 0.1s ease-in-out; */

* {
text-decoration-color: inherit;
text-decoration-thickness: 1.5em;
text-decoration-line: line-through;
/* text-rendering: optimizeSpeed; */
}
}

~ *:not(
.media-container,
.card,
.media-figure-multiple,
.spoiler-media-button
),
~ .card .meta-container {
img {
filter: invert(0.5);
background-color: black;
Expand Down Expand Up @@ -908,7 +908,7 @@
grid-auto-rows: 1fr;
gap: 2px;
/* height: 160px; */
min-height: 88px;
min-height: var(--pointer-min-dimension);
height: auto;
max-height: max(160px, 33vh);
}
Expand Down Expand Up @@ -1037,9 +1037,9 @@
.status .media-container.media-eq1 .media {
display: inline-block;
max-width: 100% !important;
min-width: 88px;
min-width: var(--pointer-min-dimension);
/* width: auto; */
min-height: 88px;
min-height: var(--pointer-min-dimension);
/* --maxAspectHeight: max(160px, 33vh);
--aspectWidth: calc(--width / --height * var(--maxAspectHeight)); */
width: min(var(--aspectWidth), var(--width), 100%);
Expand Down Expand Up @@ -1300,7 +1300,7 @@ body:has(#modal-container .carousel) .status .media img:hover {
:is(.status, .media-post) .media-audio {
width: 100%;
height: 100%;
min-height: 88px;
min-height: var(--pointer-min-dimension);
background-image: radial-gradient(
circle at center center,
transparent,
Expand Down Expand Up @@ -1696,6 +1696,7 @@ a.card:is(:hover, :focus):visited {
.poll-label input:is([type='radio'], [type='checkbox']) {
flex-shrink: 0;
margin: 3px;
min-height: 1em;
}
.poll-option-votes {
flex-shrink: 0;
Expand All @@ -1719,6 +1720,7 @@ a.card:is(:hover, :focus):visited {
}
.poll-option-title {
text-shadow: 0 1px var(--bg-color);
line-height: 1.2;
}
.poll-option-title .icon {
vertical-align: middle;
Expand Down
Loading

0 comments on commit ecd308c

Please sign in to comment.