├── .dockerignore ├── .gitignore ├── .vite └── deps │ ├── _metadata.json │ └── package.json ├── Dockerfile ├── LICENSE ├── README.md ├── biome.json ├── bun.lockb ├── index.html ├── manifest.json ├── package.json ├── postcss.config.js ├── src ├── App.tsx ├── components │ ├── background-image.tsx │ ├── motion-primitives │ │ └── dock.tsx │ ├── sidebar │ │ ├── index.tsx │ │ ├── sidebar-content.tsx │ │ ├── sidebar-options │ │ │ ├── app-options.tsx │ │ │ ├── clock-options.tsx │ │ │ ├── data-backup-options │ │ │ │ ├── export.tsx │ │ │ │ ├── import.tsx │ │ │ │ ├── index.tsx │ │ │ │ └── type.ts │ │ │ ├── dock-options │ │ │ │ └── index.tsx │ │ │ ├── gallery-options │ │ │ │ ├── gallery-tab.tsx │ │ │ │ ├── index.tsx │ │ │ │ └── interval-input.tsx │ │ │ ├── general-options.tsx │ │ │ ├── index.tsx │ │ │ ├── misc-options.tsx │ │ │ ├── shared │ │ │ │ ├── app-card.tsx │ │ │ │ ├── newtab-header.tsx │ │ │ │ ├── options-group.tsx │ │ │ │ ├── tab-switch-button.tsx │ │ │ │ └── toggle-option.tsx │ │ │ ├── tabs │ │ │ │ ├── ai-tools │ │ │ │ │ └── index.tsx │ │ │ │ └── search-engines │ │ │ │ │ ├── index.tsx │ │ │ │ │ └── search-engine-card.tsx │ │ │ └── weather-options.tsx │ │ └── sidebar-store.tsx │ ├── switch.tsx │ ├── ui │ │ ├── alert.tsx │ │ ├── app-icon.tsx │ │ ├── button.tsx │ │ ├── checkbox.tsx │ │ ├── input.tsx │ │ ├── menu.tsx │ │ └── modal.tsx │ └── widgets │ │ ├── ai-tools.tsx │ │ ├── app-drawer │ │ ├── app-form.tsx │ │ ├── app-item.tsx │ │ ├── app-list.tsx │ │ ├── app-menu.tsx │ │ ├── edit-applist.tsx │ │ ├── index.tsx │ │ └── selected-app.store.tsx │ │ ├── clock │ │ ├── analogue-clock.tsx │ │ ├── digital-clock.tsx │ │ └── index.tsx │ │ ├── custom-text.tsx │ │ ├── dock.tsx │ │ ├── gallery.tsx │ │ ├── search-bar │ │ ├── index.tsx │ │ ├── query-suggestions │ │ │ ├── index.tsx │ │ │ └── suggestion-item.tsx │ │ ├── search-engines.tsx │ │ └── search-input.tsx │ │ ├── weather │ │ └── index.tsx │ │ └── widget-container.tsx ├── index.css ├── lib │ ├── icons.ts │ └── variables.ts ├── main.tsx ├── store │ ├── app-store.ts │ ├── image-store.ts │ ├── options.ts │ ├── query-history.ts │ ├── search-engine.ts │ ├── storage.ts │ └── theme.ts ├── types │ ├── index.ts │ ├── react.ts │ └── weather.ts ├── utils │ ├── datetime.ts │ ├── index.ts │ └── theme-provider.js └── vite-env.d.ts ├── tailwind.config.js ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | Containerfile* 3 | .git 4 | dist 5 | .gitignore 6 | README.md 7 | LICENSE 8 | .env.local 9 | biome.json 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /.vite/deps/_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "hash": "e76ea2dd", 3 | "configHash": "d8b70fc0", 4 | "lockfileHash": "e3b0c442", 5 | "browserHash": "0c0bc883", 6 | "optimized": {}, 7 | "chunks": {} 8 | } -------------------------------------------------------------------------------- /.vite/deps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM oven/bun:1 as base 2 | WORKDIR /app 3 | 4 | FROM base as install 5 | RUN mkdir -p /temp/dev 6 | COPY package.json bun.lockb /temp/dev/ 7 | RUN cd /temp/dev && bun install --frozen-lockfile 8 | 9 | RUN mkdir -p /temp/prod 10 | COPY package.json bun.lockb /temp/prod/ 11 | RUN cd /temp/prod && bun install --frozen-lockfile 12 | 13 | FROM base AS prerelease 14 | COPY --from=install /temp/dev/node_modules node_modules 15 | COPY . . 16 | RUN bun run build 17 | 18 | 19 | FROM base AS release 20 | COPY --from=install /temp/prod/node_modules node_modules 21 | COPY --from=prerelease /app/dist /app/dist 22 | COPY --from=prerelease /app/package.json . 23 | 24 | USER bun 25 | EXPOSE 4173/tcp 26 | ENTRYPOINT [ "bun", "preview", "--host" ] 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | banner 3 |
4 | 5 |

Nothing UI New Tab is an elegant and feature-rich start page for your browser, heavily inspired by Material You NewTab. Designed with customization and user experience in mind, it transforms your new tab page into a personalized dashboard that caters to your needs and preferences.

