Skip to content

Commit

Permalink
fix: icons client types
Browse files Browse the repository at this point in the history
  • Loading branch information
Avivbens committed Jun 6, 2024
1 parent 4bbd63a commit c021c5c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/core/services/alfred-info.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env } from 'process'
import { env } from 'node:process'

export class AlfredInfoService {
private getEnv(key: string): string | undefined {
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/env.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-dupe-class-members */
import { env } from 'process'
import { env } from 'node:process'
import type { GetEnvOptions } from '@models/get-env-options.model'

export class EnvService {
Expand Down
47 changes: 33 additions & 14 deletions src/core/services/icon.service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
export class IconService {
private readonly ICONS = {
info: this.generateIcon('ToolbarInfo'),
warning: this.generateIcon('AlertCautionIcon'),
error: this.generateIcon('AlertStopIcon'),
alert: this.generateIcon('Actions'),
like: this.generateIcon('ToolbarFavoritesIcon'),
delete: this.generateIcon('ToolbarDeleteIcon'),
}
const generateIcon = (name: string) =>
`/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/${name}.icns` as const

private generateIcon(name: string): string {
return `/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/${name}.icns`
}
const ICONS = {
info: generateIcon('ToolbarInfo'),
warning: generateIcon('AlertCautionIcon'),
error: generateIcon('AlertStopIcon'),
alert: generateIcon('Actions'),
like: generateIcon('ToolbarFavoritesIcon'),
delete: generateIcon('ToolbarDeleteIcon'),
} as const

public getIcon(name: keyof typeof this.ICONS): string {
const icon = this.ICONS[name]
/**
* @description
* This service responsible to get icons from the system
*
* You can use it to get the icon path for a specific icon
*
* @example
* ```typescript
* alfredClient.output({
* items: [
* {
* title: 'Some Error',
* icon: {
* path: alfredClient.icons.getIcon('error'),
* },
* },
* ],
* })
* ```
*/
export class IconService {
public getIcon(name: keyof typeof ICONS): string {
const icon = ICONS[name]
if (!icon) {
throw new Error(`Icon ${name} not found`)
}
Expand Down

0 comments on commit c021c5c

Please sign in to comment.