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

View file

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

View file

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