Skip to content

Commit

Permalink
APP-5548: add toggle icons, fix icon name type-checking (viamrobotics…
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jul 23, 2024
1 parent 09d4b4f commit 66a98b0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime-core",
"version": "0.0.133",
"version": "0.0.134",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/icon/icon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $: {
} else if (Array.isArray(pathValue)) {
allPaths = pathValue.map((icon) => ({
path: icon.path,
opacity: icon.opacity,
opacity: 'opacity' in icon ? icon.opacity : undefined,
}));
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/lib/icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type IconPath = Path | CustomIcon[];
* Keys should match MDI name
* e.g. 'account-multiple' for MDI.mdiAccountMultiple
*/
export const paths: Record<string, IconPath> = {
export const paths = {
'account-group-outline': MDI.mdiAccountGroupOutline,
'account-multiple': MDI.mdiAccountMultiple,
'alert-circle-outline': MDI.mdiAlertCircleOutline,
Expand Down Expand Up @@ -125,6 +125,8 @@ export const paths: Record<string, IconPath> = {
sync: MDI.mdiSync,
tools: MDI.mdiTools,
'trash-can-outline': MDI.mdiTrashCanOutline,
'toggle-switch-outline': MDI.mdiToggleSwitchOutline,
'toggle-switch-off-outline': MDI.mdiToggleSwitchOffOutline,
twitter: MDI.mdiTwitter,
undo: MDI.mdiUndo,
'unfold-less-horizontal': MDI.mdiUnfoldLessHorizontal,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/pill.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export let disabled = false;
export let removable = true;
/** The icon shown in the button. */
export let icon: IconName = '';
export let icon: IconName | undefined = undefined;
/** Additional CSS classes to pass to the pill. */
let extraClasses: cx.Argument = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const detailedOptions = [
value: 'opt-1',
label: 'Gale',
description: 'Wizard',
icon: 'viam-process',
icon: 'viam-process' as const,
},
{
value: 'opt-2',
label: 'Karlach',
description: 'Barbarian',
icon: 'language-cpp',
icon: 'language-cpp' as const,
},
];
const stringOptions = ['hello from', 'the other side'];
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('SearchableSelect', () => {
const newOptions = [
{ value: 'New Option 1' },
{ value: 'opt1', label: 'New Option 2' },
{ value: 'opt3', label: 'New Option 3', icon: 'apple' },
{ value: 'opt3', label: 'New Option 3', icon: 'apple' as const },
];

// Update the options prop
Expand Down
4 changes: 2 additions & 2 deletions packages/storybook/src/stories/icon.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Meta, Story } from '@storybook/addon-svelte-csf';
import { Icon, Tooltip } from '@viamrobotics/prime-core';
import { Icon, Tooltip, type IconName } from '@viamrobotics/prime-core';
import { paths } from '../../../core/src/lib/icon/icons';
const pathsKeys = Object.keys(paths);
const pathsKeys = Object.keys(paths) as IconName[];
</script>

<Meta title="Elements/Icon" />
Expand Down

0 comments on commit 66a98b0

Please sign in to comment.