@anas_hameed/edly-saas-widget 0.2.46 → 0.2.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.DiscussionSidebarWidget = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
/**
|
|
9
|
-
* Closes the discussion/notifications sidebar by default on course pages.
|
|
10
|
-
* Works for both old sidebar (data-testid="sidebar-DISCUSSIONS") and
|
|
11
|
-
* new sidebar (data-testid="sidebar-DISCUSSIONS_NOTIFICATIONS").
|
|
12
|
-
* Renders nothing — uses MutationObserver to click the trigger once on mount.
|
|
13
|
-
*/
|
|
14
8
|
const DiscussionSidebarWidget = () => {
|
|
15
9
|
(0, _react.useEffect)(() => {
|
|
16
10
|
const isCoursePage = /\/learning\/course\//.test(window.location.pathname);
|
|
@@ -18,19 +12,8 @@ const DiscussionSidebarWidget = () => {
|
|
|
18
12
|
return undefined;
|
|
19
13
|
}
|
|
20
14
|
const closeSidebar = () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (newSidebar && !newSidebar.classList.contains('d-none')) {
|
|
24
|
-
const triggerBtn = document.querySelector('button[aria-label="Show sidebar tray"]');
|
|
25
|
-
if (triggerBtn) {
|
|
26
|
-
triggerBtn.click();
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// old sidebar
|
|
32
|
-
const oldSidebar = document.querySelector('[data-testid="sidebar-DISCUSSIONS"]');
|
|
33
|
-
if (oldSidebar && !oldSidebar.classList.contains('d-none')) {
|
|
15
|
+
const sidebar = document.querySelector('[data-testid="sidebar-DISCUSSIONS"]');
|
|
16
|
+
if (sidebar && !sidebar.classList.contains('d-none')) {
|
|
34
17
|
window.postMessage({
|
|
35
18
|
type: 'learning.events.sidebar.close'
|
|
36
19
|
}, '*');
|
|
@@ -38,8 +21,6 @@ const DiscussionSidebarWidget = () => {
|
|
|
38
21
|
}
|
|
39
22
|
return false;
|
|
40
23
|
};
|
|
41
|
-
|
|
42
|
-
// Try immediately in case sidebar already rendered
|
|
43
24
|
if (closeSidebar()) {
|
|
44
25
|
return undefined;
|
|
45
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","DiscussionSidebarWidget","useEffect","isCoursePage","test","window","location","pathname","undefined","closeSidebar","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","DiscussionSidebarWidget","useEffect","isCoursePage","test","window","location","pathname","undefined","closeSidebar","sidebar","document","querySelector","classList","contains","postMessage","type","observer","MutationObserver","disconnect","observe","body","childList","subtree","exports"],"sources":["../../src/DiscussionSidebarWidget/index.jsx"],"sourcesContent":["import { useEffect } from 'react';\n\nconst DiscussionSidebarWidget = () => {\n useEffect(() => {\n const isCoursePage = /\\/learning\\/course\\//.test(window.location.pathname);\n if (!isCoursePage) { return undefined; }\n\n const closeSidebar = () => {\n const sidebar = document.querySelector('[data-testid=\"sidebar-DISCUSSIONS\"]');\n if (sidebar && !sidebar.classList.contains('d-none')) {\n window.postMessage({ type: 'learning.events.sidebar.close' }, '*');\n return true;\n }\n return false;\n };\n\n if (closeSidebar()) { return undefined; }\n\n const observer = new MutationObserver(() => {\n if (closeSidebar()) {\n observer.disconnect();\n }\n });\n\n observer.observe(document.body, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n return null;\n};\n\nexport { DiscussionSidebarWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACpC,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,YAAY,GAAG,sBAAsB,CAACC,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC;IAC1E,IAAI,CAACJ,YAAY,EAAE;MAAE,OAAOK,SAAS;IAAE;IAEvC,MAAMC,YAAY,GAAGA,CAAA,KAAM;MACzB,MAAMC,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAC,qCAAqC,CAAC;MAC7E,IAAIF,OAAO,IAAI,CAACA,OAAO,CAACG,SAAS,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACpDT,MAAM,CAACU,WAAW,CAAC;UAAEC,IAAI,EAAE;QAAgC,CAAC,EAAE,GAAG,CAAC;QAClE,OAAO,IAAI;MACb;MACA,OAAO,KAAK;IACd,CAAC;IAED,IAAIP,YAAY,CAAC,CAAC,EAAE;MAAE,OAAOD,SAAS;IAAE;IAExC,MAAMS,QAAQ,GAAG,IAAIC,gBAAgB,CAAC,MAAM;MAC1C,IAAIT,YAAY,CAAC,CAAC,EAAE;QAClBQ,QAAQ,CAACE,UAAU,CAAC,CAAC;MACvB;IACF,CAAC,CAAC;IAEFF,QAAQ,CAACG,OAAO,CAACT,QAAQ,CAACU,IAAI,EAAE;MAAEC,SAAS,EAAE,IAAI;MAAEC,OAAO,EAAE;IAAK,CAAC,CAAC;IACnE,OAAO,MAAMN,QAAQ,CAACE,UAAU,CAAC,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,IAAI;AACb,CAAC;AAACK,OAAA,CAAAvB,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|