@apolitical/frontend-partials
v1.0.0
Published
Frontend Partials for use in non react applications
Downloads
46
Keywords
Readme
Frontend Skeleton
This is a boilerplate for React Redux applications.
Usage
Dependencies
You will need to import the following dependencies. We recommend doing this at the bottom of the page.
<script type="text/javascript"
src="https://unpkg.com/@babel/[email protected]/dist/polyfill.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/dist/react-redux.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/umd/react-router-dom.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/redux.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/dist/redux-saga.min.js"></script>
<script type="text/javascript"
src="https://unpkg.com/[email protected]/dist/styled-components.min.js"></script>
Additionally, there is some code shared between the partials, this should come after the above.
<script type="text/javascript"
src="https://unpkg.com/@apolitical/[email protected]/dist/vendors~footer~header.js"></script>
Script files for the partials should come after this. The elements they hook into should come before the script files.
Header
Include the header.js script, you can use unpkg to get this.
<script type="text/javascript"
src="https://unpkg.com/@apolitical/[email protected]/dist/header.js"></script>
Where you want to place the header, add an element with a data attribute partial-app
set to
header
:
<div data-partial-app="header"></div>
By default, the header will not react to someone being logged out. If you wish for something else to
happen (such as a redirect) you can pass in the name of a function in the global scope using the
header-logged-out
data attribute;
<script>
function goToLogin(e) {
// console.error(e);
window.location = '/login';
}
</script>
<div data-partial-app="header" data-header-logged-out="goToLogin"></div>
Footer
Include the footer.js script, you can use unpkg to get this.
<script type="text/javascript"
src="https://unpkg.com/@apolitical/[email protected]/dist/footer.js"></script>
Where you want to place the header, add an element with a data attribute partial-app
set to
footer
:
<div data-partial-app="footer"></div>
There are no options for the footer.
Versioning
Use npm version
to edit the version number. Either:
npm version major|minor|patch
for a full release ornpm version premajor|preminor|prepatch --preid=meta.data.here
for a pre-release
Contributing
If you want to help, that's brilliant! Have a look at our Contributing Guide. We also adhere to a Code of Conduct, so please check that out, it includes details on who to contact if you have any concerns.