feat: add image mask options and update related schemas and styles

This commit is contained in:
ByteAtATime 2025-06-23 18:47:40 -07:00
parent afa6fc8235
commit bda11b7ddc
No known key found for this signature in database
3 changed files with 23 additions and 4 deletions

View file

@ -28,6 +28,13 @@ import { BrowserExtensionAPI } from './browserExtension';
import { Clipboard } from './clipboard';
import * as OAuth from './oauth';
const Image = {
Mask: {
Circle: 'circle',
RoundedRectangle: 'roundedRectangle'
}
};
let currentPluginName: string | null = null;
let currentPluginPreferences: Array<{
name: string;
@ -55,6 +62,7 @@ export const getRaycastApi = () => {
Color,
Cache,
Icon,
Image,
LaunchType,
Toast,
OAuth,

View file

@ -16,9 +16,18 @@
);
const iconInfo = $derived(resolveIcon(icon, assetsPath));
const maskStyles = $derived(
iconInfo?.type === 'image' && iconInfo.mask === 'Circle' ? 'border-radius: 50%;' : ''
);
const maskStyles = $derived.by(() => {
if (iconInfo?.type !== 'image' || !iconInfo.mask) {
return '';
}
if (iconInfo.mask === 'circle') {
return 'border-radius: 50%;';
}
if (iconInfo.mask === 'roundedRectangle') {
return 'border-radius: 0.375rem;';
}
return '';
});
</script>
{#if iconInfo}

View file

@ -1,5 +1,7 @@
import { z } from 'zod/v4';
export const ImageMaskSchema = z.enum(['circle', 'roundedRectangle']);
export const RaycastIconSchema = z.templateLiteral([z.string(), '-16']);
export const ImageLikeSchema = z.union([
@ -7,7 +9,7 @@ export const ImageLikeSchema = z.union([
z.string(),
z.object({
source: z.union([z.string(), z.object({ light: z.string(), dark: z.string() })]),
mask: z.string().optional()
mask: ImageMaskSchema.optional()
})
]);
export type ImageLike = z.infer<typeof ImageLikeSchema>;