@learningpool/ui 1.14.0 → 1.15.0
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.
- package/components/stream/AppHub/AppHub.js +4 -0
- package/components/stream/AppHub/AppHubAdvertStyles.d.ts +13 -0
- package/components/stream/AppHub/AppHubAdvertStyles.js +10 -0
- package/components/stream/AppHub/AppHubBannerAdvert.d.ts +3 -0
- package/components/stream/AppHub/AppHubBannerAdvert.js +113 -0
- package/components/stream/AppHub/AppHubStyles.js +2 -2
- package/components/stream/AppHub/constants.d.ts +6 -0
- package/components/stream/AppHub/constants.js +7 -1
- package/components/stream/AppSwitcher/constants.js +2 -2
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ import AppHubCustom from './AppHubCustom';
|
|
|
27
27
|
import { AppHubPanel, AppHubTitle, AppHubHeader, AppHubRow } from './AppHubStyles';
|
|
28
28
|
import Grid from '@mui/material/Unstable_Grid2';
|
|
29
29
|
import { Constants } from './constants';
|
|
30
|
+
import { renderBannerAdvertRow } from './AppHubBannerAdvert';
|
|
30
31
|
var AppHub = function (props) {
|
|
31
32
|
var isPageLayout = props.isPageLayout, localization = props.localization, customLinkBgColor = props.customLinkBgColor, data = props.data;
|
|
32
33
|
var messages = __assign(__assign({}, defaultMessages), localization);
|
|
@@ -34,6 +35,9 @@ var AppHub = function (props) {
|
|
|
34
35
|
var _a, _b;
|
|
35
36
|
var type = rowData.type, items = rowData.items, title = rowData.title, addButton = rowData.addButton;
|
|
36
37
|
switch (type) {
|
|
38
|
+
case Constants.DataRowType.BannerAdvert: {
|
|
39
|
+
return (renderBannerAdvertRow(rowData, rowIndex));
|
|
40
|
+
}
|
|
37
41
|
case Constants.DataRowType.Product: {
|
|
38
42
|
return (_jsxs(AppHubRow, { children: [title && _jsx(AppHubHeader
|
|
39
43
|
// @ts-ignore
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledAdvertPaper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").PaperClasses> | undefined;
|
|
5
|
+
elevation?: number | undefined;
|
|
6
|
+
square?: boolean | undefined;
|
|
7
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
+
variant?: "outlined" | "elevation" | undefined;
|
|
9
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
11
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "square" | "elevation"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
12
|
+
export declare const StyledAdvertLink: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {}>;
|
|
13
|
+
export declare const StyledAdvertImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import { Paper } from '@mui/material';
|
|
7
|
+
export var StyledAdvertPaper = styled(Paper)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 138px;\n overflow: hidden;\n position: relative;\n box-shadow: 0 0 0 1px #ddd;\n border-radius: 10px;\n border: #ddd;\n transition: all 180ms ease;\n"], ["\n width: 100%;\n height: 138px;\n overflow: hidden;\n position: relative;\n box-shadow: 0 0 0 1px #ddd;\n border-radius: 10px;\n border: #ddd;\n transition: all 180ms ease;\n"])));
|
|
8
|
+
export var StyledAdvertLink = styled('a')(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: block;\n width: 100%;\n height: 100%;\n"], ["\n display: block;\n width: 100%;\n height: 100%;\n"])));
|
|
9
|
+
export var StyledAdvertImage = styled('img')(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n height: 100%;\n object-fit: cover;\n"], ["\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n height: 100%;\n object-fit: cover;\n"])));
|
|
10
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import { useState, useEffect } from 'react';
|
|
50
|
+
import { AppHubRow } from './AppHubStyles';
|
|
51
|
+
import Grid from '@mui/material/Unstable_Grid2';
|
|
52
|
+
import { StyledAdvertPaper, StyledAdvertLink, StyledAdvertImage } from './AppHubAdvertStyles';
|
|
53
|
+
var addUtmParams = function (baseUrl, source, medium, campaign) {
|
|
54
|
+
var url = new URL(baseUrl);
|
|
55
|
+
url.searchParams.append('utm_source,', source);
|
|
56
|
+
url.searchParams.append('utm_medium', medium);
|
|
57
|
+
url.searchParams.append('utm_campaign', campaign);
|
|
58
|
+
return url.toString();
|
|
59
|
+
};
|
|
60
|
+
var checkImageExists = function (url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var response, error_1;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
_a.trys.push([0, 2, , 3]);
|
|
66
|
+
return [4 /*yield*/, fetch(url, { method: 'HEAD' })];
|
|
67
|
+
case 1:
|
|
68
|
+
response = _a.sent();
|
|
69
|
+
return [2 /*return*/, response.ok];
|
|
70
|
+
case 2:
|
|
71
|
+
error_1 = _a.sent();
|
|
72
|
+
console.error('Error checking image:', error_1);
|
|
73
|
+
return [2 /*return*/, false];
|
|
74
|
+
case 3: return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
export var renderBannerAdvertRow = function (rowData, rowIndex) {
|
|
79
|
+
var items = rowData.items;
|
|
80
|
+
var _a = useState([]), validAdverts = _a[0], setValidAdverts = _a[1];
|
|
81
|
+
useEffect(function () {
|
|
82
|
+
var validateImages = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var validatedItems;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0: return [4 /*yield*/, Promise.all(items.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
+
var isValid;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
if (!item.imageUrl) return [3 /*break*/, 2];
|
|
92
|
+
return [4 /*yield*/, checkImageExists(item.imageUrl)];
|
|
93
|
+
case 1:
|
|
94
|
+
isValid = _a.sent();
|
|
95
|
+
return [2 /*return*/, isValid ? item : null];
|
|
96
|
+
case 2: return [2 /*return*/, null];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); }))];
|
|
100
|
+
case 1:
|
|
101
|
+
validatedItems = _a.sent();
|
|
102
|
+
setValidAdverts(validatedItems.filter(function (item) { return item !== null; }));
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); };
|
|
107
|
+
validateImages();
|
|
108
|
+
}, [items]);
|
|
109
|
+
if (validAdverts.length === 0) {
|
|
110
|
+
return null; // Don't render the row if no valid images
|
|
111
|
+
}
|
|
112
|
+
return (_jsx(AppHubRow, { children: _jsx(Grid, __assign({ container: true, spacing: 2 }, { children: validAdverts.map(function (item, index) { return (_jsx(Grid, __assign({ xs: 12 }, { children: _jsx(StyledAdvertPaper, __assign({ elevation: 0 }, { children: _jsx(StyledAdvertLink, __assign({ href: addUtmParams(item.url, 'stream-home', 'App-Hub-Banner-Advert', item.name), target: "_blank" }, { children: _jsx(StyledAdvertImage, { src: item.imageUrl, alt: item.altText }) })) })) }), index)); }) })) }, "row_".concat(rowIndex)));
|
|
113
|
+
};
|
|
@@ -5,8 +5,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { Paper, Box, Typography } from '../../../index';
|
|
7
7
|
export var AppHubPanel = styled('div')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 1rem;\n max-width: 1000px;\n"], ["\n padding: 1rem;\n max-width: 1000px;\n"])));
|
|
8
|
-
export var AppHubRow = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin:
|
|
9
|
-
export var AppHubTitle = styled(Typography)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: 2rem;\n font-weight: 700;\n line-height: 1.3;\n color: ", ";\n margin-bottom:
|
|
8
|
+
export var AppHubRow = styled(Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin: 2rem 0 0;\n"], ["\n margin: 2rem 0 0;\n"])));
|
|
9
|
+
export var AppHubTitle = styled(Typography)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: 2rem;\n font-weight: 700;\n line-height: 1.3;\n color: ", ";\n margin-bottom: 0.5rem;\n"], ["\n font-size: 2rem;\n font-weight: 700;\n line-height: 1.3;\n color: ", ";\n margin-bottom: 0.5rem;\n"])), function (props) { return props.theme.palette.text.primary; });
|
|
10
10
|
export var AppHubHeader = styled(Typography)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 1rem;\n font-weight: 500;\n color: ", ";\n margin: 0 0 1rem;\n"], ["\n font-size: 1rem;\n font-weight: 500;\n color: ", ";\n margin: 0 0 1rem;\n"])), function (props) { return props.theme.palette.text.secondary; });
|
|
11
11
|
export var StyledPaper = styled(Paper)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n width: 100%;\n height: 100%;\n background: #fff;\n"], ["\n display: flex;\n flex-direction: row;\n width: 100%;\n height: 100%;\n background: #fff;\n"])));
|
|
12
12
|
export var StyledBox = styled(Box)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n"], ["\n display: flex;\n flex-direction: column;\n"])));
|
|
@@ -3,6 +3,7 @@ export declare const Constants: Readonly<{
|
|
|
3
3
|
DataRowType: {
|
|
4
4
|
Product: string;
|
|
5
5
|
CustomLink: string;
|
|
6
|
+
BannerAdvert: string;
|
|
6
7
|
};
|
|
7
8
|
AssetsUrl: "https://uuicdn.learningpool.com/";
|
|
8
9
|
AddButtonOrder: {
|
|
@@ -83,3 +84,8 @@ export declare const hubSupportItems: {
|
|
|
83
84
|
url: string;
|
|
84
85
|
icon: JSX.Element;
|
|
85
86
|
}[];
|
|
87
|
+
export declare const hubBannerAdverts: {
|
|
88
|
+
name: string;
|
|
89
|
+
imageUrl: string;
|
|
90
|
+
url: string;
|
|
91
|
+
}[];
|
|
@@ -3,7 +3,8 @@ import HomeIcon from '@mui/icons-material/Home';
|
|
|
3
3
|
export var Constants = Object.freeze({
|
|
4
4
|
DataRowType: {
|
|
5
5
|
Product: 'product',
|
|
6
|
-
CustomLink: 'custom-link'
|
|
6
|
+
CustomLink: 'custom-link',
|
|
7
|
+
BannerAdvert: 'banner-advert'
|
|
7
8
|
},
|
|
8
9
|
AssetsUrl: 'https://uuicdn.learningpool.com/',
|
|
9
10
|
AddButtonOrder: {
|
|
@@ -55,3 +56,8 @@ export var hubCustomLinks = [
|
|
|
55
56
|
export var hubSupportItems = [
|
|
56
57
|
{ name: 'Contact us', url: 'https://learningpool.com', icon: _jsx(HomeIcon, {}) }
|
|
57
58
|
];
|
|
59
|
+
export var hubBannerAdverts = [
|
|
60
|
+
{ name: 'Banner Advert', imageUrl: 'https://uuicdn.learningpool.com/promotionalcampaigns/banner/latest/1000x138.png', url: 'https://learningpool.com' },
|
|
61
|
+
{ name: 'Another Banner Advert no image', imageUrl: '3', url: 'https://learningpool.com' },
|
|
62
|
+
{ name: 'Another Banner Advert', imageUrl: 'https://uuicdn.learningpool.com/promotionalcampaigns/banner/latest/1000x138.png', url: 'https://learningpool.com' }
|
|
63
|
+
];
|
|
@@ -52,8 +52,8 @@ export var promotionalContent = [
|
|
|
52
52
|
{
|
|
53
53
|
id: 1,
|
|
54
54
|
name: 'AIC campaign',
|
|
55
|
-
appSwitcherImageUrl: 'https://
|
|
56
|
-
hubImageUrl: '',
|
|
55
|
+
appSwitcherImageUrl: 'https://uuicdn.learningpool.com/promotionalcampaigns/appswitcheradvert/latest/300x150.png',
|
|
56
|
+
hubImageUrl: 'https://uuicdn.learningpool.com/promotionalcampaigns/banner/latest/1000x138.png',
|
|
57
57
|
altText: 'AIC',
|
|
58
58
|
basePromoUrl: 'https://aic.lp-home-web-sever.js.com',
|
|
59
59
|
isActive: true
|