/electron-shadcn

:electron: Electron Forge with shadcn-ui (Vite + Typescript)

Primary LanguageTypeScriptMIT LicenseMIT

electron-shadcn

Electron in all its glory. Everything you will need to develop your beautiful desktop application.

Demo GIF

Libs and tools

To develop a Electron app, you probably will need some UI, test, formatter, style or other kind of library or framework, so let me install and configure some of them to you.

Core ๐Ÿ๏ธ

DX ๐Ÿ› ๏ธ

UI ๐ŸŽจ

Test ๐Ÿงช

Packing and distribution ๐Ÿ“ฆ

Documentation ๐Ÿ“š

CI/CD ๐Ÿš€

Project preferences ๐ŸŽฏ

  • Use Context isolation
  • titleBarStyle: hidden (Using custom title bar)
  • Geist as default font
  • Some default styles was applied, check the styles directory

If you don't know some of these libraries or tools, I recommend you to check their documentation to understand how they work and how to use them.

Directory structure

.
โ””โ”€โ”€ ./src/
    โ”œโ”€โ”€ ./src/assets/
    โ”‚   โ””โ”€โ”€ ./src/assets/fonts/
    โ”œโ”€โ”€ ./src/components/
    โ”‚   โ””โ”€โ”€ ./src/components/ui/
    โ”œโ”€โ”€ ./src/helpers/
    โ”‚   โ””โ”€โ”€ ./src/helpers/ipc/
    โ”œโ”€โ”€ ./src/layout/
    โ”œโ”€โ”€ ./src/lib/
    โ”œโ”€โ”€ ./src/pages/
    โ”œโ”€โ”€ ./src/stories/
    โ”œโ”€โ”€ ./src/style/
    โ””โ”€โ”€ ./src/tests/
  • src/: Main directory
    • assets/: Store assets like images, fonts, etc.
    • components/: Store UI components
      • ui/: Store Shadcn UI components (this is the default direcotry used by Shadcn UI)
    • helpers/: Store IPC related functions to be called in the renderer process
      • ipc/: Directory to store IPC context and listener functions
        • Some implementations are already done, like theme and window for the custom title bar
    • layout/: Directory to store layout components
    • lib/: Store libraries and other utilities
    • pages/: Store app's pages
    • stories/: Store Storybook stories
    • style/: Store global styles
    • tests/: Store tests (from Jest and Playwright)

NPM script

To run any of those scripts:

npm run <script>
  • start: Start the app in development mode
  • package: Package your application into a platform-specific executable bundle and put the result in a folder.
  • make: Generate platform-specific distributables (e.g. .exe, .dmg, etc) of your application for distribution.
  • publish: Electron Forge's way of taking the artifacts generated by the make command and sending them to a service somewhere for you to distribute or use as updates.
  • prett: Run Prettier to format the code
  • storybook: Start Storybook
  • build-storybook: Run the Storybook's build command
  • test: Run the default unit-test script (Jest)
  • test:watch: Run the default unit-test script in watch mode (Jest)
  • test:unit: Run the Jest tests
  • test:e2e: Run the Playwright tests
  • test:all: Run all tests (Jest and Playwright)

The test scripts involving Playwright require the app be builded before running the tests. So, before run the tests, run the package, make or publish script.

How to use

  1. Clone this repository
git clone https://github.com/LuanRoger/electron-shadcn.git

Or use it as a template on GitHub

  1. Install dependencies
npm install
  1. Run the app
npm run start

Used by

  • yaste - yaste (Yet another super โ‚›แตขโ‚˜โ‚šโ‚—โ‚‘ text editor) is a text editor, that can be used as an alternative to the native text editor of your SO, maybe.
  • eletric-drizzle - shadcn-ui and Drizzle ORM with Electron.

Does you've used this template in your project? Add it here and open a PR.

License

This project is licensed under the MIT License - see the LICENSE file for details.