From e7ee512952c4bc0297581a85c28ff03aaa1d971c Mon Sep 17 00:00:00 2001
From: Benedikt Schnatterbeck <48836135+benediktms@users.noreply.github.com>
Date: Thu, 12 Jan 2023 14:36:44 +0000
Subject: [PATCH] style: add prettier (#34)
* style: add prettier
style: add prettier ignore file
style: apply formatting
style: install and apply svelte prettier
* Add prettier to recommended extensions
* chore: add check and format scripts to package.json
* chore: update prettier scripts to avoid conflict with svelte-check
---
.github/FUNDING.yml | 6 +-
.prettierignore | 3 +
.prettierrc | 6 +
.vscode/extensions.json | 3 +-
CODE_OF_CONDUCT.md | 22 +-
README.md | 2 +-
docs/themes.md | 3 +-
docs/themes/theme-blue/theme.json | 18 +-
docs/themes/theme-default/theme.json | 18 +-
docs/themes/theme-green/theme.json | 18 +-
package.json | 6 +-
src/main.ts | 69 +++---
src/routes/App/App.svelte | 42 ++--
src/routes/App/lib/CalculationResult.svelte | 100 ++++----
src/routes/App/lib/Footer.svelte | 22 +-
src/routes/App/lib/SearchBar.svelte | 82 +++----
src/routes/App/lib/SearchResult.svelte | 57 ++---
src/routes/Settings/Settings.svelte | 108 ++++-----
src/routes/Settings/lib/CheckBox.svelte | 109 ++++-----
src/routes/Settings/lib/MenuButton.svelte | 62 ++---
.../lib/controls/MenuBarIconControl.svelte | 80 +++----
.../lib/controls/ShortcutControl.svelte | 226 +++++++++---------
.../lib/controls/StartAtLoginControl.svelte | 73 +++---
src/style.css | 8 +-
svelte.config.js | 2 +-
vite.config.ts | 10 +-
yarn.lock | 10 +
27 files changed, 591 insertions(+), 574 deletions(-)
create mode 100644 .prettierignore
create mode 100644 .prettierrc
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 8b02cc0..da8dd74 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -2,4 +2,8 @@
github: [parthjadhav]
ko_fi: parthjadhav
-custom: ["https://paypal.me/parthJadhav22", "https://www.buymeacoffee.com/Parthjadhav"]
+custom:
+ [
+ 'https://paypal.me/parthJadhav22',
+ 'https://www.buymeacoffee.com/Parthjadhav',
+ ]
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..48dbe6a
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,3 @@
+node_modules
+src-tauri
+dist
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..4984e01
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,6 @@
+{
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": true,
+ "arrowParens": "avoid"
+}
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 61343e9..18073bb 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -2,6 +2,7 @@
"recommendations": [
"svelte.svelte-vscode",
"tauri-apps.tauri-vscode",
- "rust-lang.rust-analyzer"
+ "rust-lang.rust-analyzer",
+ "esbenp.prettier-vscode"
]
}
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index c622909..37bab1b 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:
-* Demonstrating empathy and kindness toward other people
-* Being respectful of differing opinions, viewpoints, and experiences
-* Giving and gracefully accepting constructive feedback
-* Accepting responsibility and apologizing to those affected by our mistakes,
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
-* Focusing on what is best not just for us as individuals, but for the
+- Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
-* The use of sexualized language or imagery, and sexual attention or
+- The use of sexualized language or imagery, and sexual attention or
advances of any kind
-* Trolling, insulting or derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or email
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email
address, without their explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
+- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
-standards, including sustained inappropriate behavior, harassment of an
+standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
diff --git a/README.md b/README.md
index c3d5328..267a6a7 100644
--- a/README.md
+++ b/README.md
@@ -16,8 +16,8 @@ Verve is a lightweight and blazingly fast launcher for accessing and opening app
## 🚀 Features
-
+
## 📥 Downloading
diff --git a/docs/themes.md b/docs/themes.md
index 5381ba3..d99e46c 100644
--- a/docs/themes.md
+++ b/docs/themes.md
@@ -15,7 +15,6 @@ Download: [theme-blue.json](./themes/theme-blue/theme.json)
![Verve Dracula Theme](./themes/theme-green/theme-green.png)
-
Download: [theme-green.json](./themes/theme-green/theme.json)
### Create your own theme
@@ -26,4 +25,4 @@ You can create your own theme by editing the theme.json file. You can find the t
Save the file & Restart the app.
-Create a Pull request to add your theme to the list.
\ No newline at end of file
+Create a Pull request to add your theme to the list.
diff --git a/docs/themes/theme-blue/theme.json b/docs/themes/theme-blue/theme.json
index d5ce8d4..0954235 100644
--- a/docs/themes/theme-blue/theme.json
+++ b/docs/themes/theme-blue/theme.json
@@ -1,10 +1,10 @@
{
- "primary_bg_color": "rgba(20, 20, 80, 0.6)",
- "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
- "primary_text_color": "#FFFFFF",
- "secondary_text_color": "#878787",
- "primary_accent_color": "#556CE5",
- "secondary_accent_color": "#48A5FF",
- "highlight_overlay": "rgba(255, 255, 255, 0.1)",
- "dark_overlay": "rgba(0, 0, 0, 0.1)"
-}
\ No newline at end of file
+ "primary_bg_color": "rgba(20, 20, 80, 0.6)",
+ "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
+ "primary_text_color": "#FFFFFF",
+ "secondary_text_color": "#878787",
+ "primary_accent_color": "#556CE5",
+ "secondary_accent_color": "#48A5FF",
+ "highlight_overlay": "rgba(255, 255, 255, 0.1)",
+ "dark_overlay": "rgba(0, 0, 0, 0.1)"
+}
diff --git a/docs/themes/theme-default/theme.json b/docs/themes/theme-default/theme.json
index 2c86d67..b3f0110 100644
--- a/docs/themes/theme-default/theme.json
+++ b/docs/themes/theme-default/theme.json
@@ -1,10 +1,10 @@
{
- "primary_bg_color": "rgba(20, 20, 30, 0.6)",
- "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
- "primary_text_color": "#FFFFFF",
- "secondary_text_color": "#878787",
- "primary_accent_color": "#556CE5",
- "secondary_accent_color": "#48A5FF",
- "highlight_overlay": "rgba(255, 255, 255, 0.1)",
- "dark_overlay": "rgba(0, 0, 0, 0.1)"
-}
\ No newline at end of file
+ "primary_bg_color": "rgba(20, 20, 30, 0.6)",
+ "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
+ "primary_text_color": "#FFFFFF",
+ "secondary_text_color": "#878787",
+ "primary_accent_color": "#556CE5",
+ "secondary_accent_color": "#48A5FF",
+ "highlight_overlay": "rgba(255, 255, 255, 0.1)",
+ "dark_overlay": "rgba(0, 0, 0, 0.1)"
+}
diff --git a/docs/themes/theme-green/theme.json b/docs/themes/theme-green/theme.json
index f5cd52f..27107ff 100644
--- a/docs/themes/theme-green/theme.json
+++ b/docs/themes/theme-green/theme.json
@@ -1,10 +1,10 @@
{
- "primary_bg_color": "rgba(20, 45, 30, 0.6)",
- "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
- "primary_text_color": "#FFFFFF",
- "secondary_text_color": "#878787",
- "primary_accent_color": "#556CE5",
- "secondary_accent_color": "#48A5FF",
- "highlight_overlay": "rgba(255, 255, 255, 0.1)",
- "dark_overlay": "rgba(0, 0, 0, 0.1)"
-}
\ No newline at end of file
+ "primary_bg_color": "rgba(20, 45, 30, 0.6)",
+ "secondary_bg_color": "rgba(84, 101, 115, 0.6)",
+ "primary_text_color": "#FFFFFF",
+ "secondary_text_color": "#878787",
+ "primary_accent_color": "#556CE5",
+ "secondary_accent_color": "#48A5FF",
+ "highlight_overlay": "rgba(255, 255, 255, 0.1)",
+ "dark_overlay": "rgba(0, 0, 0, 0.1)"
+}
diff --git a/package.json b/package.json
index d9f03a7..f76047e 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,9 @@
"tauri": "tauri",
"package-and-build-arm": "yarn tauri build --target aarch64-apple-darwin && rm -rf ./src-tauri/target/verve_aarch64.dmg && create-dmg --volname Verve --volicon './src-tauri/icons/icon.icns' --background './src/dmg-background.png' --window-pos 200 120 --window-size 653 380 --icon-size 115 --icon 'verve.app' 180 189 --hide-extension 'Verve.app' --app-drop-link 460 185 ./src-tauri/target/aarch64-apple-darwin/release/bundle/verve_aarch64.dmg ./src-tauri/target/aarch64-apple-darwin/release/bundle/macos/verve.app && mv ./src-tauri/target/aarch64-apple-darwin/release/bundle/verve_aarch64.dmg ./src-tauri/target/",
"package-and-build-x86_64": "yarn tauri build --target x86_64-apple-darwin && rm -rf ./src-tauri/target/verve_x86_64.dmg && create-dmg --volname Verve --volicon './src-tauri/icons/icon.icns' --background './src/dmg-background.png' --window-pos 200 120 --window-size 653 380 --icon-size 115 --icon 'verve.app' 180 189 --hide-extension 'Verve.app' --app-drop-link 460 185 ./src-tauri/target/x86_64-apple-darwin/release/bundle/verve_x86_64.dmg ./src-tauri/target/x86_64-apple-darwin/release/bundle/macos/verve.app && mv ./src-tauri/target/x86_64-apple-darwin/release/bundle/verve_x86_64.dmg ./src-tauri/target/",
- "package-and-build": "yarn package-and-build-arm && yarn package-and-build-x86_64 && open ./src-tauri/target/"
+ "package-and-build": "yarn package-and-build-arm && yarn package-and-build-x86_64 && open ./src-tauri/target/",
+ "format:check": "prettier --check .",
+ "format:write": "prettier --write ."
},
"dependencies": {
"@tauri-apps/api": "^1.1.0",
@@ -22,6 +24,8 @@
"@tauri-apps/cli": "^1.1.0",
"@tsconfig/svelte": "^3.0.0",
"@types/node": "^18.7.10",
+ "prettier": "^2.8.2",
+ "prettier-plugin-svelte": "^2.9.0",
"svelte": "^3.49.0",
"svelte-check": "^2.8.0",
"svelte-preprocess": "^4.10.7",
diff --git a/src/main.ts b/src/main.ts
index 0efd960..f412a33 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,79 +1,82 @@
-import "./style.css";
+import './style.css';
// @ts-ignore
-import App from "./routes/App/App.svelte";
-import { appWindow } from "@tauri-apps/api/window";
-import { register } from '@tauri-apps/api/globalShortcut'
-import { appDataDir, join, resolveResource } from "@tauri-apps/api/path";
-import { readTextFile } from "@tauri-apps/api/fs";
-import { invoke } from "@tauri-apps/api/tauri";
-import { preferences, paths } from "./cache";
-import { listen } from '@tauri-apps/api/event'
+import App from './routes/App/App.svelte';
+import { appWindow } from '@tauri-apps/api/window';
+import { register } from '@tauri-apps/api/globalShortcut';
+import { appDataDir, join, resolveResource } from '@tauri-apps/api/path';
+import { readTextFile } from '@tauri-apps/api/fs';
+import { invoke } from '@tauri-apps/api/tauri';
+import { preferences, paths } from './cache';
+import { listen } from '@tauri-apps/api/event';
// Create the app
const app = new App({
- target: document.getElementById("app"),
+ target: document.getElementById('app'),
});
const fetchPreferencesData = async () => {
- const preferencesData = await readTextFile(await join(paths.get("appDataDirPath"), `preferences.json`)).then((data) => JSON.parse(data));
- Object.keys(preferencesData).forEach((key) => {
+ const preferencesData = await readTextFile(
+ await join(paths.get('appDataDirPath'), `preferences.json`)
+ ).then(data => JSON.parse(data));
+ Object.keys(preferencesData).forEach(key => {
preferences.set(key, preferencesData[key]);
});
-}
+};
const reloadTheme = async () => {
- const theme = await readTextFile(await join(paths.get("appDataDirPath"), `theme.json`)).then((data) => JSON.parse(data));
+ const theme = await readTextFile(
+ await join(paths.get('appDataDirPath'), `theme.json`)
+ ).then(data => JSON.parse(data));
// @ts-ignore
const style = document.styleSheets[0].cssRules[0].style;
- style.setProperty("--primary-bg-color", theme.primary_bg_color);
- style.setProperty("--secondary-bg-color", theme.secondary_bg_color);
- style.setProperty("--primary-text-color", theme.primary_text_color);
- style.setProperty("--secondary-text-color", theme.secondary_text_color);
- style.setProperty("--primary-accent-color", theme.primary_accent_color);
- style.setProperty("--secondary-accent-color", theme.secondary_accent_color);
-}
+ style.setProperty('--primary-bg-color', theme.primary_bg_color);
+ style.setProperty('--secondary-bg-color', theme.secondary_bg_color);
+ style.setProperty('--primary-text-color', theme.primary_text_color);
+ style.setProperty('--secondary-text-color', theme.secondary_text_color);
+ style.setProperty('--primary-accent-color', theme.primary_accent_color);
+ style.setProperty('--secondary-accent-color', theme.secondary_accent_color);
+};
(async () => {
// get and set values
- paths.set("appDataDirPath", await appDataDir());
+ paths.set('appDataDirPath', await appDataDir());
await fetchPreferencesData();
await reloadTheme();
- document.addEventListener("keydown", (event) => {
- if (event.key === "Escape") {
+ document.addEventListener('keydown', event => {
+ if (event.key === 'Escape') {
appWindow.hide();
}
});
// Listen for Menu Bar event to open preferences emitted from main.rs
- await listen("PreferencesClicked", (data) => {
+ await listen('PreferencesClicked', data => {
app.$set({
appState: {
app: false,
- settings: true
- }
+ settings: true,
+ },
});
});
-
- await invoke("launch_on_login", {
- enable: preferences.get("launch_on_login"),
+ await invoke('launch_on_login', {
+ enable: preferences.get('launch_on_login'),
});
- await listenForHotkey(preferences.get("shortcut"));
+ await listenForHotkey(preferences.get('shortcut'));
})();
export async function listenForHotkey(shortcut: string) {
await register(shortcut, async () => {
if (document.hasFocus()) {
- await appWindow.hide()
+ await appWindow.hide();
} else {
await appWindow.show();
await appWindow.center();
await appWindow.setFocus();
document.getElementById('searchBarInput').focus();
}
- })
+ });
}
export default app;
diff --git a/src/routes/App/App.svelte b/src/routes/App/App.svelte
index 27a0b6d..c47078b 100644
--- a/src/routes/App/App.svelte
+++ b/src/routes/App/App.svelte
@@ -1,10 +1,10 @@
Show in menu bar:
-Show in menu bar:
+Hotkey:
- Hotkey: + 0 - ? shortcutArray - .map((key) => key) - .join(" + ") - .replace("Meta", "⌘") - .replace("Command", "⌘") - .replace("Control", "⌃") - .replace("Alt", "⌥") - .replace("Shift", "⇧") - : "Recording..."} + ? shortcutArray + .map(key => key) + .join(' + ') + .replace('Meta', '⌘') + .replace('Command', '⌘') + .replace('Control', '⌃') + .replace('Alt', '⌥') + .replace('Shift', '⇧') + : 'Recording...'} on:click={recordShortcut} -/> + />Start at login:
-