Skip to content

Commit

Permalink
migrate to React 18
Browse files Browse the repository at this point in the history
  • Loading branch information
ist149372 committed Mar 25, 2022
1 parent dabeda0 commit 509a189
Show file tree
Hide file tree
Showing 50 changed files with 1,123 additions and 1,386 deletions.
5 changes: 3 additions & 2 deletions microfrontend-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
"axios": "^0.25.0",
"html-react-parser": "^1.4.8",
"openseadragon": "^3.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.0.0-rc.3",
"react-dom": "^18.0.0-rc.3",
"react-modal": "^3.14.4",
"react-router-dom": "^6.2.1",
"react-tooltip": "^4.2.21",
"zustand": "^3.6.9"
},
"devDependencies": {
"@vitejs/plugin-react": "^1.0.7",
"@vitejs/plugin-react-refresh": "^1.3.6",
"vite": "^2.7.2"
}
}
13 changes: 8 additions & 5 deletions microfrontend-vite/src/AppRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import NoPage from './pages/NoPage';
import Home from './microfrontends/home/Home';
import { getUser } from './microfrontends/user/api/users';
import './resources/css/app.css';
import { getToken, isAuthenticated, logout, setError, storeStateSelector } from './store';
import {
getToken,
isAuthenticated,
logout,
setError,
storeStateSelector,
} from './store';

const UserRouter = lazy(() => import('./microfrontends/user/UserRouter'));
const AboutRouter = lazy(() => import('./microfrontends/about/AboutRouter'));
Expand All @@ -26,7 +32,6 @@ const EditionRouter = lazy(() =>
);
const SearchRouter = lazy(() => import('./microfrontends/search/SearchRouter'));


function App() {
const navigate = useNavigate();
const error = storeStateSelector('error');
Expand All @@ -37,9 +42,7 @@ function App() {
setError();
}, [error]);