6 | 7 | **[
 Features 
](#features)** 8 | **[
 Installation 
](#installation)** 9 | **[
 License 
][License]** 10 | 11 | [License]: "https://github.com/ImRayy/nothing-ui-new-tab/blob/main/LICENSE" 12 |
13 | 14 | ## Screenshots 15 | |![ss-08](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-08.png?updatedAt=1735060634920&tr=w-1389%2Ch-692%2Cfo-custom%2Ccm-extract)| 16 | |--| 17 | 18 | |![ss-01](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-02.png)|![ss-03](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-03.png)|![ss-04](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-04.png)| 19 | |---|---|---| 20 | 21 | |![ss-05](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-05.png)|![ss-06](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-06.png)|![ss-07](https://ik.imagekit.io/rayshold/projects/nothing-ui-new-tab/screenshot-07.png)| 22 | |---|---|---| 23 | 24 | ## Features 25 | 26 | - Create, Update & Remove app 27 | - Dynamic app icon upon adding 28 | - Custom icon from [iconify](https://icon-sets.iconify.design/) 29 | - Custom images for gallery widget, and custom bg image 30 | - Toggle monochrome(grayscale) image on gallery widget, and background 31 | - Toggle blur effect background image 32 | - Toggle dock, app drawer, ai-tools, greeter 33 | - Toggle between digital & analogue clock 34 | - Weather ofc, necessary 35 | - Custom greeting text 36 | - Add search engines, set icon 37 | - Set shortcut for search engine to quick switching 38 | - Search suggestions 39 | 40 | **Planned Features** 41 | - [ ] Random image from unsplash or something 42 | - [ ] Different color-schems 43 | - [ ] Glass widgets 44 | - [ ] Popup to add websites directly to app drawer, dock 45 | 46 | ...more unplanned features 47 | 48 | ## Installation 49 | 50 | **Requirements** 51 | 52 | - `bun` 53 | - `podman` or `docker` *(optional)* 54 | 55 | **Build** 56 | 57 | 1. `git clone https://github.com/ImRayy/nothing-ui-newtab` 58 | 2. `cd nothing-ui-newtab` 59 | 3. `bun install` 60 | 4. `bun run build` 61 | 62 | **NOTE:** You can build [docker/podman image as well](#step-1) 63 | 64 | ## Usage 65 | 66 | #### Firefox extension 67 | 68 | There are multiple ways to use this as a Firefox extension. The first and easiest method is to host this website on a hosting provider and use [New Tab Override](https://addons.mozilla.org/en-US/firefox/addon/new-tab-override) to set it as your new tab page. My preferred method is to use this as docker/podman image and start with systemd or add it to init script or something to start when system boots automatically 69 | 70 | > [!TIP] 71 | > When using New Tab Override extension make sure you check `Set focus to the web page instead of the address bar` option 72 | 73 | ##### Clone & Build 74 | 75 | ```sh 76 | git clone https://github.com/ImRayy/nothing-ui-newtab 77 | cd nothing-ui-newtab 78 | 79 | ## Podman 80 | podman build -t nothing-ui-newtab . 81 | 82 | ## Docker 83 | docker build -t nothing-ui-newtab . 84 | ``` 85 | --- 86 | 87 | ##### Run 88 | 89 | ```bash 90 | ## Podman 91 | podman run -d -p :4173 nothing-ui-newtab 92 | 93 | ## Docker 94 | docker run -d -p :4173 nothingui-newtab:latest 95 | ``` 96 | --- 97 | 98 | ##### Autostart (Podman) [rootless] 99 | 100 | ###### Legacy Systemd Medhod 101 | 102 | ```bash 103 | ## Generate systemd service 104 | podman generate systemd --new --name > ~/.config/systemd/user/nothing-ui-newtab.service 105 | 106 | ## Restart systemd daemon which will reload and re-execute the systemd 107 | ## user instance without stopping the currently running services 108 | systemctl --user daemon-reload 109 | 110 | ## Enable & start container service that you just created 111 | systemctl --user enable nothing-ui-newtab.service --now 112 | ``` 113 | 114 | ###### Quadlet Systemd Method [recommended] 115 | 116 | 1. Copy following content in `nothing-ui-newtab.container` and move to `~/.config/containers/systemd` 117 | ```container 118 | [Unit] 119 | Description=Nothing UI New Tab 120 | After=graphical-session.target 121 | 122 | [Container] 123 | Image=localhost/nothing-ui-newtab ## Could be something else, check with `podman container ls` 124 | PublishPort=:4173 125 | ``` 126 | 2. `systemctl --user daemon-reload` 127 | 3. `systemctl --user enable nothing-ui-newtab.service --now` 128 | 129 | --- 130 | 131 | ##### Autostart (docker) [rootless] 132 | 133 | ```bash 134 | docker run --restart unless-stopped -d -p :4173 nothingui-newtab:latest 135 | ``` 136 | 137 | ___ 138 | 139 | #### Chrome/Chromium-based Extension 140 | 141 | 1. [Install & build](#installation) 142 | 2. Click on extension icon somewhere in top right corner, click on extension button > `Manage extensions` > enable `Developer Mode` > `Load Unpacked` > Select nothing-ui-newtab/dist 143 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", 3 | "vcs": { 4 | "enabled": false, 5 | "clientKind": "git", 6 | "useIgnoreFile": false 7 | }, 8 | "files": { 9 | "ignoreUnknown": false, 10 | "ignore": [] 11 | }, 12 | "formatter": { 13 | "enabled": true, 14 | "indentStyle": "space", 15 | "indentWidth": 2, 16 | "lineEnding": "lf" 17 | }, 18 | "organizeImports": { 19 | "enabled": true 20 | }, 21 | "linter": { 22 | "enabled": true, 23 | "rules": { 24 | "recommended": true, 25 | "suspicious": { 26 | "recommended": true, 27 | "noExplicitAny": "warn", 28 | "noConsoleLog": "warn" 29 | }, 30 | "style": { 31 | "noNonNullAssertion": "off", 32 | "noUnusedTemplateLiteral": "warn", 33 | "noVar": "error", 34 | "useConst": "warn", 35 | "useTemplate": "warn" 36 | }, 37 | "nursery": { 38 | "useSortedClasses": "error" 39 | } 40 | } 41 | }, 42 | "javascript": { 43 | "formatter": { 44 | "quoteStyle": "double", 45 | "quoteProperties": "asNeeded", 46 | "trailingCommas": "all", 47 | "semicolons": "asNeeded", 48 | "attributePosition": "auto", 49 | "arrowParentheses": "always", 50 | "bracketSpacing": true 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ImRayy/nothing-ui-newtab/be687accf727b3348064b9e0724d083ba3504efd/bun.lockb -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Nothing UI New Tab 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "Nothing UI NewTab", 4 | "version": "1.0", 5 | "host_permissions": [ 6 | "https://fonts.googleapis.com/", 7 | "https://fonts.gstatic.com/" 8 | ], 9 | "web_accessible_resources": [ 10 | { 11 | "resources": ["*.ttf", "*.woff", "*.woff2", "*.ttf", "*.eot"], 12 | "matches": [""] 13 | } 14 | ], 15 | "chrome_url_overrides": { 16 | "newtab": "index.html" 17 | }, 18 | "permissions": ["tabs", "scripting"] 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nothing-new-tab", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@headlessui/react": "^2.2.0", 14 | "@iconify/react": "^5.0.2", 15 | "@leeoniya/ufuzzy": "^1.0.18", 16 | "@radix-ui/react-context-menu": "^2.2.2", 17 | "@radix-ui/react-slot": "^1.1.2", 18 | "@tailwindcss/forms": "^0.5.9", 19 | "class-variance-authority": "^0.7.1", 20 | "clsx": "^2.1.1", 21 | "compressorjs": "^1.2.1", 22 | "framer-motion": "^11.13.1", 23 | "idb-keyval": "^6.2.1", 24 | "nanoid": "^5.0.9", 25 | "react": "^18.3.1", 26 | "react-dom": "^18.3.1", 27 | "sonner": "^1.7.4", 28 | "tailwind-merge": "^2.5.5", 29 | "usehooks-ts": "^3.1.0", 30 | "zustand": "^5.0.2" 31 | }, 32 | "devDependencies": { 33 | "@biomejs/biome": "1.9.4", 34 | "@crxjs/vite-plugin": "^2.0.0-beta.28", 35 | "@types/react": "^18.3.12", 36 | "@types/react-dom": "^18.3.1", 37 | "@vitejs/plugin-react": "^4.3.4", 38 | "autoprefixer": "^10.4.20", 39 | "globals": "^15.12.0", 40 | "postcss": "^8.4.49", 41 | "tailwindcss": "^3.4.17", 42 | "typescript": "~5.6.2", 43 | "vite": "^6.0.1" 44 | }, 45 | "trustedDependencies": ["@biomejs/biome"] 46 | } 47 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as idbKeyval from "idb-keyval" 2 | import { nanoid } from "nanoid" 3 | import { Suspense, lazy, useEffect } from "react" 4 | import { Toaster } from "sonner" 5 | import BackgroundImage from "./components/background-image" 6 | import Sidebar from "./components/sidebar" 7 | import WidgetContainer from "./components/widgets/widget-container" 8 | import type { App as AppType } from "./lib/variables" 9 | import { useImageStore } from "./store/image-store" 10 | import { useOptionsStore } from "./store/options" 11 | import { useThemeStore } from "./store/theme" 12 | 13 | const Dock = lazy(() => import("./components/widgets/dock")) 14 | const AiTools = lazy(() => import("./components/widgets/ai-tools")) 15 | const AppDrawer = lazy(() => import("./components/widgets/app-drawer")) 16 | 17 | export default function App() { 18 | const { isDockEnabled, isAIToolsEnabled, isAppDrawerEnabled } = 19 | useOptionsStore() 20 | const isLightMode = useThemeStore((s) => s.isLightMode) 21 | const fetchImages = useImageStore((s) => s.fetchImages) 22 | 23 | useEffect(() => { 24 | const html = document.documentElement 25 | const mode = html.getAttribute("data-theme") 26 | if (mode !== "light" && isLightMode) { 27 | html.setAttribute("data-theme", "light") 28 | } else { 29 | html.setAttribute("data-theme", "dark") 30 | } 31 | }, [isLightMode]) 32 | 33 | useEffect(() => { 34 | migrateAppListToAddIds() 35 | fetchImages() 36 | }, [fetchImages]) 37 | 38 | return ( 39 | <> 40 | 41 | 42 |
43 | 44 | 45 | 46 | {isDockEnabled && } 47 | {isAIToolsEnabled && } 48 | {isAppDrawerEnabled && } 49 | 50 |
51 | 52 | ) 53 | } 54 | 55 | // WARN: Temporary migration function for adding IDs to existing app list 56 | // Such as app drawer, ai tools & dock apps 57 | // Reason: Database migration to include unique identifiers 58 | // Remove this function after some period of time 59 | async function migrateAppListToAddIds() { 60 | const storeName = "app-store" 61 | 62 | const allIdExists = (list: AppType[]) => { 63 | return list.findIndex(({ id }) => id) === 0 64 | } 65 | 66 | const addIds = (list: AppType[]) => { 67 | return list.map((app) => { 68 | if (!app.id) { 69 | return { ...app, id: nanoid() } 70 | } 71 | return app 72 | }) 73 | } 74 | 75 | let apps = await idbKeyval.get(storeName) 76 | 77 | if (!apps && typeof apps === "undefined") { 78 | return 79 | } 80 | 81 | apps = JSON.parse(apps) 82 | 83 | const dockApps: AppType[] = apps.state.dockApps 84 | const drawerApps = apps.state.drawerApps 85 | const aiTools = apps.state.aiTools 86 | 87 | if ( 88 | allIdExists(dockApps) && 89 | allIdExists(drawerApps) && 90 | allIdExists(aiTools) 91 | ) { 92 | return 93 | } 94 | 95 | const updatedList = { 96 | ...apps, 97 | state: { 98 | ...apps.state, 99 | aiTools: addIds(aiTools), 100 | drawerApps: addIds(drawerApps), 101 | dockApps: addIds(dockApps), 102 | }, 103 | } 104 | 105 | await idbKeyval.set(storeName, JSON.stringify(updatedList)) 106 | } 107 | -------------------------------------------------------------------------------- /src/components/background-image.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx" 2 | import { useMemo } from "react" 3 | import { useImageStore } from "~/store/image-store" 4 | import { useOptionsStore } from "~/store/options" 5 | 6 | const BackgroundImage = () => { 7 | const images = useImageStore((s) => s.images) 8 | const { bgImageId, isMonochromeBg, isBgBlur, isBgImage } = useOptionsStore() 9 | 10 | const backgroundImage = useMemo(() => { 11 | return images.find(({ id }) => id === bgImageId)?.imageUrl 12 | }, [images, bgImageId]) 13 | 14 | if ( 15 | !isBgImage || 16 | bgImageId === null || 17 | images.length === 0 || 18 | !backgroundImage 19 | ) { 20 | return null 21 | } 22 | 23 | return ( 24 | <> 25 |
26 | background-image 33 |
34 |
40 | 41 | ) 42 | } 43 | 44 | export default BackgroundImage 45 | -------------------------------------------------------------------------------- /src/components/motion-primitives/dock.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import { 4 | AnimatePresence, 5 | type MotionValue, 6 | type SpringOptions, 7 | motion, 8 | useMotionValue, 9 | useSpring, 10 | useTransform, 11 | } from "framer-motion" 12 | import { 13 | Children, 14 | cloneElement, 15 | createContext, 16 | useContext, 17 | useEffect, 18 | useMemo, 19 | useRef, 20 | useState, 21 | } from "react" 22 | import { cn } from "~/utils" 23 | 24 | const DOCK_HEIGHT = 20 25 | const DEFAULT_MAGNIFICATION = 76 26 | const DEFAULT_DISTANCE = 140 27 | const DEFAULT_PANEL_HEIGHT = 64 28 | const DEFAULT_ICON_SIZE = 44 29 | 30 | export type DockProps = { 31 | children: React.ReactNode 32 | className?: string 33 | distance?: number 34 | panelHeight?: number 35 | magnification?: number 36 | spring?: SpringOptions 37 | } 38 | 39 | export type DockItemProps = { 40 | className?: string 41 | onClick: () => void 42 | children: React.ReactNode 43 | } 44 | 45 | export type DockLabelProps = { 46 | className?: string 47 | children: React.ReactNode 48 | } 49 | 50 | export type DockIconProps = { 51 | className?: string 52 | children: React.ReactNode 53 | } 54 | 55 | export type DocContextType = { 56 | mouseX: MotionValue 57 | spring: SpringOptions 58 | magnification: number 59 | distance: number 60 | } 61 | 62 | export type DockProviderProps = { 63 | children: React.ReactNode 64 | value: DocContextType 65 | } 66 | 67 | const DockContext = createContext(undefined) 68 | 69 | function DockProvider({ children, value }: DockProviderProps) { 70 | return {children} 71 | } 72 | 73 | function useDock() { 74 | const context = useContext(DockContext) 75 | if (!context) { 76 | throw new Error("useDock must be used within an DockProvider") 77 | } 78 | return context 79 | } 80 | 81 | function Dock({ 82 | children, 83 | className, 84 | spring = { mass: 0.1, stiffness: 150, damping: 12 }, 85 | magnification = DEFAULT_MAGNIFICATION, 86 | distance = DEFAULT_DISTANCE, 87 | panelHeight = DEFAULT_PANEL_HEIGHT, 88 | }: DockProps) { 89 | const mouseX = useMotionValue(Number.POSITIVE_INFINITY) 90 | const isHovered = useMotionValue(0) 91 | 92 | const maxHeight = useMemo(() => { 93 | return Math.max(DOCK_HEIGHT, magnification + magnification / 2 + 4) 94 | }, [magnification]) 95 | 96 | const heightRow = useTransform(isHovered, [0, 1], [panelHeight, maxHeight]) 97 | const height = useSpring(heightRow, spring) 98 | 99 | return ( 100 | 107 | { 109 | isHovered.set(1) 110 | mouseX.set(pageX) 111 | }} 112 | onMouseLeave={() => { 113 | isHovered.set(0) 114 | mouseX.set(Number.POSITIVE_INFINITY) 115 | }} 116 | className={cn( 117 | "mx-auto flex w-fit gap-4 rounded-2xl bg-gray-50 px-4", 118 | className, 119 | )} 120 | style={{ height: panelHeight }} 121 | role="toolbar" 122 | aria-label="Application dock" 123 | > 124 | 125 | {children} 126 | 127 | 128 | 129 | ) 130 | } 131 | 132 | function DockItem({ children, className, onClick }: DockItemProps) { 133 | const ref = useRef(null) 134 | 135 | const { distance, magnification, mouseX, spring } = useDock() 136 | 137 | const isHovered = useMotionValue(0) 138 | 139 | const mouseDistance = useTransform(mouseX, (val) => { 140 | const domRect = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 } 141 | return val - domRect.x - domRect.width / 2 142 | }) 143 | 144 | const widthTransform = useTransform( 145 | mouseDistance, 146 | [-distance, 0, distance], 147 | [DEFAULT_ICON_SIZE, magnification, DEFAULT_ICON_SIZE], 148 | ) 149 | 150 | const width = useSpring(widthTransform, spring) 151 | 152 | return ( 153 | isHovered.set(1)} 158 | onHoverEnd={() => isHovered.set(0)} 159 | onFocus={() => isHovered.set(1)} 160 | onBlur={() => isHovered.set(0)} 161 | className={cn( 162 | "relative inline-flex items-center justify-center", 163 | className, 164 | )} 165 | tabIndex={0} 166 | aria-haspopup="true" 167 | onClick={onClick} 168 | > 169 | {Children.map(children, (child) => 170 | cloneElement(child as React.ReactElement, { width, isHovered }), 171 | )} 172 | 173 | ) 174 | } 175 | 176 | function DockLabel({ children, className, ...rest }: DockLabelProps) { 177 | const restProps = rest as Record 178 | const isHovered = restProps.isHovered as MotionValue 179 | const [isVisible, setIsVisible] = useState(false) 180 | 181 | useEffect(() => { 182 | const unsubscribe = isHovered.on("change", (latest) => { 183 | setIsVisible(latest === 1) 184 | }) 185 | 186 | return () => unsubscribe() 187 | }, [isHovered]) 188 | 189 | return ( 190 | 191 | {isVisible && ( 192 | 204 | {children} 205 | 206 | )} 207 | 208 | ) 209 | } 210 | 211 | function DockIcon({ children, className, ...rest }: DockIconProps) { 212 | const restProps = rest as Record 213 | const width = restProps.width as MotionValue 214 | 215 | const widthTransform = useTransform(width, (val) => val / 2) 216 | 217 | return ( 218 | 222 | {children} 223 | 224 | ) 225 | } 226 | 227 | export { Dock, DockIcon, DockItem, DockLabel } 228 | -------------------------------------------------------------------------------- /src/components/sidebar/index.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import { AnimatePresence, motion } from "framer-motion" 3 | import { Suspense, lazy, useState } from "react" 4 | import Button from "../ui/button" 5 | 6 | const SidebarContent = lazy(() => import("./sidebar-content")) 7 | 8 | const Backdrop = ({ onOpenChange }: { onOpenChange: () => void }) => { 9 | return ( 10 | 18 | ) 19 | } 20 | 21 | const Sidebar = () => { 22 | const [open, setOpen] = useState(false) 23 | return ( 24 | <> 25 | 26 | {!open && ( 27 | 46 | )} 47 | 48 | 49 | {open && ( 50 | 51 | 52 | setOpen(false)} /> 53 | 54 | )} 55 | 56 | 57 | ) 58 | } 59 | 60 | export default Sidebar 61 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-content.tsx: -------------------------------------------------------------------------------- 1 | import { motion } from "framer-motion" 2 | import SidebarOptions from "./sidebar-options" 3 | 4 | const SidebarContent = () => { 5 | return ( 6 | 13 |
14 | 15 | Settings 16 | 17 |
18 | 19 |
20 |
21 |
22 | ) 23 | } 24 | 25 | export default SidebarContent 26 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/app-options.tsx: -------------------------------------------------------------------------------- 1 | import { useOptionsStore } from "../../../store/options" 2 | import OptionsGroup from "./shared/options-group" 3 | import TabSwitchButton from "./shared/tab-switch-button" 4 | import ToggleOption from "./shared/toggle-option" 5 | 6 | const AppOptions = () => { 7 | const { 8 | isAppDrawerEnabled, 9 | toggleEnableAppDrawer, 10 | isDockEnabled, 11 | toggleDock, 12 | isDockBackground, 13 | toggleDockBg, 14 | } = useOptionsStore() 15 | 16 | return ( 17 | 18 | 23 | 28 | 34 | 39 | 40 | ) 41 | } 42 | 43 | export default AppOptions 44 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/clock-options.tsx: -------------------------------------------------------------------------------- 1 | import { useOptionsStore } from "../../../store/options" 2 | import OptionsGroup from "./shared/options-group" 3 | import ToggleOption from "./shared/toggle-option" 4 | 5 | const ClockOptions = () => { 6 | const { 7 | enableDigitalClock, 8 | toggleDidigtalClock, 9 | format24, 10 | toggleFormat24, 11 | greetings, 12 | toggelGreetings, 13 | } = useOptionsStore() 14 | return ( 15 | 16 | 21 | 27 | 33 | 34 | ) 35 | } 36 | 37 | export default ClockOptions 38 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/data-backup-options/export.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import * as idb from "idb-keyval" 3 | import { useState } from "react" 4 | import Button from "~/components/ui/button" 5 | import Checkbox from "~/components/ui/checkbox" 6 | import Modal from "~/components/ui/modal" 7 | import { 8 | drawerApps as initialDrawerApps, 9 | searchProviders as initialSearchProviders, 10 | } from "~/lib/variables" 11 | import type { ImageFile } from "~/types" 12 | import { toBase64 } from "~/utils" 13 | import type { Backup } from "./type" 14 | 15 | export default function Export() { 16 | const [open, setOpen] = useState(false) 17 | const [weather, setWeather] = useState(true) 18 | const [queryHist, setQueryHist] = useState(true) 19 | const [images, setImages] = useState(true) 20 | const [icons, setIcons] = useState(false) 21 | 22 | const exportHandler = async () => { 23 | // Variables 24 | let galleryImages = null 25 | const appStore = (await idb.get("app-store")) || null 26 | let iconData = null 27 | 28 | const newTabOptions = (() => { 29 | try { 30 | return ( 31 | JSON.parse(localStorage.getItem("nothing-newtab-options") || "") || {} 32 | ) 33 | } catch { 34 | return {} 35 | } 36 | })() 37 | 38 | // Options 39 | if (images) { 40 | galleryImages = await idb.get("gallery-images") 41 | } else { 42 | newTabOptions.state.bgImageId = null 43 | newTabOptions.state.currentImageIndex = 0 44 | } 45 | 46 | if (!weather) { 47 | newTabOptions.state.weatherAPI = "" 48 | newTabOptions.state.weatherLocation = "" 49 | } 50 | 51 | if (icons) { 52 | iconData = Object.keys(localStorage) 53 | .filter((key) => key.startsWith("iconify")) 54 | .map((key) => ({ 55 | key: key, 56 | value: localStorage.getItem(key), 57 | })) 58 | } 59 | 60 | // Final Object 61 | const finalData = { 62 | // To check if backup file valid, btoa not necessary just to make it look 63 | // like a little professional 64 | "backup-code": btoa("nothing-ui-newtab"), 65 | date: new Date().getTime(), 66 | 67 | // IndexDB items 68 | "gallery-images": galleryImages 69 | ? await Promise.all( 70 | galleryImages.map(async (image: ImageFile) => ({ 71 | ...image, 72 | file: await toBase64(image.file), 73 | })), 74 | ) 75 | : null, 76 | // "app-store": appStore, 77 | "app-store": 78 | appStore.match(/"drawerApps":(\[.*?\])/)[1] !== 79 | JSON.stringify(initialDrawerApps) 80 | ? appStore 81 | : null, 82 | 83 | // LocalStorage Items 84 | "data-theme": localStorage.getItem("data-theme") || null, 85 | "query-history": queryHist 86 | ? localStorage.getItem("query-histories") 87 | : null, 88 | "search-engines": (() => { 89 | const items = localStorage.getItem("search-engines") 90 | return items !== JSON.stringify(initialSearchProviders) ? items : null 91 | })(), 92 | icons: iconData, 93 | "nothing-newtab-options": JSON.stringify(newTabOptions), 94 | } satisfies Backup 95 | 96 | // Download Link 97 | const jsonString = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(finalData))}` 98 | 99 | const link = document.createElement("a") 100 | link.href = jsonString 101 | link.download = `nothing-ui-newtab-${new Date().getTime()}.json` 102 | link.click() 103 | setOpen(false) 104 | } 105 | 106 | return ( 107 | <> 108 | 112 | 113 |
114 | 120 | 126 | 132 | 138 | 139 | 142 | 143 |
144 |
145 | 146 | ) 147 | } 148 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/data-backup-options/import.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import clsx from "clsx" 3 | import * as idb from "idb-keyval" 4 | import { useEffect, useMemo, useRef, useState } from "react" 5 | import { toast } from "sonner" 6 | import Button from "~/components/ui/button" 7 | import Modal from "~/components/ui/modal" 8 | import { base64ToBlob, blobToFile } from "~/utils" 9 | import type { Backup } from "./type" 10 | 11 | export default function Import() { 12 | const [files, setFiles] = useState(null) 13 | const [open, setOpen] = useState(false) 14 | const [backupFile, setBackupFile] = useState(null) 15 | 16 | const ref = useRef(null) 17 | 18 | useEffect(() => { 19 | if (!files) return 20 | 21 | const bakFile = files[0] 22 | 23 | if (bakFile) { 24 | ;(async () => { 25 | const fileContent: Backup = JSON.parse(await bakFile.text()) 26 | 27 | // Verifying if selected backup file is valid 28 | const backupCode = fileContent["backup-code"] || null 29 | 30 | if (!backupCode || backupCode !== btoa("nothing-ui-newtab")) { 31 | toast.error("Invalid backup file selected!") 32 | return 33 | } 34 | 35 | // If backup file is valid then proceed 36 | setOpen(true) 37 | setBackupFile(fileContent) 38 | })() 39 | } 40 | }, [files]) 41 | 42 | useEffect(() => { 43 | !open && setFiles(null) 44 | }, [open]) 45 | 46 | const tableData = useMemo(() => { 47 | return [ 48 | { field: "Icons (iconify cache)", isCheck: !!backupFile?.icons }, 49 | { field: "Images", isCheck: !!backupFile?.["gallery-images"] }, 50 | { field: "Query History", isCheck: !!backupFile?.["query-history"] }, 51 | { 52 | field: "Weather Location", 53 | isCheck: backupFile?.["nothing-newtab-options"].match( 54 | /"weatherLocation"\s*:\s*"([^"]+)"/, 55 | ), 56 | }, 57 | { 58 | field: "Weather API", 59 | isCheck: backupFile?.["nothing-newtab-options"].match( 60 | /"weatherAPI"\s*:\s*"([^"]+)"/, 61 | ), 62 | }, 63 | ] 64 | }, [backupFile]) 65 | 66 | const restoreBackupHandler = async () => { 67 | // Index DB stuff 68 | const appStore = backupFile?.["app-store"] 69 | const galleryImages = backupFile?.["gallery-images"] 70 | 71 | appStore && (await idb.set("app-store", appStore)) 72 | galleryImages && 73 | (await idb.set( 74 | "gallery-images", 75 | galleryImages.map((img) => ({ 76 | ...img, 77 | file: blobToFile(base64ToBlob(img.file, img.type), img.name), 78 | })), 79 | )) 80 | 81 | // Local Storage stuff 82 | const queryHistory = backupFile?.["query-history"] 83 | const searchEngines = backupFile?.["search-engines"] 84 | const newtabOpts = backupFile?.["nothing-newtab-options"] 85 | const icons = backupFile?.icons 86 | 87 | queryHistory && localStorage.setItem("query-history", queryHistory) 88 | searchEngines && localStorage.setItem("search-engines", searchEngines) 89 | newtabOpts && localStorage.setItem("nothing-newtab-options", newtabOpts) 90 | icons?.forEach( 91 | (icon, _) => icon.value && localStorage.setItem(icon.key, icon.value), 92 | ) 93 | 94 | window.location.reload() 95 | } 96 | 97 | return ( 98 | <> 99 | setFiles(e.target.files)} 105 | /> 106 | 109 | 119 |
120 | 121 | 122 | {tableData.map((d, index) => ( 123 | 124 | 132 | 151 | 152 | ))} 153 | 154 |
130 | {d.field} 131 | 138 | 150 |
155 |
156 |
157 | 164 | 171 |
172 |
173 | 174 | ) 175 | } 176 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/data-backup-options/index.tsx: -------------------------------------------------------------------------------- 1 | import { clear } from "idb-keyval" 2 | import Alert from "~/components/ui/alert" 3 | import Export from "./export" 4 | import Import from "./import" 5 | 6 | const alertDesc = 7 | "This process is irreversible and will reset all settings to default. Make sure to back up your data before proceeding! :)" 8 | 9 | export default function DataBackupOptions() { 10 | const restoreDefaults = async () => { 11 | // Clear Index DB 12 | await clear().then(() => { 13 | // Clear all items from localStorage 14 | for (const key of Object.keys(localStorage)) { 15 | localStorage.removeItem(key) 16 | } 17 | window.location.reload() 18 | }) 19 | } 20 | 21 | return ( 22 |
23 |
24 | 25 | 26 |
27 | 28 | 35 |
36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/data-backup-options/type.ts: -------------------------------------------------------------------------------- 1 | import type { ImageFile } from "~/types" 2 | 3 | export type Base64ImageFile = Omit & { file: string } 4 | 5 | export type Backup = { 6 | "data-theme": string | null 7 | "backup-code": string 8 | date: number 9 | "gallery-images": Base64ImageFile[] | null 10 | "app-store": string 11 | "query-history": string | null 12 | "search-engines": string | null 13 | icons: { key: string; value: string | null }[] | null 14 | "nothing-newtab-options": string 15 | } 16 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/dock-options/index.tsx: -------------------------------------------------------------------------------- 1 | import { Icon, disableCache, enableCache } from "@iconify/react/dist/iconify.js" 2 | import { motion } from "framer-motion" 3 | import { nanoid } from "nanoid" 4 | import { useEffect, useState } from "react" 5 | import Button from "~/components/ui/button" 6 | import type { App } from "~/lib/variables" 7 | import { useAppStore } from "~/store/app-store" 8 | import { extractUniqueValues } from "~/utils" 9 | import AppCard from "../shared/app-card" 10 | import NewTabHeader from "../shared/newtab-header" 11 | 12 | const DockOptions = () => { 13 | const [newApp, setNewApp] = useState(null) 14 | const { addDockApp, dockApps, resetDockApp, updateDockApp, removeDockApp } = 15 | useAppStore() 16 | 17 | const addNewApp = () => { 18 | setNewApp({ 19 | id: nanoid(), 20 | name: "", 21 | icon: "fe:bookmark", 22 | url: "", 23 | }) 24 | } 25 | 26 | const saveEngineHandler = () => { 27 | if (!newApp) return 28 | 29 | if (Object.values(newApp).some((v) => v === "")) { 30 | alert("You must fill all the fields") 31 | } else { 32 | if (!dockApps.find(({ name }) => name === newApp.name)) { 33 | addDockApp(newApp) 34 | setNewApp(null) 35 | } else { 36 | alert(`App with name ${newApp.name} already exists`) 37 | } 38 | } 39 | } 40 | 41 | useEffect(() => { 42 | disableCache("all") 43 | return () => enableCache("local") 44 | }, []) 45 | 46 | return ( 47 |
48 | 51 | 57 | 60 | 61 | } 62 | /> 63 | 64 | {newApp && ( 65 |
66 | 67 |
68 | 69 | 72 |
73 |
74 | )} 75 |
76 |
77 | {dockApps.map((app) => ( 78 | 79 | 86 | 87 | ))} 88 |
89 |
90 | ) 91 | } 92 | 93 | export default DockOptions 94 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/gallery-options/gallery-tab.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react" 2 | import clsx from "clsx" 3 | import Compressor from "compressorjs" 4 | import { motion } from "framer-motion" 5 | import { del } from "idb-keyval" 6 | import { useEffect, useRef, useState } from "react" 7 | import Button from "~/components/ui/button" 8 | import Input from "~/components/ui/input" 9 | import Modal from "~/components/ui/modal" 10 | import { useImageStore } from "~/store/image-store" 11 | import { useOptionsStore } from "~/store/options" 12 | import type { ImageFile } from "~/types" 13 | import NewTabHeader from "../shared/newtab-header" 14 | 15 | type ImageSize = { 16 | id: string 17 | width: number 18 | height: number 19 | size: number 20 | } 21 | 22 | const GalleryTab = () => { 23 | const { 24 | images, 25 | addImages, 26 | removeImage, 27 | shouldSave, 28 | saveImagesToDB, 29 | setImages, 30 | } = useImageStore() 31 | 32 | const { isBgImage, bgImageId, setBgImageId, setCurrentImageIndex } = 33 | useOptionsStore() 34 | 35 | const inputRef = useRef(null) 36 | 37 | const [prevImagesLength] = useState(images.length) 38 | const [imgSizeData, setImgSizeData] = useState([]) 39 | const [openModal, setOpenModal] = useState(false) 40 | 41 | const saveImageHandler = async () => { 42 | // Reset data 43 | setImgSizeData([]) 44 | 45 | // Main logic 46 | const files = images.map(({ file, id }) => ({ file, id })) 47 | if (!files || files.length === 0) return 48 | 49 | const imgData: ImageSize[] = [] 50 | 51 | await Promise.all( 52 | Array.from(files).map( 53 | (imgFile) => 54 | new Promise((resolve) => { 55 | const reader = new FileReader() 56 | reader.onload = (e) => { 57 | const img = new Image() 58 | img.onload = () => { 59 | if (img.width > 1920 && img.height > 1080) { 60 | imgData.push({ 61 | id: imgFile.id, 62 | height: img.height, 63 | width: img.width, 64 | size: imgFile.file.size, 65 | }) 66 | } 67 | resolve({}) 68 | } 69 | img.src = e.target?.result as string 70 | } 71 | reader.readAsDataURL(imgFile.file) 72 | }), 73 | ), 74 | ) 75 | 76 | if (imgData.length > 0 && prevImagesLength !== images.length) { 77 | setImgSizeData(imgData) 78 | setOpenModal(true) 79 | } else { 80 | saveImagesToDB() 81 | } 82 | } 83 | 84 | const compressImageHandler = async () => { 85 | const newImageList: ImageFile[] = [] 86 | 87 | await Promise.all( 88 | Array.from(images).map( 89 | (image) => 90 | new Promise((resolve) => { 91 | if (!imgSizeData.some(({ id }) => id === image.id)) { 92 | newImageList.push(image) 93 | resolve({}) 94 | return 95 | } 96 | 97 | new Compressor(image.file, { 98 | width: 1920, 99 | height: 1080, 100 | success(result: Blob) { 101 | const compressedFile: ImageFile = { 102 | ...image, 103 | file: new File([result], image.file.name, { 104 | type: image.file.type, 105 | }), 106 | } 107 | newImageList.push(compressedFile) 108 | resolve({}) 109 | }, 110 | }) 111 | }), 112 | ), 113 | ) 114 | 115 | // Set compressed images 116 | setImages(newImageList) 117 | 118 | // Save images to db 119 | saveImagesToDB(newImageList) 120 | 121 | // Close modal 122 | setOpenModal(false) 123 | } 124 | 125 | const handleOnSelect = (event: React.ChangeEvent) => { 126 | const files = event.target.files 127 | 128 | if (files && files.length > 0) { 129 | const newImages: ImageFile[] = Array.from(files).map((file) => ({ 130 | id: crypto.randomUUID(), 131 | file, 132 | name: file.name, 133 | type: file.type, 134 | imageUrl: URL.createObjectURL(file), 135 | })) 136 | addImages(newImages) 137 | } 138 | } 139 | 140 | useEffect(() => { 141 | if (images.length === 0) { 142 | setBgImageId(null) 143 | } 144 | }, [images, setBgImageId]) 145 | 146 | return ( 147 |
148 | 151 | 160 | 172 | 180 | 181 | } 182 | /> 183 | 184 | {images?.length > 0 ? ( 185 |
186 | {images?.map((img) => ( 187 | isBgImage && setBgImageId(img.id)} 192 | style={bgImageId === img.id ? { padding: "10px" } : {}} 193 | > 194 | {bgImageId === img.id && ( 195 | 199 | )} 200 | gallary-image 206 | 220 | 221 | ))} 222 |
223 | ) : ( 224 |
225 | 226 | No image found! 227 |
228 | )} 229 | 237 | 243 |
244 |
245 |
246 | {images.map(({ id, imageUrl, name }) => ( 247 | {name} img.id === id) 254 | ? "border-destructive" 255 | : "border-transparent", 256 | ])} 257 | /> 258 | ))} 259 |
260 |
261 |
262 | 272 | 275 |
276 |
277 |
278 |
279 | ) 280 | } 281 | 282 | export default GalleryTab 283 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/gallery-options/index.tsx: -------------------------------------------------------------------------------- 1 | import { useOptionsStore } from "~/store/options" 2 | import OptionsGroup from "../shared/options-group" 3 | import TabSwitchButton from "../shared/tab-switch-button" 4 | import ToggleOption from "../shared/toggle-option" 5 | import IntervalInput from "./interval-input" 6 | 7 | const GalleryOptions = () => { 8 | const { 9 | isBgImage, 10 | toggleBgImage, 11 | isMonochromeWidgetImg, 12 | toggleMonochromeWidgetImg, 13 | isMonochromeBg, 14 | toggleMonochromeBg, 15 | isBgBlur, 16 | toggleBgBlur, 17 | } = useOptionsStore() 18 | 19 | return ( 20 | 21 | 26 | 32 | 38 | 44 | 50 | 51 | 52 | ) 53 | } 54 | 55 | export default GalleryOptions 56 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/gallery-options/interval-input.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx" 2 | import { useEffect, useState } from "react" 3 | import { useDebounceValue } from "usehooks-ts" 4 | import Input from "~/components/ui/input" 5 | import { useOptionsStore } from "~/store/options" 6 | 7 | const IntervalInput = () => { 8 | const { gallaryImageInterval, setGallaryImageInterval } = useOptionsStore() 9 | const [value, setValue] = useState(gallaryImageInterval) 10 | const [dValue] = useDebounceValue(value, 1400) 11 | 12 | useEffect(() => { 13 | setGallaryImageInterval(dValue) 14 | }, [dValue, setGallaryImageInterval]) 15 | 16 | return ( 17 |
18 | Gallery image switch interval 19 |

