Files
coco-app/src/components/Selection/HeaderToolbar.tsx
BiggerRain 97d2450fa7 feat: selection settings add & delete (#992)
* feat: add selection window page

* fix: chat input

* feat: add selection page

* chore: add

* chore: test

* feat: add

* feat: add store

* feat: add selection settings

* chore: remove unused code

* docs: add release note

* docs: add release note

* chore: format code

* chore: format code

* fix: copy error

* disable hashbrown default feature

* Enable unstable feature allocator_api

To make coco-app compile in CI:

```
--> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/hashbrown-0.15.5/src/raw/mod.rs:3856:12
     |
3856 | impl<T, A: Allocator> RawIntoIter<T, A> {
     |            ^^^^^^^^^
     |
     = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
     = help: add `#![feature(allocator_api)]` to the crate attributes to enable
     = note: this compiler was built on 2025-06-25; consider upgrading it if it is out of date
```

I don't know why it does not compile, feature `allocator-api2` is
enabled for `hashbrown 0.15.5`, so technically [1] it should not use the
allocator APIs from the std. According to [2], enabling the `nightly`
feature of `allocator-api2` may cause this issue as well, but it is not
enabled in our case either.

Anyway, enabling `#![feature(allocator_api)]` should make it work.

[1]: b751eef8e9/src/raw/alloc.rs (L26-L47)
[2]: https://github.com/rust-lang/hashbrown/issues/564

* put it in main.rs

* format main.rs

* Enable default-features for hashbrown 0.15.5

* format main.rs

* enable feature allocator-api2

* feat: add selection set config

* fix: selection setting

* fix: ci error

* fix: ci error

* fix: ci error

* fix: ci error

* merge: merge main

* fix: rust code warn

* fix: rust code error

* fix: rust code error

* fix: selection settings

* style: selection styles

* style: selection styles

* feat: selection settings add & delete

* feat: selection settings add & delete

* feat: selection settings add & delete

* style: selection styles

* chore: add @tauri-store/zustand plugin

* refactor: the selection store using @tauri-store/zustand

* fix: data error

* fix: data error

* chore: remove config

* chore: selection

* chore: selection

* chore: width

* chore: ignore selection in the app itself

* style: selection styles

* style: remove

* docs: add notes

* chore: add permission check

* chore: selection

* chore: style & store

---------

Co-authored-by: Steve Lau <stevelauc@outlook.com>
2025-12-05 15:32:57 +08:00

59 lines
1.4 KiB
TypeScript

import { Separator } from "@radix-ui/react-separator";
import cocoLogoImg from "@/assets/app-icon.png";
import SelectionToolbar from "@/components/Selection/Toolbar";
import type { ActionConfig, ButtonConfig } from "@/components/Settings/Advanced/components/Selection/config";
export default function HeaderToolbar({
buttons,
iconsOnly,
onAction,
onLogoClick,
className,
rootRef,
children,
}: {
buttons: ButtonConfig[];
iconsOnly: boolean;
onAction: (action: ActionConfig) => void;
onLogoClick?: () => void;
className?: string;
rootRef?: React.Ref<HTMLDivElement>;
children?: React.ReactNode;
}) {
return (
<div
ref={rootRef}
data-tauri-drag-region="false"
className={`flex items-center gap-1 px-2 py-1 flex-nowrap overflow-hidden ${className ?? ""}`}
>
<img
src={cocoLogoImg}
alt="Coco Logo"
className="w-6 h-6"
onClick={onLogoClick}
onError={(e) => {
try {
(e.target as HTMLImageElement).src = "/src-tauri/assets/logo.png";
} catch {}
}}
/>
<Separator
orientation="vertical"
decorative
className="mx-1 h-4 w-px bg-gray-300 dark:bg-white/30 shrink-0"
/>
<SelectionToolbar
buttons={buttons}
iconsOnly={iconsOnly}
onAction={onAction}
requireAssistantCheck={false}
/>
{children}
</div>
);
}