planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

View File

@@ -0,0 +1,114 @@
const React = require("react");
const renderer = require("react-test-renderer");
const ReactTopBar = require("../index");
test("ReactTopBar can show topbar", () => {
let count = 0;
const topbar = {
show() {
count++;
},
hide() {}
};
let root;
renderer.act(() => {
root = renderer.create(
React.createElement(ReactTopBar, { topbar: topbar })
);
});
renderer.act(() => {
root.unmount();
});
expect(count).toBe(1);
});
test("ReactTopBar can hide topbar", () => {
let count = 0;
const topbar = {
show() {},
hide() {
count++;
}
};
let root;
renderer.act(() => {
root = renderer.create(
React.createElement(ReactTopBar, { topbar: topbar })
);
});
renderer.act(() => {
root.unmount();
});
expect(count).toBe(1);
});
test("ReactTopBar can show/hide topbar", () => {
let count = 0;
const topbar = {
show() {
count++;
},
hide() {
count++;
}
};
let root;
renderer.act(() => {
root = renderer.create(
React.createElement(ReactTopBar, { topbar: topbar })
);
});
renderer.act(() => {
root.unmount();
});
expect(count).toBe(2);
});
test("ReactTopBar can show/hide topbar even with multiples call, but once", () => {
let count = 0;
const topbar = {
show() {
count++;
},
hide() {
count++;
}
};
let root;
renderer.act(() => {
root = renderer.create(
React.createElement(ReactTopBar, { topbar: topbar })
);
});
let root2;
renderer.act(() => {
root2 = renderer.create(
React.createElement(ReactTopBar, { topbar: topbar })
);
});
renderer.act(() => {
root.unmount();
});
renderer.act(() => {
root2.unmount();
});
expect(count).toBe(2);
});
test("ReactTopBar exposes topbar config function", () => {
expect(typeof ReactTopBar.config).toBe("function");
});

View File

@@ -0,0 +1,14 @@
/// <reference types="react" />
import * as React from "react";
export interface TopBarConfig {
barThickness?: number;
barColors?: any;
shadowBlur?: number;
shadowColor?: string;
}
export default class TopBarProgress extends React.Component {
static config(config: TopBarConfig): void;
}

View File

@@ -0,0 +1,47 @@
// @flow
var React = require("react");
// topbar require window, so here is an universal workaround
var topbar =
typeof window === "undefined"
? {
show: function() {},
hide: function() {},
config: function() {}
}
: require("topbar");
var semaphore /*: number*/ = 0;
/*::
type Props = {
topbar?: typeof topbar
};
*/
var getTopBar = function(props /*: Props*/) /*: typeof topbar*/ {
return props.topbar || topbar;
};
function TopBar(props /*: Props */) {
React.useEffect(function() {
if (semaphore === 0) {
getTopBar(props).show();
}
semaphore++;
return function() {
semaphore--;
if (semaphore === 0) {
getTopBar(props).hide();
}
};
}, []);
return null;
}
TopBar.config = topbar.config;
module.exports = TopBar;