mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
Active Styles + small bug fixes (#447)
This commit is contained in:
parent
effea61429
commit
3b380f17fd
5 changed files with 96 additions and 43 deletions
|
@ -52,7 +52,8 @@
|
||||||
<div class="version-list" class:visible={isOpened}>
|
<div class="version-list" class:visible={isOpened}>
|
||||||
{#if (pkg?.installed_versions || []).length > 0}
|
{#if (pkg?.installed_versions || []).length > 0}
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<div class="version-item flex items-center justify-start gap-x-1 text-xs"
|
<div
|
||||||
|
class="version-item flex items-center justify-start gap-x-1 text-xs"
|
||||||
on:click={(evt) => handleClick(evt, "")}
|
on:click={(evt) => handleClick(evt, "")}
|
||||||
>
|
>
|
||||||
<div>uninstall</div>
|
<div>uninstall</div>
|
||||||
|
@ -139,8 +140,8 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* width */
|
/* width */
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 6px;
|
width: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
return "primary";
|
return "primary";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isActive = (state: PackageStates): boolean => {
|
||||||
|
return state === PackageStates.INSTALLING || state === PackageStates.UPDATING;
|
||||||
|
};
|
||||||
|
|
||||||
const badgeClass: Record<PackageStates, string> = {
|
const badgeClass: Record<PackageStates, string> = {
|
||||||
[PackageStates.AVAILABLE]: "install-badge",
|
[PackageStates.AVAILABLE]: "install-badge",
|
||||||
[PackageStates.INSTALLING]: "install-badge",
|
[PackageStates.INSTALLING]: "install-badge",
|
||||||
|
@ -36,6 +40,7 @@
|
||||||
class="w-full border p-0 text-xs text-white {buttonSize === 'small' ? 'h-8' : 'h-10'}"
|
class="w-full border p-0 text-xs text-white {buttonSize === 'small' ? 'h-8' : 'h-10'}"
|
||||||
type="plain"
|
type="plain"
|
||||||
color={getColor(pkg.state)}
|
color={getColor(pkg.state)}
|
||||||
|
active={isActive(pkg.state)}
|
||||||
{onClick}
|
{onClick}
|
||||||
>
|
>
|
||||||
<div class="version-button h-full">
|
<div class="version-button h-full">
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import "$appcss";
|
import "$appcss";
|
||||||
import "@tea/ui/icons/icons.css";
|
import "@tea/ui/icons/icons.css";
|
||||||
import { t } from '$libs/translations';
|
import { t } from "$libs/translations";
|
||||||
import Button from "@tea/ui/button/button.svelte";
|
import Button from "@tea/ui/button/button.svelte";
|
||||||
import semverCompare from "semver/functions/compare";
|
import semverCompare from "semver/functions/compare";
|
||||||
|
|
||||||
import { installPackage } from "@native";
|
|
||||||
import { PackageStates, type GUIPackage } from "$libs/types";
|
import { PackageStates, type GUIPackage } from "$libs/types";
|
||||||
import { packagesStore } from "$libs/stores";
|
import { packagesStore } from "$libs/stores";
|
||||||
import { shellOpenExternal } from "@native";
|
import { shellOpenExternal } from "@native";
|
||||||
import InstallButton from "$components/install-button/install-button.svelte";
|
import InstallButton from "$components/install-button/install-button.svelte";
|
||||||
import { findAvailableVersions } from "$libs/packages/pkg-utils";
|
import { findAvailableVersions } from "$libs/packages/pkg-utils";
|
||||||
import { trimGithubSlug } from "$libs/github";
|
import { trimGithubSlug } from "$libs/github";
|
||||||
|
|
||||||
|
|
||||||
export let pkg: GUIPackage;
|
export let pkg: GUIPackage;
|
||||||
let installing = false;
|
let installing = false;
|
||||||
let pruning = false
|
let pruning = false;
|
||||||
|
|
||||||
const install = async () => {
|
const install = async (version: string) => {
|
||||||
installing = true;
|
installing = true;
|
||||||
await installPackage(pkg);
|
await packagesStore.installPkg(pkg, version);
|
||||||
installing = false;
|
installing = false;
|
||||||
packagesStore.updatePackage(pkg.full_name, {
|
packagesStore.updatePackage(pkg.full_name, {
|
||||||
state: PackageStates.INSTALLED
|
state: PackageStates.INSTALLED
|
||||||
|
@ -30,13 +28,14 @@
|
||||||
const prune = async () => {
|
const prune = async () => {
|
||||||
pruning = true;
|
pruning = true;
|
||||||
const versions = (pkg?.installed_versions || []).sort((a, b) => semverCompare(b, a));
|
const versions = (pkg?.installed_versions || []).sort((a, b) => semverCompare(b, a));
|
||||||
for(const [i,v] of versions.entries()) {
|
for (const [i, v] of versions.entries()) {
|
||||||
if (i) { // skip the latest version = 0
|
if (i) {
|
||||||
|
// skip the latest version = 0
|
||||||
await packagesStore.deletePkg(pkg, v);
|
await packagesStore.deletePkg(pkg, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pruning = false;
|
pruning = false;
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section class="mt-4 bg-black">
|
<section class="mt-4 bg-black">
|
||||||
|
@ -48,7 +47,10 @@
|
||||||
<h3 class="text-primary text-3xl">{pkg.full_name}</h3>
|
<h3 class="text-primary text-3xl">{pkg.full_name}</h3>
|
||||||
{#if pkg.homepage}
|
{#if pkg.homepage}
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<span class="cursor-pointer hover:text-primary" on:click={() => shellOpenExternal(pkg.homepage)} >{pkg.homepage}</span>
|
<span
|
||||||
|
class="hover:text-primary cursor-pointer"
|
||||||
|
on:click={() => shellOpenExternal(pkg.homepage)}>{pkg.homepage}</span
|
||||||
|
>
|
||||||
{/if}
|
{/if}
|
||||||
<p class="mt-4 text-sm">{pkg.desc}</p>
|
<p class="mt-4 text-sm">{pkg.desc}</p>
|
||||||
<menu class="mt-4 grid h-10 grid-cols-3 gap-4 text-xs">
|
<menu class="mt-4 grid h-10 grid-cols-3 gap-4 text-xs">
|
||||||
|
@ -62,15 +64,9 @@
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{#if (pkg?.installed_versions?.length || 0) > 1}
|
{#if (pkg?.installed_versions?.length || 0) > 1}
|
||||||
<Button
|
<Button class="h-10" type="plain" color="blue" onClick={prune} loading={pruning}>
|
||||||
class="h-10"
|
<div class="version-item flex w-full items-center justify-center gap-x-1 text-xs">
|
||||||
type="plain"
|
<div class="icon-scissors" />
|
||||||
color="blue"
|
|
||||||
onClick={prune}
|
|
||||||
loading={pruning}
|
|
||||||
>
|
|
||||||
<div class="w-full version-item flex items-center justify-center gap-x-1 text-xs" >
|
|
||||||
<div class="icon-scissors"/>
|
|
||||||
<div>{$t("package.cta-PRUNE")}</div>
|
<div>{$t("package.cta-PRUNE")}</div>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
export let link: string;
|
export let link: string;
|
||||||
export let progessLoading = 0;
|
export let progessLoading = 0;
|
||||||
|
|
||||||
const imgUrl = !pkg.thumb_image_url.includes("https://tea.xyz")
|
$: imgUrl = !pkg.thumb_image_url.includes("https://tea.xyz")
|
||||||
? "https://tea.xyz/Images/package-thumb-nolabel4.jpg"
|
? "https://tea.xyz/Images/package-thumb-nolabel4.jpg"
|
||||||
: pkg.thumb_image_url;
|
: pkg.thumb_image_url;
|
||||||
|
|
||||||
|
@ -20,17 +20,25 @@
|
||||||
|
|
||||||
export let onUninstall = async () => {
|
export let onUninstall = async () => {
|
||||||
console.log("do nothing");
|
console.log("do nothing");
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Using this instead of css :active because there is a button inside of a button
|
||||||
|
let isActive = false;
|
||||||
|
const activate = () => (isActive = true);
|
||||||
|
const deactivate = () => (isActive = false);
|
||||||
|
|
||||||
|
const preventPropagation = (evt: MouseEvent) => evt.stopPropagation();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
class="package-card border-gray relative h-auto border"
|
class="package-card border-gray relative h-auto border bg-center"
|
||||||
|
class:active={isActive}
|
||||||
style="background-image: url({imgUrl})"
|
style="background-image: url({imgUrl})"
|
||||||
>
|
>
|
||||||
<aside class="blur-sm">
|
<aside class="blur-sm">
|
||||||
<figure style="background-image: url({imgUrl})"></figure>
|
<figure class="bg-center" style="background-image: url({imgUrl})" />
|
||||||
</aside>
|
</aside>
|
||||||
<a href={link}>
|
<a href={link} on:mousedown={activate} on:mouseup={deactivate} on:mouseleave={deactivate}>
|
||||||
<div class="package-card-content absolute flex h-full w-full flex-col justify-between">
|
<div class="package-card-content absolute flex h-full w-full flex-col justify-between">
|
||||||
<div class="hint-container">
|
<div class="hint-container">
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
|
@ -43,14 +51,12 @@
|
||||||
<h3 class="text-bold font-mona line-clamp-1 text-2xl font-bold text-white">{pkg.name}</h3>
|
<h3 class="text-bold font-mona line-clamp-1 text-2xl font-bold text-white">{pkg.name}</h3>
|
||||||
<p class="line-clamp-2 h-[32px] text-xs font-thin">{pkg.desc ?? ""}</p>
|
<p class="line-clamp-2 h-[32px] text-xs font-thin">{pkg.desc ?? ""}</p>
|
||||||
</article>
|
</article>
|
||||||
<div class="mt-3.5 flex w-full relative">
|
<div class="relative mt-3.5 flex w-full">
|
||||||
<div class="install-button">
|
<div class="install-button" on:mousedown={preventPropagation}>
|
||||||
<InstallButton {pkg} {availableVersions} onClick={onClickCTA}
|
<InstallButton {pkg} {availableVersions} onClick={onClickCTA} uninstall={onUninstall} />
|
||||||
uninstall={onUninstall}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-1 h-[10px] leading-[10px] relative">
|
<div class="relative mt-1 h-[10px] leading-[10px]">
|
||||||
{#if pkg.state === "NEEDS_UPDATE"}
|
{#if pkg.state === "NEEDS_UPDATE"}
|
||||||
<span class="text-[0.5rem]">Updating from v{findRecentInstalledVersion(pkg)}</span>
|
<span class="text-[0.5rem]">Updating from v{findRecentInstalledVersion(pkg)}</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -60,7 +66,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{#if progessLoading > 0 && progessLoading < 100}
|
{#if progessLoading > 0 && progessLoading < 100}
|
||||||
<div class="absolute z-40 left-0 top-0 h-full w-full bg-black bg-opacity-50">
|
<div class="absolute left-0 top-0 z-40 h-full w-full bg-black bg-opacity-50">
|
||||||
<div class="absolute left-0 right-0 top-1/2 m-auto -mt-12 h-24 w-24">
|
<div class="absolute left-0 right-0 top-1/2 m-auto -mt-12 h-24 w-24">
|
||||||
<ProgressCircle value={progessLoading} />
|
<ProgressCircle value={progessLoading} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,6 +83,23 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section.active::before {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(26, 26, 26, 0.7);
|
||||||
|
z-index: 2;
|
||||||
|
content: "";
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.package-card:active {
|
||||||
|
border-color: #8000ff;
|
||||||
|
box-shadow: 0px 0px 0px 2px rgba(128, 0, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
aside {
|
aside {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
|
@ -85,6 +108,7 @@
|
||||||
height: 50%;
|
height: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
figure {
|
figure {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
|
@ -135,12 +159,6 @@
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.package-card:active {
|
|
||||||
border-color: #8000ff;
|
|
||||||
box-shadow: 0px 0px 0px 2px rgba(128, 0, 255, 0.5);
|
|
||||||
mix-blend-mode: overlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
.package-card:hover .hint {
|
.package-card:hover .hint {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,14 @@
|
||||||
background: #01997d;
|
background: #01997d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.plain.primary:active {
|
||||||
|
background: #01997d;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.plain.primary:active::before {
|
||||||
|
background: #01997d;
|
||||||
|
}
|
||||||
|
|
||||||
button.primary::before {
|
button.primary::before {
|
||||||
background: #0ecaa7;
|
background: #0ecaa7;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +94,14 @@
|
||||||
background: #410182;
|
background: #410182;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.plain.secondary:active {
|
||||||
|
background: #410182;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.plain.secondary:active::before {
|
||||||
|
background: #410182;
|
||||||
|
}
|
||||||
|
|
||||||
button.secondary::before {
|
button.secondary::before {
|
||||||
background: #6000bf;
|
background: #6000bf;
|
||||||
}
|
}
|
||||||
|
@ -111,19 +127,36 @@
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.plain.black:active {
|
||||||
|
background: #e1e1e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.plain.black:active::before {
|
||||||
|
background: #e1e1e1;
|
||||||
|
}
|
||||||
|
|
||||||
/* black button inverts colors on hover */
|
/* black button inverts colors on hover */
|
||||||
button.black:hover {
|
button.black:hover {
|
||||||
color: #1a1a1a;
|
color: #1a1a1a;
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* green */
|
/* blue */
|
||||||
button.plain.blue {
|
button.plain.blue {
|
||||||
background: #013b99;
|
background: #2675f5;
|
||||||
|
border: 1px solid #2675f5;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.blue::before {
|
button.blue::before {
|
||||||
background: #2675f5;
|
background: #013b99;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.plain.blue:active {
|
||||||
|
background: #012765;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.plain.blue:active::before {
|
||||||
|
background: #012765;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue