-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type errors for Button's use of Icon data.
- Loading branch information
1 parent
8d988d4
commit ee76171
Showing
5 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'svelte-ux': patch | ||
--- | ||
|
||
Added new `IconInput` and `IconData` types to enable inclusive & seamless passing of icon arguments between components. Also provides a `asIconData` utility function for type-safe conversion. | ||
Fixed type errors for Button & TextField's use of Icon data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import type { ComponentProps } from "svelte"; | ||
import type { default as Icon } from "$lib/components/Icon.svelte"; | ||
import { isLiteralObject } from "./object"; | ||
|
||
export type IconInput = ComponentProps<Icon>['data'] | ComponentProps<Icon>; | ||
export type IconData = ComponentProps<Icon>['data']; | ||
|
||
export function asIconData(v: IconInput): IconData { | ||
return isIconComponentProps(v) ? v.data : v; | ||
} | ||
|
||
function isIconComponentProps(v: any): v is ComponentProps<Icon> { | ||
return isLiteralObject(v) && typeof(v['iconName']) === "undefined"; | ||
} |