@reykjavik/hanna-react 0.10.134 → 0.10.136
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/Alert.d.ts +2 -0
- package/Alert.js +2 -2
- package/CHANGELOG.md +12 -0
- package/MainMenu2.d.ts +2 -0
- package/MainMenu2.js +5 -5
- package/_abstract/_AbstractCarousel.js +3 -3
- package/esm/Alert.d.ts +2 -0
- package/esm/Alert.js +2 -2
- package/esm/MainMenu2.d.ts +2 -0
- package/esm/MainMenu2.js +5 -5
- package/esm/_abstract/_AbstractCarousel.js +3 -3
- package/package.json +2 -2
package/Alert.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type AlertProps = {
|
|
|
24
24
|
closeUrl?: string;
|
|
25
25
|
texts?: AlertI18n;
|
|
26
26
|
lang?: HannaLang;
|
|
27
|
+
/** Set to true to opt out of the opening transition */
|
|
28
|
+
instantShow?: boolean;
|
|
27
29
|
} & SSRSupportProps & EitherObj<{
|
|
28
30
|
/** Seconds until the Alert auto-closes.
|
|
29
31
|
*
|
package/Alert.js
CHANGED
|
@@ -49,11 +49,11 @@ exports.alertTypes = {
|
|
|
49
49
|
};
|
|
50
50
|
const Alert = (props) => {
|
|
51
51
|
const { type, childrenHTML, children, onClose, // eslint-disable-line deprecation/deprecation
|
|
52
|
-
closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, wrapperProps, } = props;
|
|
52
|
+
closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, instantShow, wrapperProps, } = props;
|
|
53
53
|
const autoClose = Math.max(props.autoClose || 0, 0);
|
|
54
54
|
const closing = (0, react_1.useRef)();
|
|
55
55
|
const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
|
|
56
|
-
const [open, setOpen] = (0, react_1.useState)(!isBrowser);
|
|
56
|
+
const [open, setOpen] = (0, react_1.useState)(instantShow || !isBrowser);
|
|
57
57
|
const showCloseButton = closable && (isBrowser || closeUrl != null);
|
|
58
58
|
const { closeLabel, closeLabelLong } = (0, i18n_1.getTexts)(props, exports.defaultAlertTexts);
|
|
59
59
|
(0, react_1.useEffect)(() => {
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.136
|
|
8
|
+
|
|
9
|
+
_2024-09-10_
|
|
10
|
+
|
|
11
|
+
- feat: Add prop `instantShow` to `Alert`, to skip opening transitions
|
|
12
|
+
|
|
13
|
+
## 0.10.135
|
|
14
|
+
|
|
15
|
+
_2024-09-03_
|
|
16
|
+
|
|
17
|
+
- feat: Add prop `variant="light"` to `MainMenu2`
|
|
18
|
+
|
|
7
19
|
## 0.10.134
|
|
8
20
|
|
|
9
21
|
_2024-08-19_
|
package/MainMenu2.d.ts
CHANGED
|
@@ -101,6 +101,8 @@ export type MainMenu2Props = {
|
|
|
101
101
|
relatedTitle?: string;
|
|
102
102
|
related?: MainMenu2ButtonItemList;
|
|
103
103
|
};
|
|
104
|
+
/** Visual type */
|
|
105
|
+
variant?: 'default' | 'light';
|
|
104
106
|
/**
|
|
105
107
|
* NOTE: Clicking a MainMenu2 item will automatically close HannaUIState's
|
|
106
108
|
* "Hamburger menu" (a.k.a. "Mobile menu")
|
package/MainMenu2.js
CHANGED
|
@@ -89,9 +89,6 @@ const getRenderers = (props) => {
|
|
|
89
89
|
size: 'small',
|
|
90
90
|
}
|
|
91
91
|
: undefined;
|
|
92
|
-
if (label === 'Græna planið') {
|
|
93
|
-
console.log('FOOBAR', icon, icon && iconMap[icon]);
|
|
94
|
-
}
|
|
95
92
|
return (react_1.default.createElement(Tag, { key: key, className: (0, classUtils_1.modifiedClass)(`${classPrefix}item`, item.modifier), "aria-current": item.current || undefined }, isBrowser && (onClick || href == null) ? (react_1.default.createElement(ButtonTag, Object.assign({}, commonProps, { type: "button", "aria-controls": controlsId, onClick: () => {
|
|
96
93
|
const keepOpen1 = onClick && onClick(item) === false;
|
|
97
94
|
const keepOpen2 = onItemClick && onItemClick(item) === false;
|
|
@@ -117,7 +114,7 @@ const getRenderers = (props) => {
|
|
|
117
114
|
};
|
|
118
115
|
// eslint-disable-next-line complexity
|
|
119
116
|
const MainMenu2 = (props) => {
|
|
120
|
-
const { homeLink = '/', items, onItemClick, illustration, imageUrl, wrapperProps = {}, } = props;
|
|
117
|
+
const { homeLink = '/', items, onItemClick, illustration, imageUrl, variant, wrapperProps = {}, } = props;
|
|
121
118
|
const domid = (0, utils_js_1.useDomid)(wrapperProps.id);
|
|
122
119
|
const isBrowser = (0, utils_js_1.useIsBrowserSide)(props.ssr);
|
|
123
120
|
const [isMenuOpen, setIsMenuOpen] = (0, react_1.useState)(false);
|
|
@@ -198,7 +195,10 @@ const MainMenu2 = (props) => {
|
|
|
198
195
|
: homeLink)), { modifier: 'home' });
|
|
199
196
|
const menuImageUrl = imageUrl || (illustration && (0, assets_1.getIllustrationUrl)(illustration));
|
|
200
197
|
const menuId = `${domid}-menu`;
|
|
201
|
-
return (react_1.default.createElement("nav", Object.assign({}, props.wrapperProps, { className: (0, classUtils_1.modifiedClass)('MainMenu2',
|
|
198
|
+
return (react_1.default.createElement("nav", Object.assign({}, props.wrapperProps, { className: (0, classUtils_1.modifiedClass)('MainMenu2', [
|
|
199
|
+
isBrowser && (isMenuOpen ? 'open' : 'closed'),
|
|
200
|
+
variant && variant !== 'default' ? `variant--${variant}` : undefined,
|
|
201
|
+
], wrapperProps.className), style: menuImageUrl
|
|
202
202
|
? Object.assign(Object.assign({}, wrapperProps.style), { '--menu-image': `url(${menuImageUrl})` })
|
|
203
203
|
: wrapperProps.style, ref: wrapperRef, "aria-label": txt.title, "data-sprinkled": isBrowser, id: menuId }),
|
|
204
204
|
isMenuOpen && react_1.default.createElement(FocusTrap_js_1.FocusTrap, { atTop: true }),
|
|
@@ -15,12 +15,12 @@ const utils_js_1 = require("../utils.js");
|
|
|
15
15
|
const scrollXBy = (elm, deltaX) => {
|
|
16
16
|
const left = elm.scrollLeft + deltaX;
|
|
17
17
|
elm.scrollTo(left, elm.scrollTop);
|
|
18
|
-
// NOTE 1:
|
|
19
|
-
// as `behavior: 'smooth'` starts some weird interactions with the browser's
|
|
20
|
-
// `scroll-snap-type` behavior.
|
|
18
|
+
// NOTE 1: The scroll behavior is left up to the CSS styles.
|
|
21
19
|
//
|
|
22
20
|
// NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
|
|
23
21
|
// while Firefox is more smooth. Haven't found a way around that.
|
|
22
|
+
// (`behavior: 'smooth'` starts some weird interactions with the browser's
|
|
23
|
+
// CSS `scroll-snap-type` behavior.)
|
|
24
24
|
};
|
|
25
25
|
// eslint-disable-next-line complexity
|
|
26
26
|
const AbstractCarousel = (props) => {
|
package/esm/Alert.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type AlertProps = {
|
|
|
24
24
|
closeUrl?: string;
|
|
25
25
|
texts?: AlertI18n;
|
|
26
26
|
lang?: HannaLang;
|
|
27
|
+
/** Set to true to opt out of the opening transition */
|
|
28
|
+
instantShow?: boolean;
|
|
27
29
|
} & SSRSupportProps & EitherObj<{
|
|
28
30
|
/** Seconds until the Alert auto-closes.
|
|
29
31
|
*
|
package/esm/Alert.js
CHANGED
|
@@ -45,11 +45,11 @@ export const alertTypes = {
|
|
|
45
45
|
};
|
|
46
46
|
export const Alert = (props) => {
|
|
47
47
|
const { type, childrenHTML, children, onClose, // eslint-disable-line deprecation/deprecation
|
|
48
|
-
closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, wrapperProps, } = props;
|
|
48
|
+
closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, instantShow, wrapperProps, } = props;
|
|
49
49
|
const autoClose = Math.max(props.autoClose || 0, 0);
|
|
50
50
|
const closing = useRef();
|
|
51
51
|
const isBrowser = useIsBrowserSide(ssr);
|
|
52
|
-
const [open, setOpen] = useState(!isBrowser);
|
|
52
|
+
const [open, setOpen] = useState(instantShow || !isBrowser);
|
|
53
53
|
const showCloseButton = closable && (isBrowser || closeUrl != null);
|
|
54
54
|
const { closeLabel, closeLabelLong } = getTexts(props, defaultAlertTexts);
|
|
55
55
|
useEffect(() => {
|
package/esm/MainMenu2.d.ts
CHANGED
|
@@ -101,6 +101,8 @@ export type MainMenu2Props = {
|
|
|
101
101
|
relatedTitle?: string;
|
|
102
102
|
related?: MainMenu2ButtonItemList;
|
|
103
103
|
};
|
|
104
|
+
/** Visual type */
|
|
105
|
+
variant?: 'default' | 'light';
|
|
104
106
|
/**
|
|
105
107
|
* NOTE: Clicking a MainMenu2 item will automatically close HannaUIState's
|
|
106
108
|
* "Hamburger menu" (a.k.a. "Mobile menu")
|
package/esm/MainMenu2.js
CHANGED
|
@@ -85,9 +85,6 @@ const getRenderers = (props) => {
|
|
|
85
85
|
size: 'small',
|
|
86
86
|
}
|
|
87
87
|
: undefined;
|
|
88
|
-
if (label === 'Græna planið') {
|
|
89
|
-
console.log('FOOBAR', icon, icon && iconMap[icon]);
|
|
90
|
-
}
|
|
91
88
|
return (React.createElement(Tag, { key: key, className: modifiedClass(`${classPrefix}item`, item.modifier), "aria-current": item.current || undefined }, isBrowser && (onClick || href == null) ? (React.createElement(ButtonTag, Object.assign({}, commonProps, { type: "button", "aria-controls": controlsId, onClick: () => {
|
|
92
89
|
const keepOpen1 = onClick && onClick(item) === false;
|
|
93
90
|
const keepOpen2 = onItemClick && onItemClick(item) === false;
|
|
@@ -113,7 +110,7 @@ const getRenderers = (props) => {
|
|
|
113
110
|
};
|
|
114
111
|
// eslint-disable-next-line complexity
|
|
115
112
|
export const MainMenu2 = (props) => {
|
|
116
|
-
const { homeLink = '/', items, onItemClick, illustration, imageUrl, wrapperProps = {}, } = props;
|
|
113
|
+
const { homeLink = '/', items, onItemClick, illustration, imageUrl, variant, wrapperProps = {}, } = props;
|
|
117
114
|
const domid = useDomid(wrapperProps.id);
|
|
118
115
|
const isBrowser = useIsBrowserSide(props.ssr);
|
|
119
116
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
@@ -194,7 +191,10 @@ export const MainMenu2 = (props) => {
|
|
|
194
191
|
: homeLink)), { modifier: 'home' });
|
|
195
192
|
const menuImageUrl = imageUrl || (illustration && getIllustrationUrl(illustration));
|
|
196
193
|
const menuId = `${domid}-menu`;
|
|
197
|
-
return (React.createElement("nav", Object.assign({}, props.wrapperProps, { className: modifiedClass('MainMenu2',
|
|
194
|
+
return (React.createElement("nav", Object.assign({}, props.wrapperProps, { className: modifiedClass('MainMenu2', [
|
|
195
|
+
isBrowser && (isMenuOpen ? 'open' : 'closed'),
|
|
196
|
+
variant && variant !== 'default' ? `variant--${variant}` : undefined,
|
|
197
|
+
], wrapperProps.className), style: menuImageUrl
|
|
198
198
|
? Object.assign(Object.assign({}, wrapperProps.style), { '--menu-image': `url(${menuImageUrl})` })
|
|
199
199
|
: wrapperProps.style, ref: wrapperRef, "aria-label": txt.title, "data-sprinkled": isBrowser, id: menuId }),
|
|
200
200
|
isMenuOpen && React.createElement(FocusTrap, { atTop: true }),
|
|
@@ -11,12 +11,12 @@ import { useIsBrowserSide } from '../utils.js';
|
|
|
11
11
|
const scrollXBy = (elm, deltaX) => {
|
|
12
12
|
const left = elm.scrollLeft + deltaX;
|
|
13
13
|
elm.scrollTo(left, elm.scrollTop);
|
|
14
|
-
// NOTE 1:
|
|
15
|
-
// as `behavior: 'smooth'` starts some weird interactions with the browser's
|
|
16
|
-
// `scroll-snap-type` behavior.
|
|
14
|
+
// NOTE 1: The scroll behavior is left up to the CSS styles.
|
|
17
15
|
//
|
|
18
16
|
// NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
|
|
19
17
|
// while Firefox is more smooth. Haven't found a way around that.
|
|
18
|
+
// (`behavior: 'smooth'` starts some weird interactions with the browser's
|
|
19
|
+
// CSS `scroll-snap-type` behavior.)
|
|
20
20
|
};
|
|
21
21
|
// eslint-disable-next-line complexity
|
|
22
22
|
export const AbstractCarousel = (props) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/hanna-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.136",
|
|
4
4
|
"author": "Reykjavík (http://www.reykjavik.is)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Hugsmiðjan ehf (http://www.hugsmidjan.is)",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@hugsmidjan/qj": "^4.22.1",
|
|
19
19
|
"@hugsmidjan/react": "^0.4.32",
|
|
20
20
|
"@reykjavik/hanna-css": "^0.4.14",
|
|
21
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
21
|
+
"@reykjavik/hanna-utils": "^0.2.16",
|
|
22
22
|
"@types/react-autosuggest": "^10.1.0",
|
|
23
23
|
"@types/react-datepicker": "^4.8.0",
|
|
24
24
|
"@types/react-transition-group": "^4.4.0",
|