mirror of
https://github.com/flarum/framework.git
synced 2025-02-07 02:00:45 +08:00
fix: regression in typings
This commit is contained in:
parent
d818e83235
commit
1f3afca482
7
framework/core/js/src/@types/global.d.ts
vendored
7
framework/core/js/src/@types/global.d.ts
vendored
|
@ -112,6 +112,13 @@ interface FlarumObject {
|
|||
|
||||
declare const flarum: FlarumObject;
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
* Whether we are in testing mode or not.
|
||||
*/
|
||||
testing?: boolean;
|
||||
}
|
||||
|
||||
// Extend JQuery with our custom functions, defined with $.fn
|
||||
interface JQuery {
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class Avatar<CustomAttrs extends IAvatarAttrs = IAvatarAttrs> ext
|
|||
}
|
||||
|
||||
content = username.charAt(0).toUpperCase();
|
||||
attrs.style = !process.env.testing && { '--avatar-bg': user.color() };
|
||||
attrs.style = !window.testing && { '--avatar-bg': user.color() };
|
||||
}
|
||||
|
||||
return <span {...attrs}>{content}</span>;
|
||||
|
|
|
@ -34,7 +34,7 @@ export default class Badge<CustomAttrs extends IBadgeAttrs = IBadgeAttrs> extend
|
|||
|
||||
const newStyle = { ...style };
|
||||
|
||||
if (!process.env.testing) {
|
||||
if (!window.testing) {
|
||||
newStyle['--badge-bg'] = color;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class ModalManager extends Component<IModalManagerAttrs> {
|
|||
data-modal-number={i}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
style={!process.env.testing && { '--modal-number': i }}
|
||||
style={!window.testing && { '--modal-number': i }}
|
||||
aria-hidden={this.attrs.state.modal !== modal && 'true'}
|
||||
>
|
||||
{!!Tag && [
|
||||
|
@ -66,7 +66,7 @@ export default class ModalManager extends Component<IModalManagerAttrs> {
|
|||
className="Modal-backdrop backdrop"
|
||||
ontransitionend={this.onBackdropTransitionEnd.bind(this)}
|
||||
data-showing={!!this.attrs.state.modalList.length || this.attrs.state.loadingModal}
|
||||
style={!process.env.testing && { '--modal-count': this.attrs.state.modalList.length + Number(this.attrs.state.loadingModal) }}
|
||||
style={!window.testing && { '--modal-count': this.attrs.state.modalList.length + Number(this.attrs.state.loadingModal) }}
|
||||
>
|
||||
{this.attrs.state.loadingModal && <LoadingIndicator />}
|
||||
</div>
|
||||
|
|
|
@ -30,7 +30,7 @@ export default class UserCard extends Component {
|
|||
const color = user.color();
|
||||
|
||||
return (
|
||||
<div className={classList('UserCard', this.attrs.className)} style={color && !process.env.testing && { '--usercard-bg': color }}>
|
||||
<div className={classList('UserCard', this.attrs.className)} style={color && !window.testing && { '--usercard-bg': color }}>
|
||||
<div className="darkenBackground">
|
||||
<div className="container">
|
||||
<div className="UserCard-profile">{this.profileItems().toArray()}</div>
|
||||
|
|
|
@ -12,8 +12,6 @@ import jsdom from 'jsdom';
|
|||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
process.env.testing = true;
|
||||
|
||||
const dom = new jsdom.JSDOM('', {
|
||||
pretendToBeVisual: false,
|
||||
});
|
||||
|
@ -26,6 +24,7 @@ global.requestAnimationFrame = (callback) => callback();
|
|||
|
||||
// Some other needed pollyfills.
|
||||
window.$ = jquery;
|
||||
window.testing = true;
|
||||
window.m = m;
|
||||
window.$.fn.tooltip = () => {};
|
||||
window.matchMedia = () => ({
|
||||
|
|
Loading…
Reference in New Issue
Block a user