Merge pull request #251 from cheeaun/main

Update from main
This commit is contained in:
Chee Aun 2023-10-04 12:35:04 +08:00 committed by GitHub
commit 3f23d42966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 23 deletions

View file

@ -412,7 +412,7 @@ function Timeline({
const isMiddle = i > 0 && i < items.length - 1; const isMiddle = i > 0 && i < items.length - 1;
const isSpoiler = item.sensitive && !!item.spoilerText; const isSpoiler = item.sensitive && !!item.spoilerText;
const showCompact = const showCompact =
(isSpoiler && i > 0) || (!_differentAuthor && isSpoiler && i > 0) ||
(manyItems && (manyItems &&
isMiddle && isMiddle &&
(type === 'thread' || (type === 'thread' ||

View file

@ -92,6 +92,11 @@
--link-light-color: #6494ed99; --link-light-color: #6494ed99;
--link-faded-color: #6494ed88; --link-faded-color: #6494ed88;
--link-bg-hover-color: #34353799; --link-bg-hover-color: #34353799;
--link-visited-color: color-mix(
in lch,
mediumslateblue 70%,
var(--text-color) 30%
);
--reblog-faded-color: #b190f141; --reblog-faded-color: #b190f141;
--reply-to-text-color: var(--reply-to-color); --reply-to-text-color: var(--reply-to-color);
--reply-to-faded-color: #ffa60017; --reply-to-faded-color: #ffa60017;

View file

@ -3,6 +3,11 @@ import translationTargetLanguages from '../data/lingva-target-languages';
import localeMatch from './locale-match'; import localeMatch from './locale-match';
import states from './states'; import states from './states';
const locales = [
new Intl.DateTimeFormat().resolvedOptions().locale,
...navigator.languages,
];
function getTranslateTargetLanguage(fromSettings = false) { function getTranslateTargetLanguage(fromSettings = false) {
if (fromSettings) { if (fromSettings) {
const { contentTranslationTargetLanguage } = states.settings; const { contentTranslationTargetLanguage } = states.settings;
@ -11,10 +16,7 @@ function getTranslateTargetLanguage(fromSettings = false) {
} }
} }
return localeMatch( return localeMatch(
[ locales,
new Intl.DateTimeFormat().resolvedOptions().locale,
...navigator.languages,
],
translationTargetLanguages.map((l) => l.code.replace('_', '-')), // The underscore will fail Intl.Locale inside `match` translationTargetLanguages.map((l) => l.code.replace('_', '-')), // The underscore will fail Intl.Locale inside `match`
'en', 'en',
); );

View file

@ -1,27 +1,21 @@
import { useRef } from 'preact/hooks'; import { useRef } from 'preact/hooks';
import { useDebouncedCallback } from 'use-debounce'; import { useThrottledCallback } from 'use-debounce';
import useResizeObserver from 'use-resize-observer'; import useResizeObserver from 'use-resize-observer';
export default function useTruncated({ className = 'truncated' } = {}) { export default function useTruncated({ className = 'truncated' } = {}) {
const ref = useRef(); const ref = useRef();
const onResize = useDebouncedCallback( const onResize = useThrottledCallback(({ height }) => {
({ height }) => { if (ref.current) {
if (ref.current) { const { scrollHeight } = ref.current;
const { scrollHeight } = ref.current; let truncated = scrollHeight > height;
let truncated = scrollHeight > height; if (truncated) {
if (truncated) { const { height: _height, maxHeight } = getComputedStyle(ref.current);
const { height: _height, maxHeight } = getComputedStyle(ref.current); const computedHeight = parseInt(maxHeight || _height, 10);
const computedHeight = parseInt(maxHeight || _height, 10); truncated = scrollHeight > computedHeight;
truncated = scrollHeight > computedHeight;
}
ref.current.classList.toggle(className, truncated);
} }
}, ref.current.classList.toggle(className, truncated);
300, }
{ }, 300);
maxWait: 2000,
},
);
useResizeObserver({ useResizeObserver({
ref, ref,
box: 'border-box', box: 'border-box',