Skip to content

Commit

Permalink
chore: lazy loading components to improve bundle size (#4)
Browse files Browse the repository at this point in the history
* chore: lazy loading components to improve boundle size

* fix: typo

* chore: fix typo
  • Loading branch information
giuliaghisini authored Apr 8, 2024
1 parent cfe9925 commit 102445b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 20 deletions.
10 changes: 0 additions & 10 deletions src/components/FeedbackForm/Steps/Commons.jsx

This file was deleted.

14 changes: 14 additions & 0 deletions src/components/FeedbackForm/Steps/Commons/FormHeader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { useState } from 'react';
import { TextArea, Form } from 'semantic-ui-react';
import { defineMessages } from 'react-intl';

const FormHeader = ({ title, step, totalSteps, className }) => {
return (
<div className={className}>
<h6>{title}</h6>
<div>{`${step}/${totalSteps}`}</div>
</div>
);
};

export default FormHeader;
29 changes: 25 additions & 4 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
export { FormHeader } from './FeedbackForm/Steps/Commons';
export FeedbackForm from './FeedbackForm/FeedbackForm';
export AnswersStep from './FeedbackForm/Steps/AnswersStep';
export CommentsStep from './FeedbackForm/Steps/CommentsStep';
import loadable from '@loadable/component';

/*--------------------------------
--- BUNDLE VoltoFeedbackView ---
---------------------------------*/
export const FormHeader = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackView" */ './FeedbackForm/Steps/Commons/FormHeader'
),
);
export const FeedbackForm = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackView" */ './FeedbackForm/FeedbackForm'
),
);
export const AnswersStep = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackView" */ './FeedbackForm/Steps/AnswersStep'
),
);
export const CommentsStep = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackView" */ './FeedbackForm/Steps/CommentsStep'
),
);
23 changes: 19 additions & 4 deletions src/components/manage/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
export VFPanel from './VFPanel/VFPanel';
export VFPanelMenu from './VFPanel/VFPanelMenu';
export FeedbackComments from './VFPanel/FeedbackComments';
export VFToolbar from './VFToolbar';
import loadable from '@loadable/component';

/*--------------------------------
--- BUNDLE VoltoFeedbackManage ---
---------------------------------*/
export const VFPanel = loadable(() =>
import(/* webpackChunkName: "VoltoFeedbackManage" */ './VFPanel/VFPanel'),
);
export const VFPanelMenu = loadable(() =>
import(/* webpackChunkName: "VoltoFeedbackManage" */ './VFPanel/VFPanelMenu'),
);
export const FeedbackComments = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackManage" */ './VFPanel/FeedbackComments'
),
);
export const VFToolbar = loadable(() =>
import(/* webpackChunkName: "VoltoFeedbackManage" */ './VFToolbar'),
);
15 changes: 13 additions & 2 deletions src/components/widgets/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
export HoneypotWidget from './HoneypotWidget/HoneypotWidget';
export GoogleReCaptchaWidget from './GoogleReCaptchaWidget';
import loadable from '@loadable/component';

/*--------------------------------
--- BOUNDLE VoltoFeedbackView ---
---------------------------------*/
export const HoneypotWidget = loadable(() =>
import(
/* webpackChunkName: "VoltoFeedbackView" */ './HoneypotWidget/HoneypotWidget'
),
);
export const GoogleReCaptchaWidget = loadable(() =>
import(/* webpackChunkName: "VoltoFeedbackView" */ './GoogleReCaptchaWidget'),
);
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export {
generateFeedbackCommentUUID,
getNumberOfSteps,
} from 'volto-feedback/helpers';

export {
GoogleReCaptchaWidget,
HoneypotWidget,
Expand Down

0 comments on commit 102445b

Please sign in to comment.