Skip to content

Commit 2f56612

Browse files
authored
Feat: export icon path data for direct usage in non-Svelte UIs (#618)
1 parent e33fc63 commit 2f56612

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@viamrobotics/prime-core",
3-
"version": "0.0.173",
3+
"version": "0.0.174",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/viamrobotics/prime.git",

packages/core/src/lib/icon/icon.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const sizes: Record<Size, string> = {
3030

3131
<script lang="ts">
3232
import cx from 'classnames';
33-
import { paths, type IconName, type CustomIcon } from './icons';
33+
import { IconPathsByName, type IconName, type CustomIcon } from './icons';
3434
3535
/** The name of the icon. */
3636
export let name: IconName;
@@ -45,7 +45,7 @@ export { extraClasses as cx };
4545
let allPaths: CustomIcon[] = [];
4646
4747
$: {
48-
const pathValue = paths[name];
48+
const pathValue = IconPathsByName[name];
4949
5050
if (typeof pathValue === 'string') {
5151
allPaths = [{ path: pathValue }];

packages/core/src/lib/icon/icons.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import * as MDI from '@mdi/js';
22

3-
type Path = string;
3+
export type SimpleIconPath = string;
44

55
export interface CustomIcon {
66
path: string;
77
opacity?: number | undefined;
88
}
99

10-
export type IconPath = Path | CustomIcon[];
10+
export type IconPath = SimpleIconPath | CustomIcon[];
1111

1212
/**
1313
* Keys should match MDI name
1414
* e.g. 'account-multiple' for MDI.mdiAccountMultiple
1515
*/
16-
export const paths = {
16+
export const IconPathsByName = {
1717
'account-group-outline': MDI.mdiAccountGroupOutline,
1818
'account-multiple': MDI.mdiAccountMultiple,
1919
'alert-circle-outline': MDI.mdiAlertCircleOutline,
@@ -179,9 +179,9 @@ export const paths = {
179179
'view-dashboard-outline': MDI.mdiViewDashboardOutline,
180180
webhook: MDI.mdiWebhook,
181181
windows: MDI.mdiMicrosoftWindows,
182-
} as const;
182+
} satisfies Record<string, IconPath>;
183183

184184
/**
185185
* The possible icon names that can be rendered. This is good for typing props.
186186
*/
187-
export type IconName = keyof typeof paths;
187+
export type IconName = keyof typeof IconPathsByName;

packages/core/src/lib/icon/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
export { default as Icon } from './icon.svelte';
2-
export type { IconName } from './icons';
2+
export {
3+
IconPathsByName,
4+
type IconName,
5+
type IconPath,
6+
type SimpleIconPath,
7+
type CustomIcon,
8+
} from './icons';

0 commit comments

Comments
 (0)