Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UI of New Extension page #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
# VSCode Chrome Extension Developer Tools
![](https://img.shields.io/visual-studio-marketplace/d/aaravb.chrome-extension-developer-tools) ![](https://img.shields.io/visual-studio-marketplace/i/aaravb.chrome-extension-developer-tools) \
VSCode support for Chrome extension development.

![Downloads](https://img.shields.io/visual-studio-marketplace/d/aaravb.chrome-extension-developer-tools) ![Installs](https://img.shields.io/visual-studio-marketplace/i/aaravb.chrome-extension-developer-tools) \
VSCode support for Chrome extension development.
[View on Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=aaravb.chrome-extension-developer-tools).

## Features
* Initialize chrome extensions in VSCode.
* Package chrome extensions in VSCode.
* Webpack integrations.
* `manifest.json` documentation through hovers.

## Commands
### Chrome Extension: Create New
* Description: Creates a new Chrome extension (opens a webview for parameters).
* ID: `chrome-extension-developer-tools.create`

### Chrome Extension: Watch Files
* Description: Uses webpack to watch extension files.
* ID: `chrome-extension-developer-tools.watch`

### Chrome Extension: Build Files
* Description: Uses webpack to package Chrome extension for publishing.
* ID: `chrome-extension-developer-tools.build`

- Initialize chrome extensions in VSCode.
- Package chrome extensions in VSCode.
- Webpack integrations.
- `manifest.json` documentation through hovers.

## Usage

This extension provides three commands that enable you to create, watch, and build a Chrome extension.

To run any of the commands listed below, open the `Command Palette` (use `Ctrl + P`) and type the desired command:

1. **Chrome Extension: Create New**:

- Description: Creates a new Chrome extension (opens a webview for parameters).
- ID: `chrome-extension-developer-tools.create`

2. **Chrome Extension: Watch Files**:

- Description: Uses webpack to watch extension files.
- ID: `chrome-extension-developer-tools.watch`

3. **Chrome Extension: Build Files**:

- Description: Uses webpack to package Chrome extension for publishing.
- ID: `chrome-extension-developer-tools.build`

## For Contribution Opportunities

We welcome contributions to this project! If you're interested in helping, feel free to take on any of the following tasks or propose your own ideas:

- **TODO**:

- [ ] **Convert 'Create New Extension' into a Dialog/Window**: Refactor the current 'Create New ]Extension' functionality so that it opens as a dialog or window, rather than a full page.

- [ ] **Design a New Icon for the Extension**: Create and implement a new icon to represent the extension.
- [ ] **Customizable Project Templates**: Enable users to add their own custom templates or modify existing ones while creating a project.
- [ ] **Add Dependency Selection**: Allow users to choose additional dependencies they would like to include during project creation.

We are open to other suggestions, so feel free to share your ideas!
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 42 additions & 36 deletions webviews/initialization_screen/index.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
<link rel="stylesheet" href="{{styles.css}}">

<center>
<img src="{{/assets/chrome.png}}" height="5%" width="5%">
<h1 align>New Chrome Extension</h1>
</center>
<hr>
<link rel="stylesheet" href="{{styles.css}}" />
<body>
<label for="project_name">Project Name:</label>
<input type="text" id="project_name" required>

<br><br>

<label for="extension_type">Extension Type <small>[<a href="https://github.com/gadhagod/chrome-extension-cli-client/blob/master/templates/README.md#templates">?</a>]</small>:</label>

<select id="extension_type">
<option value="popup">Popup</option>
<option value="override_page">Override page</option>
<option value="devtools">Dev tools</option>
</select>

<br><br>

<label id="location_label" for="choose_location">Location: </label>
<button id="choose_location" onclick="getLocation()">Choose</button>

<br><br>

<div class="container">
<div class="header">
<div class="icon">
<img src="{{/assets/chrome.png}}" alt="icon" />
</div>
<p class="title">Create New Chrome Extension</p>
</div>
<div class="project-form">
<div class="inputs">
Copy link
Owner

Choose a reason for hiding this comment

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

Can we keep the indentation to 4 spaces please?

Copy link
Author

Choose a reason for hiding this comment

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

sure, I guess it was my editors default setting and i didn't pay much attention to it

<input type="text" id="project_name" placeholder="Project Name" />
<div class="extension_type_container">
<label for="extension_type">
Extension Type:
<a
id="extension_type_info"
href="https://github.com/gadhagod/chrome-extension-cli-client/blob/master/templates/README.md#templates"
>
(?)
</a>
</label>
<select name="Extension Type" id="extension_type">
<option value="popup">Popup</option>
<option value="override_page">Override page</option>
<option value="devtools">Dev tools</option>
</select>
</div>
<div class="location_container">
<label for="choose_location">
Choose Location:
<button id="choose_location" onclick="getLocation()">Choose</button>
</label>
<span id="location_label">(no location selected)</span>
</div>
</div>
</div>
<button id="submit" onclick="submit()">Create</button>
</div>

<div id="loading" style="display: none">
<hr>
<center>
<p id="loading_text">Creating extension and installing dependencies.</p>
<div id="loader"></div>
</center>
</div>
<div class="loading" style="visibility: hidden">
<p class="loading_text">Setting up project.</p>
<div class="loader"></div>
</div>
</body>

<script src="{{index.js}}">
</script>
<script src="{{index.js}}"></script>
112 changes: 56 additions & 56 deletions webviews/initialization_screen/index.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
const vscode = acquireVsCodeApi();

window.addEventListener("message", (data) => {
var res = data.data;
window.addEventListener("message", data => {
var res = data.data;

if (res.status === "GIVE") {
document.getElementById("location_label").innerHTML = "Location: " + res.message.path;
} else if (res.status === "ERR") {
document.getElementById("loading").style.display = "none";
document.getElementById("project_name").removeAttribute("disabled");
document.getElementById("extension_type").removeAttribute("disabled");
document.getElementById("choose_location").removeAttribute("disabled");
document.getElementById("submit").removeAttribute("disabled");
} else if (res.status === "LOAD") {
document.getElementById("loader").innerHTML += "\n" + res.message;
}
if (res.status === "GIVE") {
document.getElementById("location_label").innerHTML = res.message.path;
} else if (res.status === "ERR") {
document.querySelector(".loading").style.display = "none";
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a specific reason for using querySelector over getElementById here?

document.getElementById("project_name").removeAttribute("disabled");
document.getElementById("extension_type").removeAttribute("disabled");
document.getElementById("choose_location").removeAttribute("disabled");
document.getElementById("submit").removeAttribute("disabled");
} else if (res.status === "LOAD") {
document.getElementById("loader").innerHTML += "\n" + res.message;
}
});

function getLocation() {
vscode.postMessage({
status: "GET",
message: "Get location",
});
vscode.postMessage({
status: "GET",
message: "Get location",
});
}

function submit() {
let projectName = document.getElementById("project_name").value;
let extensionType = document.getElementById("extension_type").value;
let chosenPath = document.getElementById("location_label").innerHTML.replace("Location: ", "");
let projectName = document.getElementById("project_name").value;
let extensionType = document.getElementById("extension_type").value;
let chosenPath = document.getElementById("location_label").innerHTML.replace("Location: ", "");

document.getElementById("project_name").setAttribute("disabled", "");
document.getElementById("extension_type").setAttribute("disabled", "");
document.getElementById("choose_location").setAttribute("disabled", "");
document.getElementById("submit").setAttribute("disabled", "");

if (!projectName || !extensionType || !chosenPath) {
document.getElementById("project_name").removeAttribute("disabled");
document.getElementById("extension_type").removeAttribute("disabled");
document.getElementById("choose_location").removeAttribute("disabled");
vscode.postMessage({
status: "ERR",
message: "Missing project configuration",
});
return;
}

document.getElementById("loading").style.display = "block";
document.getElementById("project_name").setAttribute("disabled", "");
document.getElementById("extension_type").setAttribute("disabled", "");
document.getElementById("choose_location").setAttribute("disabled", "");
document.getElementById("submit").setAttribute("disabled", "");

if (!projectName || !extensionType || !chosenPath) {
document.getElementById("project_name").removeAttribute("disabled");
document.getElementById("extension_type").removeAttribute("disabled");
document.getElementById("choose_location").removeAttribute("disabled");
vscode.postMessage({
status: "OK",
message: {
projectName: projectName,
extensionType: extensionType,
chosenPath: chosenPath,
},
status: "ERR",
message: "Missing project configuration",
});
return;
}

document.querySelector(".loading").style.visibility = "visible";

vscode.postMessage({
status: "OK",
message: {
projectName: projectName,
extensionType: extensionType,
chosenPath: chosenPath,
},
});
}

(async function() {
let loadingText = document.getElementById("loading_text");
let ellipsisDotCount = 1;
setInterval(() => {
if(ellipsisDotCount > 2) {
loadingText.innerHTML = loadingText.innerHTML.replace("...", ".");
ellipsisDotCount = 1;
} else {
loadingText.innerHTML += ".";
ellipsisDotCount++;
}
}, 1000);
})();
(async function () {
let loadingText = document.querySelector(".loading_text");
let ellipsisDotCount = 1;
setInterval(() => {
if (ellipsisDotCount > 2) {
loadingText.innerHTML = loadingText.innerHTML.replace("...", ".");
ellipsisDotCount = 1;
} else {
loadingText.innerHTML += ".";
ellipsisDotCount++;
}
}, 500);
Copy link
Owner

Choose a reason for hiding this comment

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

Good idea!

})();
Loading