@kitconcept/volto-light-theme 7.6.7 → 7.7.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/.changelog.draft +3 -3
- package/CHANGELOG.md +6 -0
- package/locales/de/LC_MESSAGES/volto.po +30 -120
- package/locales/en/LC_MESSAGES/volto.po +30 -120
- package/locales/es/LC_MESSAGES/volto.po +30 -120
- package/locales/eu/LC_MESSAGES/volto.po +57 -128
- package/locales/pt_BR/LC_MESSAGES/volto.po +30 -120
- package/locales/volto.pot +31 -121
- package/package.json +1 -1
- package/src/components/StickyMenu/MobileCarouselArrowButton.tsx +81 -0
- package/src/components/StickyMenu/MobileStickyMenu.tsx +76 -0
- package/src/config/slots.ts +7 -0
- package/src/primitives/IconLinkList.tsx +53 -52
- package/src/theme/_mobile-sticky-menu.scss +92 -0
- package/src/theme/main.scss +1 -0
- package/src/types.d.ts +1 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { EmblaCarouselType } from 'embla-carousel';
|
|
3
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
4
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
5
|
+
import rightArrowSVG from '@plone/volto/icons/right-key.svg';
|
|
6
|
+
import leftArrowSVG from '@plone/volto/icons/left-key.svg';
|
|
7
|
+
|
|
8
|
+
type UsePrevNextButtonsType = {
|
|
9
|
+
prevBtnDisabled: boolean;
|
|
10
|
+
nextBtnDisabled: boolean;
|
|
11
|
+
onPrevButtonClick: () => void;
|
|
12
|
+
onNextButtonClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const usePrevNextButtons = (
|
|
16
|
+
emblaApi: EmblaCarouselType | undefined,
|
|
17
|
+
): UsePrevNextButtonsType => {
|
|
18
|
+
const [prevBtnDisabled, setPrevBtnDisabled] = useState(true);
|
|
19
|
+
const [nextBtnDisabled, setNextBtnDisabled] = useState(true);
|
|
20
|
+
|
|
21
|
+
const onPrevButtonClick = useCallback(() => {
|
|
22
|
+
if (!emblaApi) return;
|
|
23
|
+
emblaApi.scrollPrev();
|
|
24
|
+
}, [emblaApi]);
|
|
25
|
+
|
|
26
|
+
const onNextButtonClick = useCallback(() => {
|
|
27
|
+
if (!emblaApi) return;
|
|
28
|
+
emblaApi.scrollNext();
|
|
29
|
+
}, [emblaApi]);
|
|
30
|
+
|
|
31
|
+
const onSelect = useCallback((emblaApi: EmblaCarouselType) => {
|
|
32
|
+
setPrevBtnDisabled(!emblaApi.canScrollPrev());
|
|
33
|
+
setNextBtnDisabled(!emblaApi.canScrollNext());
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!emblaApi) return;
|
|
38
|
+
|
|
39
|
+
onSelect(emblaApi);
|
|
40
|
+
emblaApi.on('reInit', onSelect).on('select', onSelect);
|
|
41
|
+
}, [emblaApi, onSelect]);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
prevBtnDisabled,
|
|
45
|
+
nextBtnDisabled,
|
|
46
|
+
onPrevButtonClick,
|
|
47
|
+
onNextButtonClick,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type PropType = ComponentPropsWithRef<'button'>;
|
|
52
|
+
|
|
53
|
+
export const PrevButton: React.FC<PropType> = (props) => {
|
|
54
|
+
const { children, ...restProps } = props;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<button
|
|
58
|
+
className="embla__button embla__button--prev"
|
|
59
|
+
type="button"
|
|
60
|
+
{...restProps}
|
|
61
|
+
>
|
|
62
|
+
<Icon name={leftArrowSVG} size="48px" />
|
|
63
|
+
{children}
|
|
64
|
+
</button>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const NextButton: React.FC<PropType> = (props) => {
|
|
69
|
+
const { children, ...restProps } = props;
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<button
|
|
73
|
+
className="embla__button embla__button--next"
|
|
74
|
+
type="button"
|
|
75
|
+
{...restProps}
|
|
76
|
+
>
|
|
77
|
+
<Icon name={rightArrowSVG} size="48px" />
|
|
78
|
+
{children}
|
|
79
|
+
</button>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useLiveData } from '@kitconcept/volto-light-theme/helpers/useLiveData';
|
|
2
|
+
import { IconLinkListTemplate } from '@kitconcept/volto-light-theme/primitives/IconLinkList';
|
|
3
|
+
import type { StickyMenuSettings } from '../../types';
|
|
4
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
5
|
+
import type { EmblaOptionsType } from 'embla-carousel';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
usePrevNextButtons,
|
|
9
|
+
PrevButton,
|
|
10
|
+
NextButton,
|
|
11
|
+
} from './MobileCarouselArrowButton';
|
|
12
|
+
import type { Content } from '@plone/types';
|
|
13
|
+
|
|
14
|
+
const MobileStickyMenu = ({ content }: { content: Content }) => {
|
|
15
|
+
const options: EmblaOptionsType = {};
|
|
16
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(options);
|
|
17
|
+
const {
|
|
18
|
+
prevBtnDisabled,
|
|
19
|
+
nextBtnDisabled,
|
|
20
|
+
onPrevButtonClick,
|
|
21
|
+
onNextButtonClick,
|
|
22
|
+
} = usePrevNextButtons(emblaApi);
|
|
23
|
+
const showMobileStickyMenu = useLiveData<StickyMenuSettings['sticky_menu']>(
|
|
24
|
+
content,
|
|
25
|
+
'kitconcept.sticky_menu',
|
|
26
|
+
'enable_mobile_sticky_menu',
|
|
27
|
+
);
|
|
28
|
+
const menuData = useLiveData<StickyMenuSettings['sticky_menu']>(
|
|
29
|
+
content,
|
|
30
|
+
'kitconcept.sticky_menu',
|
|
31
|
+
'sticky_menu',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const sticky_menu_color = useLiveData<
|
|
35
|
+
StickyMenuSettings['sticky_menu_color']
|
|
36
|
+
>(content, 'kitconcept.sticky_menu', 'sticky_menu_color');
|
|
37
|
+
|
|
38
|
+
const sticky_menu_foreground_color = useLiveData<
|
|
39
|
+
StickyMenuSettings['sticky_menu_foreground_color']
|
|
40
|
+
>(content, 'kitconcept.sticky_menu', 'sticky_menu_foreground_color');
|
|
41
|
+
|
|
42
|
+
if (!showMobileStickyMenu) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className="mobile-sticky-menu"
|
|
49
|
+
role="navigation"
|
|
50
|
+
aria-label="Mobile Sticky menu"
|
|
51
|
+
style={
|
|
52
|
+
{
|
|
53
|
+
'--sticky-menu-color': sticky_menu_color,
|
|
54
|
+
'--sticky-menu-foreground-color': sticky_menu_foreground_color,
|
|
55
|
+
} as React.CSSProperties
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
<section className="embla">
|
|
59
|
+
<div className="embla__viewport" ref={emblaRef}>
|
|
60
|
+
<div className="embla__container">
|
|
61
|
+
{menuData &&
|
|
62
|
+
menuData.map((item) => (
|
|
63
|
+
<ul className="embla__slide" key={item['@id']}>
|
|
64
|
+
<IconLinkListTemplate item={item} />
|
|
65
|
+
</ul>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
<PrevButton onClick={onPrevButtonClick} disabled={prevBtnDisabled} />
|
|
70
|
+
<NextButton onClick={onNextButtonClick} disabled={nextBtnDisabled} />
|
|
71
|
+
</section>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default MobileStickyMenu;
|
package/src/config/slots.ts
CHANGED
|
@@ -5,6 +5,7 @@ import FollowUsLogoAndLinks from '../components/Footer/slots/FollowUsLogoAndLink
|
|
|
5
5
|
import Colophon from '../components/Footer/slots/Colophon';
|
|
6
6
|
import CoreFooter from '../components/Footer/slots/CoreFooter';
|
|
7
7
|
import StickyMenu from '../components/StickyMenu/StickyMenu';
|
|
8
|
+
import MobileStickyMenu from '../components/StickyMenu/MobileStickyMenu';
|
|
8
9
|
import Anontools from '../components/Anontools/Anontools';
|
|
9
10
|
import type { Content } from '@plone/types';
|
|
10
11
|
|
|
@@ -57,5 +58,11 @@ export default function install(config: ConfigType) {
|
|
|
57
58
|
component: Colophon,
|
|
58
59
|
});
|
|
59
60
|
|
|
61
|
+
config.registerSlotComponent({
|
|
62
|
+
name: 'MobileStickyMenu',
|
|
63
|
+
slot: 'preFooter',
|
|
64
|
+
component: MobileStickyMenu,
|
|
65
|
+
});
|
|
66
|
+
|
|
60
67
|
return config;
|
|
61
68
|
}
|
|
@@ -6,6 +6,58 @@ type IconLinkListProps = {
|
|
|
6
6
|
iconLinks: Array<iconLink>;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
export const IconLinkListTemplate = ({ item }) => {
|
|
10
|
+
const itemInfo: {
|
|
11
|
+
title: string;
|
|
12
|
+
hrefTitle: string;
|
|
13
|
+
href: string;
|
|
14
|
+
itemHref: string;
|
|
15
|
+
src: string;
|
|
16
|
+
srcAlt: string;
|
|
17
|
+
} = {
|
|
18
|
+
title: '',
|
|
19
|
+
hrefTitle: '',
|
|
20
|
+
href: '',
|
|
21
|
+
itemHref: '',
|
|
22
|
+
src: '',
|
|
23
|
+
srcAlt: '',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// If the item has title, always set it
|
|
27
|
+
itemInfo.title = item ? item?.title || item?.href?.[0]?.['title'] || '' : '';
|
|
28
|
+
if (item?.href?.length > 0) {
|
|
29
|
+
itemInfo.title = item.title || item.href[0]['title'];
|
|
30
|
+
itemInfo.href = flattenToAppURL(item.href[0]['@id']);
|
|
31
|
+
}
|
|
32
|
+
if (item?.icon && item.icon[0]?.image_scales) {
|
|
33
|
+
itemInfo.itemHref = item.icon[0]['@id'];
|
|
34
|
+
itemInfo.srcAlt = item['alt'];
|
|
35
|
+
itemInfo.src = `${flattenToAppURL(itemInfo.itemHref)}/${item.icon[0].image_scales[item.icon[0].image_field][0].download}`;
|
|
36
|
+
} else if (item?.icon && item.icon[0]) {
|
|
37
|
+
itemInfo.itemHref = item.icon[0]['@id'];
|
|
38
|
+
itemInfo.srcAlt = item['alt'];
|
|
39
|
+
itemInfo.src = `${flattenToAppURL(itemInfo.itemHref)}/@@images/image`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!itemInfo.src) return null;
|
|
43
|
+
return (
|
|
44
|
+
<li className="item" key={item['@id']}>
|
|
45
|
+
{/* @ts-ignore */}
|
|
46
|
+
<ConditionalLink
|
|
47
|
+
condition={itemInfo.href}
|
|
48
|
+
to={itemInfo.href}
|
|
49
|
+
title={itemInfo.hrefTitle || itemInfo.srcAlt}
|
|
50
|
+
openLinkInNewTab={item.openInNewTab}
|
|
51
|
+
>
|
|
52
|
+
<div className="image-wrapper">
|
|
53
|
+
<img src={itemInfo.src} alt={itemInfo.srcAlt || ''} />
|
|
54
|
+
</div>
|
|
55
|
+
<span className="title">{itemInfo.title}</span>
|
|
56
|
+
</ConditionalLink>
|
|
57
|
+
</li>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
9
61
|
const IconLinkList = (props: IconLinkListProps) => {
|
|
10
62
|
const { iconLinks } = props;
|
|
11
63
|
|
|
@@ -13,58 +65,7 @@ const IconLinkList = (props: IconLinkListProps) => {
|
|
|
13
65
|
<ul>
|
|
14
66
|
{iconLinks && Array.isArray(iconLinks)
|
|
15
67
|
? iconLinks.map((item) => {
|
|
16
|
-
|
|
17
|
-
title: string;
|
|
18
|
-
hrefTitle: string;
|
|
19
|
-
href: string;
|
|
20
|
-
itemHref: string;
|
|
21
|
-
src: string;
|
|
22
|
-
srcAlt: string;
|
|
23
|
-
} = {
|
|
24
|
-
title: '',
|
|
25
|
-
hrefTitle: '',
|
|
26
|
-
href: '',
|
|
27
|
-
itemHref: '',
|
|
28
|
-
src: '',
|
|
29
|
-
srcAlt: '',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// If the item has title, always set it
|
|
33
|
-
itemInfo.title = item
|
|
34
|
-
? item?.title || item?.href?.[0]?.['title'] || ''
|
|
35
|
-
: '';
|
|
36
|
-
if (item?.href?.length > 0) {
|
|
37
|
-
itemInfo.title = item.title || item.href[0]['title'];
|
|
38
|
-
itemInfo.href = flattenToAppURL(item.href[0]['@id']);
|
|
39
|
-
}
|
|
40
|
-
if (item?.icon && item.icon[0]?.image_scales) {
|
|
41
|
-
itemInfo.itemHref = item.icon[0]['@id'];
|
|
42
|
-
itemInfo.srcAlt = item['alt'];
|
|
43
|
-
itemInfo.src = `${flattenToAppURL(itemInfo.itemHref)}/${item.icon[0].image_scales[item.icon[0].image_field][0].download}`;
|
|
44
|
-
} else if (item?.icon && item.icon[0]) {
|
|
45
|
-
itemInfo.itemHref = item.icon[0]['@id'];
|
|
46
|
-
itemInfo.srcAlt = item['alt'];
|
|
47
|
-
itemInfo.src = `${flattenToAppURL(itemInfo.itemHref)}/@@images/image`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!itemInfo.src) return null;
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<li className="item" key={item['@id']}>
|
|
54
|
-
{/* @ts-ignore */}
|
|
55
|
-
<ConditionalLink
|
|
56
|
-
condition={itemInfo.href}
|
|
57
|
-
to={itemInfo.href}
|
|
58
|
-
title={itemInfo.hrefTitle || itemInfo.srcAlt}
|
|
59
|
-
openLinkInNewTab={item.openInNewTab}
|
|
60
|
-
>
|
|
61
|
-
<div className="image-wrapper">
|
|
62
|
-
<img src={itemInfo.src} alt={itemInfo.srcAlt || ''} />
|
|
63
|
-
</div>
|
|
64
|
-
<span>{itemInfo.title}</span>
|
|
65
|
-
</ConditionalLink>
|
|
66
|
-
</li>
|
|
67
|
-
);
|
|
68
|
+
return <IconLinkListTemplate item={item} key={item['@id']} />;
|
|
68
69
|
})
|
|
69
70
|
: null}
|
|
70
71
|
</ul>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.mobile-sticky-menu {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 100;
|
|
4
|
+
bottom: 0;
|
|
5
|
+
display: flex;
|
|
6
|
+
display: none;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100px;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
background-color: var(--sticky-menu-color, #555);
|
|
11
|
+
@media only screen and (max-width: $narrow-container-width) {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.embla {
|
|
16
|
+
position: relative;
|
|
17
|
+
--slide-size: 33%;
|
|
18
|
+
|
|
19
|
+
.embla__button {
|
|
20
|
+
display: flex;
|
|
21
|
+
height: 100px;
|
|
22
|
+
align-items: center;
|
|
23
|
+
padding: 0px;
|
|
24
|
+
border: none;
|
|
25
|
+
background-color: transparent;
|
|
26
|
+
color: var(--sticky-menu-foreground-color, #fff);
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-size: 30px;
|
|
29
|
+
}
|
|
30
|
+
.embla__button--prev {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0px;
|
|
33
|
+
left: -5px;
|
|
34
|
+
}
|
|
35
|
+
.embla__button--next {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0px;
|
|
38
|
+
right: -5px;
|
|
39
|
+
}
|
|
40
|
+
.embla__viewport {
|
|
41
|
+
position: relative;
|
|
42
|
+
display: inline-block;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
width: 85%;
|
|
45
|
+
|
|
46
|
+
.embla__container {
|
|
47
|
+
display: flex;
|
|
48
|
+
height: 100px;
|
|
49
|
+
touch-action: pan-y pinch-zoom;
|
|
50
|
+
touch-action: pan-x;
|
|
51
|
+
|
|
52
|
+
.embla__slide {
|
|
53
|
+
min-width: 0;
|
|
54
|
+
flex: 0 0 var(--slide-size);
|
|
55
|
+
padding: 0px;
|
|
56
|
+
margin: 0px;
|
|
57
|
+
transform: translate3d(0, 0, 0);
|
|
58
|
+
|
|
59
|
+
.image-wrapper {
|
|
60
|
+
display: block;
|
|
61
|
+
width: 65px;
|
|
62
|
+
height: 65px;
|
|
63
|
+
img {
|
|
64
|
+
display: block;
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
li {
|
|
71
|
+
list-style: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
span {
|
|
75
|
+
display: block;
|
|
76
|
+
color: var(--sticky-menu-foreground-color, #fff);
|
|
77
|
+
font-size: 10px;
|
|
78
|
+
font-weight: 700;
|
|
79
|
+
line-height: 12px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
a {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-flow: column;
|
|
85
|
+
align-items: center;
|
|
86
|
+
padding: 5px 10px 15px 10px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/theme/main.scss
CHANGED
package/src/types.d.ts
CHANGED