Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Re-organizing files according to Rapi's suggestions #46

Merged
merged 6 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changed pageTitle to pagetitle to get rid of console error when modul…
…e is hosted on another page
  • Loading branch information
michellexliu committed Jul 28, 2021
commit e4d530b4cad698fe7fb56ccc74fa632368e39575
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Add the following code into your project:

```
<link rel="stylesheet" href="main.css" />
<div id="feedback-widget" lang="en" pageTitle="<your page name>" endpoint="<your unique id>"></div>
<div id="feedback-widget" lang="en" pagetitle="<your page name>" endpoint="<your unique id>"></div>
<script src="./feedback-module.min.js"></script>
```

Expand All @@ -89,7 +89,7 @@ Add the following code into your project:
<div
id="feedback-widget"
lang={<your page's current language>}
pageTitle="<your page name>"
title="<your page name>"
endpoint="<your unique id>"
></div>
<ScriptTag src="/feedback-module.min.js" type="text/javascript" />
Expand Down
2 changes: 1 addition & 1 deletion backend/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function (context, req) {
const body = req.body;
body.id = uniqid();

if (!body.pageTitle || body.pageTitle === "") {
if (!body.pagetitle || body.pagetitle === "") {
errorMsg("Please enter a valid page title.");
} else if (!body.agency || body.agency === "") {
errorMsg("Please enter a valid agency name.");
Expand Down
2 changes: 1 addition & 1 deletion feedback-module/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div
id="feedback-widget"
lang="en"
pageTitle="{this current page}"
pagetitle="{this current page}"
endpoint="1"
></div>
<!--
Expand Down
4 changes: 2 additions & 2 deletions feedback-module/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Helmet, HelmetProvider } from "react-helmet-async";

import Module from "./components/Module";

function App({ pageTitle, lang, endpoint }) {
function App({ pagetitle, lang, endpoint }) {
const { i18n } = useTranslation();

useEffect(() => {
Expand All @@ -22,7 +22,7 @@ function App({ pageTitle, lang, endpoint }) {
/>
</Helmet>
<Module
pageTitle={pageTitle}
pagetitle={pagetitle}
endpoint={endpoint}
dir={i18n.dir(i18n.language)}
/>
Expand Down
4 changes: 2 additions & 2 deletions feedback-module/src/components/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TextboxList from "./TextboxList";
import ErrorAlert from "./common/ErrorAlert";
import LightContainer from "./LightContainer";

function Module({ pageTitle, endpoint, dir }) {
function Module({ pagetitle, endpoint, dir }) {
const [feedbackForAPI, setFeedbackForAPI] = useState({});
const [userInfo, setUserInfo] = useState({});
const [screen, setScreen] = useState(INITIAL_SCREEN);
Expand Down Expand Up @@ -246,7 +246,7 @@ function Module({ pageTitle, endpoint, dir }) {
<LightContainer formID={screen.formID}>
{screen.title && (
<p className={`${H1_DARK_STYLE} ${dir === "rtl" && "text-right"}`}>
{`${t(screen.title, { page: pageTitle })}${
{`${t(screen.title, { page: pagetitle })}${
screen.checkboxes && screen.checkboxes.required ? "*" : ""
}`}
</p>
Expand Down
12 changes: 6 additions & 6 deletions feedback-module/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import App from "./App";

const WidgetDivs = document.querySelectorAll("#feedback-widget");

const renderApp = (Div, lang, pageTitle, endpoint) => {
const renderApp = (Div, lang, pagetitle, endpoint) => {
Div.attributes.lang && (lang = Div.attributes.lang.value);
Div.attributes.pageTitle && (pageTitle = Div.attributes.pageTitle.value);
Div.attributes.pagetitle && (pagetitle = Div.attributes.pagetitle.value);
Div.attributes.endpoint && (endpoint = Div.attributes.endpoint.value);
ReactDOM.render(
<React.StrictMode>
<Suspense fallback="... is loading">
<App
domElement={Div}
lang={lang}
pageTitle={pageTitle}
pagetitle={pagetitle}
endpoint={endpoint}
/>
</Suspense>
Expand All @@ -28,14 +28,14 @@ const renderApp = (Div, lang, pageTitle, endpoint) => {

WidgetDivs.forEach((Div) => {
let currentLang = "en";
let pageTitle = "";
let pagetitle = "";
let endpoint = "";
renderApp(Div, currentLang, pageTitle, endpoint);
renderApp(Div, currentLang, pagetitle, endpoint);

let observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type == "attributes") {
renderApp(Div, currentLang, pageTitle, endpoint);
renderApp(Div, currentLang, pagetitle, endpoint);
}
});
});
Expand Down
Loading