@griddo/ax 1.62.8 → 1.63.2

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.
Files changed (86) hide show
  1. package/package.json +19 -15
  2. package/src/GlobalStore.tsx +1 -1
  3. package/src/Style/index.tsx +2 -0
  4. package/src/api/pages.tsx +20 -0
  5. package/src/api/utils.tsx +5 -2
  6. package/src/components/Browser/index.tsx +144 -39
  7. package/src/components/Browser/style.tsx +47 -11
  8. package/src/components/ConfigPanel/index.tsx +3 -3
  9. package/src/components/Fields/CheckField/index.tsx +0 -2
  10. package/src/components/Fields/RadioField/index.tsx +1 -1
  11. package/src/components/Fields/RichText/index.tsx +2 -2
  12. package/src/components/Fields/UrlField/utils.tsx +10 -1
  13. package/src/components/Icon/components/Desktop.js +9 -4
  14. package/src/components/Icon/components/Phone.js +4 -4
  15. package/src/components/Icon/components/Share.js +12 -0
  16. package/src/components/Icon/components/Tablet.js +4 -4
  17. package/src/components/Icon/svgs/Share.svg +3 -0
  18. package/src/components/MainWrapper/AppBar/index.tsx +19 -7
  19. package/src/components/MainWrapper/AppBar/style.tsx +20 -4
  20. package/src/components/MainWrapper/index.tsx +1 -1
  21. package/src/components/SideModal/index.tsx +1 -1
  22. package/src/components/TableFilters/DateFilter/index.tsx +48 -0
  23. package/src/components/TableFilters/DateFilter/style.tsx +29 -0
  24. package/src/components/TableFilters/index.tsx +2 -0
  25. package/src/components/Tabs/index.tsx +17 -7
  26. package/src/components/Tabs/style.tsx +29 -16
  27. package/src/components/Tooltip/index.tsx +1 -1
  28. package/src/components/Tooltip/style.tsx +2 -0
  29. package/src/components/index.tsx +2 -0
  30. package/src/containers/App/reducer.tsx +3 -1
  31. package/src/containers/PageEditor/actions.tsx +65 -10
  32. package/src/containers/Settings/DataPacks/actions.tsx +4 -1
  33. package/src/containers/Sites/actions.tsx +3 -1
  34. package/src/helpers/dates.tsx +3 -4
  35. package/src/helpers/index.tsx +2 -0
  36. package/src/helpers/strings.tsx +38 -7
  37. package/src/index.tsx +2 -3
  38. package/src/modules/App/Routing/index.tsx +1 -1
  39. package/src/modules/Content/OptionTable/index.tsx +29 -2
  40. package/src/modules/Content/PageItem/index.tsx +11 -2
  41. package/src/modules/Content/index.tsx +9 -0
  42. package/src/modules/GlobalEditor/Editor/index.tsx +7 -9
  43. package/src/modules/GlobalEditor/{Editor/PageBrowser → PageBrowser}/index.tsx +14 -6
  44. package/src/modules/GlobalEditor/Preview/index.tsx +19 -0
  45. package/src/modules/GlobalEditor/Preview/style.tsx +9 -0
  46. package/src/modules/GlobalEditor/index.tsx +36 -9
  47. package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +5 -1
  48. package/src/modules/PageEditor/Editor/index.tsx +5 -5
  49. package/src/modules/PageEditor/{Editor/PageBrowser → PageBrowser}/index.tsx +11 -4
  50. package/src/modules/PageEditor/Preview/index.tsx +14 -0
  51. package/src/modules/PageEditor/Preview/style.tsx +9 -0
  52. package/src/modules/PageEditor/index.tsx +39 -16
  53. package/src/modules/PublicPreview/index.tsx +92 -0
  54. package/src/modules/PublicPreview/style.tsx +18 -0
  55. package/src/modules/Redirects/BulkHeader/TableHeader/index.tsx +16 -3
  56. package/src/modules/Redirects/BulkHeader/TableHeader/style.tsx +9 -3
  57. package/src/modules/Redirects/BulkHeader/index.tsx +7 -1
  58. package/src/modules/Redirects/RedirectItem/index.tsx +4 -0
  59. package/src/modules/Redirects/RedirectItem/style.tsx +19 -3
  60. package/src/modules/Redirects/atoms.tsx +0 -1
  61. package/src/modules/Redirects/hooks.tsx +67 -0
  62. package/src/modules/Redirects/index.tsx +23 -9
  63. package/src/modules/Redirects/utils.tsx +10 -0
  64. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/Field/index.tsx +107 -0
  65. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/Field/style.tsx +54 -0
  66. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/index.tsx +66 -0
  67. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/style.tsx +42 -0
  68. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +58 -0
  69. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +41 -0
  70. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +93 -0
  71. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/style.tsx +25 -0
  72. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/index.tsx +48 -0
  73. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/style.tsx +53 -0
  74. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +40 -36
  75. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/style.tsx +4 -5
  76. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +4 -4
  77. package/src/modules/Settings/ContentTypes/DataPacks/index.tsx +5 -1
  78. package/src/modules/Settings/{Analytics → SeoAnalyticsSettings/Analytics}/atoms.tsx +0 -0
  79. package/src/modules/Settings/{Analytics → SeoAnalyticsSettings/Analytics}/index.tsx +20 -11
  80. package/src/modules/Settings/{Analytics → SeoAnalyticsSettings/Analytics}/style.tsx +6 -0
  81. package/src/modules/Settings/{SeoSettings → SeoAnalyticsSettings}/index.tsx +11 -4
  82. package/src/react-app-env.d.ts +0 -2
  83. package/src/routes/publicRoutes.tsx +3 -1
  84. package/src/routes/site.tsx +14 -10
  85. package/src/types/index.tsx +9 -0
  86. package/tsconfig.json +1 -0
