Skip to content

Commit 021e975

Browse files
committed
refactor: rename app and small fixes to appease linter
1 parent 442a3be commit 021e975

7 files changed

+64
-19
lines changed

README.md

+42-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,45 @@
1-
# React + Vite
1+
# Tab Control
22

3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3+
## Purpose
44

5-
Currently, two official plugins are available:
5+
**Tab Control** is a Chrome/Brave extension designed to help users efficiently manage their browser windows and tabs. It allows you to view all open windows, see the active tab in each window, and merge multiple windows into a single window seamlessly. This extension is particularly useful for users who handle numerous tabs across different windows and seek a streamlined way to organize their browsing sessions.
66

7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
7+
## Building and Publishing
8+
9+
### Building the Extension
10+
11+
1. **Install Dependencies**
12+
13+
Install the necessary packages using npm:
14+
15+
```bash
16+
npm install
17+
```
18+
19+
2. **Build the Project**
20+
21+
Use Vite to build the project for production:
22+
23+
```bash
24+
npm run build
25+
```
26+
27+
This will generate the production-ready files in the `dist` directory.
28+
29+
### Loading the Extension into Chrome/Brave
30+
31+
1. **Open the Extensions Page**
32+
33+
Navigate to the extensions page in Chrome or Brave by entering `chrome://extensions/` in the address bar.
34+
35+
2. **Enable Developer Mode**
36+
37+
Toggle the **Developer mode** switch located at the top right corner of the page.
38+
39+
3. **Load Unpacked Extension**
40+
41+
Click on the **Load unpacked** button and select the `dist` folder from your project directory.
42+
43+
4. **Verify the Extension**
44+
45+
The **Chrome Tab Manager** extension should now appear in your list of installed extensions. Click on its icon to ensure it's functioning as expected.

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<title>Chrome Tab Manager</title>
5+
<title>Tab Control</title>
66
</head>
77
<body>
88
<div id="root"></div>

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "chrome-tab-manager",
2+
"name": "tab-control",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",

src/TabItem.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import PropTypes from 'prop-types';
2+
13
// TabItem.jsx
2-
import React from 'react';
34

45
function TabItem({ tab }) {
56
return (
@@ -18,5 +19,11 @@ function TabItem({ tab }) {
1819
);
1920
}
2021

21-
export default TabItem;
22+
TabItem.propTypes = {
23+
tab: PropTypes.shape({
24+
favIconUrl: PropTypes.string,
25+
title: PropTypes.string.isRequired,
26+
}).isRequired,
27+
};
2228

29+
export default TabItem;

src/WindowItem.jsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// WindowItem.jsx
2-
import React, { useState, useRef, useEffect } from 'react'; // {{ edit: Import useRef and useEffect }}
3-
import PropTypes from 'prop-types'; // {{ edit: Import PropTypes for props validation }}
2+
import { useState, useRef, useEffect } from 'react';
3+
import PropTypes from 'prop-types';
44
import TabItem from './TabItem';
55

66
function WindowItem({ window, isSelected, onSelect }) {
77
const [dropdownOpen, setDropdownOpen] = useState(false);
8-
const dropdownRef = useRef(null); // {{ edit: Create ref for dropdown }}
8+
const dropdownRef = useRef(null);
99
const activeTab = window.tabs.find(tab => tab.active);
1010

11-
// {{ edit: Handle click outside to close dropdown }}
1211
useEffect(() => {
1312
const handleClickOutside = (event) => {
1413
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
@@ -29,10 +28,10 @@ function WindowItem({ window, isSelected, onSelect }) {
2928

3029
return (
3130
<div
32-
className={`window-item ${isSelected ? 'selected' : ''}`} // {{ edit: Add 'selected' class based on isSelected prop }}
31+
className={`window-item ${isSelected ? 'selected' : ''}`}
3332
onClick={() => onSelect(window.id.toString())}
3433
>
35-
<span className="window-label">{activeTab.title}</span>
34+
<span className="window-label">{activeTab.title}</span>
3635
{activeTab && (
3736
<div className="active-tab" onClick={(e) => e.stopPropagation()} ref={dropdownRef}>
3837
<TabItem tab={activeTab} />
@@ -41,7 +40,7 @@ function WindowItem({ window, isSelected, onSelect }) {
4140
</button>
4241
{dropdownOpen && (
4342
<ul className="tab-dropdown">
44-
{window.tabs.map(tab => ( // {{ edit: Include all tabs in dropdown }}
43+
{window.tabs.map(tab => (
4544
<TabItem key={tab.id} tab={tab} />
4645
))}
4746
</ul>
@@ -52,7 +51,7 @@ function WindowItem({ window, isSelected, onSelect }) {
5251
);
5352
}
5453

55-
WindowItem.propTypes = { // {{ edit: Define prop types for WindowItem }}
54+
WindowItem.propTypes = {
5655
window: PropTypes.shape({
5756
id: PropTypes.number.isRequired,
5857
tabs: PropTypes.arrayOf(PropTypes.object).isRequired,

src/utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// utils.js
22
// Utility functions to wrap Chrome API callbacks in Promises
33

4+
/* global chrome */
5+
46
export function getAllWindows(getInfo) {
57
return new Promise((resolve) => {
68
chrome.windows.getAll(getInfo, (windows) => {

0 commit comments

Comments
 (0)