Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-01 04:23:53 +11:00
parent 3cd159a63e
commit a6ad8651b3
605 changed files with 11480 additions and 9125 deletions
+15 -13
View File
@@ -1,6 +1,5 @@
import { IconName, IconSrc } from '../components/icons';
export const bytesToSize = (bytes: number): string => {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) return '0KB';
@@ -53,7 +52,7 @@ export const fulfilledPromiseSettledResult = <T>(prs: PromiseSettledResult<T>[])
}, []);
export const promiseFulfilledResult = <T>(
settledResult: PromiseSettledResult<T>
settledResult: PromiseSettledResult<T>,
): T | undefined => {
if (settledResult.status === 'fulfilled') return settledResult.value;
return undefined;
@@ -92,7 +91,7 @@ export const fitMediaSize = (
w: number,
h: number,
maxW: number,
maxH: number
maxH: number,
): { width: number; height: number } => {
if (w <= 0 || h <= 0) {
return { width: maxW, height: Math.round(maxW * 0.75) };
@@ -170,15 +169,18 @@ export const stripAlphaFromColor = (color: string): string => {
const b = parseInt(rgbaMatch[3], 10).toString(16).padStart(2, '0');
return `#${r}${g}${b}`.toUpperCase();
}
// Handle hex format
let hex = color.replace('#', '');
// Convert shorthand #RGB or #RGBA to full form
if (hex.length === 3 || hex.length === 4) {
hex = hex.split('').map(c => c + c).join('');
hex = hex
.split('')
.map((c) => c + c)
.join('');
}
// Take only the first 6 characters (RGB), ignore alpha if present
return `#${hex.substring(0, 6).toUpperCase()}`;
};
@@ -191,15 +193,15 @@ export const stripAlphaFromColor = (color: string): string => {
export const getContrastingTextColor = (bgColor: string): string => {
// Remove # if present
const hex = bgColor.replace('#', '');
// Parse RGB values (ignore alpha if present)
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
// Calculate relative luminance using WCAG formula
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
// Return black for light backgrounds, white for dark backgrounds
return luminance > 0.5 ? '#000000' : '#FFFFFF';
};
@@ -212,15 +214,15 @@ export const getContrastingTextColor = (bgColor: string): string => {
export const getTextShadowColor = (textColor: string): string => {
// Remove # if present
const hex = textColor.replace('#', '');
// Parse RGB values (ignore alpha if present)
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
// Calculate relative luminance using WCAG formula
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
// Return white shadow only for very dark text (luminance < 0.2)
return luminance < 0.2 ? '#FFFFFF' : '#000000';
};