mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-05-02 13:02:04 -04:00
Toast fixes & styling
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ReactNode, useState, useEffect, useCallback } from 'react'
|
import { ReactNode, useState, useEffect, useCallback } from 'react'
|
||||||
import { Icon, check, info, warning, error } from '@/components/icons'
|
import { Icon, check, info, warning, error, close } from '@/components/icons'
|
||||||
|
|
||||||
export interface ToastProps {
|
export interface ToastProps {
|
||||||
id: string
|
id: string
|
||||||
@@ -32,7 +32,7 @@ const Toast = ({
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setVisible(false)
|
setVisible(false)
|
||||||
setTimeout(() => onDismiss(id), 50)
|
setTimeout(() => onDismiss(id), 50)
|
||||||
}, 300)
|
}, 400)
|
||||||
}, [id, onDismiss])
|
}, [id, onDismiss])
|
||||||
|
|
||||||
// Handle animation on mount/unmount
|
// Handle animation on mount/unmount
|
||||||
@@ -40,7 +40,7 @@ const Toast = ({
|
|||||||
// Start the enter animation
|
// Start the enter animation
|
||||||
const enterTimer = setTimeout(() => {
|
const enterTimer = setTimeout(() => {
|
||||||
setVisible(true)
|
setVisible(true)
|
||||||
}, 10)
|
}, 50)
|
||||||
|
|
||||||
// Auto-dismiss after duration, if not Infinity
|
// Auto-dismiss after duration, if not Infinity
|
||||||
let dismissTimer: NodeJS.Timeout | null = null
|
let dismissTimer: NodeJS.Timeout | null = null
|
||||||
@@ -60,15 +60,33 @@ const Toast = ({
|
|||||||
const getIcon = (): ReactNode => {
|
const getIcon = (): ReactNode => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'success':
|
case 'success':
|
||||||
return <Icon name={check} size="md" variant="bold" />
|
return <Icon name={check} size="md" variant="solid" className="toast-type-icon toast-success-icon"/>
|
||||||
case 'error':
|
case 'error':
|
||||||
return <Icon name={error} size="md" variant="bold" />
|
return <Icon name={error} size="md" variant="solid" className="toast-type-icon toast-error-icon"/>
|
||||||
case 'warning':
|
case 'warning':
|
||||||
return <Icon name={warning} size="md" variant="bold" />
|
return <Icon name={warning} size="md" variant="solid" className="toast-type-icon toast-warning-icon"/>
|
||||||
case 'info':
|
case 'info':
|
||||||
return <Icon name={info} size="md" variant="bold" />
|
return <Icon name={info} size="md" variant="solid" className="toast-type-icon toast-info-icon"/>
|
||||||
default:
|
default:
|
||||||
return <Icon name={info} size="md" variant="bold" />
|
return <Icon name={info} size="md" variant="solid" className="toast-type-icon toast-info-icon"/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get default title if none provided
|
||||||
|
const getTitle = (): string => {
|
||||||
|
if (title) return title
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'success':
|
||||||
|
return 'Success'
|
||||||
|
case 'error':
|
||||||
|
return 'Error'
|
||||||
|
case 'warning':
|
||||||
|
return 'Warning'
|
||||||
|
case 'info':
|
||||||
|
return 'Information'
|
||||||
|
default:
|
||||||
|
return 'Notification'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +96,11 @@ const Toast = ({
|
|||||||
>
|
>
|
||||||
<div className="toast-icon">{getIcon()}</div>
|
<div className="toast-icon">{getIcon()}</div>
|
||||||
<div className="toast-content">
|
<div className="toast-content">
|
||||||
{title && <h4 className="toast-title">{title}</h4>}
|
<h4 className="toast-title">{getTitle()}</h4>
|
||||||
<p className="toast-message">{message}</p>
|
<p className="toast-message">{message}</p>
|
||||||
</div>
|
</div>
|
||||||
<button className="toast-close" onClick={handleDismiss} aria-label="Dismiss">
|
<button className="toast-close" onClick={handleDismiss} aria-label="Dismiss">
|
||||||
×
|
<Icon name={close} size="sm" variant="solid" className="toast-close-icon" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,15 +88,19 @@ export const AppProvider = ({ children }: AppProviderProps) => {
|
|||||||
try {
|
try {
|
||||||
await executeGameAction(gameId, action, games)
|
await executeGameAction(gameId, action, games)
|
||||||
|
|
||||||
// Show success message
|
// Show appropriate success message based on action type
|
||||||
if (action.includes('install')) {
|
const product = action.includes('cream') ? 'Creamlinux' : 'SmokeAPI'
|
||||||
success(
|
const isUninstall = action.includes('uninstall')
|
||||||
`Successfully installed ${action.includes('cream') ? 'CreamLinux' : 'SmokeAPI'} for ${game.title}`
|
const isInstall = action.includes('install') && !isUninstall
|
||||||
)
|
|
||||||
|
console.log('DEBUG: Action processed. Product:', product, 'isInstall:', isInstall, 'isUninstall:', isUninstall, 'action:', action)
|
||||||
|
|
||||||
|
if (isInstall) {
|
||||||
|
success(`Successfully installed ${product} for ${game.title}`)
|
||||||
|
} else if (isUninstall) {
|
||||||
|
info(`${product} uninstalled from ${game.title}`)
|
||||||
} else {
|
} else {
|
||||||
success(
|
console.log('Unknown action type:', action)
|
||||||
`Successfully uninstalled ${action.includes('cream') ? 'CreamLinux' : 'SmokeAPI'} from ${game.title}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showError(`Action failed: ${error}`)
|
showError(`Action failed: ${error}`)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
z-index: var(--z-tooltip);
|
z-index: var(--z-tooltip);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5rem;
|
gap: 0.75rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
max-width: 380px;
|
max-width: 400px;
|
||||||
|
|
||||||
// Position variations
|
// Position variations
|
||||||
&.top-right {
|
&.top-right {
|
||||||
@@ -60,120 +60,163 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
background-color: var(--elevated-bg);
|
background-color: var(--elevated-bg);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-lg);
|
||||||
box-shadow: var(--shadow-lg);
|
box-shadow: var(--shadow-lg);
|
||||||
padding: 0.75rem 1rem;
|
padding: 1rem 1.25rem;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-width: 280px;
|
min-width: 320px;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(10px);
|
transform: translateY(20px) scale(0.95);
|
||||||
transition: all 0.3s var(--easing-ease-out);
|
transition: all 0.4s var(--easing-bounce);
|
||||||
border-left: 4px solid;
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0) scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.closing {
|
&.closing {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-10px);
|
transform: translateY(-20px) scale(0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type-specific styling
|
// Type-specific styling
|
||||||
&.toast-success {
|
&.toast-success {
|
||||||
border-color: var(--success);
|
border-left: 4px solid var(--success);
|
||||||
|
|
||||||
.toast-icon {
|
.toast-icon {
|
||||||
|
.toast-success-icon {
|
||||||
color: var(--success);
|
color: var(--success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.toast-error {
|
&.toast-error {
|
||||||
border-color: var(--danger);
|
border-left: 4px solid var(--danger);
|
||||||
|
|
||||||
.toast-icon {
|
.toast-icon {
|
||||||
|
.toast-error-icon {
|
||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.toast-warning {
|
&.toast-warning {
|
||||||
border-color: var(--warning);
|
border-left: 4px solid var(--warning);
|
||||||
|
|
||||||
.toast-icon {
|
.toast-icon {
|
||||||
|
.toast-warning-icon {
|
||||||
color: var(--warning);
|
color: var(--warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.toast-info {
|
&.toast-info {
|
||||||
border-color: var(--info);
|
border-left: 4px solid var(--info);
|
||||||
|
|
||||||
.toast-icon {
|
.toast-icon {
|
||||||
|
.toast-info-icon {
|
||||||
color: var(--info);
|
color: var(--info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Toast elements
|
// Toast elements
|
||||||
.toast-icon {
|
.toast-icon {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 1.25rem;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
background: var(--tertiary-bg);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.35rem;
|
||||||
margin-right: 0.75rem;
|
margin-right: 0.75rem;
|
||||||
margin-top: 0.125rem;
|
margin-top: 0;
|
||||||
|
|
||||||
|
.toast-type-icon {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-content {
|
.toast-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0; // Required for proper overflow handling
|
min-width: 0; // Required for proper overflow handling
|
||||||
|
padding-top: 0.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-title {
|
.toast-title {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.95rem;
|
font-size: 1rem;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.4rem;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-message {
|
.toast-message {
|
||||||
font-size: 0.875rem;
|
font-size: 0.9rem;
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-close {
|
.toast-close {
|
||||||
background: none;
|
background: rgba(255, 255, 255, 0.1);
|
||||||
border: none;
|
border: none;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
font-size: 1.25rem;
|
padding: 0.4rem;
|
||||||
line-height: 1;
|
|
||||||
padding: 0;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.75rem;
|
||||||
transition: color 0.2s ease;
|
border-radius: 50%;
|
||||||
|
width: 1.75rem;
|
||||||
|
height: 1.75rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.toast-close-icon {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
transform: scale(1.1);
|
||||||
|
|
||||||
|
.toast-close-icon {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animations for toast
|
// Animations for toast
|
||||||
@keyframes toast-in {
|
@keyframes toast-in {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(20px);
|
transform: translateY(30px) scale(0.9);
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0) scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes toast-out {
|
@keyframes toast-out {
|
||||||
from {
|
from {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0);
|
transform: translateY(0) scale(1);
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-20px);
|
transform: translateY(-30px) scale(0.9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user