momesana / react-ts-webpack-template Goto Github PK
View Code? Open in Web Editor NEWA simple react-ts webpack template
A simple react-ts webpack template
Us react-intl to introduce i18n capabilities for the application. Do it the way we have done it in the yumlet client
DoD:
Rationale:
Supporting dark themes is a common requirement in web applications these days.
Dod:
use a very simple theme object with just a few attributes based on Antd's well-thought out theme seed token, namely:
colorPrimary
colorLink
colorBgContainer
colorBgElevated
colorText
colorTextSecondary
colorWhite
the theme info is made accessible to the app via a context. The context exposes a function to set the theme to either "system", "light" or "dark", the set of available themes ("system"| "light"| "dark" for now), and the currently selected value
the value should be stored in the local storage.
the browser when loading (that is before the theme kicks in) should use the browser preference for the color-scheme
pass down the theme via styled-components
in global styles the theme variables should be turned into css variables of the same name as well (css variables are easier to use but don't let you access the value in js to for example apply transformations. We'd like to have both available)
derive css variables based on that theme object
apply patterns of high cohesion and loose coupling (the theming infrastructure should all be in just one folder expoing a context provider that will wrap the app)
the selected theme needs to be stored in localstorage lest it is lost during a reload. Before even react loads the preferred color scheme should be defined via css. When react is up and running we look into local storage to get the value for theme. If it doesn't exist or is set to system, we default to browser meaning we'll use the color scheme to whatever the browser tells us is the preferred scheme. If the value exists in the local storage we set it to that overriding the system.
for testing purposes introduce a simple select (just the standard html select) with these three options so the user can change them at will.
Add facilities (this should merely be scripts in package.json) that help up analyse the created bundle via https://github.com/webpack-contrib/webpack-bundle-analyzer. No need to pollute our dependencies with it as it can be just used via pnpm dlx
.
DoD
pnpm bundle-stats
pnpm show-bundle-analysis
.pnpm analyse-bundle
Rationale
The idea is to have a most minimal entry point to already be in a react context and lazily start bootstrapping the actual app. This is important for apps where the actual bundle grows in time and might take more than a few seconds to load. While the app hasn't loaded yet any errors (also fetch errors) will lead to a blank page and the user is wondering why he is staring at a blank content.
Therefore we'd like to achieve these things:
In spirit, this is the render initial route as soon as possible aspect of the PRPL pattern.
DoD:
bootstrap.tsx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.