20 | It will be saved automatically upon input, and the time is measured in 21 | seconds 22 |

23 | setValue(Number.parseInt(e.currentTarget.value))} 33 | placeholder="Gallary image switch interval" 34 | /> 35 |
36 | ) 37 | } 38 | 39 | export default IntervalInput 40 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/general-options.tsx: -------------------------------------------------------------------------------- 1 | import { useThemeStore } from "~/store/theme" 2 | import OptionsGroup from "./shared/options-group" 3 | import TabSwitchButton from "./shared/tab-switch-button" 4 | import ToggleOption from "./shared/toggle-option" 5 | 6 | const GeneralOptions = () => { 7 | const { isLightMode, toggleLightMode } = useThemeStore() 8 | return ( 9 | 10 | 15 | 21 | 22 | ) 23 | } 24 | 25 | export default GeneralOptions 26 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/index.tsx: -------------------------------------------------------------------------------- 1 | import { motion } from "framer-motion" 2 | import { Suspense, lazy, useEffect, useState } from "react" 3 | import { useSidebarOptions } from "../sidebar-store" 4 | import AppOptions from "./app-options" 5 | import ClockOptions from "./clock-options" 6 | import DataBackupOptions from "./data-backup-options" 7 | import GalleryOptions from "./gallery-options" 8 | import GeneralOptions from "./general-options" 9 | import MiscOptions from "./misc-options" 10 | import WeatherOptions from "./weather-options" 11 | 12 | const AIToolsTab = lazy(() => import("./tabs/ai-tools")) 13 | const DockOptions = lazy(() => import("./dock-options")) 14 | const GalleryTab = lazy(() => import("./gallery-options/gallery-tab")) 15 | const SearchEnginesTab = lazy(() => import("./tabs/search-engines")) 16 | 17 | const MotionDiv = ({ 18 | children, 19 | direction = "right", 20 | }: { 21 | children: React.ReactNode 22 | direction?: "right" | "left" 23 | }) => { 24 | const x = 280 25 | return ( 26 | 33 | {children} 34 | 35 | ) 36 | } 37 | 38 | const SidebarOptions = () => { 39 | const tab = useSidebarOptions((s) => s.tab) 40 | 41 | const [isOpen, setIsOpen] = useState(false) 42 | useEffect(() => { 43 | setIsOpen(true) 44 | return () => setIsOpen(false) 45 | }, []) 46 | 47 | return ( 48 | 49 | {tab === "default" && ( 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | )} 60 | {tab === "search-engines" && ( 61 | 62 | 63 | 64 | )} 65 | {tab === "apps" && ( 66 | 67 | 68 | 69 | )} 70 | {tab === "ai-tools" && ( 71 | 72 | 73 | 74 | )} 75 | {tab === "gallery" && ( 76 | 77 | 78 | 79 | )} 80 | 81 | ) 82 | } 83 | 84 | export default SidebarOptions 85 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/misc-options.tsx: -------------------------------------------------------------------------------- 1 | import { useOptionsStore } from "../../../store/options" 2 | import OptionsGroup from "./shared/options-group" 3 | import TabSwitchButton from "./shared/tab-switch-button" 4 | import ToggleOption from "./shared/toggle-option" 5 | 6 | const MiscOptions = () => { 7 | const { 8 | isQuerySuggestions, 9 | toggleQuerySuggestions, 10 | isAIToolsEnabled, 11 | toggleEnableAITools, 12 | isMonochromeIcon, 13 | toggleMonochromeIcon, 14 | } = useOptionsStore() 15 | 16 | return ( 17 | 18 | 23 | 28 | 35 | 41 | 42 | ) 43 | } 44 | 45 | export default MiscOptions 46 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/shared/app-card.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import { AnimatePresence, motion } from "framer-motion" 3 | import type React from "react" 4 | import { useEffect, useState } from "react" 5 | import { useDebounceValue } from "usehooks-ts" 6 | import Button from "~/components/ui/button" 7 | import Input from "~/components/ui/input" 8 | import type { App } from "~/lib/variables" 9 | import type { Setter } from "~/types/react" 10 | import { areObjectsEqual } from "~/utils" 11 | 12 | interface AppCardContainerProps { 13 | icon: string 14 | children: React.ReactNode 15 | delFunc: () => void 16 | } 17 | 18 | export const AppCardContainer = (props: AppCardContainerProps) => { 19 | return ( 20 |
21 | 22 | {props.icon.startsWith("webicon:") ? ( 23 | app-icon 27 | ) : ( 28 | 29 | )} 30 | 31 |
32 | {props.children} 33 |
34 | 42 |
43 | ) 44 | } 45 | 46 | interface AppCardFooterProps { 47 | open: boolean 48 | setOpen: Setter 49 | saveFunc: () => void 50 | } 51 | 52 | export const AppCardFooter = (props: AppCardFooterProps) => { 53 | return ( 54 | 62 | 63 | {props.open && ( 64 | 70 | 71 | 74 | 75 | )} 76 | 77 | 78 | ) 79 | } 80 | 81 | interface AppCardProps { 82 | cardLabel?: string // what kind, like dockApp, aiTool, search engine... 83 | app: App 84 | setApp?: Setter 85 | appNames?: string[] 86 | update?: (id: string, app: App) => void 87 | remove?: (id: string) => void 88 | } 89 | 90 | export default function AppCard({ 91 | cardLabel, 92 | app, 93 | setApp, 94 | appNames, 95 | update, 96 | remove, 97 | }: AppCardProps) { 98 | const [dockApp, setDockApp] = useState(app) 99 | const [debouncedIcon] = useDebounceValue(app.icon, 500) 100 | const [isFocused, setIsFocused] = useState(false) 101 | 102 | useEffect(() => { 103 | setApp?.(dockApp) 104 | }, [dockApp, setApp]) 105 | 106 | const submitHandler = () => { 107 | if (Object.values(dockApp).some((value) => value === "")) { 108 | return 109 | } 110 | 111 | if ( 112 | update && 113 | !appNames?.includes(dockApp.name) && 114 | !areObjectsEqual(dockApp, app, ["id"]) 115 | ) { 116 | update(app.id, dockApp) 117 | setIsFocused(false) 118 | } 119 | } 120 | 121 | return ( 122 | remove?.(app.id)}> 123 | 129 | setDockApp((prev) => ({ ...prev, icon: value })) 130 | } 131 | onFocus={() => setIsFocused(true)} 132 | className="text-foreground" 133 | /> 134 | 142 | setDockApp((prev) => ({ ...prev, name: value })) 143 | } 144 | onFocus={() => setIsFocused(true)} 145 | className="text-foreground" 146 | /> 147 | 153 | setDockApp((prev) => ({ ...prev, url: value })) 154 | } 155 | onFocus={() => setIsFocused(true)} 156 | className="text-foreground" 157 | /> 158 | 163 | 164 | ) 165 | } 166 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/shared/newtab-header.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import Button from "../../../ui/button" 3 | import { useSidebarOptions } from "../../sidebar-store" 4 | 5 | interface NewTabHeader { 6 | rightButtons?: React.ReactNode 7 | } 8 | 9 | const NewTabHeader = ({ rightButtons }: NewTabHeader) => { 10 | const setTab = useSidebarOptions((s) => s.setTab) 11 | return ( 12 |
13 | 16 |
{rightButtons}
17 |
18 | ) 19 | } 20 | 21 | export default NewTabHeader 22 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/shared/options-group.tsx: -------------------------------------------------------------------------------- 1 | interface OptionsGroupProps { 2 | title: string 3 | children: React.ReactNode 4 | } 5 | 6 | const OptionsGroup = ({ title, children }: OptionsGroupProps) => { 7 | return ( 8 |
9 | {title} 10 | {children} 11 |
12 | ) 13 | } 14 | 15 | export default OptionsGroup 16 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/shared/tab-switch-button.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react" 2 | import clsx from "clsx" 3 | import { type Tab, useSidebarOptions } from "../../sidebar-store" 4 | 5 | interface TabSwitchProps { 6 | title: string 7 | desc: string 8 | icon: string 9 | tabToSwitch: Tab 10 | disabled?: boolean 11 | } 12 | 13 | const TabSwitchButton = ({ 14 | title, 15 | desc, 16 | icon, 17 | tabToSwitch, 18 | disabled, 19 | }: TabSwitchProps) => { 20 | const setTab = useSidebarOptions((s) => s.setTab) 21 | 22 | return ( 23 | 53 | ) 54 | } 55 | 56 | export default TabSwitchButton 57 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/shared/toggle-option.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx" 2 | import Switch from "~/components/switch" 3 | 4 | interface ToggleOptionProps { 5 | label: string 6 | desc?: string 7 | enabled: boolean 8 | onChange: (state: boolean) => void 9 | disabled?: boolean 10 | } 11 | 12 | const ToggleOption = ({ 13 | label, 14 | desc, 15 | enabled, 16 | onChange, 17 | disabled = false, 18 | }: ToggleOptionProps) => { 19 | return ( 20 |
21 |
27 | {label} 28 | {desc} 29 |
30 | 31 |
32 | ) 33 | } 34 | 35 | export default ToggleOption 36 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/tabs/ai-tools/index.tsx: -------------------------------------------------------------------------------- 1 | import { Icon, disableCache, enableCache } from "@iconify/react/dist/iconify.js" 2 | import { motion } from "framer-motion" 3 | import { nanoid } from "nanoid" 4 | import { useEffect, useState } from "react" 5 | import Button from "~/components/ui/button" 6 | import type { App } from "~/lib/variables" 7 | import { useAppStore } from "~/store/app-store" 8 | import { extractUniqueValues } from "~/utils" 9 | import AppCard from "../../shared/app-card" 10 | import NewTabHeader from "../../shared/newtab-header" 11 | 12 | const AIToolsTab = () => { 13 | const { 14 | aiTools, 15 | addAITool: add, 16 | resetAITools: reset, 17 | updateAITool, 18 | removeAITool, 19 | } = useAppStore() 20 | const [newAITool, setNewAITool] = useState(null) 21 | 22 | const addNewAITool = () => { 23 | setNewAITool({ id: nanoid(), name: "", icon: "mingcute:ai-fill", url: "" }) 24 | } 25 | 26 | const saveEngineHandler = () => { 27 | if (!newAITool) return 28 | 29 | if (!aiTools.find(({ name }) => name === newAITool.name)) { 30 | add(newAITool) 31 | setNewAITool(null) 32 | } else { 33 | alert( 34 | "The name for the new AI tool must be unique. Please choose a different one", 35 | ) 36 | } 37 | } 38 | 39 | useEffect(() => { 40 | disableCache("all") 41 | return () => enableCache("local") 42 | }, []) 43 | 44 | return ( 45 |
46 | 49 | 55 | 58 | 59 | } 60 | /> 61 |
62 | 63 | {newAITool && ( 64 |
65 | 66 |
67 | 68 | 71 |
72 |
73 | )} 74 |
75 | {aiTools.map((tool) => ( 76 | 77 | 84 | 85 | ))} 86 |
87 |
88 | ) 89 | } 90 | 91 | export default AIToolsTab 92 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/tabs/search-engines/index.tsx: -------------------------------------------------------------------------------- 1 | import { Icon, disableCache, enableCache } from "@iconify/react/dist/iconify.js" 2 | import { motion } from "framer-motion" 3 | import { useEffect, useState } from "react" 4 | import Button from "~/components/ui/button" 5 | import { type SearchEngine, useSearchEngineStore } from "~/store/search-engine" 6 | import { extractUniqueValues } from "~/utils" 7 | import NewTabHeader from "../../shared/newtab-header" 8 | import SearchEngineCard from "./search-engine-card" 9 | 10 | const SearchEnginesTab = () => { 11 | const { searchEngines, add, reset, update, remove } = useSearchEngineStore() 12 | const [newEngine, setNewEngine] = useState(null) 13 | 14 | const addNewEngine = () => { 15 | setNewEngine({ 16 | name: "", 17 | short: "", 18 | icon: "tdesign:internet", 19 | baseUrl: "https://", 20 | }) 21 | } 22 | 23 | const saveEngineHandler = () => { 24 | if (!newEngine) return 25 | 26 | if ( 27 | !searchEngines.find( 28 | ({ name, short }) => 29 | name === newEngine.name || short === newEngine.short, 30 | ) 31 | ) { 32 | add(newEngine) 33 | setNewEngine(null) 34 | } else { 35 | alert( 36 | "The name or shortcut for the new engine must be unique. Please choose a different one", 37 | ) 38 | } 39 | } 40 | 41 | useEffect(() => { 42 | disableCache("all") 43 | return () => enableCache("local") 44 | }, []) 45 | 46 | return ( 47 |
48 | 51 | 57 | 60 | 61 | } 62 | /> 63 | 64 | {newEngine && ( 65 |
66 | 71 |
72 | 78 | 86 |
87 |
88 | )} 89 |
90 |
91 | {searchEngines.map((engine, index) => ( 92 | 93 | 109 | 110 | ))} 111 |
112 |
113 | ) 114 | } 115 | 116 | export default SearchEnginesTab 117 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/tabs/search-engines/search-engine-card.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react" 2 | import { toast } from "sonner" 3 | import Input from "~/components/ui/input" 4 | import type { SearchEngine } from "~/store/search-engine" 5 | import type { Setter } from "~/types/react" 6 | import { AppCardContainer, AppCardFooter } from "../../shared/app-card" 7 | 8 | interface SearchEngineCardProps { 9 | index: number 10 | engine: SearchEngine 11 | setEngine?: Setter 12 | engineNames?: string[] 13 | engineShortcuts?: string[] 14 | update?: (id: number, engine: SearchEngine) => void 15 | remove?: (name: string) => void 16 | } 17 | 18 | const SearchEngineCard = (props: SearchEngineCardProps) => { 19 | const [engine, setEngine] = useState(props.engine) 20 | const [isFocused, setIsFocused] = useState(false) 21 | 22 | useEffect(() => { 23 | props.setEngine?.(engine) 24 | }, [engine, props.setEngine]) 25 | 26 | const onSaveHandler = () => { 27 | if (Object.values(engine).some((value) => value === "")) { 28 | return 29 | } 30 | 31 | if (props.engineNames?.includes(engine.name)) { 32 | toast.error(`Engine with name "${engine.name}" already found!`) 33 | return 34 | } 35 | 36 | if (props.engineShortcuts?.includes(engine.short)) { 37 | toast.error(`Engine with shortcut "${engine.short}" already found`) 38 | return 39 | } 40 | 41 | if (props.update) { 42 | props.update(props.index, engine) 43 | setIsFocused(false) 44 | } 45 | } 46 | 47 | return ( 48 | props.remove?.(engine.name)} 51 | > 52 | 58 | setEngine((prev) => ({ ...prev, icon: value })) 59 | } 60 | onFocus={() => setIsFocused(true)} 61 | className="text-foreground" 62 | /> 63 |
64 | 70 | setEngine((prev) => ({ ...prev, name: value })) 71 | } 72 | onFocus={() => setIsFocused(true)} 73 | isError={props.engineNames?.includes(engine.name)} 74 | className="text-foreground" 75 | /> 76 | 82 | setEngine((prev) => ({ ...prev, short: value.trim() })) 83 | } 84 | onFocus={() => setIsFocused(true)} 85 | isError={props.engineShortcuts?.includes(engine.short)} 86 | className="text-foreground" 87 | /> 88 |
89 | 95 | setEngine((prev) => ({ ...prev, baseUrl: value })) 96 | } 97 | onFocus={() => setIsFocused(true)} 98 | className="text-foreground" 99 | /> 100 | 105 |
106 | ) 107 | } 108 | 109 | export default SearchEngineCard 110 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-options/weather-options.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react" 2 | import { useOptionsStore } from "../../../store/options" 3 | import Button from "../../ui/button" 4 | import Input from "../../ui/input" 5 | import OptionsGroup from "./shared/options-group" 6 | import ToggleOption from "./shared/toggle-option" 7 | 8 | const WeatherOptions = () => { 9 | const { 10 | weatherAPI, 11 | setWeatherAPI, 12 | weatherLocation, 13 | setWeatherLocation, 14 | isScaleFahrenheit, 15 | toggleFahrenheitScale, 16 | showLocation, 17 | toggleShowLocation, 18 | } = useOptionsStore() 19 | 20 | const [api, setApi] = useState(weatherAPI) 21 | const [location, setLocation] = useState(weatherLocation) 22 | 23 | return ( 24 | 25 | 30 | 36 |
37 | setLocation(e.currentTarget.value)} 42 | /> 43 | 52 |
53 |
54 | setApi(e.currentTarget.value)} 60 | /> 61 |
62 | 66 | Learn More 67 | 68 | 77 |
78 |
79 |
80 | ) 81 | } 82 | 83 | export default WeatherOptions 84 | -------------------------------------------------------------------------------- /src/components/sidebar/sidebar-store.tsx: -------------------------------------------------------------------------------- 1 | import { create } from "zustand" 2 | 3 | export type Tab = "default" | "apps" | "gallery" | "search-engines" | "ai-tools" 4 | 5 | interface SiebarOptions { 6 | tab: Tab 7 | setTab: (tab: Tab) => void 8 | } 9 | 10 | export const useSidebarOptions = create()((set) => ({ 11 | tab: "default", 12 | setTab: (tab: Tab) => set({ tab }), 13 | })) 14 | -------------------------------------------------------------------------------- /src/components/switch.tsx: -------------------------------------------------------------------------------- 1 | import { Switch as ToggleSwitch } from "@headlessui/react" 2 | 3 | interface SwitchProps { 4 | enabled: boolean 5 | onChange: (state: boolean) => void 6 | disabled?: boolean 7 | } 8 | 9 | const Switch = ({ enabled, onChange, disabled }: SwitchProps) => { 10 | return ( 11 | 17 | 22 | ) 23 | } 24 | 25 | export default Switch 26 | -------------------------------------------------------------------------------- /src/components/ui/alert.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react" 2 | import Button from "./button" 3 | import type { ButtonProps } from "./button" 4 | import Modal from "./modal" 5 | 6 | interface AlertProps { 7 | btnText: string 8 | title?: string 9 | desc: string 10 | confirmFunc: () => void 11 | buttonClassName?: string 12 | } 13 | 14 | export default function Alert({ 15 | btnText, 16 | variant, 17 | title = "Are you absolutely sure?", 18 | desc, 19 | confirmFunc, 20 | buttonClassName, 21 | }: AlertProps & ButtonProps) { 22 | const [open, setOpen] = useState(false) 23 | 24 | return ( 25 | <> 26 | 33 | 34 |
35 | 38 | 41 |
42 |
43 | 44 | ) 45 | } 46 | -------------------------------------------------------------------------------- /src/components/ui/app-icon.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import { useOptionsStore } from "~/store/options" 3 | import { googleFavIcon } from "~/utils" 4 | 5 | interface AppIconProps { 6 | icon: string 7 | iconSize?: number 8 | className?: string 9 | } 10 | 11 | export default function AppIcon({ icon, iconSize, className }: AppIconProps) { 12 | const isMonochromeEnabled = useOptionsStore((s) => s.isMonochromeIcon) 13 | return ( 14 |
15 | {icon && !icon.startsWith("webicon:") ? ( 16 | 17 | ) : ( 18 | icon-image 24 | )} 25 |
26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /src/components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import { Slot } from "@radix-ui/react-slot" 2 | import { type VariantProps, cva } from "class-variance-authority" 3 | import React from "react" 4 | import { cn } from "../../utils" 5 | 6 | const buttonVariants = cva( 7 | "button active:scale-95 flex items-center justify-center rounded-xl transition-colors duration-300 gap-1 disabled:opacity-60 disabled:pointer-events-none", 8 | { 9 | variants: { 10 | variant: { 11 | primary: "bg-card text-card-foreground hover:bg-card-hover", 12 | secondary: "bg-background text-foreground hover:bg-card-foreground/10", 13 | accent: "bg-foreground text-background", 14 | destructive: 15 | "bg-destructive text-destructive-foreground hover:bg-destructive/80", 16 | }, 17 | size: { 18 | default: "px-4 h-10", 19 | icon: "size-11 rounded-full", 20 | }, 21 | }, 22 | defaultVariants: { 23 | variant: "primary", 24 | size: "default", 25 | }, 26 | }, 27 | ) 28 | 29 | export interface ButtonProps 30 | extends React.ButtonHTMLAttributes, 31 | VariantProps { 32 | asChild?: boolean 33 | } 34 | 35 | const Button = React.forwardRef( 36 | ({ type, asChild, className, children, variant, size, ...props }, ref) => { 37 | const Comp = asChild ? Slot : "button" 38 | return ( 39 | 45 | {children} 46 | 47 | ) 48 | }, 49 | ) 50 | 51 | Button.displayName = "button" 52 | 53 | export default Button 54 | -------------------------------------------------------------------------------- /src/components/ui/checkbox.tsx: -------------------------------------------------------------------------------- 1 | import type { Setter } from "~/types/react" 2 | 3 | interface CheckboxProps { 4 | id: string 5 | label: string 6 | checked: boolean 7 | setChecked: Setter 8 | } 9 | 10 | export default function Checkbox({ 11 | id, 12 | label, 13 | checked, 14 | setChecked, 15 | }: CheckboxProps) { 16 | return ( 17 |
18 | setChecked(e.target.checked)} 24 | /> 25 | 26 |
27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /src/components/ui/input.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react" 2 | import { type VariantProps, cva } from "class-variance-authority" 3 | import React, { useState } from "react" 4 | import { cn } from "../../utils" 5 | import Button from "./button" 6 | 7 | const input = cva( 8 | "w-full py-2 border-2 focus:border-transparent border-transparent rounded-xl px-4 focus:outline-none focus:ring-2 disabled:opacity-40 text-sm", 9 | { 10 | variants: { 11 | variant: { 12 | default: 13 | "bg-background text-foreground focus:ring-foreground placeholder:text-foreground placeholder:opacity-60", 14 | secondary: "bg-card text-card-foreground focus:ring-foreground", 15 | }, 16 | outline: { 17 | ghost: "focus:ring-0", 18 | }, 19 | }, 20 | defaultVariants: { 21 | variant: "default", 22 | }, 23 | }, 24 | ) 25 | 26 | interface InputProps 27 | extends React.InputHTMLAttributes, 28 | VariantProps { 29 | isError?: boolean 30 | errorTxt?: string 31 | label?: string 32 | } 33 | 34 | const Input = React.forwardRef( 35 | ( 36 | { 37 | type, 38 | id, 39 | className, 40 | label, 41 | variant, 42 | outline, 43 | isError, 44 | errorTxt, 45 | ...props 46 | }, 47 | ref, 48 | ) => { 49 | const [show, setShow] = useState(false) 50 | 51 | return ( 52 |
53 | {label && ( 54 | 57 | )} 58 |
59 | 71 | {type === "password" && ( 72 | 83 | )} 84 |
85 | {isError && errorTxt && ( 86 | {errorTxt} 87 | )} 88 |
89 | ) 90 | }, 91 | ) 92 | 93 | Input.displayName = "Input" 94 | 95 | export default Input 96 | -------------------------------------------------------------------------------- /src/components/ui/menu.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import * as ContextMenu from "@radix-ui/react-context-menu" 3 | import Button from "./button" 4 | 5 | interface MenuProps { 6 | title?: string 7 | menuTrigger: React.ReactNode 8 | data: { 9 | icon: string 10 | label: string 11 | func: () => void 12 | disabled?: boolean 13 | hidden?: boolean 14 | }[] 15 | } 16 | 17 | const Menu = ({ menuTrigger, title, data }: MenuProps) => { 18 | return ( 19 | 20 | 21 | {menuTrigger} 22 | 23 | 24 | 25 | {title && ( 26 | 27 | {title} 28 | 29 | )} 30 | {data.map((btn) => { 31 | if (!btn.hidden) { 32 | return ( 33 | 34 | 43 | 44 | ) 45 | } 46 | })} 47 | 48 | 49 | 50 | ) 51 | } 52 | 53 | export default Menu 54 | -------------------------------------------------------------------------------- /src/components/ui/modal.tsx: -------------------------------------------------------------------------------- 1 | import { Dialog, DialogPanel, DialogTitle } from "@headlessui/react" 2 | import clsx from "clsx" 3 | import type React from "react" 4 | import type { Setter } from "../../types/react" 5 | import Button from "./button" 6 | 7 | interface ModalProps { 8 | title?: string 9 | description?: string 10 | isOpen: boolean 11 | setIsOpen: Setter 12 | btnFunc?: () => void 13 | children?: React.ReactNode 14 | btnDisabled?: boolean 15 | } 16 | 17 | export default function Modal({ 18 | title, 19 | description, 20 | isOpen, 21 | setIsOpen, 22 | btnFunc, 23 | children, 24 | btnDisabled = false, 25 | }: ModalProps) { 26 | function close() { 27 | setIsOpen(false) 28 | } 29 | 30 | return ( 31 | 37 |
38 |
39 | 50 | 54 | {title} 55 | 56 | {description && ( 57 |

{description}

58 | )} 59 | {children} 60 | {btnFunc && ( 61 |
62 | 71 |
72 | )} 73 |
74 |
75 |
76 |
77 | ) 78 | } 79 | -------------------------------------------------------------------------------- /src/components/widgets/ai-tools.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import { AnimatePresence, motion } from "framer-motion" 3 | import { useState } from "react" 4 | import { useAppStore } from "~/store/app-store" 5 | import Button from "../ui/button" 6 | 7 | const AiTools = () => { 8 | const [showTools, setShowTools] = useState(false) 9 | const aiTools = useAppStore((s) => s.aiTools) 10 | 11 | return ( 12 | <> 13 | 14 | {showTools && ( 15 | 21 | )} 22 | 23 |
24 | 25 | 32 | 33 | 34 | {showTools && ( 35 | <> 36 | 43 | {aiTools.map(({ id, name, icon, url }, index) => { 44 | return ( 45 | 57 | 58 | {name} 59 | 60 | ) 61 | })} 62 | 63 | )} 64 | 65 |
66 | 67 | ) 68 | } 69 | 70 | export default AiTools 71 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/app-form.tsx: -------------------------------------------------------------------------------- 1 | import { Icon, disableCache, enableCache } from "@iconify/react" 2 | import clsx from "clsx" 3 | import { motion } from "framer-motion" 4 | import { nanoid } from "nanoid" 5 | import { useCallback, useEffect, useRef, useState } from "react" 6 | import { useDebounceValue } from "usehooks-ts" 7 | import Button from "~/components/ui/button" 8 | import Input from "~/components/ui/input" 9 | import Modal from "~/components/ui/modal" 10 | import type { App } from "~/lib/variables" 11 | import { useAppStore } from "~/store/app-store" 12 | import type { Setter } from "~/types/react" 13 | import { getDomain, googleFavIcon } from "~/utils" 14 | 15 | const IconPreview = ({ 16 | url, 17 | icon, 18 | btnFunc, 19 | }: { 20 | url: string 21 | icon: string 22 | btnFunc: () => void 23 | }) => { 24 | const [debouncedUrl] = useDebounceValue(url, 300) 25 | const [debouncedIcon] = useDebounceValue(icon, 300) 26 | 27 | useEffect(() => { 28 | disableCache("all") 29 | return () => enableCache("local") 30 | }, []) 31 | 32 | return ( 33 | 37 | {!icon || icon.startsWith("webicon:") ? ( 38 | website-favicon 43 | ) : ( 44 | 49 | )} 50 | 57 | 58 | ) 59 | } 60 | 61 | interface AppFormProps { 62 | isOpen: boolean 63 | setIsOpen: Setter 64 | app?: App | null 65 | } 66 | 67 | const AppForm = ({ isOpen, setIsOpen, app }: AppFormProps) => { 68 | // Store functions 69 | const { addDrawerApp, updateDrawerApp } = useAppStore() 70 | 71 | // Form vars 72 | const [name, setName] = useState(app?.name ?? "") 73 | const [url, setUrl] = useState(app?.url ?? "") 74 | const [icon, setIcon] = useState(app?.icon ?? "") 75 | const [isIconInput, setIsIconInput] = useState(false) 76 | const [formTitle, setFormTitle] = useState("") 77 | const timeoutID = useRef(null) 78 | 79 | const resetFormValues = useCallback(() => { 80 | setName("") 81 | setUrl("") 82 | setIcon("") 83 | setFormTitle("ADD APP") 84 | }, []) 85 | 86 | useEffect(() => { 87 | if (!isOpen && timeoutID.current) { 88 | clearTimeout(timeoutID.current) 89 | timeoutID.current = null 90 | } 91 | }, [isOpen]) 92 | 93 | useEffect(() => { 94 | if (!app) { 95 | timeoutID.current = setTimeout(() => { 96 | resetFormValues() 97 | setIsIconInput(false) 98 | }, 250) 99 | return 100 | } 101 | 102 | setName(app.name) 103 | setUrl(app.url) 104 | setIcon(app.icon) 105 | setFormTitle("UPDATE APP") 106 | 107 | if (app.icon && !app.icon.startsWith("webicon:")) { 108 | setIsIconInput(true) 109 | } 110 | }, [app, resetFormValues]) 111 | 112 | const submitHandler = () => { 113 | if (!name || !url) return 114 | 115 | if (!app) { 116 | addDrawerApp({ 117 | id: nanoid(), 118 | name, 119 | url, 120 | icon: !icon ? `webicon:${getDomain(url)}` : icon, 121 | }) 122 | } else { 123 | updateDrawerApp(app.id, { 124 | id: app.id, 125 | name, 126 | url, 127 | icon: icon || `webicon:${getDomain(url ?? app.url)}`, 128 | }) 129 | } 130 | setIsOpen(false) 131 | } 132 | 133 | const isSubmitBtnDisabled = 134 | !name || 135 | !url || 136 | JSON.stringify({ name: app?.name, icon: app?.icon, url: app?.url }) === 137 | JSON.stringify({ name, icon, url }) 138 | 139 | return ( 140 | 146 |
152 | {(url || icon) && ( 153 |
154 | setIsIconInput((prev) => !prev)} 158 | /> 159 |
160 | )} 161 | 162 | 168 |
{formTitle}
169 | {isIconInput && ( 170 | 175 | setIcon(e.currentTarget.value)} 179 | placeholder="e.g. solar:gallery-bold" 180 | className="mb-2 h-11" 181 | /> 182 | 183 | )} 184 | 185 | setName(e.currentTarget.value)} 189 | placeholder="e.g. Wallhaven" 190 | className="h-11" 191 | /> 192 | setUrl(e.currentTarget.value)} 196 | placeholder="e.g. https://wallhaven.cc" 197 | className="h-11" 198 | /> 199 | 200 |
201 |
202 |
203 | ) 204 | } 205 | 206 | export default AppForm 207 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/app-item.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import clsx from "clsx" 3 | import AppIcon from "~/components/ui/app-icon" 4 | import { useAppStore } from "~/store/app-store" 5 | import type { App } from "../../../lib/variables" 6 | import { ensureHttpPrefix } from "../../../utils" 7 | import Button from "../../ui/button" 8 | import AppMenu from "./app-menu" 9 | 10 | interface AppButtonProps { 11 | app: App 12 | isRemoveMode: boolean 13 | } 14 | 15 | const AppItem = ({ app, isRemoveMode }: AppButtonProps) => { 16 | const { drawerApps, removeDrawerApp } = useAppStore() 17 | 18 | if (!app) return null 19 | 20 | return ( 21 | 22 | isRemoveMode && e.preventDefault()} 29 | > 30 | 33 | 34 | {stringTruncate(app.name, 10)} 35 | 36 | {isRemoveMode && ( 37 | 44 | )} 45 | 46 | 47 | ) 48 | } 49 | 50 | export default AppItem 51 | 52 | function stringTruncate(str: string, maxCharLen: number) { 53 | if (str.length > maxCharLen) { 54 | return `${str.substring(0, 10)}...` 55 | } 56 | return str 57 | } 58 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/app-list.tsx: -------------------------------------------------------------------------------- 1 | import { motion } from "framer-motion" 2 | import { useAppStore } from "~/store/app-store" 3 | import AppItem from "./app-item" 4 | 5 | interface AppListProps { 6 | isRemoveMode: boolean 7 | } 8 | 9 | const AppList = ({ isRemoveMode }: AppListProps) => { 10 | const drawerApps = useAppStore((s) => s.drawerApps) 11 | 12 | return ( 13 | 19 | 26 | {drawerApps.map((app) => ( 27 | 32 | ))} 33 | 34 | 35 | ) 36 | } 37 | 38 | export default AppList 39 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/app-menu.tsx: -------------------------------------------------------------------------------- 1 | import type React from "react" 2 | import { useEffect } from "react" 3 | import Menu from "~/components/ui/menu" 4 | import { useAppStore } from "~/store/app-store" 5 | import type { App } from "../../../lib/variables" 6 | import { appListStore } from "./selected-app.store" 7 | 8 | interface AppMenuProps { 9 | children: React.ReactNode 10 | app: App 11 | } 12 | 13 | const AppMenu = ({ children, app }: AppMenuProps) => { 14 | const { removeDrawerApp, dockApps, addToDock } = useAppStore() 15 | const setSelectedApp = appListStore((s) => s.setSelectedApp) 16 | 17 | const isCurrentAppInDock = (): boolean => { 18 | return typeof dockApps.find(({ name }) => name === app.name) !== "undefined" 19 | } 20 | 21 | useEffect(() => { 22 | return () => setSelectedApp(null) 23 | }, [setSelectedApp]) 24 | 25 | return ( 26 | addToDock(app), 34 | disabled: isCurrentAppInDock(), 35 | }, 36 | { 37 | label: "Edit/Update", 38 | icon: "tabler:mood-edit", 39 | func: () => setSelectedApp(app), 40 | }, 41 | { 42 | label: "Remove", 43 | icon: "tabler:trash", 44 | func: () => removeDrawerApp(app.id), 45 | }, 46 | ]} 47 | /> 48 | ) 49 | } 50 | 51 | export default AppMenu 52 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/edit-applist.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import clsx from "clsx" 3 | import { useState } from "react" 4 | import { useAppStore } from "~/store/app-store" 5 | import type { Setter } from "../../../types/react" 6 | import Button from "../../ui/button" 7 | import AppForm from "./app-form" 8 | import { appListStore } from "./selected-app.store" 9 | 10 | interface EditAppListProps { 11 | removeMode: boolean 12 | setRemoveMode: Setter 13 | } 14 | 15 | const EditAppList = ({ removeMode, setRemoveMode }: EditAppListProps) => { 16 | const resetDrawerApp = useAppStore((s) => s.resetDrawerApp) 17 | const [isOpen, setIsOpen] = useState(false) 18 | 19 | const { selectedApp, setSelectedApp } = appListStore() 20 | 21 | return ( 22 | <> 23 |
24 | 31 | 39 | 46 |
47 | setSelectedApp(null) : setIsOpen 51 | } 52 | app={selectedApp} 53 | /> 54 | 55 | ) 56 | } 57 | 58 | export default EditAppList 59 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/index.tsx: -------------------------------------------------------------------------------- 1 | import { Icon } from "@iconify/react/dist/iconify.js" 2 | import { AnimatePresence } from "framer-motion" 3 | import { useState } from "react" 4 | import Button from "../../ui/button" 5 | import AppList from "./app-list" 6 | import EditAppList from "./edit-applist" 7 | 8 | const AppDrawer = () => { 9 | const [isOpen, setIsOpen] = useState(false) 10 | const [removeMode, setRemoveMode] = useState(false) 11 | 12 | return ( 13 |
14 |
15 | {isOpen && } 16 | 23 |
24 | 25 | {isOpen && } 26 | 27 |
28 | ) 29 | } 30 | 31 | export default AppDrawer 32 | -------------------------------------------------------------------------------- /src/components/widgets/app-drawer/selected-app.store.tsx: -------------------------------------------------------------------------------- 1 | import { create } from "zustand" 2 | import { combine } from "zustand/middleware" 3 | import type { App } from "../../../lib/variables" 4 | 5 | export const appListStore = create( 6 | combine( 7 | { 8 | selectedApp: null as App | null, 9 | }, 10 | (set) => ({ 11 | setSelectedApp: (app: App | null) => set({ selectedApp: app }), 12 | }), 13 | ), 14 | ) 15 | -------------------------------------------------------------------------------- /src/components/widgets/clock/analogue-clock.tsx: -------------------------------------------------------------------------------- 1 | export interface AnalogueClockProps { 2 | seconds: number 3 | miniutes: number 4 | hours: number 5 | } 6 | 7 | const SecondTicker = ({ 8 | seconds, 9 | }: Omit) => { 10 | return ( 11 |
12 |
13 |
14 | ) 15 | } 16 | 17 | const MiniuteTicker = ({ 18 | miniutes, 19 | }: Omit) => { 20 | return ( 21 |
25 |
26 |
27 | ) 28 | } 29 | 30 | const HourTicker = ({ 31 | hours, 32 | miniutes, 33 | }: Omit) => { 34 | const fullHourDeg = hours * 30 35 | const halfHourDeg = miniutes * 0.5 36 | const totalDeg = fullHourDeg + halfHourDeg 37 | 38 | return ( 39 |
43 |
44 |
45 | ) 46 | } 47 | 48 | const AnalogueClock = ({ seconds, miniutes, hours }: AnalogueClockProps) => { 49 | return ( 50 |
51 | 52 | 53 | 54 |
55 | ) 56 | } 57 | 58 | export default AnalogueClock 59 | -------------------------------------------------------------------------------- /src/components/widgets/clock/digital-clock.tsx: -------------------------------------------------------------------------------- 1 | import { useOptionsStore } from "../../../store/options" 2 | import { parseDate } from "../../../utils/datetime" 3 | 4 | interface DigitalClockProps { 5 | hours: number 6 | miniutes: number 7 | } 8 | 9 | const DigitalClock = ({ miniutes, hours }: DigitalClockProps) => { 10 | const is24HoursEnabled = useOptionsStore((s) => s.format24) 11 | 12 | const { weekDay, day } = parseDate(new Date()) 13 | 14 | return ( 15 |
16 |
17 | 18 | {!is24HoursEnabled 19 | ? formatPad(hours > 12 ? hours - 12 : hours) 20 | : formatPad(hours)} 21 | 22 | : 23 | {formatPad(miniutes)} 24 | {!is24HoursEnabled && ( 25 | 26 | {hours > 11 ? "PM" : "AM"} 27 | 28 | )} 29 |
30 |
31 | 32 | {weekDay.split("").splice(0, 3).join("").toUpperCase()} 33 | 34 | 35 | {day} 36 | 37 |
38 |
39 | ) 40 | } 41 | 42 | function formatPad(arg: number) { 43 | return arg.toString().padStart(2, "0") 44 | } 45 | 46 | export default DigitalClock 47 | -------------------------------------------------------------------------------- /src/components/widgets/clock/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react" 2 | import AnalogueClock from "./analogue-clock" 3 | import DigitalClock from "./digital-clock" 4 | 5 | interface ClockProps { 6 | clockType: "analogue" | "digital" 7 | } 8 | 9 | const Clock = ({ clockType }: ClockProps) => { 10 | const date = new Date() 11 | const [seconds, setSeconds] = useState(date.getSeconds()) 12 | const [miniutes, setMiniutes] = useState(date.getMinutes()) 13 | const [hours, setHours] = useState(date.getHours()) 14 | 15 | useEffect(() => { 16 | const intervalId = setInterval(() => { 17 | const newDate = new Date() 18 | setSeconds(newDate.getSeconds()) 19 | setMiniutes(newDate.getMinutes()) 20 | setHours(newDate.getHours()) 21 | }, 1000) 22 | 23 | return () => clearInterval(intervalId) 24 | }, []) 25 | 26 | if (clockType === "analogue") { 27 | return 28 | } 29 | 30 | return 31 | } 32 | 33 | export default Clock 34 | -------------------------------------------------------------------------------- /src/components/widgets/custom-text.tsx: -------------------------------------------------------------------------------- 1 | import clsx from "clsx" 2 | import { useEffect, useRef, useState } from "react" 3 | import { useOptionsStore } from "../../store/options" 4 | import { getGreetings } from "../../utils/datetime" 5 | import { parseDate } from "../../utils/datetime" 6 | 7 | const date = new Date() 8 | 9 | const getFirstWords = (str: string) => str.split("").splice(0, 3).join("") 10 | const textPlaceHolder = "Click here to edit" 11 | 12 | export const CustomText = () => { 13 | const { customText, setCustomText } = useOptionsStore() 14 | const { 15 | enableDigitalClock: isDigitalClockEnabled, 16 | greetings, 17 | isBgImage, 18 | } = useOptionsStore() 19 | 20 | const [isFocused, setIsFocused] = useState(false) 21 | const inputRef = useRef(null) 22 | const parentRef = useRef(null) 23 | const hiddenSpanRef = useRef(null) 24 | 25 | const { day, month, weekDay } = parseDate(date) 26 | 27 | // biome-ignore lint/correctness/useExhaustiveDependencies: 28 | useEffect(() => { 29 | if (inputRef.current) { 30 | inputRef.current.style.height = "auto" 31 | inputRef.current.style.height = `${inputRef.current.scrollHeight}px` 32 | 33 | if (parentRef.current && hiddenSpanRef.current) { 34 | const parentWidth = parentRef.current.scrollWidth 35 | const textWidth = hiddenSpanRef.current.scrollWidth 36 | 37 | const newWidth = Math.min( 38 | Math.max(textWidth + (isFocused ? 40 : 20), 50), 39 | parentWidth, 40 | ) 41 | inputRef.current.style.width = `${newWidth}px` 42 | } 43 | } 44 | }, [customText, isFocused]) 45 | 46 | return ( 47 |
54 | 55 | {customText || textPlaceHolder} 56 | 57 |