-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add custom window frame option + some tweaks
- Loading branch information
Showing
17 changed files
with
155 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import ModrinthImage from '~assets/logos/modrinth.svg?component-solid'; | ||
import { type Component, type JSX, Match, Show, splitProps, Switch } from 'solid-js'; | ||
import type { ManagedPackage, Providers } from '@onelauncher/client/bindings'; | ||
|
||
export function getProviderLogoElement(provider: ManagedPackage | Providers): string | Component { | ||
const providerName = (typeof provider === 'string' ? provider : provider.provider)?.toLowerCase() as Lowercase<Providers>; | ||
|
||
// [provider logo, is svg] | ||
const mapping: Record<Lowercase<Providers>, string | Component> = { | ||
modrinth: ModrinthImage, | ||
}; | ||
|
||
return mapping[providerName]; | ||
} | ||
|
||
type ProviderIconProps = JSX.HTMLAttributes<HTMLImageElement> & { | ||
provider: Providers | undefined; | ||
}; | ||
|
||
function ProviderIcon(props: ProviderIconProps) { | ||
const [split, rest] = splitProps(props, ['provider', 'class']); | ||
|
||
const Element = () => { | ||
const value = getProviderLogoElement(split.provider!); | ||
|
||
return ( | ||
<Switch> | ||
<Match when={typeof value === 'string'}> | ||
<img {...rest} {...(split.class ? { class: split.class } : {})} alt={`${split.provider}'s logo`} src={value as string} /> | ||
</Match> | ||
<Match when> | ||
{value} | ||
</Match> | ||
</Switch> | ||
); | ||
}; | ||
|
||
return ( | ||
<Show | ||
children={( | ||
<Element /> | ||
)} | ||
fallback={( | ||
<div class={`bg-gray-05 ${split.class || ''}`} {...rest as JSX.HTMLAttributes<HTMLDivElement>} /> | ||
)} | ||
when={split.provider !== undefined} | ||
/> | ||
); | ||
} | ||
|
||
export default ProviderIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
pub mod http; | ||
pub mod java; | ||
pub mod watcher; | ||
|
||
#[cfg(feature = "tauri")] | ||
pub mod window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use tauri::WebviewWindow; | ||
|
||
pub fn set_window_styling( | ||
win: &WebviewWindow, | ||
custom: bool, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
win.set_decorations(!custom)?; | ||
|
||
#[cfg(target_os = "macos")] | ||
{ | ||
if custom { | ||
win.set_title_bar_style(tauri_utils::TitleBarStyle::Overlay)?; | ||
} else { | ||
win.set_title_bar_style(tauri_utils::TitleBarStyle::Visible)?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |