Skip to content

Commit

Permalink
Extended with favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jul 4, 2024
1 parent bb001de commit ba697c5
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 7 deletions.
11 changes: 11 additions & 0 deletions apps/spa/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const copyStaticFiles = require('esbuild-copy-static-files');

module.exports = function (config) {
config.plugins.push(
copyStaticFiles({
src: './static',
dest: config.outdir,
}),
);
return config;
};
7 changes: 7 additions & 0 deletions apps/spa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@types/react-dom": "^18",
"@types/react-router": "^5",
"@types/react-router-dom": "^5",
"esbuild-copy-static-files": "0.1.0",
"piral-cli": "1.5.6",
"piral-cli-esbuild": "latest",
"typescript": "latest"
Expand Down
12 changes: 7 additions & 5 deletions apps/spa/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getCurrentUser } from './auth';

const root = createRoot(document.querySelector('#app'));
const user = getCurrentUser();
const autoUpdate = process.env.DEBUG_PILET === 'on';

if (!user) {
root.render(<SelectUser />);
Expand All @@ -23,12 +24,13 @@ if (!user) {
},
plugins: [
...createStandardApi(),
createUpdateApi({
listen: checkPeriodically({
period: 10 * 1000,
autoUpdate &&
createUpdateApi({
listen: checkPeriodically({
period: 10 * 1000,
}),
}),
}),
],
].filter(Boolean),
requestPilets() {
return fetch(`${feedUrl}?role=${user.role}&target=spa`)
.then((res) => res.json())
Expand Down
Binary file added apps/spa/static/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/spa/static/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/spa/static/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/spa/static/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/spa/static/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/spa/static/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions apps/spa/static/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
27 changes: 27 additions & 0 deletions mfs/profile/src/Profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import type { ExtensionComponentProps } from 'spa-app';

interface ProfileData {
user: any;
logout: any;
}

const Profile: React.FC<ExtensionComponentProps<ProfileData>> = ({ params }) => {
const { user, logout } = params;
const exit = (e: React.SyntheticEvent) => {
e.preventDefault();
logout();
};

return (
<div style={{ display: 'flex', flexDirection: 'row', gap: '0.5rem' }}>
<img src={user.icon} width="24" height="24" />
<span>{user.name}</span>
<a href="#" onClick={exit}>
🚪
</a>
</div>
);
};

export default Profile;
7 changes: 5 additions & 2 deletions mfs/profile/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { PiletApi } from 'spa-app';
import type { PiletApi } from 'spa-app';
import Profile from './Profile';

export function setup(api: PiletApi) {}
export function setup(api: PiletApi) {
api.registerExtension('user-profile-menu', Profile);
}

0 comments on commit ba697c5

Please sign in to comment.