forked from misskey-dev/misskey
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
258 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Directive } from 'vue'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
mounted(src) { | ||
const isTransparent = (color?: string | null): boolean => { | ||
if (!color) return false; | ||
if (color === 'transparent') return true; | ||
const [_r, _g, _b, alpha = null] = [...color.match(/\d+/g) ?? []]; | ||
return alpha === '0'; | ||
}; | ||
|
||
const getBgColor = (el: HTMLElement | null): string => { | ||
if (!el) return 'transparent'; | ||
const { backgroundColor } = window.getComputedStyle(el); | ||
if (backgroundColor && !isTransparent(backgroundColor)) { | ||
return backgroundColor; | ||
} else { | ||
return getBgColor(el.parentElement); | ||
} | ||
}; | ||
|
||
const parentBg = getBgColor(src.parentElement); | ||
|
||
const { backgroundColor: myBg } = window.getComputedStyle(src); | ||
|
||
if (parentBg === myBg) { | ||
src.style.backgroundColor = 'var(--bg)'; | ||
} else { | ||
src.style.backgroundColor = myBg; | ||
} | ||
}, | ||
} as Directive<HTMLElement>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import { Directive } from 'vue'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
mounted(src, binding, vn) { | ||
const getBgColor = (el: HTMLElement) => { | ||
const style = window.getComputedStyle(el); | ||
if (style.backgroundColor && !['rgba(0, 0, 0, 0)', 'rgba(0,0,0,0)', 'transparent'].includes(style.backgroundColor)) { | ||
return style.backgroundColor; | ||
mounted(src) { | ||
const isTransparent = (color?: string | null): boolean => { | ||
if (!color) return false; | ||
if (color === 'transparent') return true; | ||
const [_r, _g, _b, alpha = null] = [...color.match(/\d+/g) ?? []]; | ||
return alpha === '0'; | ||
}; | ||
|
||
const getBgColor = (el: HTMLElement | null): string => { | ||
if (!el) return 'transparent'; | ||
const { backgroundColor } = window.getComputedStyle(el); | ||
if (backgroundColor && !isTransparent(backgroundColor)) { | ||
return backgroundColor; | ||
} else { | ||
return el.parentElement ? getBgColor(el.parentElement) : 'transparent'; | ||
return getBgColor(el.parentElement); | ||
} | ||
}; | ||
|
||
const parentBg = getBgColor(src.parentElement); | ||
|
||
const myBg = window.getComputedStyle(src).backgroundColor; | ||
const { backgroundColor: myBg } = window.getComputedStyle(src); | ||
|
||
if (parentBg === myBg) { | ||
src.style.borderColor = 'var(--divider)'; | ||
} else { | ||
src.style.borderColor = myBg; | ||
} | ||
}, | ||
} as Directive; | ||
} as Directive<HTMLElement>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { Directive } from 'vue'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
beforeMount(src, binding, vn) { | ||
beforeMount(src) { | ||
src.style.opacity = '0'; | ||
src.style.transform = 'scale(0.9)'; | ||
// ページネーションと相性が悪いので | ||
//if (typeof binding.value === 'number') src.style.transitionDelay = `${binding.value * 30}ms`; | ||
src.classList.add('_zoom'); | ||
}, | ||
|
||
mounted(src, binding, vn) { | ||
mounted(src) { | ||
window.setTimeout(() => { | ||
src.style.opacity = '1'; | ||
src.style.transform = 'none'; | ||
}, 1); | ||
}, | ||
} as Directive; | ||
} as Directive<HTMLElement, number>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import { Directive } from 'vue'; | ||
import { makeHotkey } from '../scripts/hotkey'; | ||
import { Keymap, makeHotkey } from '../scripts/hotkey'; | ||
|
||
export default { | ||
mounted(el, binding) { | ||
el._hotkey_global = binding.modifiers.global === true; | ||
const map = new WeakMap<HTMLElement, () => void>(); | ||
|
||
el._keyHandler = makeHotkey(binding.value); | ||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
mounted(src, binding) { | ||
const global = binding.modifiers.global === true; | ||
const handler = makeHotkey(binding.value); | ||
|
||
if (el._hotkey_global) { | ||
document.addEventListener('keydown', el._keyHandler); | ||
if (global) { | ||
document.addEventListener('keydown', handler); | ||
map.set(src, () => document.removeEventListener('keydown', handler)); | ||
} else { | ||
el.addEventListener('keydown', el._keyHandler); | ||
src.addEventListener('keydown', handler); | ||
map.set(src, () => src.removeEventListener('keydown', handler)); | ||
} | ||
}, | ||
|
||
unmounted(el) { | ||
if (el._hotkey_global) { | ||
document.removeEventListener('keydown', el._keyHandler); | ||
} else { | ||
el.removeEventListener('keydown', el._keyHandler); | ||
unmounted(src) { | ||
const stopHandler = map.get(src); | ||
if (stopHandler) { | ||
stopHandler(); | ||
map.delete(src); | ||
} | ||
} | ||
} as Directive; | ||
}, | ||
} as Directive<HTMLElement, Keymap>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.