@ably/ui 10.1.1 → 10.2.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/core/DropdownMenu.jsx +0 -4
- package/core/Flash.jsx +132 -57
- package/core/Logo.jsx +28 -113
- package/core/Meganav.jsx +166 -174
- package/core/Notice/component.js +1 -1
- package/core/Notice.jsx +133 -58
- package/core/images/ably-logo.png +0 -0
- package/package.json +1 -1
- package/src/core/DropdownMenu/component.jsx +0 -2
- package/src/core/Flash/component.jsx +42 -14
- package/src/core/Logo/component.html.erb +2 -27
- package/src/core/Logo/component.jsx +7 -40
- package/src/core/Logo/component.rb +15 -6
- package/src/core/Meganav/component.html.erb +1 -1
- package/src/core/Meganav/component.jsx +1 -1
- package/src/core/Meganav/component.rb +1 -0
- package/src/core/core.rb +4 -0
- package/src/core/images/ably-logo.png +0 -0
package/core/Notice.jsx
CHANGED
|
@@ -92,22 +92,55 @@ var ConnectStateWrapper = function ConnectStateWrapper(Component, selectors) {
|
|
|
92
92
|
|
|
93
93
|
/***/ }),
|
|
94
94
|
|
|
95
|
-
/***/
|
|
95
|
+
/***/ 8696:
|
|
96
96
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
|
|
99
|
+
// EXPORTS
|
|
100
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
101
|
+
"FLASH_DATA_ID": () => (/* binding */ FLASH_DATA_ID)
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// UNUSED EXPORTS: Flashes, default, reducerFlashes
|
|
105
|
+
|
|
106
|
+
// EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react"}
|
|
107
|
+
var external_commonjs_react_commonjs2_react_ = __webpack_require__(9281);
|
|
108
|
+
var external_commonjs_react_commonjs2_react_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_react_commonjs2_react_);
|
|
109
|
+
// EXTERNAL MODULE: external {"commonjs":"dompurify","commonjs2":"dompurify"}
|
|
110
|
+
var external_commonjs_dompurify_commonjs2_dompurify_ = __webpack_require__(6357);
|
|
111
|
+
var external_commonjs_dompurify_commonjs2_dompurify_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_dompurify_commonjs2_dompurify_);
|
|
112
|
+
// EXTERNAL MODULE: external {"commonjs":"prop-types","commonjs2":"prop-types"}
|
|
113
|
+
var external_commonjs_prop_types_commonjs2_prop_types_ = __webpack_require__(3474);
|
|
114
|
+
var external_commonjs_prop_types_commonjs2_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_prop_types_commonjs2_prop_types_);
|
|
115
|
+
;// CONCATENATED MODULE: ./node_modules/nanoid/non-secure/index.js
|
|
116
|
+
let urlAlphabet =
|
|
117
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
118
|
+
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
119
|
+
return (size = defaultSize) => {
|
|
120
|
+
let id = ''
|
|
121
|
+
let i = size
|
|
122
|
+
while (i--) {
|
|
123
|
+
id += alphabet[(Math.random() * alphabet.length) | 0]
|
|
124
|
+
}
|
|
125
|
+
return id
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let nanoid = (size = 21) => {
|
|
129
|
+
let id = ''
|
|
130
|
+
let i = size
|
|
131
|
+
while (i--) {
|
|
132
|
+
id += urlAlphabet[(Math.random() * 64) | 0]
|
|
133
|
+
}
|
|
134
|
+
return id
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// EXTERNAL MODULE: ./src/core/remote-data-store.js
|
|
138
|
+
var remote_data_store = __webpack_require__(3511);
|
|
139
|
+
// EXTERNAL MODULE: ./src/core/ConnectStateWrapper/component.jsx
|
|
140
|
+
var component = __webpack_require__(9787);
|
|
141
|
+
// EXTERNAL MODULE: ./src/core/Icon/component.jsx
|
|
142
|
+
var Icon_component = __webpack_require__(9008);
|
|
143
|
+
;// CONCATENATED MODULE: ./src/core/Flash/component.jsx
|
|
111
144
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
112
145
|
|
|
113
146
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -142,6 +175,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
142
175
|
|
|
143
176
|
|
|
144
177
|
|
|
178
|
+
|
|
145
179
|
var REDUCER_KEY = "flashes";
|
|
146
180
|
var FLASH_DATA_ID = "ui-flashes";
|
|
147
181
|
var initialState = {
|
|
@@ -171,8 +205,8 @@ var selectFlashes = function selectFlashes(store) {
|
|
|
171
205
|
};
|
|
172
206
|
|
|
173
207
|
var FlashT = {
|
|
174
|
-
type:
|
|
175
|
-
content: (
|
|
208
|
+
type: external_commonjs_prop_types_commonjs2_prop_types_default().oneOf(["error", "success", "notice", "info", "alert"]),
|
|
209
|
+
content: (external_commonjs_prop_types_commonjs2_prop_types_default()).string
|
|
176
210
|
};
|
|
177
211
|
var FLASH_BG_COLOR = {
|
|
178
212
|
error: "bg-gui-error",
|
|
@@ -191,48 +225,60 @@ var FLASH_TEXT_COLOR = {
|
|
|
191
225
|
var AUTO_HIDE = ["success", "info", "notice"];
|
|
192
226
|
var AUTO_HIDE_TIME = 8000;
|
|
193
227
|
|
|
228
|
+
var useAutoHide = function useAutoHide(type, closeFlash) {
|
|
229
|
+
var timeoutId = (0,external_commonjs_react_commonjs2_react_.useRef)(null);
|
|
230
|
+
(0,external_commonjs_react_commonjs2_react_.useEffect)(function () {
|
|
231
|
+
if (AUTO_HIDE.includes(type)) {
|
|
232
|
+
timeoutId.current = setTimeout(function () {
|
|
233
|
+
closeFlash();
|
|
234
|
+
}, AUTO_HIDE_TIME);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return function () {
|
|
238
|
+
if (timeoutId.current) {
|
|
239
|
+
clearTimeout(timeoutId.current);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}, []);
|
|
243
|
+
};
|
|
244
|
+
|
|
194
245
|
var Flash = function Flash(_ref) {
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
246
|
+
var id = _ref.id,
|
|
247
|
+
type = _ref.type,
|
|
248
|
+
content = _ref.content,
|
|
249
|
+
removeFlash = _ref.removeFlash;
|
|
250
|
+
var ref = (0,external_commonjs_react_commonjs2_react_.useRef)(null);
|
|
198
251
|
|
|
199
|
-
var _useState = (0,
|
|
252
|
+
var _useState = (0,external_commonjs_react_commonjs2_react_.useState)(false),
|
|
200
253
|
_useState2 = _slicedToArray(_useState, 2),
|
|
201
254
|
closed = _useState2[0],
|
|
202
255
|
setClosed = _useState2[1];
|
|
203
256
|
|
|
204
|
-
var _useState3 = (0,
|
|
257
|
+
var _useState3 = (0,external_commonjs_react_commonjs2_react_.useState)(0),
|
|
205
258
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
206
259
|
flashHeight = _useState4[0],
|
|
207
260
|
setFlashHeight = _useState4[1];
|
|
208
261
|
|
|
209
|
-
var _useState5 = (0,
|
|
262
|
+
var _useState5 = (0,external_commonjs_react_commonjs2_react_.useState)(false),
|
|
210
263
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
211
264
|
triggerEntryAnimation = _useState6[0],
|
|
212
265
|
setTriggerEntryAnimation = _useState6[1];
|
|
213
266
|
|
|
214
|
-
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
215
|
-
return setTriggerEntryAnimation(true);
|
|
216
|
-
}, []);
|
|
217
|
-
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
218
|
-
if (AUTO_HIDE.includes(type)) {
|
|
219
|
-
setTimeout(function () {
|
|
220
|
-
// closeFlash is idempotent, we can call it even if the flash has been already closed
|
|
221
|
-
closeFlash();
|
|
222
|
-
}, AUTO_HIDE_TIME);
|
|
223
|
-
}
|
|
224
|
-
}, [closed]);
|
|
225
|
-
|
|
226
267
|
var closeFlash = function closeFlash() {
|
|
227
268
|
if (ref.current) {
|
|
228
269
|
setFlashHeight(ref.current.getBoundingClientRect().height);
|
|
229
270
|
}
|
|
230
271
|
|
|
272
|
+
setClosed(true);
|
|
231
273
|
setTimeout(function () {
|
|
232
|
-
|
|
233
|
-
},
|
|
274
|
+
removeFlash(id);
|
|
275
|
+
}, 100);
|
|
234
276
|
};
|
|
235
277
|
|
|
278
|
+
(0,external_commonjs_react_commonjs2_react_.useEffect)(function () {
|
|
279
|
+
return setTriggerEntryAnimation(true);
|
|
280
|
+
}, []);
|
|
281
|
+
useAutoHide(type, closeFlash);
|
|
236
282
|
var animateEntry = triggerEntryAnimation && !closed;
|
|
237
283
|
var style;
|
|
238
284
|
|
|
@@ -250,7 +296,7 @@ var Flash = function Flash(_ref) {
|
|
|
250
296
|
style = {};
|
|
251
297
|
}
|
|
252
298
|
|
|
253
|
-
var safeContent =
|
|
299
|
+
var safeContent = external_commonjs_dompurify_commonjs2_dompurify_default().sanitize(content, {
|
|
254
300
|
ALLOWED_TAGS: ["a"],
|
|
255
301
|
ALLOWED_ATTR: ["href", "data-method", "rel"]
|
|
256
302
|
});
|
|
@@ -266,28 +312,28 @@ var Flash = function Flash(_ref) {
|
|
|
266
312
|
error: "text-white",
|
|
267
313
|
alert: "text-white"
|
|
268
314
|
};
|
|
269
|
-
return /*#__PURE__*/
|
|
315
|
+
return /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement("div", {
|
|
270
316
|
className: "ui-flash-message ui-grid-px ".concat(animateEntry ? "ui-flash-message-enter" : ""),
|
|
271
317
|
style: style,
|
|
272
318
|
ref: ref,
|
|
273
319
|
"data-id": "ui-flash"
|
|
274
|
-
}, /*#__PURE__*/
|
|
320
|
+
}, /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement("div", {
|
|
275
321
|
className: "".concat(FLASH_BG_COLOR[type], " p-32 flex align-center rounded shadow-container-subtle")
|
|
276
|
-
}, withIcons[type] && /*#__PURE__*/
|
|
322
|
+
}, withIcons[type] && /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement(Icon_component.default, {
|
|
277
323
|
name: withIcons[type],
|
|
278
324
|
color: iconColor[type],
|
|
279
325
|
size: "1.5rem",
|
|
280
326
|
additionalCSS: "mr-16 self-baseline"
|
|
281
|
-
}), /*#__PURE__*/
|
|
327
|
+
}), /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement("p", {
|
|
282
328
|
className: "ui-flash-text ".concat(FLASH_TEXT_COLOR[type]),
|
|
283
329
|
dangerouslySetInnerHTML: {
|
|
284
330
|
__html: safeContent
|
|
285
331
|
}
|
|
286
|
-
}), /*#__PURE__*/
|
|
332
|
+
}), /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement("button", {
|
|
287
333
|
type: "button",
|
|
288
334
|
className: "p-0 ml-auto self-start focus:outline-none",
|
|
289
335
|
onClick: closeFlash
|
|
290
|
-
}, /*#__PURE__*/
|
|
336
|
+
}, /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement(Icon_component.default, {
|
|
291
337
|
name: "icon-gui-close",
|
|
292
338
|
color: iconColor[type],
|
|
293
339
|
size: "1.5rem",
|
|
@@ -299,26 +345,55 @@ Flash.propTypes = _objectSpread({}, FlashT);
|
|
|
299
345
|
|
|
300
346
|
var Flashes = function Flashes(_ref2) {
|
|
301
347
|
var flashes = _ref2.flashes;
|
|
302
|
-
|
|
303
|
-
|
|
348
|
+
|
|
349
|
+
var _useState7 = (0,external_commonjs_react_commonjs2_react_.useState)([]),
|
|
350
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
351
|
+
flashesWithIds = _useState8[0],
|
|
352
|
+
setFlashesWithIds = _useState8[1];
|
|
353
|
+
|
|
354
|
+
var removeFlash = function removeFlash(flashId) {
|
|
355
|
+
return setFlashesWithIds(function (items) {
|
|
356
|
+
return items.filter(function (item) {
|
|
357
|
+
return item.id !== flashId;
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
(0,external_commonjs_react_commonjs2_react_.useEffect)(function () {
|
|
363
|
+
setFlashesWithIds(function (state) {
|
|
364
|
+
return [].concat(_toConsumableArray(state), _toConsumableArray(((flashes === null || flashes === void 0 ? void 0 : flashes.items) || []).map(function (flash) {
|
|
365
|
+
return _objectSpread(_objectSpread({}, flash), {}, {
|
|
366
|
+
id: nanoid(),
|
|
367
|
+
removed: false
|
|
368
|
+
});
|
|
369
|
+
})));
|
|
370
|
+
});
|
|
371
|
+
}, [flashes]);
|
|
372
|
+
console.log({
|
|
373
|
+
flashesWithIds: flashesWithIds
|
|
374
|
+
});
|
|
375
|
+
return /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement("div", {
|
|
304
376
|
className: "ui-flash",
|
|
305
377
|
"data-id": FLASH_DATA_ID
|
|
306
|
-
},
|
|
307
|
-
return
|
|
308
|
-
|
|
378
|
+
}, flashesWithIds.filter(function (item) {
|
|
379
|
+
return !item.removed;
|
|
380
|
+
}).map(function (flash) {
|
|
381
|
+
return /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement(Flash, _extends({
|
|
382
|
+
removeFlash: removeFlash,
|
|
383
|
+
key: flash.id
|
|
309
384
|
}, flash));
|
|
310
385
|
}));
|
|
311
386
|
};
|
|
312
387
|
|
|
313
388
|
Flashes.propTypes = {
|
|
314
|
-
flashes:
|
|
315
|
-
items:
|
|
389
|
+
flashes: external_commonjs_prop_types_commonjs2_prop_types_default().shape({
|
|
390
|
+
items: external_commonjs_prop_types_commonjs2_prop_types_default().arrayOf(external_commonjs_prop_types_commonjs2_prop_types_default().shape(FlashT))
|
|
316
391
|
})
|
|
317
392
|
};
|
|
318
393
|
|
|
319
394
|
var BackendFlashes = function BackendFlashes(_ref3) {
|
|
320
395
|
var flashes = _ref3.flashes;
|
|
321
|
-
(0,
|
|
396
|
+
(0,external_commonjs_react_commonjs2_react_.useEffect)(function () {
|
|
322
397
|
var transformedFlashes = flashes.map(function (flash) {
|
|
323
398
|
var _flash = _slicedToArray(flash, 2),
|
|
324
399
|
type = _flash[0],
|
|
@@ -331,24 +406,24 @@ var BackendFlashes = function BackendFlashes(_ref3) {
|
|
|
331
406
|
}) || [];
|
|
332
407
|
|
|
333
408
|
if (transformedFlashes.length > 0) {
|
|
334
|
-
var store = (0,
|
|
409
|
+
var store = (0,remote_data_store/* getRemoteDataStore */.cO)();
|
|
335
410
|
store.dispatch({
|
|
336
411
|
type: "flash/push",
|
|
337
412
|
payload: transformedFlashes
|
|
338
413
|
});
|
|
339
414
|
}
|
|
340
415
|
}, []);
|
|
341
|
-
var WrappedFlashes = (0,
|
|
416
|
+
var WrappedFlashes = (0,component.default)(Flashes, {
|
|
342
417
|
flashes: selectFlashes
|
|
343
418
|
});
|
|
344
|
-
return /*#__PURE__*/
|
|
419
|
+
return /*#__PURE__*/external_commonjs_react_commonjs2_react_default().createElement(WrappedFlashes, null);
|
|
345
420
|
};
|
|
346
421
|
|
|
347
422
|
BackendFlashes.propTypes = {
|
|
348
|
-
flashes:
|
|
423
|
+
flashes: external_commonjs_prop_types_commonjs2_prop_types_default().arrayOf(external_commonjs_prop_types_commonjs2_prop_types_default().arrayOf((external_commonjs_prop_types_commonjs2_prop_types_default()).string))
|
|
349
424
|
};
|
|
350
425
|
|
|
351
|
-
/*
|
|
426
|
+
/* harmony default export */ const Flash_component = ((/* unused pure expression or super */ null && (BackendFlashes)));
|
|
352
427
|
|
|
353
428
|
/***/ }),
|
|
354
429
|
|
|
@@ -599,8 +674,8 @@ var external_commonjs_lodash_throttle_commonjs2_lodash_throttle_ = __webpack_req
|
|
|
599
674
|
var external_commonjs_lodash_throttle_commonjs2_lodash_throttle_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_lodash_throttle_commonjs2_lodash_throttle_);
|
|
600
675
|
// EXTERNAL MODULE: ./src/core/dom-query.js
|
|
601
676
|
var dom_query = __webpack_require__(9581);
|
|
602
|
-
// EXTERNAL MODULE: ./src/core/Flash/component.jsx
|
|
603
|
-
var component = __webpack_require__(
|
|
677
|
+
// EXTERNAL MODULE: ./src/core/Flash/component.jsx + 1 modules
|
|
678
|
+
var component = __webpack_require__(8696);
|
|
604
679
|
;// CONCATENATED MODULE: ./src/core/Notice/component.js
|
|
605
680
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
606
681
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ably/ui",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from "react";
|
|
2
2
|
import DOMPurify from "dompurify";
|
|
3
3
|
import T from "prop-types";
|
|
4
|
+
import { nanoid } from "nanoid/non-secure";
|
|
4
5
|
|
|
5
6
|
import { getRemoteDataStore } from "../remote-data-store";
|
|
6
7
|
import ConnectStateWrapper from "../ConnectStateWrapper/component.jsx";
|
|
@@ -50,30 +51,45 @@ const FLASH_TEXT_COLOR = {
|
|
|
50
51
|
const AUTO_HIDE = ["success", "info", "notice"];
|
|
51
52
|
const AUTO_HIDE_TIME = 8000;
|
|
52
53
|
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const [closed, setClosed] = useState(false);
|
|
56
|
-
const [flashHeight, setFlashHeight] = useState(0);
|
|
57
|
-
const [triggerEntryAnimation, setTriggerEntryAnimation] = useState(false);
|
|
54
|
+
const useAutoHide = (type, closeFlash) => {
|
|
55
|
+
const timeoutId = useRef(null);
|
|
58
56
|
|
|
59
|
-
useEffect(() => setTriggerEntryAnimation(true), []);
|
|
60
57
|
useEffect(() => {
|
|
61
58
|
if (AUTO_HIDE.includes(type)) {
|
|
62
|
-
setTimeout(() => {
|
|
63
|
-
// closeFlash is idempotent, we can call it even if the flash has been already closed
|
|
59
|
+
timeoutId.current = setTimeout(() => {
|
|
64
60
|
closeFlash();
|
|
65
61
|
}, AUTO_HIDE_TIME);
|
|
66
62
|
}
|
|
67
|
-
|
|
63
|
+
|
|
64
|
+
return () => {
|
|
65
|
+
if (timeoutId.current) {
|
|
66
|
+
clearTimeout(timeoutId.current);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const Flash = ({ id, type, content, removeFlash }) => {
|
|
73
|
+
const ref = useRef(null);
|
|
74
|
+
const [closed, setClosed] = useState(false);
|
|
75
|
+
const [flashHeight, setFlashHeight] = useState(0);
|
|
76
|
+
const [triggerEntryAnimation, setTriggerEntryAnimation] = useState(false);
|
|
68
77
|
|
|
69
78
|
const closeFlash = () => {
|
|
70
79
|
if (ref.current) {
|
|
71
80
|
setFlashHeight(ref.current.getBoundingClientRect().height);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
|
|
83
|
+
setClosed(true);
|
|
84
|
+
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
removeFlash(id);
|
|
87
|
+
}, 100);
|
|
75
88
|
};
|
|
76
89
|
|
|
90
|
+
useEffect(() => setTriggerEntryAnimation(true), []);
|
|
91
|
+
useAutoHide(type, closeFlash);
|
|
92
|
+
|
|
77
93
|
const animateEntry = triggerEntryAnimation && !closed;
|
|
78
94
|
|
|
79
95
|
let style;
|
|
@@ -123,13 +139,25 @@ Flash.propTypes = {
|
|
|
123
139
|
};
|
|
124
140
|
|
|
125
141
|
const Flashes = ({ flashes }) => {
|
|
126
|
-
const
|
|
142
|
+
const [flashesWithIds, setFlashesWithIds] = useState([]);
|
|
143
|
+
|
|
144
|
+
const removeFlash = (flashId) => setFlashesWithIds((items) => items.filter((item) => item.id !== flashId));
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
setFlashesWithIds((state) => {
|
|
148
|
+
return [...state, ...(flashes?.items || []).map((flash) => ({ ...flash, id: nanoid(), removed: false }))];
|
|
149
|
+
});
|
|
150
|
+
}, [flashes]);
|
|
151
|
+
|
|
152
|
+
console.log({ flashesWithIds });
|
|
127
153
|
|
|
128
154
|
return (
|
|
129
155
|
<div className="ui-flash" data-id={FLASH_DATA_ID}>
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
156
|
+
{flashesWithIds
|
|
157
|
+
.filter((item) => !item.removed)
|
|
158
|
+
.map((flash) => (
|
|
159
|
+
<Flash removeFlash={removeFlash} key={flash.id} {...flash} />
|
|
160
|
+
))}
|
|
133
161
|
</div>
|
|
134
162
|
);
|
|
135
163
|
};
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
<%= link_to logo_href, class: '
|
|
2
|
-
<%= tag.
|
|
3
|
-
<path
|
|
4
|
-
d="M62.922 24.9786V4.08813H66.6933V11.6512C67.9709 10.435 69.6164 9.76044 71.3538 9.76044C75.4318 9.76044 79.0498 12.8674 79.0498 17.5484C79.0498 22.2293 75.4318 25.3465 71.3538 25.3465C69.5244 25.3465 67.7971 24.6209 66.5094 23.3024V24.9786H62.922ZM75.2785 17.5484C75.2785 14.932 73.4183 13.1025 70.9859 13.1025C68.6148 13.1025 66.7853 14.84 66.6933 17.3644V17.5484C66.6933 20.1648 68.5534 21.9942 70.9859 21.9942C73.4183 21.9942 75.2785 20.1648 75.2785 17.5484ZM80.7975 24.9786V4.08813H84.5688V24.9786H80.7975ZM89.8425 30.3954L92.0399 25.1523L86.0712 10.1284H90.1491L93.9511 20.6247L97.8144 10.1284H101.954L93.8591 30.4056H89.8425V30.3954ZM56.9329 10.1284V12.0191C55.6247 10.5883 53.7952 9.77066 51.9147 9.77066C47.8367 9.77066 44.2187 12.8777 44.2187 17.5586C44.2187 22.2497 47.8367 25.3465 51.9147 25.3465C53.8668 25.3465 55.7166 24.4982 57.0555 22.9754V24.9888H60.3465V10.1284H56.9329ZM56.5649 17.5484C56.5649 20.1341 54.7048 21.9942 52.2724 21.9942C49.8399 21.9942 47.9798 20.1341 47.9798 17.5484C47.9798 14.9626 49.8399 13.1025 52.2724 13.1025C54.6435 13.1025 56.473 14.8706 56.5649 17.3644V17.5484Z"
|
|
5
|
-
fill="currentColor"
|
|
6
|
-
/>
|
|
7
|
-
<path d="M19.2858 0L3.14788 29.5369L0 27.3293L14.932 0H19.2858ZM19.5107 0L35.6487 29.5369L38.7965 27.3293L23.8646 0H19.5107Z" fill="url(#<%= gradient_id_0 %>)" />
|
|
8
|
-
<path d="M35.4238 29.7107L19.3983 17.16L3.37271 29.7107L6.64323 32L19.3983 22.0147L32.1533 32L35.4238 29.7107Z" fill="url(#<%= gradient_id_1 %>)" />
|
|
9
|
-
<defs>
|
|
10
|
-
<linearGradient id="<%= gradient_id_0 %>" x1="5.47361" y1="37.4219" x2="32.4603" y2="7.45023" gradientUnits="userSpaceOnUse">
|
|
11
|
-
<stop stop-color="#FF5416" />
|
|
12
|
-
<stop offset="0.2535" stop-color="#FF5115" />
|
|
13
|
-
<stop offset="0.461" stop-color="#FF4712" />
|
|
14
|
-
<stop offset="0.6523" stop-color="#FF350E" />
|
|
15
|
-
<stop offset="0.8327" stop-color="#FF1E08" />
|
|
16
|
-
<stop offset="1" stop-color="#FF0000" />
|
|
17
|
-
</linearGradient>
|
|
18
|
-
<linearGradient id="<%= gradient_id_1 %>" x1="10.7084" y1="39.3593" x2="26.6583" y2="21.6452" gradientUnits="userSpaceOnUse">
|
|
19
|
-
<stop stop-color="#FF5416" />
|
|
20
|
-
<stop offset="0.2535" stop-color="#FF5115" />
|
|
21
|
-
<stop offset="0.461" stop-color="#FF4712" />
|
|
22
|
-
<stop offset="0.6523" stop-color="#FF350E" />
|
|
23
|
-
<stop offset="0.8327" stop-color="#FF1E08" />
|
|
24
|
-
<stop offset="1" stop-color="#FF0000" />
|
|
25
|
-
</linearGradient>
|
|
26
|
-
</defs>
|
|
27
|
-
<% end %>
|
|
1
|
+
<%= link_to logo_href, class: 'block', style: "height: 2.125rem", data: { id: data_id }, **additional_link_attrs do %>
|
|
2
|
+
<%= tag.img src: logo_url, width: "108px", alt: "Ably logo", **additional_img_attrs %>
|
|
28
3
|
<% end %>
|
|
@@ -1,46 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import T from "prop-types";
|
|
3
|
-
import { nanoid } from "nanoid/non-secure";
|
|
4
|
-
|
|
5
|
-
const Logo = ({ dataId, href = "/" }) => {
|
|
6
|
-
// This fixes a bug where if the logo is rendered more than once on the page, and one of the instances
|
|
7
|
-
// if it is hidden, the other instance will not show the ably shape from the logo.
|
|
8
|
-
|
|
9
|
-
// This is because the defs in this SVG reference ids that need to be unique ids. The browser discards the "newer"
|
|
10
|
-
// linearGradients defined in the other logo, and inherits the `hidden` style from the first.
|
|
11
|
-
const gradientIds = useMemo(() => [nanoid(), nanoid()], []);
|
|
12
3
|
|
|
4
|
+
const Logo = ({ dataId, logoUrl, href = "/", additionalImgAttrs, additionalLinkAttrs }) => {
|
|
13
5
|
return (
|
|
14
|
-
<a href={href} className="
|
|
15
|
-
<
|
|
16
|
-
<path
|
|
17
|
-
d="M62.922 24.9786V4.08813H66.6933V11.6512C67.9709 10.435 69.6164 9.76044 71.3538 9.76044C75.4318 9.76044 79.0498 12.8674 79.0498 17.5484C79.0498 22.2293 75.4318 25.3465 71.3538 25.3465C69.5244 25.3465 67.7971 24.6209 66.5094 23.3024V24.9786H62.922ZM75.2785 17.5484C75.2785 14.932 73.4183 13.1025 70.9859 13.1025C68.6148 13.1025 66.7853 14.84 66.6933 17.3644V17.5484C66.6933 20.1648 68.5534 21.9942 70.9859 21.9942C73.4183 21.9942 75.2785 20.1648 75.2785 17.5484ZM80.7975 24.9786V4.08813H84.5688V24.9786H80.7975ZM89.8425 30.3954L92.0399 25.1523L86.0712 10.1284H90.1491L93.9511 20.6247L97.8144 10.1284H101.954L93.8591 30.4056H89.8425V30.3954ZM56.9329 10.1284V12.0191C55.6247 10.5883 53.7952 9.77066 51.9147 9.77066C47.8367 9.77066 44.2187 12.8777 44.2187 17.5586C44.2187 22.2497 47.8367 25.3465 51.9147 25.3465C53.8668 25.3465 55.7166 24.4982 57.0555 22.9754V24.9888H60.3465V10.1284H56.9329ZM56.5649 17.5484C56.5649 20.1341 54.7048 21.9942 52.2724 21.9942C49.8399 21.9942 47.9798 20.1341 47.9798 17.5484C47.9798 14.9626 49.8399 13.1025 52.2724 13.1025C54.6435 13.1025 56.473 14.8706 56.5649 17.3644V17.5484Z"
|
|
18
|
-
fill="currentColor"
|
|
19
|
-
/>
|
|
20
|
-
<path
|
|
21
|
-
d="M19.2858 0L3.14788 29.5369L0 27.3293L14.932 0H19.2858ZM19.5107 0L35.6487 29.5369L38.7965 27.3293L23.8646 0H19.5107Z"
|
|
22
|
-
fill={`url(#${gradientIds[0]})`}
|
|
23
|
-
/>
|
|
24
|
-
<path d="M35.4238 29.7107L19.3983 17.16L3.37271 29.7107L6.64323 32L19.3983 22.0147L32.1533 32L35.4238 29.7107Z" fill={`url(#${gradientIds[1]})`} />
|
|
25
|
-
<defs>
|
|
26
|
-
<linearGradient id={gradientIds[0]} x1="5.47361" y1="37.4219" x2="32.4603" y2="7.45023" gradientUnits="userSpaceOnUse">
|
|
27
|
-
<stop stopColor="#FF5416" />
|
|
28
|
-
<stop offset="0.2535" stopColor="#FF5115" />
|
|
29
|
-
<stop offset="0.461" stopColor="#FF4712" />
|
|
30
|
-
<stop offset="0.6523" stopColor="#FF350E" />
|
|
31
|
-
<stop offset="0.8327" stopColor="#FF1E08" />
|
|
32
|
-
<stop offset="1" stopColor="#FF0000" />
|
|
33
|
-
</linearGradient>
|
|
34
|
-
<linearGradient id={gradientIds[1]} x1="10.7084" y1="39.3593" x2="26.6583" y2="21.6452" gradientUnits="userSpaceOnUse">
|
|
35
|
-
<stop stopColor="#FF5416" />
|
|
36
|
-
<stop offset="0.2535" stopColor="#FF5115" />
|
|
37
|
-
<stop offset="0.461" stopColor="#FF4712" />
|
|
38
|
-
<stop offset="0.6523" stopColor="#FF350E" />
|
|
39
|
-
<stop offset="0.8327" stopColor="#FF1E08" />
|
|
40
|
-
<stop offset="1" stopColor="#FF0000" />
|
|
41
|
-
</linearGradient>
|
|
42
|
-
</defs>
|
|
43
|
-
</svg>
|
|
6
|
+
<a href={href} data-id={dataId} className="block" style={{ height: "2.125rem" }} {...additionalLinkAttrs}>
|
|
7
|
+
<img src={logoUrl} width="108px" alt="Ably logo" {...additionalImgAttrs} />
|
|
44
8
|
</a>
|
|
45
9
|
);
|
|
46
10
|
};
|
|
@@ -48,6 +12,9 @@ const Logo = ({ dataId, href = "/" }) => {
|
|
|
48
12
|
Logo.propTypes = {
|
|
49
13
|
dataId: T.string,
|
|
50
14
|
href: T.string,
|
|
15
|
+
logoUrl: T.string,
|
|
16
|
+
additionalImgAttrs: T.object,
|
|
17
|
+
additionalLinkAttrs: T.object,
|
|
51
18
|
};
|
|
52
19
|
|
|
53
20
|
export default React.memo(Logo);
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
require 'securerandom'
|
|
2
|
-
|
|
3
1
|
module AblyUi
|
|
4
2
|
module Core
|
|
5
3
|
class Logo < ViewComponent::Base
|
|
6
4
|
include AblyUi::Core::MeganavConfig
|
|
7
5
|
|
|
8
|
-
attr_reader :href,
|
|
6
|
+
attr_reader :href,
|
|
7
|
+
:logo_url,
|
|
8
|
+
:data_id,
|
|
9
|
+
:additional_img_attrs,
|
|
10
|
+
:additional_link_attrs
|
|
9
11
|
|
|
10
|
-
def initialize(
|
|
12
|
+
def initialize(
|
|
13
|
+
href:,
|
|
14
|
+
logo_url:,
|
|
15
|
+
data_id: '',
|
|
16
|
+
additional_img_attrs: {},
|
|
17
|
+
additional_link_attrs: {}
|
|
18
|
+
)
|
|
11
19
|
@data_id = data_id
|
|
12
20
|
@href = href
|
|
13
|
-
@
|
|
14
|
-
@
|
|
21
|
+
@logo_url = logo_url
|
|
22
|
+
@additional_img_attrs = additional_img_attrs
|
|
23
|
+
@additional_link_attrs = additional_link_attrs
|
|
15
24
|
end
|
|
16
25
|
|
|
17
26
|
def logo_href
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="ui-meganav ui-grid-px">
|
|
5
5
|
<div className="mr-24">
|
|
6
|
-
<%= render(AblyUi::Core::Logo.new(data_id: "meganav-logo", href: logo_link)) %>
|
|
6
|
+
<%= render(AblyUi::Core::Logo.new(data_id: "meganav-logo", href: logo_link, logo_url: ably_logo)) %>
|
|
7
7
|
</div>
|
|
8
8
|
<%= render(AblyUi::Core::MeganavItemsDesktop.new(theme_name: @theme_name, url_base: url_base)) %>
|
|
9
9
|
|
|
@@ -86,7 +86,7 @@ export default function Meganav({ paths, themeName = "white", notice, loginLink
|
|
|
86
86
|
{notice && <Notice {...notice.props} config={notice.config} />}
|
|
87
87
|
<div className="ui-meganav ui-grid-px">
|
|
88
88
|
<div className="mr-24">
|
|
89
|
-
<Logo dataId="meganav-logo" href={urlBase} />
|
|
89
|
+
<Logo dataId="meganav-logo" href={urlBase} logoUrl={paths.logo} />
|
|
90
90
|
</div>
|
|
91
91
|
|
|
92
92
|
<MeganavItemsDesktop panels={panels} paths={paths} theme={theme} absUrl={absUrl} />
|
package/src/core/core.rb
CHANGED
|
Binary file
|