@kitconcept/volto-light-theme 8.0.0-alpha.3 → 8.0.0-alpha.30
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 +6 -9
- package/CHANGELOG.md +310 -0
- package/locales/af/LC_MESSAGES/volto.po +645 -0
- package/locales/ar/LC_MESSAGES/volto.po +645 -0
- package/locales/bg/LC_MESSAGES/volto.po +645 -0
- package/locales/bn/LC_MESSAGES/volto.po +645 -0
- package/locales/ca/LC_MESSAGES/volto.po +645 -0
- package/locales/cs/LC_MESSAGES/volto.po +645 -0
- package/locales/cy/LC_MESSAGES/volto.po +645 -0
- package/locales/da/LC_MESSAGES/volto.po +645 -0
- package/locales/de/LC_MESSAGES/volto.po +83 -167
- package/locales/el/LC_MESSAGES/volto.po +645 -0
- package/locales/en/LC_MESSAGES/volto.po +30 -115
- package/locales/en_AU/LC_MESSAGES/volto.po +645 -0
- package/locales/en_GB/LC_MESSAGES/volto.po +645 -0
- package/locales/eo/LC_MESSAGES/volto.po +645 -0
- package/locales/es/LC_MESSAGES/volto.po +75 -160
- package/locales/et/LC_MESSAGES/volto.po +645 -0
- package/locales/eu/LC_MESSAGES/volto.po +59 -125
- package/locales/fa/LC_MESSAGES/volto.po +645 -0
- package/locales/fi/LC_MESSAGES/volto.po +645 -0
- package/locales/fr/LC_MESSAGES/volto.po +645 -0
- package/locales/fu/LC_MESSAGES/volto.po +645 -0
- package/locales/ga/LC_MESSAGES/volto.po +645 -0
- package/locales/gl/LC_MESSAGES/volto.po +645 -0
- package/locales/he/LC_MESSAGES/volto.po +645 -0
- package/locales/hi/LC_MESSAGES/volto.po +645 -0
- package/locales/hr/LC_MESSAGES/volto.po +645 -0
- package/locales/hu/LC_MESSAGES/volto.po +645 -0
- package/locales/hy/LC_MESSAGES/volto.po +645 -0
- package/locales/id/LC_MESSAGES/volto.po +645 -0
- package/locales/it/LC_MESSAGES/volto.po +645 -0
- package/locales/ja/LC_MESSAGES/volto.po +645 -0
- package/locales/ka/LC_MESSAGES/volto.po +645 -0
- package/locales/kn/LC_MESSAGES/volto.po +645 -0
- package/locales/ko/LC_MESSAGES/volto.po +645 -0
- package/locales/lt/LC_MESSAGES/volto.po +645 -0
- package/locales/lv/LC_MESSAGES/volto.po +645 -0
- package/locales/mi/LC_MESSAGES/volto.po +645 -0
- package/locales/mk_MK/LC_MESSAGES/volto.po +645 -0
- package/locales/ms/LC_MESSAGES/volto.po +645 -0
- package/locales/mt/LC_MESSAGES/volto.po +645 -0
- package/locales/my/LC_MESSAGES/volto.po +645 -0
- package/locales/nl/LC_MESSAGES/volto.po +645 -0
- package/locales/nl_BE/LC_MESSAGES/volto.po +645 -0
- package/locales/nn/LC_MESSAGES/volto.po +645 -0
- package/locales/no/LC_MESSAGES/volto.po +645 -0
- package/locales/pl/LC_MESSAGES/volto.po +645 -0
- package/locales/pt/LC_MESSAGES/volto.po +645 -0
- package/locales/pt_BR/LC_MESSAGES/volto.po +38 -123
- package/locales/rm/LC_MESSAGES/volto.po +645 -0
- package/locales/ro/LC_MESSAGES/volto.po +645 -0
- package/locales/ru/LC_MESSAGES/volto.po +645 -0
- package/locales/sk/LC_MESSAGES/volto.po +645 -0
- package/locales/sl/LC_MESSAGES/volto.po +645 -0
- package/locales/sm/LC_MESSAGES/volto.po +645 -0
- package/locales/sq/LC_MESSAGES/volto.po +645 -0
- package/locales/sr/LC_MESSAGES/volto.po +645 -0
- package/locales/sr_Cyrl/LC_MESSAGES/volto.po +645 -0
- package/locales/sr_Latn/LC_MESSAGES/volto.po +645 -0
- package/locales/sv/LC_MESSAGES/volto.po +645 -0
- package/locales/sw/LC_MESSAGES/volto.po +645 -0
- package/locales/ta/LC_MESSAGES/volto.po +645 -0
- package/locales/te/LC_MESSAGES/volto.po +645 -0
- package/locales/th/LC_MESSAGES/volto.po +645 -0
- package/locales/tl/LC_MESSAGES/volto.po +645 -0
- package/locales/to/LC_MESSAGES/volto.po +645 -0
- package/locales/tr/LC_MESSAGES/volto.po +645 -0
- package/locales/uk/LC_MESSAGES/volto.po +645 -0
- package/locales/vi/LC_MESSAGES/volto.po +645 -0
- package/locales/volto.pot +31 -116
- package/locales/zh_CN/LC_MESSAGES/volto.po +645 -0
- package/locales/zh_HK/LC_MESSAGES/volto.po +645 -0
- package/locales/zh_TW/LC_MESSAGES/volto.po +645 -0
- package/package.json +7 -4
- package/src/__mocks__/semantic-ui-react.ts +31 -0
- package/src/components/Blocks/Block/EditBlockWrapper.jsx +9 -3
- package/src/components/Blocks/Button/schema.js +12 -0
- package/src/components/Blocks/EventCalendar/Search/components/EventTemplate.tsx +1 -1
- package/src/components/Blocks/Image/Edit.jsx +9 -32
- package/src/components/Blocks/Image/View.jsx +9 -26
- package/src/components/Blocks/Image/adapter.js +28 -14
- package/src/components/Blocks/Image/adapter.test.js +156 -0
- package/src/components/Blocks/Image/schema.js +21 -7
- package/src/components/Blocks/Listing/DefaultTemplate.jsx +12 -6
- package/src/components/Blocks/Listing/GridTemplate.jsx +17 -7
- package/src/components/Blocks/Listing/ListingBody.jsx +4 -1
- package/src/components/Blocks/Listing/SummaryTemplate.jsx +17 -7
- package/src/components/Blocks/Maps/MapsSidebar.jsx +68 -0
- package/src/components/Blocks/Maps/View.jsx +37 -0
- package/src/components/Blocks/Maps/adapter.js +27 -0
- package/src/components/Blocks/Maps/adapter.test.js +63 -0
- package/src/components/Blocks/Maps/schema.js +42 -2
- package/src/components/Blocks/Separator/schema.js +12 -0
- package/src/components/Blocks/Teaser/DefaultBody.tsx +35 -6
- package/src/components/Blocks/Video/VideoSidebar.jsx +68 -0
- package/src/components/Blocks/Video/View.jsx +38 -0
- package/src/components/Blocks/Video/adapter.js +28 -0
- package/src/components/Blocks/Video/adapter.test.js +63 -0
- package/src/components/Blocks/Video/schema.js +42 -2
- package/src/components/Blocks/schema.ts +69 -0
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +128 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +117 -0
- package/src/components/Caption/Caption.test.tsx +31 -0
- package/src/components/Caption/{Caption.jsx → Caption.tsx} +14 -21
- package/src/components/Footer/ColumnLinks.tsx +2 -2
- package/src/components/Footer/Footer.tsx +2 -2
- package/src/components/Footer/slots/Colophon.tsx +13 -1
- package/src/components/Footer/slots/CoreFooter.tsx +4 -2
- package/src/components/Footer/slots/FollowUsLogoAndLinks.tsx +12 -23
- package/src/components/Header/Header.tsx +3 -3
- package/src/components/LanguageSelector/LanguageSelector.tsx +91 -0
- package/src/components/MobileNavigation/MobileNavigation.jsx +11 -9
- package/src/components/Navigation/Navigation.test.tsx +176 -0
- package/src/components/Navigation/{Navigation.jsx → Navigation.tsx} +89 -42
- package/src/components/StickyMenu/MobileCarouselArrowButton.tsx +81 -0
- package/src/components/StickyMenu/MobileStickyMenu.tsx +76 -0
- package/src/components/Summary/DefaultSummary.tsx +10 -3
- package/src/components/Summary/EventSummary.tsx +10 -3
- package/src/components/Summary/FileSummary.tsx +10 -3
- package/src/components/Summary/NewsItemSummary.tsx +10 -3
- package/src/components/Summary/PersonSummary.tsx +10 -3
- package/src/components/Summary/Summary.stories.tsx +46 -30
- package/src/components/Tags/Tags.test.tsx +71 -0
- package/src/components/Tags/{Tags.jsx → Tags.tsx} +9 -25
- package/src/components/Theme/EventView.jsx +4 -4
- package/src/components/Theme/ImageView.jsx +8 -1
- package/src/components/Theme/NewsItemView.jsx +4 -4
- package/src/components/Theme/RenderBlocksV2.jsx +38 -15
- package/src/components/Widgets/ColorSwatch.stories.tsx +197 -0
- package/src/components/Widgets/ColorSwatch.test.tsx +188 -0
- package/src/components/Widgets/ColorSwatch.tsx +77 -39
- package/src/components/Widgets/ObjectList.tsx +37 -27
- package/src/components/Widgets/SoftTextWidget.tsx +129 -0
- package/src/components/Widgets/SoftTextareaWidget.tsx +118 -0
- package/src/components/Widgets/ThemeColorSwatch.tsx +5 -9
- package/src/config/blocks.tsx +83 -28
- package/src/config/classExtenders.ts +11 -10
- package/src/config/settings.ts +6 -0
- package/src/config/slots.ts +7 -0
- package/src/config/widgets.ts +5 -9
- package/src/customizations/volto/components/manage/Blocks/Maps/MapsSidebar.jsx +10 -0
- package/src/customizations/volto/components/manage/Blocks/Maps/View.jsx +10 -0
- package/src/customizations/volto/components/manage/Blocks/Video/VideoSidebar.jsx +10 -0
- package/src/customizations/volto/components/manage/Blocks/Video/View.jsx +10 -0
- package/src/customizations/volto/components/manage/DragDropList/DragDropList.jsx +263 -0
- package/src/customizations/volto/components/theme/LanguageSelector/LanguageSelector.tsx +10 -0
- package/src/helpers/styleDefinitions.test.tsx +30 -0
- package/src/helpers/styleDefinitions.ts +49 -0
- package/src/helpers/useLiveData.ts +7 -2
- package/src/index.ts +15 -0
- package/src/internalChecks.test.ts +94 -0
- package/src/primitives/Card/Card.stories.tsx +4 -1
- package/src/primitives/Card/Card.test.tsx +11 -33
- package/src/primitives/Card/Card.tsx +37 -44
- package/src/primitives/IconLinkList.tsx +53 -52
- package/src/primitives/LinkIconButton.tsx +52 -0
- package/src/reducers/errorContext.ts +14 -0
- package/src/reducers/index.ts +7 -0
- package/src/theme/_bgcolor-blocks-layout.scss +48 -46
- package/src/theme/_content.scss +12 -13
- package/src/theme/_export_import.scss +94 -0
- package/src/theme/_footer.scss +131 -64
- package/src/theme/_header.scss +25 -5
- package/src/theme/_insets.scss +1 -1
- package/src/theme/_layout.scss +41 -77
- package/src/theme/_mobile-sticky-menu.scss +92 -0
- package/src/theme/_search-page.scss +250 -0
- package/src/theme/_typo-custom.scss +24 -8
- package/src/theme/_variables.scss +40 -4
- package/src/theme/_widgets.scss +6 -17
- package/src/theme/blocks/_accordion.scss +11 -4
- package/src/theme/blocks/_form.scss +350 -0
- package/src/theme/blocks/_grid.scss +10 -77
- package/src/theme/blocks/_highlight.scss +10 -7
- package/src/theme/blocks/_image.scss +99 -184
- package/src/theme/blocks/_listing.scss +61 -128
- package/src/theme/blocks/_maps.scss +60 -34
- package/src/theme/blocks/_search.scss +3 -4
- package/src/theme/blocks/_table.scss +1 -0
- package/src/theme/blocks/_teaser.scss +7 -117
- package/src/theme/blocks/_toc.scss +2 -1
- package/src/theme/card.scss +136 -69
- package/src/theme/main.scss +4 -0
- package/src/theme/notfound.scss +2 -0
- package/src/theme/person.scss +7 -1
- package/src/theme/sticky-menu.scss +7 -5
- package/src/transforms/to6.ts +5 -49
- package/src/transforms/to8.test.js +201 -0
- package/src/transforms/to8.ts +109 -0
- package/src/types.d.ts +1 -0
- package/vitest.config.mjs +28 -3
- package/razzle.extend.js +0 -38
- package/src/components/Blocks/schema.js +0 -44
- package/src/components/Breadcrumbs/Breadcrumbs.jsx +0 -118
- package/src/components/Widgets/AlignWidget.tsx +0 -84
- package/src/components/Widgets/BlockAlignment.tsx +0 -88
- package/src/components/Widgets/BlockWidth.tsx +0 -101
- package/src/components/Widgets/Buttons.tsx +0 -167
- package/src/components/Widgets/Size.tsx +0 -78
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
-
import ButtonsWidget, {
|
|
4
|
-
type ActionInfo,
|
|
5
|
-
type ButtonsWidgetProps,
|
|
6
|
-
} from './Buttons';
|
|
7
|
-
import imageLeftSVG from '@plone/volto/icons/image-left.svg';
|
|
8
|
-
import imageRightSVG from '@plone/volto/icons/image-right.svg';
|
|
9
|
-
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
10
|
-
import imageNarrowSVG from '@plone/volto/icons/image-narrow.svg';
|
|
11
|
-
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
12
|
-
import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
13
|
-
import type { IntlShape } from 'react-intl';
|
|
14
|
-
|
|
15
|
-
const messages = defineMessages({
|
|
16
|
-
left: {
|
|
17
|
-
id: 'Left',
|
|
18
|
-
defaultMessage: 'Left',
|
|
19
|
-
},
|
|
20
|
-
right: {
|
|
21
|
-
id: 'Right',
|
|
22
|
-
defaultMessage: 'Right',
|
|
23
|
-
},
|
|
24
|
-
center: {
|
|
25
|
-
id: 'Center',
|
|
26
|
-
defaultMessage: 'Center',
|
|
27
|
-
},
|
|
28
|
-
narrow: {
|
|
29
|
-
id: 'Narrow',
|
|
30
|
-
defaultMessage: 'Narrow',
|
|
31
|
-
},
|
|
32
|
-
wide: {
|
|
33
|
-
id: 'Wide',
|
|
34
|
-
defaultMessage: 'Wide',
|
|
35
|
-
},
|
|
36
|
-
full: {
|
|
37
|
-
id: 'Full',
|
|
38
|
-
defaultMessage: 'Full',
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export const defaultActionsInfo = ({
|
|
43
|
-
intl,
|
|
44
|
-
}: {
|
|
45
|
-
intl: IntlShape;
|
|
46
|
-
}): Record<string, ActionInfo> => ({
|
|
47
|
-
left: [imageLeftSVG, intl.formatMessage(messages.left)],
|
|
48
|
-
center: [imageFitSVG, intl.formatMessage(messages.center)],
|
|
49
|
-
right: [imageRightSVG, intl.formatMessage(messages.right)],
|
|
50
|
-
narrow: [imageNarrowSVG, intl.formatMessage(messages.narrow)],
|
|
51
|
-
wide: [imageWideSVG, intl.formatMessage(messages.wide)],
|
|
52
|
-
full: [imageFullSVG, intl.formatMessage(messages.full)],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
type AlignWidgetProps = ButtonsWidgetProps & {
|
|
56
|
-
defaultAction?: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const AlignWidget = (props: AlignWidgetProps) => {
|
|
60
|
-
const intl = useIntl();
|
|
61
|
-
|
|
62
|
-
const {
|
|
63
|
-
actions = ['left', 'center', 'right', 'full'],
|
|
64
|
-
actionsInfoMap,
|
|
65
|
-
default: defaultValue,
|
|
66
|
-
defaultAction,
|
|
67
|
-
} = props;
|
|
68
|
-
|
|
69
|
-
const actionsInfo = {
|
|
70
|
-
...defaultActionsInfo({ intl }),
|
|
71
|
-
...actionsInfoMap,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<ButtonsWidget
|
|
76
|
-
{...props}
|
|
77
|
-
actions={actions}
|
|
78
|
-
actionsInfoMap={actionsInfo}
|
|
79
|
-
default={defaultValue ?? defaultAction ?? 'center'}
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default AlignWidget;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
-
import ButtonsWidget, {
|
|
4
|
-
type ActionInfo,
|
|
5
|
-
type ButtonsWidgetProps,
|
|
6
|
-
} from './Buttons';
|
|
7
|
-
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
8
|
-
import imageLeftSVG from '@plone/volto/icons/image-left.svg';
|
|
9
|
-
import imageRightSVG from '@plone/volto/icons/image-right.svg';
|
|
10
|
-
import type { IntlShape } from 'react-intl';
|
|
11
|
-
import type { StyleDefinition } from '@plone/types';
|
|
12
|
-
|
|
13
|
-
const messages = defineMessages({
|
|
14
|
-
left: {
|
|
15
|
-
id: 'Left',
|
|
16
|
-
defaultMessage: 'Left',
|
|
17
|
-
},
|
|
18
|
-
right: {
|
|
19
|
-
id: 'Right',
|
|
20
|
-
defaultMessage: 'Right',
|
|
21
|
-
},
|
|
22
|
-
center: {
|
|
23
|
-
id: 'Center',
|
|
24
|
-
defaultMessage: 'Center',
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export const defaultActionsInfo = ({
|
|
29
|
-
intl,
|
|
30
|
-
}: {
|
|
31
|
-
intl: IntlShape;
|
|
32
|
-
}): Record<string, ActionInfo> => ({
|
|
33
|
-
left: [imageLeftSVG, intl.formatMessage(messages.left)],
|
|
34
|
-
right: [imageRightSVG, intl.formatMessage(messages.right)],
|
|
35
|
-
center: [imageFitSVG, intl.formatMessage(messages.center)],
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const DEFAULT_ACTIONS: StyleDefinition[] = [
|
|
39
|
-
{
|
|
40
|
-
style: {
|
|
41
|
-
'--block-alignment': 'var(--align-left)',
|
|
42
|
-
},
|
|
43
|
-
name: 'left',
|
|
44
|
-
label: 'Left',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
style: {
|
|
48
|
-
'--block-alignment': 'var(--align-center)',
|
|
49
|
-
},
|
|
50
|
-
name: 'center',
|
|
51
|
-
label: 'Center',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
style: {
|
|
55
|
-
'--block-alignment': 'var(--align-right)',
|
|
56
|
-
},
|
|
57
|
-
name: 'right',
|
|
58
|
-
label: 'Right',
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
const BlockAlignmentWidget = (props: ButtonsWidgetProps) => {
|
|
63
|
-
const intl = useIntl();
|
|
64
|
-
|
|
65
|
-
const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
|
|
66
|
-
const filteredActions =
|
|
67
|
-
filterActions && filterActions.length > 0
|
|
68
|
-
? actions.filter((action) => {
|
|
69
|
-
const actionName = typeof action === 'string' ? action : action.name;
|
|
70
|
-
return filterActions.includes(actionName);
|
|
71
|
-
})
|
|
72
|
-
: actions;
|
|
73
|
-
|
|
74
|
-
const actionsInfo = {
|
|
75
|
-
...defaultActionsInfo({ intl }),
|
|
76
|
-
...actionsInfoMap,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<ButtonsWidget
|
|
81
|
-
{...props}
|
|
82
|
-
actions={filteredActions}
|
|
83
|
-
actionsInfoMap={actionsInfo}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export default BlockAlignmentWidget;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
3
|
-
import type { IntlShape } from 'react-intl';
|
|
4
|
-
import ButtonsWidget, {
|
|
5
|
-
type ActionInfo,
|
|
6
|
-
type ButtonsWidgetProps,
|
|
7
|
-
} from './Buttons';
|
|
8
|
-
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
9
|
-
import imageNarrowSVG from '@plone/volto/icons/image-narrow.svg';
|
|
10
|
-
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
11
|
-
import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
12
|
-
import type { StyleDefinition } from '@plone/types';
|
|
13
|
-
|
|
14
|
-
const messages = defineMessages({
|
|
15
|
-
narrow: {
|
|
16
|
-
id: 'Narrow',
|
|
17
|
-
defaultMessage: 'Narrow',
|
|
18
|
-
},
|
|
19
|
-
default: {
|
|
20
|
-
id: 'Default',
|
|
21
|
-
defaultMessage: 'Default',
|
|
22
|
-
},
|
|
23
|
-
layout: {
|
|
24
|
-
id: 'Layout',
|
|
25
|
-
defaultMessage: 'Layout',
|
|
26
|
-
},
|
|
27
|
-
full: {
|
|
28
|
-
id: 'Full',
|
|
29
|
-
defaultMessage: 'Full',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export const defaultActionsInfo = ({
|
|
34
|
-
intl,
|
|
35
|
-
}: {
|
|
36
|
-
intl: IntlShape;
|
|
37
|
-
}): Record<string, ActionInfo> => ({
|
|
38
|
-
narrow: [imageNarrowSVG, intl.formatMessage(messages.narrow)],
|
|
39
|
-
default: [imageFitSVG, intl.formatMessage(messages.default)],
|
|
40
|
-
layout: [imageWideSVG, intl.formatMessage(messages.layout)],
|
|
41
|
-
full: [imageFullSVG, intl.formatMessage(messages.full)],
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const DEFAULT_ACTIONS: StyleDefinition[] = [
|
|
45
|
-
{
|
|
46
|
-
style: {
|
|
47
|
-
'--block-width': 'var(--narrow-container-width)',
|
|
48
|
-
},
|
|
49
|
-
name: 'narrow',
|
|
50
|
-
label: 'Narrow',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
style: {
|
|
54
|
-
'--block-width': 'var(--default-container-width)',
|
|
55
|
-
},
|
|
56
|
-
name: 'default',
|
|
57
|
-
label: 'Default',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
style: {
|
|
61
|
-
'--block-width': 'var(--layout-container-width)',
|
|
62
|
-
},
|
|
63
|
-
name: 'layout',
|
|
64
|
-
label: 'Layout',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
style: {
|
|
68
|
-
'--block-width': 'unset',
|
|
69
|
-
},
|
|
70
|
-
name: 'full',
|
|
71
|
-
label: 'Full',
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
const BlockWidthWidget = (props: ButtonsWidgetProps) => {
|
|
76
|
-
const intl = useIntl();
|
|
77
|
-
|
|
78
|
-
const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
|
|
79
|
-
const filteredActions =
|
|
80
|
-
filterActions && filterActions.length > 0
|
|
81
|
-
? actions.filter((action) => {
|
|
82
|
-
const actionName = typeof action === 'string' ? action : action.name;
|
|
83
|
-
return filterActions.includes(actionName);
|
|
84
|
-
})
|
|
85
|
-
: actions;
|
|
86
|
-
|
|
87
|
-
const actionsInfo = {
|
|
88
|
-
...defaultActionsInfo({ intl }),
|
|
89
|
-
...actionsInfoMap,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<ButtonsWidget
|
|
94
|
-
{...props}
|
|
95
|
-
actions={filteredActions}
|
|
96
|
-
actionsInfoMap={actionsInfo}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default BlockWidthWidget;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
|
|
3
|
-
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
4
|
-
import { RadioGroup } from '@plone/components';
|
|
5
|
-
import { Radio } from 'react-aria-components';
|
|
6
|
-
import isEqual from 'lodash/isEqual';
|
|
7
|
-
import type { StyleDefinition } from '@plone/types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A tuple that has an icon in the first element and a i18n string in the second.
|
|
11
|
-
*/
|
|
12
|
-
export type ActionInfo = [React.ReactElement<any>, string] | [string, string];
|
|
13
|
-
|
|
14
|
-
type ActionValue = string | Record<`--${string}`, string>;
|
|
15
|
-
|
|
16
|
-
export type ButtonsWidgetProps = {
|
|
17
|
-
/**
|
|
18
|
-
* Unique identifier for the widget.
|
|
19
|
-
*/
|
|
20
|
-
id: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Callback function to handle changes.
|
|
24
|
-
*/
|
|
25
|
-
onChange: (id: string, value: ActionValue) => void;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* List of actions available for the widget.
|
|
29
|
-
*/
|
|
30
|
-
actions?: Array<StyleDefinition | string>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Map containing additional the information (icon and i18n string) for each action.
|
|
34
|
-
*/
|
|
35
|
-
actionsInfoMap?: Record<string, ActionInfo>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* List of actions to be filtered out. In case that we don't want the default ones
|
|
39
|
-
* we can filter them out.
|
|
40
|
-
*/
|
|
41
|
-
filterActions?: string[];
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Current value of the widget.
|
|
45
|
-
*/
|
|
46
|
-
value?: ActionValue;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Default value of the widget.
|
|
50
|
-
*/
|
|
51
|
-
default?: ActionValue;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Indicates if the widget is disabled.
|
|
55
|
-
*/
|
|
56
|
-
disabled?: boolean;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Indicates if the widget is disabled (alternative flag for compatibility reasons).
|
|
60
|
-
*/
|
|
61
|
-
isDisabled?: boolean;
|
|
62
|
-
[key: string]: any;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type NormalizedAction = {
|
|
66
|
-
name: string;
|
|
67
|
-
value: ActionValue;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const ButtonsWidget = (props: ButtonsWidgetProps) => {
|
|
71
|
-
const {
|
|
72
|
-
disabled,
|
|
73
|
-
id,
|
|
74
|
-
onChange,
|
|
75
|
-
actions = [],
|
|
76
|
-
actionsInfoMap,
|
|
77
|
-
value,
|
|
78
|
-
isDisabled,
|
|
79
|
-
default: defaultValue,
|
|
80
|
-
} = props;
|
|
81
|
-
const normalizedActions = React.useMemo<NormalizedAction[]>(
|
|
82
|
-
() =>
|
|
83
|
-
actions.map((action) =>
|
|
84
|
-
typeof action === 'string'
|
|
85
|
-
? { name: action, value: action }
|
|
86
|
-
: {
|
|
87
|
-
name: action.name,
|
|
88
|
-
value: action.style ?? action.name,
|
|
89
|
-
},
|
|
90
|
-
),
|
|
91
|
-
[actions],
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const selectedActionName = React.useMemo(
|
|
95
|
-
() =>
|
|
96
|
-
normalizedActions.find((action) => isEqual(value, action.value))?.name,
|
|
97
|
-
[normalizedActions, value],
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const handleChange = React.useCallback(
|
|
101
|
-
(selectedName: string) => {
|
|
102
|
-
const selectedAction = normalizedActions.find(
|
|
103
|
-
({ name }) => name === selectedName,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
if (selectedAction) {
|
|
107
|
-
onChange(id, selectedAction.value);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
[id, normalizedActions, onChange],
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
React.useEffect(() => {
|
|
114
|
-
if (!value && defaultValue) {
|
|
115
|
-
const nextValue =
|
|
116
|
-
typeof defaultValue === 'string'
|
|
117
|
-
? normalizedActions.find(({ name }) => name === defaultValue)
|
|
118
|
-
?.value ?? defaultValue
|
|
119
|
-
: defaultValue;
|
|
120
|
-
|
|
121
|
-
onChange(id, nextValue);
|
|
122
|
-
}
|
|
123
|
-
}, [defaultValue, id, normalizedActions, onChange, value]);
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<FormFieldWrapper {...props} className="widget">
|
|
127
|
-
<RadioGroup
|
|
128
|
-
aria-label={props.title || props.label || id}
|
|
129
|
-
orientation="horizontal"
|
|
130
|
-
value={selectedActionName}
|
|
131
|
-
onChange={handleChange}
|
|
132
|
-
isDisabled={disabled || isDisabled}
|
|
133
|
-
className="buttons buttons-widget"
|
|
134
|
-
>
|
|
135
|
-
{normalizedActions.map((action) => {
|
|
136
|
-
const actionInfo = actionsInfoMap?.[action.name];
|
|
137
|
-
const [iconOrText, ariaLabel] = actionInfo ?? [
|
|
138
|
-
action.name,
|
|
139
|
-
action.name,
|
|
140
|
-
];
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<Radio
|
|
144
|
-
key={action.name}
|
|
145
|
-
aria-label={ariaLabel}
|
|
146
|
-
value={action.name}
|
|
147
|
-
className="buttons-widget-option"
|
|
148
|
-
>
|
|
149
|
-
{typeof iconOrText === 'string' ? (
|
|
150
|
-
<div className="image-sizes-text">{iconOrText}</div>
|
|
151
|
-
) : (
|
|
152
|
-
<Icon
|
|
153
|
-
name={iconOrText}
|
|
154
|
-
title={ariaLabel || action.name}
|
|
155
|
-
size="24px"
|
|
156
|
-
ariaHidden={true}
|
|
157
|
-
/>
|
|
158
|
-
)}
|
|
159
|
-
</Radio>
|
|
160
|
-
);
|
|
161
|
-
})}
|
|
162
|
-
</RadioGroup>
|
|
163
|
-
</FormFieldWrapper>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export default ButtonsWidget;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
2
|
-
import ButtonsWidget, {
|
|
3
|
-
type ActionInfo,
|
|
4
|
-
type ButtonsWidgetProps,
|
|
5
|
-
} from './Buttons';
|
|
6
|
-
import type { IntlShape } from 'react-intl';
|
|
7
|
-
import type { StyleDefinition } from '@plone/types';
|
|
8
|
-
|
|
9
|
-
const messages = defineMessages({
|
|
10
|
-
s: {
|
|
11
|
-
id: 'Small',
|
|
12
|
-
defaultMessage: 'Small',
|
|
13
|
-
},
|
|
14
|
-
m: {
|
|
15
|
-
id: 'Medium',
|
|
16
|
-
defaultMessage: 'Medium',
|
|
17
|
-
},
|
|
18
|
-
l: {
|
|
19
|
-
id: 'Large',
|
|
20
|
-
defaultMessage: 'Large',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const defaultActionsInfo = ({
|
|
25
|
-
intl,
|
|
26
|
-
}: {
|
|
27
|
-
intl: IntlShape;
|
|
28
|
-
}): Record<string, ActionInfo> => ({
|
|
29
|
-
s: ['S', intl.formatMessage(messages.s)],
|
|
30
|
-
m: ['M', intl.formatMessage(messages.m)],
|
|
31
|
-
l: ['L', intl.formatMessage(messages.l)],
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const DEFAULT_ACTIONS: StyleDefinition[] = [
|
|
35
|
-
{
|
|
36
|
-
name: 's',
|
|
37
|
-
label: 'Small',
|
|
38
|
-
style: undefined,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'm',
|
|
42
|
-
label: 'Medium',
|
|
43
|
-
style: undefined,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'l',
|
|
47
|
-
label: 'Large',
|
|
48
|
-
style: undefined,
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const SizeWidget = (props: ButtonsWidgetProps) => {
|
|
53
|
-
const intl = useIntl();
|
|
54
|
-
|
|
55
|
-
const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
|
|
56
|
-
const filteredActions =
|
|
57
|
-
filterActions && filterActions.length > 0
|
|
58
|
-
? actions.filter((action) => {
|
|
59
|
-
const actionName = typeof action === 'string' ? action : action.name;
|
|
60
|
-
return filterActions.includes(actionName);
|
|
61
|
-
})
|
|
62
|
-
: actions;
|
|
63
|
-
|
|
64
|
-
const actionsInfo = {
|
|
65
|
-
...defaultActionsInfo({ intl }),
|
|
66
|
-
...actionsInfoMap,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<ButtonsWidget
|
|
71
|
-
{...props}
|
|
72
|
-
actions={filteredActions}
|
|
73
|
-
actionsInfoMap={actionsInfo}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export default SizeWidget;
|