@@ -0,0 +1,107 @@
1
+ import React from "react";
2
+
3
+ import { useModal } from "@ax/hooks";
4
+ import { SideModal, ActionMenu } from "@ax/components";
5
+
6
+ import * as S from "./style";
7
+
8
+ const pageEditorID = 0;
9
+
10
+ const Field = (props: IField): JSX.Element => {
11
+ const {
12
+ type,
13
+ template,
14
+ defaults,
15
+ updateEditorContent,
16
+ content,
17
+ updateDataPackFormValue,
18
+ dataPackConfigFormData,
19
+ theme,
20
+ } = props;
21
+ const { isOpen, toggleModal } = useModal();
22
+ const options = defaults.filter((component: any) =>
23
+ component.type === type && content[component.type]?.id !== component.id && !component.setAsDefault
24
+ );
25
+ const optionsType = `${type}s`;
26
+
27
+ const actionMenuOptions = [
28
+ {
29
+ label: "replace",
30
+ icon: "change",
31
+ action: toggleModal,
32
+ },
33
+ ];
34
+
35
+ const actionMenuIcon = "more";
36
+
37
+ const handleReplace = (option: any) => {
38
+ const configFormData = {
39
+ ...dataPackConfigFormData,
40
+ templates: {
41
+ ...dataPackConfigFormData.templates,
42
+ [template]: {
43
+ ...(!!dataPackConfigFormData.templates && dataPackConfigFormData.templates[template]),
44
+ ...(type === "header" && { defaultHeader: option.id }),
45
+ ...(type === "footer" && { defaultFooter: option.id }),
46
+ }
47
+ },
48
+ }
49
+ updateDataPackFormValue(configFormData);
50
+ updateEditorContent(pageEditorID, type, option.id);
51
+ toggleModal();
52
+ };
53
+
54
+ const isDefaultNavigation = () => {
55
+ const defaultType = type === "header" ? "defaultHeader" : "defaultFooter";
56
+ const templateNavigation = dataPackConfigFormData.templates && dataPackConfigFormData.templates[template]
57
+ const templateDefaultNavigation = templateNavigation && templateNavigation[defaultType];
58
+ if (!templateDefaultNavigation) return true;
59
+ const siteDefaultNavigation = defaults.find((navigation: any) => navigation.id === templateDefaultNavigation);
60
+ return !!siteDefaultNavigation?.isDefault;
61
+ }
62
+
63
+ const setDefault = {
64
+ title: `Put the default ${type}`,
65
+ action: () => handleReplace({ id: null }),
66
+ checked: isDefaultNavigation(),
67
+ }
68
+
69
+ const hasOptions: boolean | undefined = options?.length > 0 || !isDefaultNavigation();
70
+
71
+ if (!content[type]) return <></>;
72
+
73
+ return (
74
+ <>
75
+ <S.Component isArray disabled>
76
+ <S.Label>{content[type].title}</S.Label>
77
+ <S.HiddenButtonsWrapper>
78
+ {hasOptions && <ActionMenu options={actionMenuOptions} icon={actionMenuIcon} />}
79
+ </S.HiddenButtonsWrapper>
80
+ </S.Component>
81
+ {hasOptions && (
82
+ <SideModal
83
+ optionsType={optionsType}
84
+ whiteList={options}
85
+ handleClick={handleReplace}
86
+ toggleModal={toggleModal}
87
+ isOpen={isOpen}
88
+ setDefault={setDefault}
89
+ theme={theme}
90
+ />
91
+ )}
92
+ </>
93
+ )
94
+ }
95
+
96
+ interface IField {
97
+ type: string;
98
+ template: string;
99
+ defaults: any;
100
+ content: any,
101
+ dataPackConfigFormData: any;
102
+ theme: string;
103
+ updateEditorContent: (selectedEditorID: number, key: string, value: any) => void;
104
+ updateDataPackFormValue: (value: any) => void;
105
+ }
106
+
107
+ export { Field }
@@ -0,0 +1,54 @@
1
+ import styled from "styled-components";
2
+
3
+ const HiddenButtonsWrapper = styled.span`
4
+ margin-left: auto;
5
+ display: none;
6
+ opacity: 0;
7
+ `;
8
+
9
+ const Component = styled.span<{ isArray?: boolean | undefined; disabled?: boolean }>`
10
+ color: ${p => p.theme.color.textHighEmphasis};
11
+ position: relative;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: ${p => p.isArray ? "space-between" : "initial"};
15
+ width: 100%;
16
+ height: ${p => p.theme.spacing.l};
17
+ background: ${p => p.theme.color.uiBackground02};
18
+ border: 1px solid transparent;
19
+ margin-bottom: ${p => p.theme.spacing.xs};
20
+ padding: 0 ${p => p.theme.spacing.xs};
21
+ border-radius: ${p => p.theme.radii.s};
22
+ box-shadow: ${p => p.theme.shadow.shadowS};
23
+ ${p => p.theme.textStyle.fieldLabel};
24
+ text-align: left;
25
+ cursor: ${p => p.disabled ? `default` : `pointer`};
26
+
27
+ &:hover {
28
+ background: ${p => p.theme.color.overlayHoverPrimary};
29
+ }
30
+
31
+ &:hover ${HiddenButtonsWrapper}{
32
+ display: flex;
33
+ opacity: 1;
34
+ }
35
+
36
+ &:focus,
37
+ &:active {
38
+ background: ${p => p.disabled ? p.theme.color.uiBackground02 : p.theme.color.overlayFocusPrimary};
39
+ border: 1px solid ${p => p.disabled ? `transparent` : p.theme.color.interactive01};
40
+ outline: none;
41
+ }
42
+ `;
43
+
44
+ const Label = styled.span`
45
+ ${p => p.theme.textStyle.fieldLabel};
46
+ color: ${p => p.theme.color.textHighEmphasis};
47
+ margin-left: ${p => p.theme.spacing.xs};
48
+ `;
49
+
50
+ export {
51
+ HiddenButtonsWrapper,
52
+ Component,
53
+ Label,
54
+ };
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { IRootState } from "@ax/types";
5
+ import { Loading } from "@ax/components";
6
+ import { pageEditorActions } from "@ax/containers/PageEditor";
7
+ import { dataPacksActions } from "@ax/containers/Settings";
8
+
9
+ import { Field } from "./Field";
10
+ import * as S from "./style";
11
+
12
+ const navigationTypes = ["header", "footer"];
13
+
14
+ const ConfigPanel = (props: IProps): JSX.Element => {
15
+ const {
16
+ isLoading,
17
+ template,
18
+ ...rest
19
+ } = props;
20
+
21
+ if (isLoading && !template) return <Loading />;
22
+
23
+ return (
24
+ <>
25
+ <S.HeaderWrapper>
26
+ <S.Title>{template}</S.Title>
27
+ </S.HeaderWrapper>
28
+ <S.Tab>Config</S.Tab>
29
+ <S.FieldsWrapper>
30
+ <S.FieldsTitle>Default modules</S.FieldsTitle>
31
+ {navigationTypes.map((type, idx) => (
32
+ <Field key={idx} type={type} template={template} {...rest} />
33
+ ))}
34
+ </S.FieldsWrapper>
35
+ </>
36
+ );
37
+ };
38
+
39
+ interface IStateProps {
40
+ isLoading: boolean;
41
+ template: string;
42
+ defaults: any;
43
+ content: any;
44
+ dataPackConfigFormData: any;
45
+ theme: string;
46
+ }
47
+
48
+ interface IDispatchProps {
49
+ updateEditorContent: (selectedEditorID: number, key: string, value: any) => void;
50
+ updateDataPackFormValue: (value: any) => void;
51
+ }
52
+
53
+ type IProps = IStateProps & IDispatchProps;
54
+
55
+ const mapStateToProps = (state: IRootState) => ({
56
+ defaults: state.navigation.currentDefaultsContent,
57
+ content: { ...state.pageEditor.editorContent },
58
+ dataPackConfigFormData: state.dataPacks.configFormData,
59
+ });
60
+
61
+ const mapDispatchToProps = {
62
+ updateEditorContent: pageEditorActions.updateEditorContent,
63
+ updateDataPackFormValue: dataPacksActions.updateFormValue,
64
+ };
65
+
66
+ export default connect(mapStateToProps, mapDispatchToProps)(ConfigPanel);
@@ -0,0 +1,42 @@
1
+ import styled from "styled-components";
2
+
3
+ const HeaderWrapper = styled.div`
4
+ display: flex;
5
+ flex-direction: column;
6
+ position: relative;
7
+ `;
8
+
9
+ const Title = styled.p`
10
+ ${(p) => p.theme.textStyle.headingS};
11
+ margin-bottom: ${(p) => p.theme.spacing.xs};
12
+ `;
13
+
14
+ const Tab = styled.div`
15
+ border-bottom: ${p => `1px solid ${p.theme.color.uiLine}`};
16
+ margin: ${p => p.theme.spacing.s} 0;
17
+ padding-bottom: ${p => p.theme.spacing.s};
18
+ ${(p) => p.theme.textStyle.headingXS};
19
+ color: ${p => p.theme.color.textHighEmphasis};
20
+ text-align: center;
21
+ `;
22
+
23
+ const FieldsWrapper = styled.div`
24
+ margin: ${(p) => `${p.theme.spacing.m} 0 ${p.theme.spacing.m} 0`};
25
+ `;
26
+
27
+ const FieldsTitle = styled.div`
28
+ position: relative;
29
+ ${(p) => p.theme.textStyle.headingXXS};
30
+ color: ${(p) => p.theme.colors.textMediumEmphasis};
31
+ padding-bottom: ${(p) => p.theme.spacing.xs};
32
+ margin-bottom: ${(p) => p.theme.spacing.m};
33
+ border-bottom: 1px solid ${(p) => p.theme.color.uiLine};
34
+ `;
35
+
36
+ export {
37
+ HeaderWrapper,
38
+ Title,
39
+ Tab,
40
+ FieldsWrapper,
41
+ FieldsTitle,
42
+ };
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { Browser } from "@ax/components";
5
+ import { ILanguage, IRootState, ISocialState } from "@ax/types";
6
+
7
+ const TemplateBrowser = (props: IProps) => {
8
+ const {
9
+ socials,
10
+ cloudinaryName,
11
+ damDomain,
12
+ content: { editorContent, header, footer },
13
+ selectedEditorID,
14
+ currentSiteInfo: { theme, id: siteID },
15
+ siteLangs,
16
+ } = props;
17
+
18
+ const updatedContent = { ...editorContent };
19
+
20
+ return (
21
+ <Browser
22
+ isPage={true}
23
+ socials={socials}
24
+ content={updatedContent}
25
+ selectedEditorID={selectedEditorID}
26
+ url=""
27
+ theme={theme}
28
+ cloudinaryName={cloudinaryName}
29
+ damDomain={damDomain}
30
+ siteLangs={siteLangs}
31
+ siteID={siteID}
32
+ header={header}
33
+ footer={footer}
34
+ />
35
+ );
36
+ };
37
+
38
+ interface IProps {
39
+ content: any;
40
+ selectedEditorID: number;
41
+ currentSiteInfo: any;
42
+ socials: ISocialState;
43
+ cloudinaryName: string | null;
44
+ damDomain: string | null;
45
+ siteLangs: ILanguage[];
46
+ }
47
+
48
+ const mapStateToProps = (state: IRootState): IProps => ({
49
+ content: { ...state.pageEditor.editorContent },
50
+ selectedEditorID: state.navigation.selectedEditorID as number,
51
+ currentSiteInfo: state.sites.currentSiteInfo,
52
+ socials: state.social,
53
+ cloudinaryName: state.app.globalSettings.cloudinaryName,
54
+ damDomain: state.app.globalSettings.damDomain,
55
+ siteLangs: state.sites.currentSiteLanguages,
56
+ });
57
+
58
+ export default connect(mapStateToProps)(TemplateBrowser);
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+ import { themes } from "components";
4
+
5
+ import { ResizePanel } from "@ax/components";
6
+ import { IRootState } from "@ax/types";
7
+
8
+ import TemplateBrowser from "./TemplateBrowser";
9
+ import ConfigPanel from "./ConfigPanel";
10
+
11
+ const Editor = (props: IProps) => {
12
+ const { isLoading, template } = props;
13
+
14
+ const defaultTheme = themes.find((theme: any) => theme.default);
15
+ const theme = defaultTheme ? defaultTheme.value : themes[0].value;
16
+
17
+ return (
18
+ <ResizePanel
19
+ leftPanel={<TemplateBrowser />}
20
+ rightPanel={
21
+ <ConfigPanel
22
+ template={template}
23
+ isLoading={isLoading}
24
+ theme={theme}
25
+ />
26
+ }
27
+ />
28
+ );
29
+ };
30
+
31
+ type IProps = {
32
+ isLoading: boolean;
33
+ template: string;
34
+ }
35
+
36
+ const mapStateToProps = (state: IRootState): IProps => ({
37
+ isLoading: state.app.isLoading,
38
+ template: state.pageEditor.template,
39
+ });
40
+
41
+ export default connect(mapStateToProps)(Editor);
@@ -0,0 +1,93 @@
1
+ import React, { useEffect } from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { IRootState } from "@ax/types";
5
+ import { useIsDirty } from "@ax/hooks";
6
+ import { RouteLeavingGuard } from "@ax/guards";
7
+ import { ErrorToast, Loading, MainWrapper } from "@ax/components";
8
+ import { appActions } from "@ax/containers/App";
9
+ import { dataPacksActions } from "@ax/containers/Settings";
10
+
11
+ import Editor from "./Editor";
12
+ import * as S from "./style";
13
+
14
+ const TemplateEditor = (props: IProps) => {
15
+ const {
16
+ isLoading,
17
+ isSaving,
18
+ editorContent,
19
+ setHistoryPush,
20
+ template,
21
+ updateDataPack,
22
+ dataPackSelected,
23
+ } = props;
24
+
25
+ const { isDirty, setIsDirty } = useIsDirty(editorContent);
26
+
27
+ const rightButtonProps = {
28
+ label: !isDirty ? "Saved" : isSaving ? "Saving" : "Save",
29
+ disabled: isSaving || !isDirty,
30
+ action: async () => {
31
+ await updateDataPack(dataPackSelected.id);
32
+ setIsDirty(false);
33
+ },
34
+ };
35
+
36
+ const leavingGuardText = (
37
+ <>
38
+ Some content <strong>is not saved</strong> on this page.
39
+ </>
40
+ );
41
+
42
+ const goBack = (path: string) => setHistoryPush(path);
43
+
44
+ return isLoading && !template ? (
45
+ <Loading />
46
+ ) : (
47
+ <>
48
+ <RouteLeavingGuard when={isDirty} action={goBack} text={leavingGuardText} />
49
+ <MainWrapper
50
+ title={template}
51
+ backLink={true}
52
+ rightButton={rightButtonProps}
53
+ fixedAppBar={true}
54
+ fullWidth={true}
55
+ >
56
+ <ErrorToast size="l" />
57
+ <S.Content>
58
+ <Editor />
59
+ </S.Content>
60
+ </MainWrapper>
61
+ </>
62
+ );
63
+ };
64
+
65
+ const mapStateToProps = (state: IRootState) => ({
66
+ isLoading: state.app.isLoading,
67
+ isSaving: state.app.isSaving,
68
+ editorContent: state.pageEditor.editorContent,
69
+ template: state.pageEditor.template,
70
+ dataPackSelected: state.dataPacks.selected,
71
+ });
72
+
73
+ interface IStateProps {
74
+ isLoading: boolean;
75
+ isSaving: boolean;
76
+ editorContent: any;
77
+ template: string;
78
+ dataPackSelected: any;
79
+ }
80
+
81
+ const mapDispatchToProps = {
82
+ setHistoryPush: appActions.setHistoryPush,
83
+ updateDataPack: dataPacksActions.updateDataPack,
84
+ };
85
+
86
+ interface IDispatchProps {
87
+ setHistoryPush(path: string, isEditor?: boolean): void;
88
+ updateDataPack: (dataPack?: any) => Promise<void>;
89
+ }
90
+
91
+ type IProps = IStateProps & IDispatchProps;
92
+
93
+ export default connect(mapStateToProps, mapDispatchToProps)(TemplateEditor);
@@ -0,0 +1,25 @@
1
+ import styled from "styled-components";
2
+
3
+ const Content = styled.section`
4
+ display: flex;
5
+ min-height: 100%;
6
+ `;
7
+
8
+ const NotificationWrapper = styled.div`
9
+ position: fixed;
10
+ width: 100%;
11
+ top: ${p => `calc(${p.theme.spacing.s} * 4)`};
12
+ left: 0;
13
+ right: 0;
14
+ z-index: 1100;
15
+ `;
16
+
17
+ const ModalContent = styled.div`
18
+ padding: ${p => p.theme.spacing.m};
19
+ `;
20
+
21
+ export {
22
+ Content,
23
+ NotificationWrapper,
24
+ ModalContent
25
+ }
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { ITemplate } from "@ax/types";
5
+ import { appActions } from "@ax/containers/App";
6
+ import { pageEditorActions } from "@ax/containers/PageEditor";
7
+
8
+ import * as S from "./style";
9
+
10
+ const TemplateConfig = (props: IProps): React.ReactElement => {
11
+ const { setHistoryPush, templates, getTemplatePage } = props;
12
+
13
+ const goToEditor = async (template: ITemplate) => {
14
+ await getTemplatePage(template.id);
15
+ setHistoryPush("/sites/settings/content-types/editor", true);
16
+ };
17
+
18
+ return (
19
+ <>
20
+ <S.Heading>Template configuration</S.Heading>
21
+ <S.Text>
22
+ {"You can set custom settings in these templates and will be shown by default. However, they can be modified on the page's editor."}
23
+ </S.Text>
24
+ <S.TemplatesWrapper>
25
+ {templates &&
26
+ templates.map((template: ITemplate, key: number) => (
27
+ <S.TemplateCard key={`${key}${template.title}`} onClick={() => goToEditor(template)}>
28
+ {template.thumbnails && <S.TemplateThumbnail backgroundUrl={template.thumbnails["2x"]} />}
29
+ <S.TemplateCardTitle>{template.title}</S.TemplateCardTitle>
30
+ </S.TemplateCard>
31
+ ))}
32
+ </S.TemplatesWrapper>
33
+ </>
34
+ )
35
+ }
36
+
37
+ interface IProps {
38
+ templates: ITemplate[];
39
+ setHistoryPush(path: string, isEditor?: boolean): void;
40
+ getTemplatePage: (template: string) => Promise<void>;
41
+ }
42
+
43
+ const mapDispatchToProps = {
44
+ setHistoryPush: appActions.setHistoryPush,
45
+ getTemplatePage: pageEditorActions.getTemplatePage,
46
+ };
47
+
48
+ export default connect(null, mapDispatchToProps)(TemplateConfig);
@@ -0,0 +1,53 @@
1
+ import styled from "styled-components";
2
+
3
+ const TemplatesWrapper = styled.div`
4
+ display: grid;
5
+ grid-template-columns: repeat(3, 1fr);
6
+ grid-gap: ${p => p.theme.spacing.xs};
7
+ padding: ${p => p.theme.spacing.m} 0;
8
+ `;
9
+
10
+ const TemplateCard = styled.div`
11
+ display: flex;
12
+ align-items: center;
13
+ padding: ${(p) => p.theme.spacing.s};
14
+ background-color: ${(p) => p.theme.color.interactiveBackground};
15
+ border-radius: ${p => p.theme.radii.s};
16
+ border: 1px solid ${(p) => p.theme.color.uiLine};
17
+ cursor: pointer;
18
+ `;
19
+
20
+ const TemplateCardTitle = styled.div`
21
+ ${p => p.theme.textStyle.uiMSemibold};
22
+ color: ${p => p.theme.color.textHighEmphasis};
23
+ `;
24
+
25
+ const TemplateThumbnail = styled.div<{ backgroundUrl: string }>`
26
+ background: url(${p => p.backgroundUrl}) no-repeat;
27
+ background-size: cover;
28
+ background-position: top;
29
+ min-height: 86px;
30
+ width: 63px;
31
+ margin-right: ${(p) => p.theme.spacing.s};
32
+ `;
33
+
34
+ const Heading = styled.div`
35
+ ${(p) => p.theme.textStyle.headingXS};
36
+ color: ${(p) => p.theme.color.textHighEmphasis};
37
+ padding-bottom: ${(p) => p.theme.spacing.xs};
38
+ `;
39
+
40
+ const Text = styled.div`
41
+ ${(p) => p.theme.textStyle.uiM};
42
+ color: ${(p) => p.theme.color.textMediumEmphasis};
43
+ width: calc(${(p) => p.theme.spacing.l} * 12);
44
+ `;
45
+
46
+ export {
47
+ TemplateCard,
48
+ TemplateCardTitle,
49
+ TemplateThumbnail,
50
+ TemplatesWrapper,
51
+ Heading,
52
+ Text,
53
+ }