@kitconcept/volto-light-theme 5.0.1 → 6.0.0-alpha.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 +26 -6
- package/CHANGELOG.md +32 -0
- package/README.md +7 -367
- package/package.json +20 -7
- package/razzle.extend.js +38 -0
- package/src/components/Anontools/Anontools.jsx +1 -1
- package/src/components/Blocks/Button/schema.js +25 -5
- package/src/components/Blocks/EventMetadata/View.jsx +8 -7
- package/src/components/Blocks/Image/Edit.jsx +4 -6
- package/src/components/Blocks/Image/ImageSidebar.jsx +4 -2
- package/src/components/Blocks/Image/View.jsx +3 -6
- package/src/components/Blocks/Image/schema.js +37 -6
- package/src/components/Blocks/Listing/DefaultTemplate.jsx +3 -2
- package/src/components/Blocks/Listing/GridTemplate.jsx +4 -2
- package/src/components/Blocks/Listing/ImageGallery.jsx +2 -2
- package/src/components/Blocks/Listing/SummaryTemplate.jsx +3 -2
- package/src/components/Blocks/Search/components/SearchInput.jsx +1 -1
- package/src/components/Blocks/Separator/schema.js +59 -0
- package/src/components/Blocks/Slider/DefaultBody.jsx +4 -2
- package/src/components/Blocks/Teaser/schema.js +21 -1
- package/src/components/Blocks/schema.js +16 -15
- package/src/components/Breadcrumbs/Breadcrumbs.jsx +4 -3
- package/src/components/Footer/Footer.jsx +77 -27
- package/src/components/Header/Header.jsx +34 -29
- package/src/components/LanguageSelector/{LanguageSelector.js → LanguageSelector.jsx} +11 -7
- package/src/components/Logo/Logo.jsx +28 -22
- package/src/components/MobileNavigation/MobileNavigation.jsx +3 -2
- package/src/components/MobileNavigation/MobileToolsFooter.jsx +1 -1
- package/src/components/Navigation/Navigation.jsx +4 -3
- package/src/components/SearchWidget/IntranetSearchWidget.jsx +1 -1
- package/src/components/SearchWidget/SearchWidget.jsx +1 -1
- package/src/components/Theme/EventView.jsx +3 -2
- package/src/components/Theme/FileView.jsx +1 -1
- package/src/components/Theme/NewsItemView.jsx +1 -1
- package/src/components/Theming/Theming.tsx +52 -0
- package/src/components/Widgets/AlignWidget.jsx +2 -2
- package/src/components/Widgets/BackgroundColorWidget.tsx +18 -0
- package/src/components/Widgets/BlockAlignmentWidget.tsx +81 -0
- package/src/components/Widgets/BlockWidthWidget.tsx +94 -0
- package/src/components/Widgets/BlocksObjectWidget.tsx +333 -0
- package/src/components/Widgets/ButtonsWidget.tsx +68 -0
- package/src/components/Widgets/ColorPickerWidget.tsx +60 -0
- package/src/components/Widgets/FooterLinksWidget.tsx +106 -0
- package/src/components/Widgets/FooterLogosWidget.tsx +120 -0
- package/src/components/Widgets/ThemingColorPicker.tsx +33 -0
- package/src/config/blocks.tsx +352 -0
- package/src/config/classExtenders.ts +101 -0
- package/src/config/settings.ts +35 -0
- package/src/config/slots.ts +12 -0
- package/src/config/widgets.ts +31 -0
- package/src/customizations/volto/components/theme/View/RenderBlocks.jsx +97 -80
- package/src/customizations/volto/components/theme/View/RenderBlocks.test.jsx +16 -48
- package/src/helpers/helpers.test.ts +51 -0
- package/src/helpers/helpers.ts +48 -0
- package/src/index.ts +54 -0
- package/src/theme/_bgcolor-blocks-layout.scss +1127 -20
- package/src/theme/_footer.scss +8 -5
- package/src/theme/_header.scss +3 -8
- package/src/theme/_layout.scss +24 -7
- package/src/theme/_typo-custom.scss +1 -1
- package/src/theme/_variables.scss +95 -12
- package/src/theme/_widgets.scss +102 -0
- package/src/theme/blocks/_accordion.scss +2 -4
- package/src/theme/blocks/_button.scss +32 -31
- package/src/theme/blocks/_eventMetadata.scss +7 -0
- package/src/theme/blocks/_grid.scss +11 -36
- package/src/theme/blocks/_highlight.scss +1 -0
- package/src/theme/blocks/_image.scss +38 -17
- package/src/theme/blocks/_introduction.scss +16 -0
- package/src/theme/blocks/_listing.scss +1 -6
- package/src/theme/blocks/_search.scss +1 -23
- package/src/theme/blocks/_separator.scss +17 -20
- package/src/theme/blocks/_slider.scss +57 -56
- package/src/theme/blocks/_teaser.scss +3 -3
- package/src/theme/main.scss +1 -0
- package/src/transforms/to6.ts +94 -0
- package/tsconfig.json +33 -0
- package/.release-it.json +0 -31
- package/babel.config.js +0 -17
- package/build/messages/src/components/Anontools/Anontools.json +0 -10
- package/build/messages/src/components/Blocks/Button/schema.json +0 -6
- package/build/messages/src/components/Blocks/EventMetadata/View.json +0 -30
- package/build/messages/src/components/Blocks/Image/Edit.json +0 -10
- package/build/messages/src/components/Blocks/Image/ImageSidebar.json +0 -18
- package/build/messages/src/components/Blocks/Image/schema.json +0 -10
- package/build/messages/src/components/Blocks/Listing/ListingBody.json +0 -26
- package/build/messages/src/components/Blocks/Search/TopSideFacets.json +0 -10
- package/build/messages/src/components/Blocks/Search/components/SearchDetails.json +0 -10
- package/build/messages/src/components/Blocks/Search/components/SearchInput.json +0 -6
- package/build/messages/src/components/Blocks/Slider/DefaultBody.json +0 -18
- package/build/messages/src/components/Blocks/Slider/schema.json +0 -14
- package/build/messages/src/components/Blocks/schema.json +0 -6
- package/build/messages/src/components/Breadcrumbs/Breadcrumbs.json +0 -10
- package/build/messages/src/components/Footer/Footer.json +0 -30
- package/build/messages/src/components/Header/Header.json +0 -6
- package/build/messages/src/components/LanguageSelector/LanguageSelector.json +0 -6
- package/build/messages/src/components/Logo/Logo.json +0 -10
- package/build/messages/src/components/MobileNavigation/MobileNavigation.json +0 -26
- package/build/messages/src/components/Navigation/Navigation.json +0 -10
- package/build/messages/src/components/SearchWidget/IntranetSearchWidget.json +0 -14
- package/build/messages/src/components/SearchWidget/SearchWidget.json +0 -10
- package/build/messages/src/components/Theme/EventView.json +0 -6
- package/build/messages/src/components/Widgets/AlignWidget.json +0 -22
- package/build/messages/src/index.json +0 -10
- package/news/.gitkeep +0 -0
- package/src/components/Atoms/Container/Container.jsx +0 -32
- package/src/components/Atoms/README.md +0 -1
- package/src/components/Atoms/helpers.jsx +0 -9
- package/src/components/CQPolyfill.jsx +0 -9
- package/src/index.js +0 -367
- package/towncrier.toml +0 -33
- /package/src/components/Blocks/Slate/{ExtraAlignWrapper.js → ExtraAlignWrapper.jsx} +0 -0
|
@@ -1,44 +1,50 @@
|
|
|
1
1
|
// SemanticUI-free pre-@plone/components
|
|
2
2
|
import { defineMessages, useIntl } from 'react-intl';
|
|
3
3
|
import { useSelector } from 'react-redux';
|
|
4
|
-
import
|
|
5
|
-
import { UniversalLink } from '@plone/volto/components';
|
|
6
|
-
import { toBackendLang } from '@plone/volto/helpers';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
7
5
|
import LogoImage from '@plone/volto/components/theme/Logo/Logo.svg';
|
|
8
|
-
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
6
|
+
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
9
7
|
|
|
10
8
|
const messages = defineMessages({
|
|
11
|
-
|
|
12
|
-
id: '
|
|
13
|
-
defaultMessage: '
|
|
9
|
+
home: {
|
|
10
|
+
id: 'Home',
|
|
11
|
+
defaultMessage: 'Home',
|
|
14
12
|
},
|
|
15
|
-
|
|
16
|
-
id: '
|
|
17
|
-
defaultMessage: '
|
|
13
|
+
logoOf: {
|
|
14
|
+
id: 'Logo of',
|
|
15
|
+
defaultMessage: 'Logo of',
|
|
18
16
|
},
|
|
19
17
|
});
|
|
20
18
|
|
|
21
19
|
const Logo = () => {
|
|
22
|
-
const { settings } = config;
|
|
23
|
-
const lang = useSelector((state) => state.intl.locale);
|
|
24
20
|
const intl = useIntl();
|
|
25
21
|
const site = useSelector((state) => state.site.data);
|
|
22
|
+
const navroot = useSelector((state) => state.navroot.data);
|
|
23
|
+
const navRootPath = flattenToAppURL(navroot?.navroot?.['@id']) || '/';
|
|
24
|
+
const navRootLogo = navroot?.navroot?.logo?.download || null;
|
|
25
|
+
const navRootLogoWidth = navroot?.navroot?.logo?.width || null;
|
|
26
|
+
const navRootLogoHeight = navroot?.navroot?.logo?.height || null;
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
-
href={settings.isMultilingual ? `/${toBackendLang(lang)}` : '/'}
|
|
30
|
-
title={intl.formatMessage(messages.site)}
|
|
31
|
-
>
|
|
29
|
+
<Link to={navRootPath} aria-label={intl.formatMessage(messages.home)}>
|
|
32
30
|
<img
|
|
33
31
|
src={
|
|
34
|
-
|
|
35
|
-
? flattenToAppURL(
|
|
36
|
-
:
|
|
32
|
+
navRootLogo
|
|
33
|
+
? flattenToAppURL(navRootLogo)
|
|
34
|
+
: site['plone.site_logo']
|
|
35
|
+
? flattenToAppURL(site['plone.site_logo'])
|
|
36
|
+
: LogoImage
|
|
37
|
+
}
|
|
38
|
+
width={navRootLogoWidth}
|
|
39
|
+
height={navRootLogoHeight}
|
|
40
|
+
alt={
|
|
41
|
+
intl.formatMessage(messages.logoOf) + ' ' + site['plone.site_title']
|
|
42
|
+
}
|
|
43
|
+
title={
|
|
44
|
+
intl.formatMessage(messages.logoOf) + ' ' + site['plone.site_title']
|
|
37
45
|
}
|
|
38
|
-
alt={intl.formatMessage(messages.homepage)}
|
|
39
|
-
title={intl.formatMessage(messages.homepage)}
|
|
40
46
|
/>
|
|
41
|
-
</
|
|
47
|
+
</Link>
|
|
42
48
|
);
|
|
43
49
|
};
|
|
44
50
|
|
|
@@ -7,8 +7,9 @@ import { CSSTransition } from 'react-transition-group';
|
|
|
7
7
|
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
8
8
|
|
|
9
9
|
import config from '@plone/volto/registry';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
11
|
+
import SearchWidget from '@plone/volto/components/theme/SearchWidget/SearchWidget';
|
|
12
|
+
import { toBackendLang } from '@plone/volto/helpers/Utils/Utils';
|
|
12
13
|
import arrowRightSVG from '@plone/volto/icons/right-key.svg';
|
|
13
14
|
import arrowLeftSVG from '@plone/volto/icons/left-key.svg';
|
|
14
15
|
import { MobileNavigationToggler } from './MobileNavigationToggler';
|
|
@@ -7,11 +7,12 @@ import { NavLink } from 'react-router-dom';
|
|
|
7
7
|
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
8
8
|
import { useIntl, defineMessages, injectIntl } from 'react-intl';
|
|
9
9
|
import cx from 'classnames';
|
|
10
|
-
import { getBaseUrl
|
|
10
|
+
import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
|
|
11
|
+
import { hasApiExpander } from '@plone/volto/helpers/Utils/Utils';
|
|
11
12
|
import config from '@plone/volto/registry';
|
|
12
13
|
|
|
13
|
-
import { getNavigation } from '@plone/volto/actions';
|
|
14
|
-
import
|
|
14
|
+
import { getNavigation } from '@plone/volto/actions/navigation/navigation';
|
|
15
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
15
16
|
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
16
17
|
import NavItem from '@plone/volto/components/theme/Navigation/NavItem';
|
|
17
18
|
|
|
@@ -10,7 +10,7 @@ import { compose } from 'redux';
|
|
|
10
10
|
import { PropTypes } from 'prop-types';
|
|
11
11
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
14
14
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
15
15
|
|
|
16
16
|
const messages = defineMessages({
|
|
@@ -6,7 +6,7 @@ import { compose } from 'redux';
|
|
|
6
6
|
import { PropTypes } from 'prop-types';
|
|
7
7
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
10
10
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
11
11
|
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
12
12
|
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { hasBlocksData
|
|
8
|
+
import { hasBlocksData } from '@plone/volto/helpers/Blocks/Blocks';
|
|
9
|
+
import { flattenHTMLToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
9
10
|
import { Container as SemanticContainer } from 'semantic-ui-react';
|
|
10
11
|
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
11
12
|
|
|
12
|
-
import
|
|
13
|
+
import FormattedDate from '@plone/volto/components/theme/FormattedDate/FormattedDate';
|
|
13
14
|
import config from '@plone/volto/registry';
|
|
14
15
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
|
15
16
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { Container as SemanticContainer } from 'semantic-ui-react';
|
|
9
|
-
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
9
|
+
import { flattenToAppURL } from '@plone/volto/helpers/';
|
|
10
10
|
import config from '@plone/volto/registry';
|
|
11
11
|
import FileType from '../../helpers/Filetype';
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
9
|
-
import
|
|
9
|
+
import FormattedDate from '@plone/volto/components/theme/FormattedDate/FormattedDate';
|
|
10
10
|
import config from '@plone/volto/registry';
|
|
11
11
|
import { Container as SemanticContainer } from 'semantic-ui-react';
|
|
12
12
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Helmet from '@plone/volto/helpers/Helmet/Helmet';
|
|
2
|
+
import type { Content } from '@plone/types';
|
|
3
|
+
import { useSelector } from 'react-redux';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
|
+
import config from '@plone/registry';
|
|
6
|
+
|
|
7
|
+
type FormState = {
|
|
8
|
+
content: {
|
|
9
|
+
data: Content;
|
|
10
|
+
};
|
|
11
|
+
form: {
|
|
12
|
+
global: Content;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// TODO: Change when we have the final list of colors
|
|
17
|
+
// and if they are nested in the serialization under a key
|
|
18
|
+
function buildStyleTag(content: Content, colors: string[]) {
|
|
19
|
+
if (Array.isArray(colors)) {
|
|
20
|
+
return colors
|
|
21
|
+
.filter((color) => content[color])
|
|
22
|
+
.map((color) => {
|
|
23
|
+
return `--${color.replace(/_/g, '-')}: ${content[color]}; `;
|
|
24
|
+
})
|
|
25
|
+
.join('');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Theming = ({ navRoot }) => {
|
|
30
|
+
const colorFields = config.settings.userDefinedControlPanelColors;
|
|
31
|
+
const formData = useSelector<FormState, Content>(
|
|
32
|
+
(state) => state.form.global,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const liveContent = navRoot ? (!isEmpty(formData) ? formData : navRoot) : {};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<Helmet>
|
|
40
|
+
<style>
|
|
41
|
+
{`
|
|
42
|
+
:root {
|
|
43
|
+
${buildStyleTag(liveContent, colorFields)}
|
|
44
|
+
}
|
|
45
|
+
`}
|
|
46
|
+
</style>
|
|
47
|
+
</Helmet>
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Theming;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
-
import { FormFieldWrapper } from '@plone/volto/components';
|
|
4
|
-
import
|
|
3
|
+
import { FormFieldWrapper } from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
|
|
4
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
5
5
|
import { Button } from 'semantic-ui-react';
|
|
6
6
|
import imageLeftSVG from '@plone/volto/icons/image-left.svg';
|
|
7
7
|
import imageRightSVG from '@plone/volto/icons/image-right.svg';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ColorPickerWidget from '@plone/volto/components/manage/Widgets/ColorPickerWidget';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
import type { ColorPickerWidgetProps } from '@plone/volto/components/manage/Widgets/ColorPickerWidget';
|
|
4
|
+
|
|
5
|
+
const BackgroundColorWidget = (props: ColorPickerWidgetProps) => {
|
|
6
|
+
const colors: ColorPickerWidgetProps['colors'] =
|
|
7
|
+
config.settings.backgroundColors;
|
|
8
|
+
|
|
9
|
+
const defaultValue = colors.find(
|
|
10
|
+
(color) => color.name === config.settings.defaultBackgroundColor,
|
|
11
|
+
)?.style;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<ColorPickerWidget {...props} default={defaultValue} colors={colors} />
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default BackgroundColorWidget;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
+
import ButtonsWidget, { type ButtonsWidgetProps } from './ButtonsWidget';
|
|
4
|
+
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
5
|
+
import imageLeftSVG from '@plone/volto/icons/image-left.svg';
|
|
6
|
+
import imageRightSVG from '@plone/volto/icons/image-right.svg';
|
|
7
|
+
import type { IntlShape } from 'react-intl';
|
|
8
|
+
|
|
9
|
+
const messages = defineMessages({
|
|
10
|
+
left: {
|
|
11
|
+
id: 'Left',
|
|
12
|
+
defaultMessage: 'Left',
|
|
13
|
+
},
|
|
14
|
+
right: {
|
|
15
|
+
id: 'Right',
|
|
16
|
+
defaultMessage: 'Right',
|
|
17
|
+
},
|
|
18
|
+
center: {
|
|
19
|
+
id: 'Center',
|
|
20
|
+
defaultMessage: 'Center',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const defaultActionsInfo = ({ intl }: { intl: IntlShape }) => ({
|
|
25
|
+
left: [imageLeftSVG, intl.formatMessage(messages.left)],
|
|
26
|
+
right: [imageRightSVG, intl.formatMessage(messages.right)],
|
|
27
|
+
center: [imageFitSVG, intl.formatMessage(messages.center)],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const DEFAULT_ACTIONS = [
|
|
31
|
+
{
|
|
32
|
+
style: {
|
|
33
|
+
'--block-alignment': 'var(--align-left)',
|
|
34
|
+
},
|
|
35
|
+
name: 'left',
|
|
36
|
+
label: 'Left',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
style: {
|
|
40
|
+
'--block-alignment': 'var(--align-center)',
|
|
41
|
+
},
|
|
42
|
+
name: 'center',
|
|
43
|
+
label: 'Center',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
style: {
|
|
47
|
+
'--block-alignment': 'var(--align-right)',
|
|
48
|
+
},
|
|
49
|
+
name: 'right',
|
|
50
|
+
label: 'Right',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const BlockAlignmentWidget = (props: ButtonsWidgetProps) => {
|
|
55
|
+
const intl = useIntl();
|
|
56
|
+
|
|
57
|
+
const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
|
|
58
|
+
let filteredActions;
|
|
59
|
+
if (filterActions) {
|
|
60
|
+
filteredActions = actions.filter((action) =>
|
|
61
|
+
filterActions.includes(action.name),
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
filteredActions = actions;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const actionsInfo = {
|
|
68
|
+
...defaultActionsInfo({ intl }),
|
|
69
|
+
...actionsInfoMap,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ButtonsWidget
|
|
74
|
+
{...props}
|
|
75
|
+
actions={filteredActions}
|
|
76
|
+
actionsInfoMap={actionsInfo}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default BlockAlignmentWidget;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
+
import ButtonsWidget, { type ButtonsWidgetProps } from './ButtonsWidget';
|
|
4
|
+
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
5
|
+
import imageNarrowSVG from '@plone/volto/icons/image-narrow.svg';
|
|
6
|
+
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
7
|
+
import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
8
|
+
import type { IntlShape } from 'react-intl';
|
|
9
|
+
|
|
10
|
+
const messages = defineMessages({
|
|
11
|
+
narrow: {
|
|
12
|
+
id: 'Narrow',
|
|
13
|
+
defaultMessage: 'Narrow',
|
|
14
|
+
},
|
|
15
|
+
default: {
|
|
16
|
+
id: 'Default',
|
|
17
|
+
defaultMessage: 'Default',
|
|
18
|
+
},
|
|
19
|
+
layout: {
|
|
20
|
+
id: 'Layout',
|
|
21
|
+
defaultMessage: 'Layout',
|
|
22
|
+
},
|
|
23
|
+
full: {
|
|
24
|
+
id: 'Full',
|
|
25
|
+
defaultMessage: 'Full',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const defaultActionsInfo = ({ intl }: { intl: IntlShape }) => ({
|
|
30
|
+
narrow: [imageNarrowSVG, intl.formatMessage(messages.narrow)],
|
|
31
|
+
default: [imageFitSVG, intl.formatMessage(messages.default)],
|
|
32
|
+
layout: [imageWideSVG, intl.formatMessage(messages.layout)],
|
|
33
|
+
full: [imageFullSVG, intl.formatMessage(messages.full)],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const DEFAULT_ACTIONS = [
|
|
37
|
+
{
|
|
38
|
+
style: {
|
|
39
|
+
'--block-width': 'var(--narrow-container-width)',
|
|
40
|
+
},
|
|
41
|
+
name: 'narrow',
|
|
42
|
+
label: 'Narrow',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
style: {
|
|
46
|
+
'--block-width': 'var(--default-container-width)',
|
|
47
|
+
},
|
|
48
|
+
name: 'default',
|
|
49
|
+
label: 'Default',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
style: {
|
|
53
|
+
'--block-width': 'var(--layout-container-width)',
|
|
54
|
+
},
|
|
55
|
+
name: 'layout',
|
|
56
|
+
label: 'Layout',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
style: {
|
|
60
|
+
'--block-width': 'unset',
|
|
61
|
+
},
|
|
62
|
+
name: 'full',
|
|
63
|
+
label: 'Full',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const BlockWidthWidget = (props: ButtonsWidgetProps) => {
|
|
68
|
+
const intl = useIntl();
|
|
69
|
+
|
|
70
|
+
const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
|
|
71
|
+
let filteredActions;
|
|
72
|
+
if (filterActions) {
|
|
73
|
+
filteredActions = actions.filter((action) =>
|
|
74
|
+
filterActions.includes(action.name),
|
|
75
|
+
);
|
|
76
|
+
} else {
|
|
77
|
+
filteredActions = actions;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const actionsInfo = {
|
|
81
|
+
...defaultActionsInfo({ intl }),
|
|
82
|
+
...actionsInfoMap,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<ButtonsWidget
|
|
87
|
+
{...props}
|
|
88
|
+
actions={filteredActions}
|
|
89
|
+
actionsInfoMap={actionsInfo}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default BlockWidthWidget;
|