chore: update formatting

This commit is contained in:
Eana Hufwe 2024-07-30 23:32:52 +00:00 committed by GitHub
parent bf28e75dac
commit f0337595f6
21 changed files with 148 additions and 99 deletions

View file

@ -36,24 +36,35 @@ function setPosition() {
const rootRect = props.rootElement.getBoundingClientRect();
const rect = props.targetElement.getBoundingClientRect();
const isRtl = getComputedStyle(props.rootElement).direction === "rtl";
const writingMode = getComputedStyle(props.rootElement)['writing-mode'];
const writingMode = getComputedStyle(props.rootElement)["writing-mode"];
const isVertical = writingMode.startsWith("vertical");
const targetInlineSize = isVertical ? props.targetElement.offsetHeight : props.targetElement.offsetWidth;
const targetInlineSize = isVertical
? props.targetElement.offsetHeight
: props.targetElement.offsetWidth;
const rectInlineSize = isVertical ? rect.height : rect.width;
const windowInlineSize = isVertical ? window.innerHeight : window.innerWidth;
const rootInsetInlineStart =
isRtl && isVertical ? rootRect.bottom :
!isRtl && isVertical ? rootRect.top :
isRtl && !isVertical ? rootRect.right :
rootRect.left;
isRtl && isVertical
? rootRect.bottom
: !isRtl && isVertical
? rootRect.top
: isRtl && !isVertical
? rootRect.right
: rootRect.left;
const rectInsetInlineStart =
isRtl && isVertical ? rect.bottom :
!isRtl && isVertical ? rect.top :
isRtl && !isVertical ? rect.right :
rect.left;
isRtl && isVertical
? rect.bottom
: !isRtl && isVertical
? rect.top
: isRtl && !isVertical
? rect.right
: rect.left;
let insetInlineStart = targetInlineSize;
if (rootInsetInlineStart + insetInlineStart > windowInlineSize - rectInlineSize) {
if (
rootInsetInlineStart + insetInlineStart >
windowInlineSize - rectInlineSize
) {
insetInlineStart = -rectInlineSize;
}
if (rectInsetInlineStart + insetInlineStart < 0) {
@ -61,10 +72,13 @@ function setPosition() {
}
const insetBlockStart =
writingMode === "vertical-rl" ? rootRect.right - rect.right - 8:
writingMode === "vertical-lr" ? rootRect.left - rect.left - 8 :
writingMode === "horizontal-bt" ? rect.right - rootRect.right - 8 :
rect.top - rootRect.top - 8;
writingMode === "vertical-rl"
? rootRect.right - rect.right - 8
: writingMode === "vertical-lr"
? rootRect.left - rect.left - 8
: writingMode === "horizontal-bt"
? rect.right - rootRect.right - 8
: rect.top - rootRect.top - 8;
el.value!.style.insetInlineStart = `${insetInlineStart}px`;
el.value!.style.insetBlockStart = `${insetBlockStart}px`;
}

View file

@ -221,7 +221,11 @@ function onBgClick() {
if (type.value === "drawer") {
maxHeight.value = window.innerHeight / 1.5;
if (getComputedStyle(document.documentElement)["writing-mode"].startsWith("vertical")) {
if (
getComputedStyle(document.documentElement)["writing-mode"].startsWith(
"vertical",
)
) {
maxHeight.value = window.innerHeight / 1.5;
}
}
@ -254,7 +258,7 @@ const align = () => {
const styles = getComputedStyle(props.src);
const direction = styles.direction;
const writingMode = styles['writing-mode'];
const writingMode = styles["writing-mode"];
if (direction === "rtl") {
if (anchorX === "right") {
@ -268,27 +272,27 @@ const align = () => {
const prevAnchorX = anchorX;
const prevAnchorY = anchorY;
if (prevAnchorX === "left") {
anchorY = "top"
anchorY = "top";
} else if (prevAnchorX === "right") {
anchorY = "bottom"
anchorY = "bottom";
} else if (prevAnchorX === "center") {
anchorY = "top"
anchorY = "top";
}
if (writingMode === "vertical-rl") {
if (prevAnchorY === "top") {
anchorX = "right"
anchorX = "right";
} else if (prevAnchorY === "bottom") {
anchorX = "left"
anchorX = "left";
} else if (prevAnchorY === "center") {
anchorX = "center"
anchorX = "center";
}
} else if (writingMode === "vertical-lr") {
if (prevAnchorY === "top") {
anchorX = "left"
anchorX = "left";
} else if (prevAnchorY === "bottom") {
anchorX = "right"
anchorX = "right";
} else if (prevAnchorY === "center") {
anchorX = "center"
anchorX = "center";
}
}
}
@ -313,18 +317,24 @@ const align = () => {
const windowBlockSize = isVertical ? window.innerWidth : window.innerHeight;
const windowScrollBlock = isVertical ? window.scrollX : window.scrollY;
const insetBlockStart =
writingMode === "vertical-rl" ? windowBlockSize - left - width :
writingMode === "vertical-lr" ? left :
top;
writingMode === "vertical-rl"
? windowBlockSize - left - width
: writingMode === "vertical-lr"
? left
: top;
const insetBlockEnd =
writingMode === "vertical-rl" ? windowBlockSize - left :
writingMode === "vertical-lr" ? left + width :
top + height;
writingMode === "vertical-rl"
? windowBlockSize - left
: writingMode === "vertical-lr"
? left + width
: top + height;
const blockSize = isVertical ? width : height;
const srcRectBlockStart =
writingMode === "vertical-rl" ? srcRect.right :
writingMode === "vertical-lr" ? srcRect.left :
srcRect.top;
writingMode === "vertical-rl"
? srcRect.right
: writingMode === "vertical-lr"
? srcRect.left
: srcRect.top;
if (fixed.value) {
//
@ -349,7 +359,10 @@ const align = () => {
const blockEndSpace = windowBlockSize - MARGIN - insetBlockStart;
const blockStartSpace = srcRectBlockStart - MARGIN;
if (insetBlockEnd > windowBlockSize - MARGIN || blockSize > windowBlockSize - MARGIN) {
if (
insetBlockEnd > windowBlockSize - MARGIN ||
blockSize > windowBlockSize - MARGIN
) {
if (props.noOverlap) {
if (blockEndSpace >= blockStartSpace / 3) {
maxHeight.value = blockEndSpace;
@ -378,8 +391,8 @@ const align = () => {
}
}
const blockEndSpace =windowBlockSize - MARGIN - (insetBlockStart - windowScrollBlock);
const blockEndSpace =
windowBlockSize - MARGIN - (insetBlockStart - windowScrollBlock);
const blockStartSpace = srcRectBlockStart - MARGIN;
//
@ -400,7 +413,10 @@ const align = () => {
top = MARGIN;
}
if (left > window.innerWidth - width - MARGIN && writingMode !== "vertical-lr") {
if (
left > window.innerWidth - width - MARGIN &&
writingMode !== "vertical-lr"
) {
left = window.innerWidth - width - MARGIN;
}
if (left < 0 && writingMode !== "vertical-rl") {

View file

@ -60,7 +60,7 @@ function setPosition() {
direction = "right";
}
}
if (getComputedStyle(el.value!)['writing-mode'].startsWith("vertical")) {
if (getComputedStyle(el.value!)["writing-mode"].startsWith("vertical")) {
if (direction === "top") {
direction = "right";
} else if (direction === "bottom") {

View file

@ -189,7 +189,11 @@ function show(_ev: MouseEvent) {
scanOptions(options);
os.popupMenu(menu, container.value!, {
width: getComputedStyle(container.value!)['writing-mode'].startsWith('vertical') ? container.value!.offsetHeight : container.value!.offsetWidth,
width: getComputedStyle(container.value!)["writing-mode"].startsWith(
"vertical",
)
? container.value!.offsetHeight
: container.value!.offsetWidth,
// onClosing: () => {
// opening.value = false;
// },

View file

@ -270,23 +270,28 @@ onMounted(() => {
if (!isTabs(props.tabs)) return;
const tabEl = tabRefs[props.tab];
if (tabEl && tabHighlightEl.value) {
const isVertical = getComputedStyle(tabHighlightEl.value)['writing-mode'].startsWith("vertical");
const isVertical = getComputedStyle(tabHighlightEl.value)[
"writing-mode"
].startsWith("vertical");
// offsetWidth offsetLeft getBoundingClientRect 使
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
const tabSizeX = (isVertical ? tabEl.scrollHeight : tabEl.scrollWidth) + 20; // + the tab's padding
const tabSizeX =
(isVertical ? tabEl.scrollHeight : tabEl.scrollWidth) + 20; // + the tab's padding
if (props.tabs.length > 3) {
tabEl.style = `--width: ${tabSizeX}px`;
}
setTimeout(() => {
if (tabHighlightEl.value == null) return;
let translateFunction = 'translateX';
let translateFunction = "translateX";
let translateValue = tabEl.offsetLeft;
if (isVertical) {
translateFunction = 'translateY';
translateFunction = "translateY";
translateValue = tabEl.offsetTop;
}
if (getComputedStyle(tabHighlightEl.value).direction === "rtl") {
translateValue += isVertical ? tabEl.offsetHeight - tabEl.offsetParent.scrollHeight : tabEl.offsetWidth - tabEl.offsetParent.scrollWidth;
translateValue += isVertical
? tabEl.offsetHeight - tabEl.offsetParent.scrollHeight
: tabEl.offsetWidth - tabEl.offsetParent.scrollWidth;
}
tabHighlightEl.value.style.inlineSize = `${tabSizeX}px`;
tabHighlightEl.value.style.transform = `${translateFunction}(${translateValue}px)`;

View file

@ -302,9 +302,9 @@ function setSwiperRef(swiper: SwiperType) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -265,9 +265,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -173,19 +173,24 @@ onMounted(() => {
const rect = tabEl.getBoundingClientRect();
var inlineSize = rect.width;
var insetInlineStart = rect.left - parentRect.left;
const isVertical = getComputedStyle(tabHighlightEl.value)['writing-mode'].startsWith("vertical");
const isVertical = getComputedStyle(tabHighlightEl.value)[
"writing-mode"
].startsWith("vertical");
if (isVertical) {
inlineSize = rect.height;
}
if (getComputedStyle(tabHighlightEl.value).direction === "rtl") {
if (isVertical) {
tabHighlightEl.value.style.insetBlockEnd = rect.bottom - parentRect.bottom + "px";
tabHighlightEl.value.style.insetBlockEnd =
rect.bottom - parentRect.bottom + "px";
} else {
tabHighlightEl.value.style.insetInlineEnd = rect.right - parentRect.right + "px";
tabHighlightEl.value.style.insetInlineEnd =
rect.right - parentRect.right + "px";
}
} else {
if (isVertical) {
tabHighlightEl.value.style.insetBlockStart = rect.top - parentRect.top + "px";
tabHighlightEl.value.style.insetBlockStart =
rect.top - parentRect.top + "px";
}
}
tabHighlightEl.value.style.inlineSize = inlineSize + "px";

View file

@ -223,9 +223,9 @@ function setSwiperRef(swiper: SwiperType) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -82,9 +82,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -196,9 +196,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -437,9 +437,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -242,9 +242,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -180,9 +180,9 @@ function setSwiperRef(swiper: SwiperType) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -157,9 +157,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -141,9 +141,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -454,9 +454,7 @@ const mergeThreadInTimeline = computed(
const mergeRenotesInTimeline = computed(
defaultStore.makeGetterSetter("mergeRenotesInTimeline"),
);
const writingMode = computed(
defaultStore.makeGetterSetter("writingMode"),
);
const writingMode = computed(defaultStore.makeGetterSetter("writingMode"));
// This feature (along with injectPromo) is currently disabled
// function onChangeInjectFeaturedNote(v) {
@ -528,7 +526,7 @@ watch(
useEmojiCdn,
enableTimelineStreaming,
enablePullToRefresh,
pullToRefreshThreshold
pullToRefreshThreshold,
],
async () => {
await reloadAsk();

View file

@ -99,9 +99,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(tabs.indexOf(tab.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -310,9 +310,9 @@ function setSwiperRef(swiper) {
swiperRef = swiper;
syncSlide(timelineIndex(src.value));
const styles = getComputedStyle(swiper.el);
swiper.changeLanguageDirection(styles.direction as ("rtl" | "ltr"));
if (styles['writing-mode'].startsWith('vertical')) {
swiper.changeDirection('vertical');
swiper.changeLanguageDirection(styles.direction as "rtl" | "ltr");
if (styles["writing-mode"].startsWith("vertical")) {
swiper.changeDirection("vertical");
}
}

View file

@ -471,8 +471,13 @@ export const defaultStore = markRaw(
},
writingMode: {
where: "deviceAccount",
default: "horizontal-tb" as "horizontal-tb" | "vertical-rl" | "vertical-lr" | "vertical-rl-upright" | "vertical-lr-upright",
}
default: "horizontal-tb" as
| "horizontal-tb"
| "vertical-rl"
| "vertical-lr"
| "vertical-rl-upright"
| "vertical-lr-upright",
},
}),
);

View file

@ -394,7 +394,9 @@ async function startGroup(): void {
onMounted(() => {
if (!isDesktop.value) {
matchMedia(`(min-inline-size: ${DESKTOP_THRESHOLD - 1}px)`).onchange = (mql) => {
matchMedia(`(min-inline-size: ${DESKTOP_THRESHOLD - 1}px)`).onchange = (
mql,
) => {
if (mql.matches) isDesktop.value = true;
};
}