From d5a1bd38aafc51300a9af69e627c1a133d0ed76b Mon Sep 17 00:00:00 2001 From: Sparkenstein Date: Thu, 29 Aug 2024 20:26:46 +0530 Subject: [PATCH 01/18] fix: macos asset csp --- src-tauri/tauri.conf.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1b8e356..e5bbe29 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -80,7 +80,7 @@ "windows": [], "security": { "dangerousDisableAssetCspModification": true, - "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" + "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: asset: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" } } -} +} From 663c9d7b78ca94df3c04c05bae4cfe976aa780f7 Mon Sep 17 00:00:00 2001 From: Thijs Zijdel Date: Fri, 30 Aug 2024 08:52:07 +0200 Subject: [PATCH 02/18] add: package tauri-plugin-sql-api --- .gitignore | 3 +- package.json | 3 +- src-tauri/Cargo.lock | 583 ++++++++++++++++++++++++++++++++++++++++++- src-tauri/Cargo.toml | 5 + yarn.lock | 8 +- 5 files changed, 597 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9d22bd1..e2a00d9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ yarn-error.log assets/vips/ .yarn -.eslintcache \ No newline at end of file +.eslintcache +.idea diff --git a/package.json b/package.json index 09ed47f..2f816e7 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "rehype-raw": "^7.0.0", "remark-math": "^6.0.0", "simple-base-converter": "^1.0.19", + "tauri-plugin-sql-api": "https://github.com/tauri-apps/tauri-plugin-sql#v1", "tauri-plugin-store-api": "https://github.com/tauri-apps/tauri-plugin-store", "terser": "^5.30.0", "tinycolor2": "^1.6.0", @@ -128,4 +129,4 @@ "vite": "^5.2.7", "vite-tsconfig-paths": "^5.0.1" } -} +} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5bbf3e0..759da24 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -74,6 +74,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -139,6 +145,15 @@ dependencies = [ "system-deps 6.2.2", ] +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + [[package]] name = "autocfg" version = "1.2.0" @@ -200,6 +215,12 @@ dependencies = [ "simd-abstraction", ] +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bit_field" version = "0.10.2" @@ -217,6 +238,9 @@ name = "bitflags" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -485,6 +509,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-str" version = "0.3.2" @@ -573,6 +603,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.0" @@ -610,6 +655,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.19" @@ -755,6 +809,17 @@ dependencies = [ "matches", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -812,6 +877,7 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-aptabase", + "tauri-plugin-sql", "tauri-plugin-store", "tokio", "webp", @@ -824,7 +890,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -863,6 +931,12 @@ dependencies = [ "libloading", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -895,6 +969,9 @@ name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +dependencies = [ + "serde", +] [[package]] name = "embed-resource" @@ -947,6 +1024,23 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "exr" version = "1.72.0" @@ -1033,7 +1127,9 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ - "spin", + "futures-core", + "futures-sink", + "spin 0.9.8", ] [[package]] @@ -1151,6 +1247,17 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -1577,6 +1684,19 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.3", +] [[package]] name = "heck" @@ -1592,6 +1712,9 @@ name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "heck" @@ -1611,6 +1734,24 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "home" version = "0.5.9" @@ -1980,6 +2121,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "lebe" @@ -2021,6 +2165,12 @@ dependencies = [ "windows-targets 0.52.4", ] +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libredox" version = "0.0.1" @@ -2032,6 +2182,17 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libwebp-sys" version = "0.9.5" @@ -2364,12 +2525,49 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2377,6 +2575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2663,6 +2862,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2825,6 +3033,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.30" @@ -3304,6 +3533,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -3588,6 +3837,17 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -3617,6 +3877,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "simd-abstraction" version = "0.7.1" @@ -3697,6 +3967,12 @@ dependencies = [ "system-deps 5.0.0", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" @@ -3706,6 +3982,224 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f895e3734318cc55f1fe66258926c9b910c124d47520339efecbb6c59cec7c1f" +dependencies = [ + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" +dependencies = [ + "ahash 0.8.11", + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.2.6", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "time", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.1", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.5.0", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa 1.0.11", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.5.0", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa 1.0.11", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.5", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "time", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "time", + "tracing", + "url", + "urlencoding", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3747,12 +4241,29 @@ dependencies = [ "quote", ] +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "surge-ping" version = "0.8.1" @@ -4072,10 +4583,26 @@ dependencies = [ "uuid", ] +[[package]] +name = "tauri-plugin-sql" +version = "0.0.0" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#677bade9089f2963e5858cc5062e5504787eaf7f" +dependencies = [ + "futures-core", + "log", + "serde", + "serde_json", + "sqlx", + "tauri", + "thiserror", + "time", + "tokio", +] + [[package]] name = "tauri-plugin-store" version = "0.0.0" -source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#066058f631b81d1203f55f6369b7b0a19e29a4d4" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#677bade9089f2963e5858cc5062e5504787eaf7f" dependencies = [ "log", "serde", @@ -4322,6 +4849,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -4416,6 +4954,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4533,12 +5072,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-properties" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" + [[package]] name = "unicode-segmentation" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "url" version = "2.5.0" @@ -4551,6 +5102,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf-8" version = "0.7.6" @@ -4653,6 +5210,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + [[package]] name = "wasm-bindgen" version = "0.2.92" @@ -4916,6 +5479,16 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "whoami" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +dependencies = [ + "redox_syscall", + "wasite", +] + [[package]] name = "winapi" version = "0.3.9" @@ -5465,6 +6038,12 @@ dependencies = [ "syn 2.0.57", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zip" version = "0.6.6" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index ac9fa36..17184df 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -41,6 +41,11 @@ flate2 = "1.0" bardecoder = "0.5.0" imageinfo = "0.7.17" +[dependencies.tauri-plugin-sql] +git = "https://github.com/tauri-apps/plugins-workspace" +branch = "v1" +features = ["sqlite"] # or "postgres", or "mysql" + [features] default = ["custom-protocol"] custom-protocol = ["tauri/custom-protocol"] diff --git a/yarn.lock b/yarn.lock index 828c1da..20006b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1815,7 +1815,7 @@ resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.5.3.tgz#f7b362b1f30aadb0a8bbeb7ae111755c0ed33d73" integrity sha512-zxnDjHHKjOsrIzZm6nO5Xapb/BxqUq1tc7cGkFXsFkGTsSWgCPH1D8mm0XS9weJY2OaR73I3k3S+b7eSzJDfqA== -"@tauri-apps/api@^1.6.0": +"@tauri-apps/api@1.6.0", "@tauri-apps/api@^1.6.0": version "1.6.0" resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.6.0.tgz#745b7e4e26782c3b2ad9510d558fa5bb2cf29186" integrity sha512-rqI++FWClU5I2UBp4HXFvl+sBWkdigBkxnpJDQUWttNyG7IZP4FwQGhTNL5EOw0vI8i6eSAJ5frLqO7n7jbJdg== @@ -7736,6 +7736,12 @@ tar@^6.1.11: mkdirp "^1.0.3" yallist "^4.0.0" +"tauri-plugin-sql-api@https://github.com/tauri-apps/tauri-plugin-sql#v1": + version "0.0.0" + resolved "https://github.com/tauri-apps/tauri-plugin-sql#7ae8847ab1f2252e8b6f0fe44af215ac40664fd6" + dependencies: + "@tauri-apps/api" "1.6.0" + "tauri-plugin-store-api@https://github.com/tauri-apps/tauri-plugin-store": version "0.0.0" resolved "https://github.com/tauri-apps/tauri-plugin-store#02243686d0507d2aeeb2924cd889dd0bcb47ecef" From 2633aec49e8ae7a072ff5eaeecbb04ba28bd3b31 Mon Sep 17 00:00:00 2001 From: Thijs Zijdel Date: Fri, 30 Aug 2024 08:52:50 +0200 Subject: [PATCH 03/18] add: snippets db setup --- src-tauri/src/main.rs | 45 ++++++++++ src/App.tsx | 2 + src/Features/snippets/Snippets.tsx | 36 ++++++++ src/Layout/Navbar/items.tsx | 7 ++ src/utils/database.ts | 128 +++++++++++++++++++++++++++++ src/utils/db.ts | 2 +- 6 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 src/Features/snippets/Snippets.tsx create mode 100644 src/utils/database.ts diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4ee79a5..4ad387c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -7,6 +7,8 @@ use std::convert::TryInto; use std::env; use tauri::{Manager, WindowBuilder, WindowUrl}; +use tauri_plugin_sql::{Migration, MigrationKind}; + mod commands; use commands::base64_image::base64_image::base64_image; @@ -19,7 +21,50 @@ use commands::ping::ping::ping; use commands::qr::qr::read_qr; fn main() { + // Todo move to different file + let migrations = vec![ + Migration { + version: 1, + description: "create_initial_tables", + sql: "\ + CREATE TABLE snippets (\ + id INTEGER PRIMARY KEY AUTOINCREMENT,\ + name TEXT NOT NULL,\ + path TEXT NOT NULL,\ + content TEXT,\ + filetype TEXT,\ + parent_id INTEGER,\ + created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\ + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP\ + );\ + CREATE TABLE snippets_tags (\ + id INTEGER PRIMARY KEY AUTOINCREMENT,\ + snippet_id INTEGER NOT NULL,\ + tag TEXT NOT NULL,\ + FOREIGN KEY(snippet_id) REFERENCES snippets (id)\ + );\ + CREATE TABLE snippets_notes (\ + id INTEGER PRIMARY KEY AUTOINCREMENT,\ + snippet_id INTEGER NOT NULL,\ + note TEXT NOT NULL,\ + FOREIGN KEY(snippet_id) REFERENCES snippets (id)\ + );\ + CREATE TABLE snippets_files (\ + id INTEGER PRIMARY KEY AUTOINCREMENT,\ + snippet_id INTEGER NOT NULL,\ + file_path TEXT NOT NULL,\ + FOREIGN KEY(snippet_id) REFERENCES snippets (id)\ + );", + kind: MigrationKind::Up, + } + ]; + tauri::Builder::default() + .plugin( + tauri_plugin_sql::Builder::default() + .add_migrations("sqlite:devtools.db", migrations) + .build() + ) .plugin(tauri_plugin_store::Builder::default().build()) .plugin(tauri_plugin_aptabase::Builder::new("A-EU-0242299228").build()) .invoke_handler(tauri::generate_handler![ diff --git a/src/App.tsx b/src/App.tsx index 99a8b55..dffbf97 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -51,6 +51,7 @@ const TextDiff = loadable(() => import("./Features/text/TextDiff")); const TextUtils = loadable(() => import("./Features/text/TextUtils")); const Markdown = loadable(() => import("./Features/markdown/Markdown")); const Readme = loadable(() => import("./Features/markdown/Readme")); +const Snippets = loadable(() => import("./Features/snippets/Snippets")); const YamlJson = loadable(() => import("./Features/json-yaml/Yaml")); const Pastebin = loadable(() => import("./Features/pastebin/Pastebin")); const Repl = loadable(() => import("./Features/repl/Repl")); @@ -237,6 +238,7 @@ function App() { }> }> }> + }> }> }> }> diff --git a/src/Features/snippets/Snippets.tsx b/src/Features/snippets/Snippets.tsx new file mode 100644 index 0000000..bae7140 --- /dev/null +++ b/src/Features/snippets/Snippets.tsx @@ -0,0 +1,36 @@ +import { Group, Stack } from "@mantine/core"; +import { findAllSnippets, seedDatabase } from "@/utils/database"; +import { useEffect, useState } from "react"; + +const Snippets = () => { + const [snippets, setSnippets] = useState([]); + useEffect(() => { + const fetchData = async () => { + const data = await findAllSnippets(); + setSnippets(data as any); + }; + fetchData().then((r) => r); + }, []); + + const seed = async () => { + await seedDatabase(); + const data = await findAllSnippets(); + setSnippets(data as any); + }; + return ( + + +
+ Snippets +
+ +
{JSON.stringify(snippets, null, 2)}
+
+ ); +}; + +export default Snippets; diff --git a/src/Layout/Navbar/items.tsx b/src/Layout/Navbar/items.tsx index 2e6a250..8355807 100644 --- a/src/Layout/Navbar/items.tsx +++ b/src/Layout/Navbar/items.tsx @@ -260,6 +260,13 @@ export const navitems: NavItem[] = [ text: "Count chars", group: "Utilities", }, + { + id: "snippets", + to: "/snippets", + icon: , + text: "Snippets", + group: "Utilities", + }, { id: "markdown", to: "/markdown", diff --git a/src/utils/database.ts b/src/utils/database.ts new file mode 100644 index 0000000..b501df4 --- /dev/null +++ b/src/utils/database.ts @@ -0,0 +1,128 @@ +import Database from "tauri-plugin-sql-api"; + +const getDb = async () => await Database.load("sqlite:devtools.db"); + +// Insert a new snippet +async function insertSnippet(snippet: { + name: string; + path: string; + content?: string; + filetype?: string; + parent_id?: number; +}) { + const db = await getDb(); + await db + .execute( + "INSERT INTO snippets (name, path, content, filetype, parent_id) VALUES (?, ?, ?, ?, ?)", + [ + snippet.name, + snippet.path, + snippet.content, + snippet.filetype, + snippet.parent_id, + ] + ) + .then((r) => console.log(r)) + .catch((e) => console.log(e)); +} + +// Insert a new tag +async function insertSnippetTag(snippet_id: number, tag: string) { + const db = await getDb(); + await db.execute( + "INSERT INTO snippets_tags (snippet_id, tag) VALUES (?, ?)", + [snippet_id, tag] + ); +} + +// Insert a new note +async function insertSnippetNote(snippet_id: number, note: string) { + const db = await getDb(); + await db.execute( + "INSERT INTO snippets_notes (snippet_id, note) VALUES (?, ?)", + [snippet_id, note] + ); +} + +// Update a snippet +async function updateSnippet(snippet: { + id: number; + name?: string; + path?: string; + content?: string; + filetype?: string; + parent_id?: number; +}) { + const db = await getDb(); + await db.execute( + `UPDATE snippets SET + name = COALESCE(?, name), + path = COALESCE(?, path), + content = COALESCE(?, content), + filetype = COALESCE(?, filetype), + parent_id = COALESCE(?, parent_id) + WHERE id = ?`, + [ + snippet.name, + snippet.path, + snippet.content, + snippet.filetype, + snippet.parent_id, + snippet.id, + ] + ); +} + +// Get snippet by ID +async function getSnippetById(id: number) { + const db = await getDb(); + const snippet = await db.execute("SELECT * FROM snippets WHERE id = ?", [id]); + return snippet; +} + +export async function findAllSnippets() { + try { + const db = await getDb(); + const snippets = await db.execute("SELECT * FROM snippets"); + return snippets; + } catch (error) { + console.error(error); + return []; + } +} + +export async function seedDatabase() { + const db = await getDb(); + + // Clear existing data (optional) + await db.execute("DELETE FROM snippets"); + await db.execute("DELETE FROM snippets_tags"); + await db.execute("DELETE FROM snippets_notes"); + + // Insert sample snippets + const snippetId1 = await insertSnippet({ + name: "Sample Snippet 1", + path: "/path/to/snippet1", + content: "Content of the first snippet.", + filetype: "text", + parent_id: undefined, + }); + + const snippetId2 = await insertSnippet({ + name: "Sample Snippet 2", + path: "/path/to/snippet2", + content: "Content of the second snippet.", + filetype: "text", + parent_id: undefined, + }); + + // Insert tags + await insertSnippetTag(snippetId1, "sample"); + await insertSnippetTag(snippetId2, "example"); + + // Insert notes + await insertSnippetNote(snippetId1, "This is a note for the first snippet."); + await insertSnippetNote(snippetId2, "This is a note for the second snippet."); + + console.log("Database seeded successfully."); +} diff --git a/src/utils/db.ts b/src/utils/db.ts index 68abecd..c0131c5 100644 --- a/src/utils/db.ts +++ b/src/utils/db.ts @@ -1,5 +1,5 @@ import { Store } from "tauri-plugin-store-api"; -import { defaultConfig } from "../Contexts/AppContextProvider"; +import { defaultConfig } from "@/Contexts/AppContextProvider"; const db = new Store("settings.json"); From 1ff9cd3ab2e98e999db2e8f9d88cbf03d3314ba0 Mon Sep 17 00:00:00 2001 From: Sparkenstein Date: Sat, 14 Sep 2024 02:04:18 +0530 Subject: [PATCH 04/18] feat: new uniform icons --- package.json | 4 +- src/App.tsx | 4 +- src/Components/Copy.tsx | 6 +- src/Components/OutputBox.tsx | 6 +- src/Components/Welcome.tsx | 4 +- src/Features/colors/ColorTesting.tsx | 18 +- src/Features/colors/Colors.tsx | 6 +- src/Features/colors/CustomPicker.tsx | 1 + src/Features/epoch/Epoch.tsx | 4 +- src/Features/faker/Faker.tsx | 22 +- src/Features/image/BulkImage.tsx | 4 +- src/Features/image/Image.tsx | 19 +- src/Features/json/SingleTab.tsx | 16 +- src/Features/password/Counter.tsx | 6 +- src/Features/password/index.tsx | 11 +- src/Features/pdf/PdfReader.tsx | 19 +- src/Features/rest/Row.tsx | 6 +- src/Features/unit-converter/UnitConverter.tsx | 4 +- src/Layout/Navbar/ColorIcons.tsx | 261 ++++++++++++++++++ src/Layout/Navbar/components/GroupedView.tsx | 30 +- .../Navbar/components/UngroupedView.tsx | 14 +- .../Navbar/components/ungrouped.module.css | 3 +- src/Layout/Navbar/index.tsx | 6 +- src/Layout/Navbar/items.tsx | 227 +++++++-------- src/Layout/Settings.tsx | 10 +- yarn.lock | 17 +- 26 files changed, 501 insertions(+), 227 deletions(-) create mode 100644 src/Layout/Navbar/ColorIcons.tsx diff --git a/package.json b/package.json index 09ed47f..7ee94bb 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@prettier/plugin-xml": "^3.4.1", "@rollup/plugin-alias": "^5.1.0", "@sqltools/formatter": "^1.2.5", + "@tabler/icons-react": "^3.16.0", "@tauri-apps/api": "^1.6.0", "@uiw/react-markdown-preview": "^5.1.1", "angular-html-parser": "^5.2.0", @@ -64,7 +65,6 @@ "react-compare-slider": "^3.0.1", "react-cropper": "^2.3.3", "react-dom": "^18.2.0", - "react-icons": "^5.2.1", "react-katex": "^3.0.1", "react-live": "^4.1.5", "react-pdf": "^7.7.3", @@ -128,4 +128,4 @@ "vite": "^5.2.7", "vite-tsconfig-paths": "^5.0.1" } -} +} diff --git a/src/App.tsx b/src/App.tsx index 99a8b55..39ec712 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,7 +18,7 @@ import { import { Spotlight } from "@mantine/spotlight"; import { loader } from "@monaco-editor/react"; import { useEffect, useState } from "react"; -import { FaSearch } from "react-icons/fa"; +import { IconSearch } from "@tabler/icons-react"; import { useShepherdTour } from "react-shepherd"; import steps from "./utils/steps"; import { Route, Routes, useLocation, useNavigate } from "react-router-dom"; @@ -282,7 +282,7 @@ function App() { , + leftSection: , placeholder: "Jump to", }} actions={data.map((a) => ({ diff --git a/src/Components/Copy.tsx b/src/Components/Copy.tsx index 1129541..862a069 100644 --- a/src/Components/Copy.tsx +++ b/src/Components/Copy.tsx @@ -1,6 +1,6 @@ import { Button, CopyButton, Tooltip } from "@mantine/core"; import { clipboard } from "@tauri-apps/api"; -import { FaCheck, FaCopy } from "react-icons/fa"; +import { IconCheck, IconCopy } from "@tabler/icons-react"; export function Copy({ value, @@ -14,7 +14,9 @@ export function Copy({ {({ copied, copy }) => ( diff --git a/src/Features/image/BulkImage.tsx b/src/Features/image/BulkImage.tsx index 11192eb..0a497ca 100644 --- a/src/Features/image/BulkImage.tsx +++ b/src/Features/image/BulkImage.tsx @@ -13,7 +13,7 @@ import { invoke } from "@tauri-apps/api"; import { open } from "@tauri-apps/api/dialog"; import { useEffect, useState } from "react"; import classes from "./styles.module.css"; -import { MdInfo } from "react-icons/md"; +import { IconInfoCircle } from "@tabler/icons-react"; import { useDisclosure } from "@mantine/hooks"; import { listen } from "@tauri-apps/api/event"; import clsx from "clsx"; @@ -122,7 +122,7 @@ export default function BulkImageCompressor() { allowDeselect={false} /> - + diff --git a/src/Features/image/Image.tsx b/src/Features/image/Image.tsx index 712d5b2..982ffc8 100644 --- a/src/Features/image/Image.tsx +++ b/src/Features/image/Image.tsx @@ -14,7 +14,10 @@ import { dialog, fs, invoke } from "@tauri-apps/api"; import { save } from "@tauri-apps/api/dialog"; import { convertFileSrc } from "@tauri-apps/api/tauri"; import { useEffect, useState } from "react"; -import { ReactCompareSlider } from "react-compare-slider"; +import { + ReactCompareSlider, + ReactCompareSliderImage, +} from "react-compare-slider"; type ImageType = "Jpeg" | "Png" | "Webp"; @@ -126,16 +129,15 @@ export default function Image2() { {converted && ( } itemTwo={ - {converted && ( - NOTE: extremly large images may take a while to load. + NOTE: Large images may take a while to load, instead try + squoosh.app/ )} diff --git a/src/Features/json/SingleTab.tsx b/src/Features/json/SingleTab.tsx index 399a954..7a3b660 100644 --- a/src/Features/json/SingleTab.tsx +++ b/src/Features/json/SingleTab.tsx @@ -8,10 +8,10 @@ import { useState, } from "react"; import { - BsArrowReturnLeft, - BsTextIndentLeft, - BsTextParagraph, -} from "react-icons/bs"; + IconTextWrap, + IconIndentIncrease, + IconPilcrow, +} from "@tabler/icons-react"; import { Monaco } from "@/Components/MonacoWrapper"; @@ -42,7 +42,7 @@ export const SingleTab = ({ setCode(JSON.stringify(JSON.parse(code), null, 2)); }} > - + - + - + - + {children} diff --git a/src/Features/password/Counter.tsx b/src/Features/password/Counter.tsx index 2ef373b..aef73b4 100644 --- a/src/Features/password/Counter.tsx +++ b/src/Features/password/Counter.tsx @@ -9,7 +9,7 @@ import { Text, } from "@mantine/core"; import { useRef } from "react"; -import { FiMinus, FiPlus } from "react-icons/fi"; +import { IconPlus, IconMinus } from "@tabler/icons-react"; interface QuantityInputProps { min: number; @@ -41,7 +41,7 @@ export function QuantityInput({ className={classes.control} onMouseDown={(event) => event.preventDefault()} > - + event.preventDefault()} > - + diff --git a/src/Features/password/index.tsx b/src/Features/password/index.tsx index 157b45d..409b0bd 100644 --- a/src/Features/password/index.tsx +++ b/src/Features/password/index.tsx @@ -15,9 +15,8 @@ import { notifications } from "@mantine/notifications"; //@ts-ignore import { generatePassword } from "lesspass"; import { useEffect, useState } from "react"; -import { FaCheck } from "react-icons/fa"; -import { FiCheck } from "react-icons/fi"; -import { MdDelete } from "react-icons/md"; + +import { IconCheck, IconX } from "@tabler/icons-react"; import { OutputBox } from "@/Components/OutputBox"; import { db } from "@/utils"; @@ -82,7 +81,7 @@ const StatelessPassword = () => { notifications.show({ title: "Done", - icon: , + icon: , message: "Data stored to db", }); }); @@ -236,7 +235,7 @@ const StatelessPassword = () => { onClick={() => loadConfig(site, config)} variant="filled" > - + { }} variant="filled" > - + diff --git a/src/Features/pdf/PdfReader.tsx b/src/Features/pdf/PdfReader.tsx index 2b6bc16..17e0618 100644 --- a/src/Features/pdf/PdfReader.tsx +++ b/src/Features/pdf/PdfReader.tsx @@ -7,12 +7,13 @@ import { open } from "@tauri-apps/api/dialog"; import "react-pdf/dist/Page/AnnotationLayer.css"; import "react-pdf/dist/Page/TextLayer.css"; import { SizeMe } from "react-sizeme"; + import { - MdKeyboardArrowLeft, - MdKeyboardArrowRight, - MdZoomIn, - MdZoomOut, -} from "react-icons/md"; + IconArrowLeft, + IconArrowRight, + IconZoomIn, + IconZoomOut, +} from "@tabler/icons-react"; import classes from "./styles.module.css"; @@ -72,7 +73,7 @@ export default function PdfReader() { Open new setPage((p) => p - 1)} disabled={page === 1}> - + {page} of {numPages} @@ -81,11 +82,11 @@ export default function PdfReader() { onClick={() => setPage((p) => p + 1)} disabled={page === numPages} > - + setScale((scale) => scale + 0.5)}> - + @@ -93,7 +94,7 @@ export default function PdfReader() { disabled={scale === 1} onClick={() => setScale((scale) => scale - 0.5)} > - + diff --git a/src/Features/rest/Row.tsx b/src/Features/rest/Row.tsx index e760a8c..9f793cf 100644 --- a/src/Features/rest/Row.tsx +++ b/src/Features/rest/Row.tsx @@ -1,5 +1,5 @@ import { Group, TextInput, ThemeIcon } from "@mantine/core"; -import { MdCheckCircle, MdCircle, MdDelete } from "react-icons/md"; +import { IconCheck, IconX } from "@tabler/icons-react"; import { ParamType } from "./SingleTab"; @@ -44,7 +44,7 @@ export const Row = ({ }} color={param.enabled ? "green" : "gray"} > - {param.enabled ? : } + - + ); diff --git a/src/Features/unit-converter/UnitConverter.tsx b/src/Features/unit-converter/UnitConverter.tsx index 7f8e4b1..ea59082 100644 --- a/src/Features/unit-converter/UnitConverter.tsx +++ b/src/Features/unit-converter/UnitConverter.tsx @@ -8,7 +8,7 @@ import { } from "@mantine/core"; import Convert, { Unit } from "convert-units"; import { useRef, useState } from "react"; -import { FaExchangeAlt } from "react-icons/fa"; +import { IconExchange } from "@tabler/icons-react"; const UnitConverter = () => { const [category, setCategory] = useState("length"); @@ -98,7 +98,7 @@ const UnitConverter = () => { setFromUnit(toUnit); }} > - + diff --git a/src/Layout/Navbar/ColorIcons.tsx b/src/Layout/Navbar/ColorIcons.tsx new file mode 100644 index 0000000..552bc52 --- /dev/null +++ b/src/Layout/Navbar/ColorIcons.tsx @@ -0,0 +1,261 @@ +export const Package = () => ( + + + + +); + +export const Transit = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const DataProtection = () => ( + + + + + + + + +); + +export const Safe = () => ( + + + + + + + + + + + + + + + + + + + +); + +export const Picture = () => ( + + + + + + +); + +export const Shop = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const MindMap = () => ( + + + + + + + + + + + +); + +export const Binoculars = () => ( + + + + + + + + + + + + + + + + + + + +); + +export const Electricity = () => ( + + + +); + +export const SerialTask = () => ( + + + + + + + + + + +); diff --git a/src/Layout/Navbar/components/GroupedView.tsx b/src/Layout/Navbar/components/GroupedView.tsx index f4504c0..126542a 100644 --- a/src/Layout/Navbar/components/GroupedView.tsx +++ b/src/Layout/Navbar/components/GroupedView.tsx @@ -1,12 +1,12 @@ import { Accordion, Stack, Group, ActionIcon, Text } from "@mantine/core"; -import { VscPinned, VscPin } from "react-icons/vsc"; +import { IconPin, IconPinned } from "@tabler/icons-react"; import cx from "clsx"; import { groupIcons } from "../items"; import { DropDownItem } from ".."; import classes from "../styles.module.css"; import { useLocation, useNavigate } from "react-router-dom"; -import { useEffect, useState } from "react"; +import { cloneElement, ReactElement, useEffect, useState } from "react"; type GroupedViewProps = { dropDownItems: DropDownItem[]; @@ -48,8 +48,18 @@ export const GroupedView = ({ .map((group) => { return ( - - {group.group} + + {group.group} @@ -69,10 +79,10 @@ export const GroupedView = ({ onClick={() => nav(i.value)} > - - {i.icon} - - + {cloneElement(i.icon as ReactElement, { + size: "16px", + })} + {i.label} @@ -91,9 +101,9 @@ export const GroupedView = ({ }} > {pinExists ? ( - + ) : ( - + )} diff --git a/src/Layout/Navbar/components/UngroupedView.tsx b/src/Layout/Navbar/components/UngroupedView.tsx index ad52683..f9e1a71 100644 --- a/src/Layout/Navbar/components/UngroupedView.tsx +++ b/src/Layout/Navbar/components/UngroupedView.tsx @@ -6,14 +6,14 @@ import { } from "@hello-pangea/dnd"; import cx from "clsx"; import { ActionIcon, Box, Stack, Text, Tooltip } from "@mantine/core"; -import { VscPin, VscPinned } from "react-icons/vsc"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { trackOtherEvent } from "@/utils/analytics"; import { db } from "@/utils"; import classes from "./ungrouped.module.css"; import { NavItem } from ".."; -import { MdDragIndicator } from "react-icons/md"; +import { IconMenuOrder, IconPin, IconPinned } from "@tabler/icons-react"; +import { cloneElement, ReactElement } from "react"; type UngroupedViewProps = { navItems: NavItem[]; @@ -88,9 +88,11 @@ export const UngroupedView = ({ size={"xs"} variant="subtle" > - + - {e.icon} + {cloneElement(e.icon as ReactElement, { + size: "16px", + })} {e.extra ? ( {pinExists ? ( - + ) : ( - + )} diff --git a/src/Layout/Navbar/components/ungrouped.module.css b/src/Layout/Navbar/components/ungrouped.module.css index 4c0d483..dc0fe52 100644 --- a/src/Layout/Navbar/components/ungrouped.module.css +++ b/src/Layout/Navbar/components/ungrouped.module.css @@ -60,7 +60,7 @@ .listTitle { display: flex; - gap: 5px; + gap: 10px; align-items: center; flex-direction: row; text-align: center; @@ -120,6 +120,5 @@ .rowIcon { margin-top: 5px; - font-size: 14px; color: light-dark(var(--mantine-color-dark-7), var(--mantine-color-dark-1)); } diff --git a/src/Layout/Navbar/index.tsx b/src/Layout/Navbar/index.tsx index 3373fd5..9dc4c23 100644 --- a/src/Layout/Navbar/index.tsx +++ b/src/Layout/Navbar/index.tsx @@ -9,7 +9,7 @@ import { } from "@mantine/core"; import React, { useEffect, useMemo, useState } from "react"; -import { MdHome, MdMenu, MdMenuOpen } from "react-icons/md"; +import { IconHome, IconMenu2, IconX } from "@tabler/icons-react"; import { useLocation, useNavigate } from "react-router-dom"; import cx from "clsx"; @@ -174,7 +174,7 @@ export const Navbar = () => { onClick={() => nav("/")} display={iconMode ? "none" : "flex"} > - +