-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from ProjectMirador/mirador4-compat-clean
Update plugin for Mirador 4
- Loading branch information
Showing
19 changed files
with
672 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { render } from '@testing-library/react'; | ||
import PropTypes from 'prop-types'; | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import { thunk } from 'redux-thunk'; | ||
import { createTheme, ThemeProvider, StyledEngineProvider } from '@mui/material/styles'; | ||
import { rootReducer as createRootReducer, settings } from 'mirador'; | ||
|
||
const rootReducer = createRootReducer(); | ||
const theme = createTheme(settings.theme); | ||
|
||
/** | ||
* Hook up our rendered object to redux | ||
*/ | ||
function renderWithProviders( | ||
ui, | ||
{ | ||
preloadedState = {}, | ||
// Automatically create a store instance if no store was passed in | ||
store = createStore(rootReducer, preloadedState, applyMiddleware(thunk)), | ||
...renderOptions | ||
} = {}, | ||
) { | ||
/** :nodoc: */ | ||
function Wrapper({ children }) { | ||
return ( | ||
<StyledEngineProvider injectFirst> | ||
<ThemeProvider theme={theme}> | ||
<Provider store={store}>{children}</Provider> | ||
</ThemeProvider> | ||
</StyledEngineProvider> | ||
); | ||
} | ||
|
||
Wrapper.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
const rendered = render(ui, { wrapper: Wrapper, ...renderOptions }); | ||
|
||
// Return an object with the store and all of RTL's query functions | ||
return { | ||
store, | ||
...rendered, | ||
rerender: (newUi, options) => render( | ||
newUi, | ||
{ container: rendered.container, wrapper: Wrapper, ...options }, | ||
), | ||
}; | ||
} | ||
|
||
export * from '@testing-library/react'; | ||
export { renderWithProviders as render }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,93 @@ | ||
module.exports = { | ||
const moduleFormatMap = { | ||
cjs: 'commonjs', | ||
es: false, | ||
}; | ||
|
||
module.exports = (api) => ({ | ||
presets: [ | ||
[ | ||
api.env('test') && [ | ||
'@babel/preset-env', | ||
{ | ||
modules: 'commonjs', | ||
targets: { | ||
node: 'current', | ||
}, | ||
}, | ||
], | ||
'@babel/preset-react', | ||
], | ||
}; | ||
(api.env('production') || api.env('development')) && [ | ||
'@babel/preset-env', | ||
{ | ||
corejs: 3, | ||
exclude: ['transform-typeof-symbol'], | ||
forceAllTransforms: true, | ||
modules: moduleFormatMap[process.env.MODULE_FORMAT] || false, | ||
useBuiltIns: 'entry', | ||
}, | ||
], | ||
[ | ||
'@babel/preset-react', | ||
{ | ||
development: api.env('development') || api.env('test'), | ||
runtime: 'automatic', | ||
useBuiltIns: true, | ||
}, | ||
], | ||
].filter(Boolean), | ||
plugins: [ | ||
'babel-plugin-macros', | ||
'@babel/plugin-transform-destructuring', | ||
[ | ||
'@babel/plugin-proposal-class-properties', | ||
{ | ||
loose: true, | ||
}, | ||
], | ||
['@babel/plugin-proposal-private-property-in-object', { loose: true }], | ||
['@babel/plugin-proposal-private-methods', { loose: true }], | ||
[ | ||
'@babel/plugin-proposal-object-rest-spread', | ||
{ | ||
useBuiltIns: true, | ||
}, | ||
], | ||
[ | ||
'@babel/plugin-transform-runtime', | ||
{ | ||
corejs: false, | ||
helpers: false, // Needed to support IE/Edge | ||
regenerator: true, | ||
}, | ||
], | ||
[ | ||
'@babel/plugin-transform-regenerator', | ||
{ | ||
async: false, | ||
}, | ||
], | ||
['transform-react-remove-prop-types', | ||
{ | ||
ignoreFilenames: ['node_modules'], | ||
removeImport: true, | ||
}, | ||
], | ||
[ | ||
"@emotion", | ||
{ | ||
importMap: { | ||
"@mui/system": { | ||
styled: { | ||
canonicalImport: ["@emotion/styled", "default"], | ||
styledBaseImport: ["@mui/system", "styled"] | ||
} | ||
}, | ||
"@mui/material/styles": { | ||
styled: { | ||
canonicalImport: ["@emotion/styled", "default"], | ||
styledBaseImport: ["@mui/material/styles", "styled"] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
].filter(Boolean) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
</head> | ||
|
||
<body> | ||
<div id="demo"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.