Skip to content

Commit

Permalink
Merge pull request #117 from reZach/load-images
Browse files Browse the repository at this point in the history
Load images
  • Loading branch information
reZach authored Jul 20, 2022
2 parents c4e046a + f101216 commit ebc8bf1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"Core": "./app/src/core",
"Pages": "./app/src/pages",
"Redux": "./app/src/redux",
"I18n": "./app/localization"
"I18n": "./app/localization",
"Images": "./resources/images"
}
},
"@babel/plugin-syntax-dynamic-import"
Expand Down
3 changes: 2 additions & 1 deletion app/src/constants/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"MOTD": "/motd",
"LOCALIZATION": "/localization",
"UNDOREDO": "/undoredo",
"CONTEXTMENU": "/contextmenu"
"CONTEXTMENU": "/contextmenu",
"IMAGE": "/image"
}
5 changes: 5 additions & 0 deletions app/src/core/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ class Nav extends React.Component {
onClick={() => this.navigate(ROUTES.CONTEXTMENU)}>
Custom context menu
</a>
<a
className="navbar-item"
onClick={() => this.navigate(ROUTES.IMAGE)}>
Sample image loaded
</a>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/src/core/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const UndoRedo = loadable(() =>
const ContextMenu = loadable(() =>
import(/* webpackChunkName: "ContextMenuChunk" */ "Pages/contextmenu/contextmenu")
);
const Image = loadable(() =>
import(/* webpackChunkName: "ContextMenuChunk" */ "Pages/image/image")
);

class AppRoutes extends React.Component {
render() {
Expand All @@ -35,6 +38,7 @@ class AppRoutes extends React.Component {
<Route path={ROUTES.LOCALIZATION} element={<Localization />}></Route>
<Route path={ROUTES.UNDOREDO} element={<UndoRedo />}></Route>
<Route path={ROUTES.CONTEXTMENU} element={<ContextMenu />}></Route>
<Route path={ROUTES.IMAGE} element={<Image />}></Route>
</Routes>
);
}
Expand Down
24 changes: 24 additions & 0 deletions app/src/pages/image/image.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";

import img from "Images/testimage.png";

class Image extends React.Component {
render() {
return (
<section className="section">
<div className="container">
<h1 className="title is-1">Loading images</h1>
</div>
<div className="container mt-2">
This page is to demonstrate that we can load an image hosted from a
directory in our project.
</div>
<div className="container mt-2">
<img src={img} />
</div>
</section>
);
}
}

export default Image;
1 change: 1 addition & 0 deletions app/src/pages/welcome/welcome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Welcome extends React.Component {
<Link to={ROUTES.LOCALIZATION}>Changing locales.</Link> <br />
<Link to={ROUTES.UNDOREDO}>Undo/redoing actions.</Link> <br />
<Link to={ROUTES.CONTEXTMENU}>Custom context menu.</Link> <br />
<Link to={ROUTES.IMAGE}>Sample image loaded.</Link> <br />
</div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "secure-electron-template",
"version": "19.0.1",
"version": "20.0.0",
"description": "The best way to build Electron apps with security in mind.",
"private": true,
"main": "app/electron/main.js",
Expand Down
Binary file added resources/images/testimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ module.exports = {
},
// loads common image formats
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
test: /\.(svg|png|jpg|gif)$/,
include: [
path.resolve(__dirname, "resources/images")
],
type: "asset/inline"
},
// loads common font formats
{
test: /\.(eot|woff|woff2|ttf)$/,
include: [
path.resolve(__dirname, "resources/fonts")
],
type: "asset/inline"
}
]
Expand Down

0 comments on commit ebc8bf1

Please sign in to comment.