GithubHelp home page GithubHelp logo

lukashaas / wxt-react-shadcn-tailwindcss-chrome-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imtiger/wxt-react-shadcn-tailwindcss-chrome-extension

0.0 0.0 0.0 3.06 MB

JavaScript 6.79% TypeScript 84.11% CSS 7.52% HTML 1.58%

wxt-react-shadcn-tailwindcss-chrome-extension's Introduction

AgentGPT Logo

This is a boilerplate and starter for Chrome browser extension, built with Wxt、 React、 Tailwind css 、Shadcn ui and Typescript. Support dark mode and localization

Node version English 简体中文

  •   🐦 X About me


🔐 Prerequisites ☝️

Before you get started, please make sure you have the following installed:

🗂️ Getting Started 🚀

  1. Open your editor

  2. Open the Terminal

    • Typically, you can do this from a 'Terminal' tab or by using a shortcut (e.g., Ctrl + ~ for Windows or Control + ~ for Mac in VS Code).
  3. Clone the Repository and Navigate into the Directory

    • Once your terminal is open, you can clone the repository and move into the directory by running the commands below.

    • For Mac/Linux users 🍎 🐧

    git clone [email protected]:imtiger/wxt-react-shadcn-tailwindcss-chrome-extension.git
    cd wxt-react-shadcn-tailwindcss-chrome-extension
    npm install
    npm run dev
    • For Windows users :windows:
    git clone [email protected]:imtiger/wxt-react-shadcn-tailwindcss-chrome-extension.git
    cd wxt-react-shadcn-tailwindcss-chrome-extension
    npm install
    npm run dev
  4. The browser will be auto opened

    • you will see the content-script panel and side panel

❇️ Tech Stack

🚀 Localization and i18n

The locales file in the locales folder ,and you can edit it.

initTranslations(i18nConfig.defaultLocale, ["common", "content"])

👀 Considerations

  • Chrome extension tailwind css rem not working shadow dom.

Because Tailwind CSS uses rem by default, and rem is computed based on the font-size of the html element on the page, even if a content-script uses shadow dom, the internal elements' rem are also calculated based on the root html element's font-size of the host page. Therefore, to prevent style differences in the plugin due to varying font-sizes set by different websites, we can modify the default configuration of Tailwind CSS, allowing it to calculate directly in pixels.

npm install @thedutchcoder/postcss-rem-to-px
//postcss.config.js
export default {
   plugins: {
      tailwindcss: {},
      '@thedutchcoder/postcss-rem-to-px': {}, // you can add option like the base font size
      autoprefixer: {},
   },    
};
  • Add new component
npx shadcn-ui@latest add
  • Not trigger the click event listener.

    When a popup or side panel is defined, and set

browser.sidePanel.setPanelBehavior({openPanelOnActionClick: true}).catch((error: any) => console.error(error));

clicking on the browser extension icon won't trigger the listening event,and just open the side panel.

//monitor the event from extension icon click
browser.action.onClicked.addListener((tab) => {
   // 发送消息给content-script.js
   console.log("click icon")
   console.log(tab)
   browser.tabs.sendMessage(tab.id!, {messageType: MessageType.clickExtIcon});
});

👨‍🚀About Me

  • Full-Stack Engineer

  • Once worked at Tencent and Alibaba

Github
Twitter/X

If this project is helpful to you, star the repo and buy be a coffee, thank you guys.

Buy Me A Coffee

赞赏作者

wxt-react-shadcn-tailwindcss-chrome-extension's People

Contributors

imtiger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.