useEffect(async () => {
useEffect(() => {
getToken() &&
getUser()
.then(() => isAuthenticated() && navigate('/', { replace: true }))
Expand Down
Empty file.
12 changes: 6 additions & 6 deletions microfrontend-vite/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from 'react-dom/client';
import AppRouter from './AppRouter';
import { BrowserRouter as Router } from 'react-router-dom'
import { BrowserRouter as Router } from 'react-router-dom';

const root = ReactDOM.createRoot(document.getElementById('root'));

ReactDOM.render(
root.render(
<Router basename={import.meta.env.VITE_BASE_PATH}>
<AppRouter />
</Router>,
document.getElementById('root')
<AppRouter />
</Router>
);
72 changes: 49 additions & 23 deletions microfrontend-vite/src/microfrontends/about/AboutRouter.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Route, Routes } from 'react-router-dom';
import { lazy } from 'react';
import { lazy, Suspense } from 'react';
import './resources/about.css';
import messages from './resources/constants';

// TODO: dependecy from Home MFE
import HomeInfo from '../home/HomeInfo';
import { storeStateSelector } from '../../store';
import { getLanguage, storeStateSelector } from '../../store';

const Archive = lazy(() => import('./pages/archive/Archive'));
const Videos = lazy(() => import('./pages/videos/Videos'));
Expand All @@ -20,39 +20,65 @@ const Team = lazy(() => import('./pages/team/Team'));
const Ack = lazy(() => import('./pages/Ack/Ack'));
const Copyright = lazy(() => import('./pages/copyright/Copyright'));

const scroll = (ref) => {
const section = document.querySelector(ref);
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
};

const getLazyContact = (lang) => {
const Contact = () => messages[lang]['contact'];
return <Contact />;
};

export default () => {
const language = storeStateSelector('language')
const Contact = () => messages?.[language]['contact'];

const scroll = (ref) => {
const section = document.querySelector(ref);
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
};
const language = storeStateSelector('language');

return (
<div className="ldod-default">
<div className="container">
<div className="col-md-8 col-md-offset-2 ldod-about">
<Routes>
<Route path="archive" element={<Archive />} />
<Route path="videos" element={<Videos scroll={scroll} />} />
<Route path="tutorials" element={<Tutorials scroll={scroll} />} />
<Route path="faq" element={<Faq scroll={scroll} />} />
<Route path="encoding" element={<Encoding />} />
<Route path="articles" element={<Articles scroll={scroll} />} />
<Route path="book" element={<Book />} />
<Route path="conduct" element={<Conduct messages={messages} language={language}/>} />
<Route path="privacy" element={<Privacy />} />
<Route path="team" element={<Team />} />
<Route path="acknowledgements" element={<Ack />} />
<Route path="contact" element={<Contact />} />
<Route path="copyright" element={<Copyright />} />
<Route path="archive" element={<Archive language={language} />} />
<Route
path="videos"
element={<Videos scroll={scroll} language={language} />}
/>
<Route
path="tutorials"
element={<Tutorials scroll={scroll} language={language} />}
/>
<Route
path="faq"
element={<Faq scroll={scroll} language={language} />}
/>
<Route path="encoding" element={<Encoding language={language} />} />
<Route
path="articles"
element={<Articles scroll={scroll} language={language} />}
/>
<Route path="book" element={<Book language={language} />} />
<Route
path="conduct"
element={<Conduct messages={messages} language={language} />}
/>
<Route path="privacy" element={<Privacy language={language} />} />
<Route
path="team"
element={<Team scroll={scroll} language={language} />}
/>
<Route
path="acknowledgements"
element={<Ack language={language} />}
/>
<Route
path="copyright"
element={<Copyright language={language} />}
/>
<Route path="contact" element={<>{getLazyContact(language)}</>} />
</Routes>
</div>
<div className="ldod-default col-md-8 col-md-offset-2 ldod-about">
<HomeInfo info={messages[language].info} />
<HomeInfo info={messages[getLanguage()].info} />
</div>
</div>
<div className="bottom-bar"></div>
Expand Down
58 changes: 20 additions & 38 deletions microfrontend-vite/src/microfrontends/about/pages/Ack/Ack-en.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';

export default ({ posY, scroll }) => {
useEffect(() => window.scrollTo({ top: posY }));
export default ({ posY }) => {
useEffect(() => window.scrollTo({ top: posY }), []);
return (
<>
<h1 className="text-center">Acknowledgements</h1>
Expand Down Expand Up @@ -85,8 +85,7 @@ export default ({ posY, scroll }) => {
(FCSH): VI Seminar “
<a
href="http://elab.fcsh.unl.pt/actividades/estranhar-pessoa-vi-seminario"
target="new"
>
target="new">
Assuntos Materiais
</a>
,” organized by the Project “Estranhar Pessoa” (Februrary 7, 2013;
Expand All @@ -98,8 +97,7 @@ export default ({ posY, scroll }) => {
organized by the Project “
<a
href="https://www.westernsydney.edu.au/writing_and_society/research/past_research_projects/creative_nation_writers_and_writing_in_the_new_media_culture"
target="new"
>
target="new">
Creative Nation: Writers and Writing in the New Media Culture
</a>
” (June 10, 2013; coords. Anna Gibbs and Maria Angel)
Expand Down Expand Up @@ -134,8 +132,7 @@ export default ({ posY, scroll }) => {
modernes (ITEM): “
<a
href="https://textualscholarship.files.wordpress.com/2015/04/programme-ests-paris-conference-2013.pdf"
target="new"
>
target="new">
Variance in Textual Scholarship and Genetic Criticism/ La variance
en philologie et dans la critique génétique
</a>
Expand All @@ -151,8 +148,7 @@ export default ({ posY, scroll }) => {
University of Coimbra, Biblioteca Geral: International Congress “
<a
href="http://www.uc.pt/bguc/500anos/Congresso_internacional"
target="new"
>
target="new">
A Biblioteca da Universidade: Permanências e Metamorfoses
</a>
” (January 16-18, 2014; coord. J. A. Cardoso Bernardes)
Expand All @@ -172,8 +168,7 @@ export default ({ posY, scroll }) => {
Los Andes University, Bogotá: International conference “
<a
href="https://ilusionymaterialidad.wordpress.com/programa-2/"
target="new"
>
target="new">
Ilusión y materialidad de los archivos literarios
</a>
, ” organized by Universidad de los Andes, Instituto Caro y Cuervo
Expand Down Expand Up @@ -202,8 +197,7 @@ export default ({ posY, scroll }) => {
University of Grenoble: Symposium “
<a
href="http://www.nedimah.eu/reports/toward-new-social-contract-between-publishers-and-editors"
target="new"
>
target="new">
Toward a New Social Contract between Publishers and Editors
</a>
,” organized by the Network for Digital Methods in the Arts and
Expand All @@ -215,8 +209,7 @@ export default ({ posY, scroll }) => {
University of Rome La Sapienza: Symposium “
<a
href="http://www.disp.let.uniroma1.it/archivionotizie/ecd/dce-edizioni-confronto/comparing-editions"
target="new"
>
target="new">
Edizioni Critiche Digitali: Edizioni a Confronto / Digital
Critical Editions: Comparing Editions
</a>
Expand All @@ -229,8 +222,7 @@ export default ({ posY, scroll }) => {
Arts: Symposium “
<a
href="https://willson.uga.edu/event/textual-machines-a-spring-symposium-exhibit/"
target="new"
>
target="new">
Textual Machines
</a>
” (April 17-18, 2015; coord. Jonathan Baillehache)
Expand All @@ -253,8 +245,7 @@ export default ({ posY, scroll }) => {
University of Gothemburg, Center for Digital Humanities:{' '}
<a
href="http://cdh.hum.gu.se/Aktuellt/e/?eventId=2355210788"
target="new"
>
target="new">
Seminar
</a>{' '}
(September 24, 2015; coord. Jenny Bergenmar)
Expand All @@ -264,8 +255,7 @@ export default ({ posY, scroll }) => {
(FCSH): International congress “
<a
href="https://congressohdpt.wordpress.com/programa/"
target="new"
>
target="new">
Humanidades Digitais em Portugal: Construir Pontes e Quebrar
Barreiras na Era Digital
</a>
Expand All @@ -276,23 +266,20 @@ export default ({ posY, scroll }) => {
(CHSC): International conference “
<a
href="http://ahlist.org/conferences/2015-ahlist-coimbra/program/"
target="new"
>
target="new">
Consilience and Inclusion: Scientific and Cultural Encounters
</a>
<a
href="http://ahlist.org/conferences/2015-ahlist-coimbra/"
target="new"
></a>
target="new"></a>
,” organized by the Association of History, Literature, Science, and
Technology (November 19-21, 2015; coord. Yonsoo Kim)
</li>
<li>
University of Coimbra, School of Economics: Colloquium “
<a
href="https://www.uc.pt/feuc/noticias/2015/novembro15/20151123"
target="new"
>
target="new">
On/Off: Navegando pelas Culturas Digitais, Tecnologia e
Conhecimento
</a>
Expand Down Expand Up @@ -329,8 +316,7 @@ export default ({ posY, scroll }) => {
University of Pisa, Informatica Umanistica:{' '}
<a
href="http://www.labcd.unipi.it/seminari/silvestre-a-digital-archive-of-fernando-pessoa/"
target="new"
>
target="new">
Seminario di Cultura Digitale
</a>{' '}
(December 7, 2016; coord. Enrica Salvatori)
Expand All @@ -342,8 +328,7 @@ export default ({ posY, scroll }) => {
University of Lisbon, School of Arts and Humanities:{' '}
<a
href="http://www.letras.ulisboa.pt/pt/agenda/conferencia-reimaginar-a-edicao-digital-no-arquivo-livro-do-desassossego"
target="new"
>
target="new">
Lecture for the Program in Textual Criticism
</a>
(January 24, 2017; coords. Esperança Cardeira, Cristina Sobral and
Expand All @@ -354,8 +339,7 @@ export default ({ posY, scroll }) => {
and Information Studies:{' '}
<a
href="https://is.gseis.ucla.edu/research/colloquium/"
target="new"
>
target="new">
Colloquium: Breslauer lecture series
</a>{' '}
(February 2, 2017; coord. Johanna Drucker)
Expand All @@ -364,8 +348,7 @@ export default ({ posY, scroll }) => {
Calouste Gulbenkian Foundation:{' '}
<a
href="http://casafernandopessoa.cm-lisboa.pt/fileadmin/CASA_FERNANDO_PESSOA/AF_CFP_Congresso_Internacional_FP_2017_Programa_Digital_V3.pdf"
target="new"
>
target="new">
IV Congresso Internacional Fernando Pessoa
</a>
, organizaed by Casa Fernando Pessoa (February 9-11, 2017; coord.
Expand All @@ -375,8 +358,7 @@ export default ({ posY, scroll }) => {
Fernando Pessoa University, Porto: International conference “
<a
href="https://conference.eliterature.org/2017/conference"
target="new"
>
target="new">
ELO 2017: Affiliations, Communities, Translations
</a>
” (July 18-22, 2017; coords. Rui Torres and Sandy Baldwin)
Expand Down
Loading

0 comments on commit 509a189

Please sign in to comment.