refactor
This commit is contained in:
parent
b186c67767
commit
5e3d8fc9b8
|
|
@ -3,6 +3,8 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: (可能な部分を)sharedに抽出して frontend と共通化
|
||||||
|
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import lightTheme from '@@/themes/_light.json5';
|
import lightTheme from '@@/themes/_light.json5';
|
||||||
import darkTheme from '@@/themes/_dark.json5';
|
import darkTheme from '@@/themes/_dark.json5';
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: (可能な部分を)sharedに抽出して frontend-embed と共通化
|
||||||
|
|
||||||
import { ref, nextTick } from 'vue';
|
import { ref, nextTick } from 'vue';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import lightTheme from '@@/themes/_light.json5';
|
import lightTheme from '@@/themes/_light.json5';
|
||||||
|
|
@ -166,8 +168,12 @@ export function compile(theme: Theme): Record<string, string> {
|
||||||
return getColor(theme.props[val]);
|
return getColor(theme.props[val]);
|
||||||
} else if (val[0] === ':') { // func
|
} else if (val[0] === ':') { // func
|
||||||
const parts = val.split('<');
|
const parts = val.split('<');
|
||||||
const func = parts.shift().substring(1);
|
const funcTxt = parts.shift();
|
||||||
const arg = parseFloat(parts.shift());
|
const argTxt = parts.shift();
|
||||||
|
|
||||||
|
if (funcTxt && argTxt) {
|
||||||
|
const func = funcTxt.substring(1);
|
||||||
|
const arg = parseFloat(argTxt);
|
||||||
const color = getColor(parts.join('<'));
|
const color = getColor(parts.join('<'));
|
||||||
|
|
||||||
switch (func) {
|
switch (func) {
|
||||||
|
|
@ -178,6 +184,7 @@ export function compile(theme: Theme): Record<string, string> {
|
||||||
case 'saturate': return color.saturate(arg);
|
case 'saturate': return color.saturate(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// other case
|
// other case
|
||||||
return tinycolor(val);
|
return tinycolor(val);
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||||
left = rect.left + window.scrollX + (props.anchorElement.offsetWidth / 2);
|
left = rect.left + window.scrollX + (props.anchorElement.offsetWidth / 2);
|
||||||
top = (rect.top + window.scrollY - contentHeight) - props.innerMargin;
|
top = (rect.top + window.scrollY - contentHeight) - props.innerMargin;
|
||||||
} else {
|
} else {
|
||||||
left = props.x;
|
left = props.x!;
|
||||||
top = (props.y - contentHeight) - props.innerMargin;
|
top = (props.y! - contentHeight) - props.innerMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= (el.offsetWidth / 2);
|
left -= (el.offsetWidth / 2);
|
||||||
|
|
@ -54,8 +54,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||||
left = rect.left + window.scrollX + (props.anchorElement.offsetWidth / 2);
|
left = rect.left + window.scrollX + (props.anchorElement.offsetWidth / 2);
|
||||||
top = (rect.top + window.scrollY + props.anchorElement.offsetHeight) + props.innerMargin;
|
top = (rect.top + window.scrollY + props.anchorElement.offsetHeight) + props.innerMargin;
|
||||||
} else {
|
} else {
|
||||||
left = props.x;
|
left = props.x!;
|
||||||
top = (props.y) + props.innerMargin;
|
top = (props.y!) + props.innerMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= (el.offsetWidth / 2);
|
left -= (el.offsetWidth / 2);
|
||||||
|
|
@ -79,8 +79,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||||
left = (rect.left + window.scrollX - contentWidth) - props.innerMargin;
|
left = (rect.left + window.scrollX - contentWidth) - props.innerMargin;
|
||||||
top = rect.top + window.scrollY + (props.anchorElement.offsetHeight / 2);
|
top = rect.top + window.scrollY + (props.anchorElement.offsetHeight / 2);
|
||||||
} else {
|
} else {
|
||||||
left = (props.x - contentWidth) - props.innerMargin;
|
left = (props.x! - contentWidth) - props.innerMargin;
|
||||||
top = props.y;
|
top = props.y!;
|
||||||
}
|
}
|
||||||
|
|
||||||
top -= (el.offsetHeight / 2);
|
top -= (el.offsetHeight / 2);
|
||||||
|
|
@ -97,8 +97,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||||
};
|
};
|
||||||
|
|
||||||
const calcPosWhenRight = () => {
|
const calcPosWhenRight = () => {
|
||||||
let left: number;
|
let left = 0; // TSを黙らすためとりあえず初期値を0に
|
||||||
let top: number;
|
let top = 0; // TSを黙らすためとりあえず初期値を0に
|
||||||
|
|
||||||
if (props.anchorElement) {
|
if (props.anchorElement) {
|
||||||
left = (rect.left + props.anchorElement.offsetWidth + window.scrollX) + props.innerMargin;
|
left = (rect.left + props.anchorElement.offsetWidth + window.scrollX) + props.innerMargin;
|
||||||
|
|
@ -113,8 +113,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||||
top -= (el.offsetHeight / 2);
|
top -= (el.offsetHeight / 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
left = props.x + props.innerMargin;
|
left = props.x! + props.innerMargin;
|
||||||
top = props.y;
|
top = props.y!;
|
||||||
top -= (el.offsetHeight / 2);
|
top -= (el.offsetHeight / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue