Skip to content

Commit

Permalink
display size
Browse files Browse the repository at this point in the history
  • Loading branch information
nyakase committed Sep 13, 2024
1 parent 7c9fdb5 commit 5dc9040
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"localforage": "^1.10.0",
"merge-refs": "^1.3.0",
"pako": "^2.1.0",
"pretty-bytes": "^6.1.1",
"qr-code-styling": "^1.6.0-rc.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
6 changes: 5 additions & 1 deletion src/routes/Loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NyafileImage from "../components/nyafile/NyafileImage.jsx";
* @returns {JSX.Element}
* @constructor
*/
export default function Loader({loadingString, progress}) {
export default function Loader({loadingString, progress, progressString}) {
const { t } = useTranslation();
const { nyafile, holiday } = useContext(AppContext);
console.log(nyafile?.assetCache?.logo)
Expand All @@ -31,6 +31,10 @@ export default function Loader({loadingString, progress}) {
<div className={styles.loadingBar}>
<div className={styles.loadingBarStretcher} style={{width: `${progress}%`}}></div>
</div>

<div className={styles.loadingBarText}>
{progressString}
</div>
</div>
</> : null}
</span>
Expand Down
5 changes: 4 additions & 1 deletion src/routes/Loader.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
.loadingBarImage {
position: absolute;
z-index: 1;
bottom: 1em;
bottom: 2em;
transform: translateX(-40px);
transition: all 500ms;
}
.loadingBarText {
font-size: small;
}
7 changes: 5 additions & 2 deletions src/routes/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import localForage from "localforage";
import * as i18n from "i18next";
import WooScreen from "./WooScreen.jsx";
import axios from "axios";
import prettyBytes from "pretty-bytes";

/**
* The root. Wraps later routes so that Nyafiles can be real.
Expand All @@ -18,6 +19,7 @@ export default function Root() {
let appContext = useContext(AppContext);
const [loadingString, setLoadingString] = useState("LOADING_TRANSLATIONS");
const [loadingPercentage, setLoadingPercentage] = useState(null);
const [loadingPercentageText, setLoadingPercentageText] = useState("");

useEffect(() => {
async function loadNyafile() {
Expand All @@ -43,6 +45,7 @@ export default function Root() {
const nyafileBlob = await axios.get("/quarky.nya", {
onDownloadProgress: progressEvent => {
setLoadingPercentage(progressEvent.loaded / progressEvent.total * 100);
setLoadingPercentageText(`${prettyBytes(progressEvent.loaded)}/${prettyBytes(progressEvent.total)}`)
},
responseType: "blob"
})
Expand Down Expand Up @@ -95,7 +98,7 @@ export default function Root() {
})
}

appContext.setLoading(false);
//appContext.setLoading(false);
}
loadNyafile();
}, []);
Expand All @@ -104,7 +107,7 @@ export default function Root() {
i18n.changeLanguage(appContext.settings.LANGUAGE)
}, [appContext.settings.LANGUAGE])

if(appContext.loading) return <Loader loadingString={loadingString} progress={loadingPercentage} />
if(appContext.loading) return <Loader loadingString={loadingString} progress={loadingPercentage} progressString={loadingPercentageText}/>

return <Sentry.ErrorBoundary fallback={<WooScreen/>}><Outlet /></Sentry.ErrorBoundary>
}

1 comment on commit 5dc9040

@vercel
Copy link

@vercel vercel bot commented on 5dc9040 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.