Skip to content

Commit

Permalink
fix: #169 use IconDefinition from FontAwesome instead of a custom i…
Browse files Browse the repository at this point in the history
…nterface `FontAwesomeIcon`

BREAKING CHANGE:

The custom `FontAwesomeIcon` is now replaced with `IconDefinition` from FontAwesome
  • Loading branch information
josdejong committed Oct 21, 2022
1 parent 8029ad2 commit 9d693f9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const editor = new JSONEditor({
```ts
interface MenuButtonItem {
onClick: () => void
icon?: FontAwesomeIcon
icon?: IconDefinition
text?: string
title?: string
className?: string
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/controls/Message.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

<script lang="ts">
import Icon from 'svelte-awesome'
import type { FontAwesomeIcon, MessageAction } from '../../types'
import type { MessageAction } from '../../types'
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
export let type: 'success' | 'error' = 'success' // 'success' or 'error'
export let icon: FontAwesomeIcon = undefined
export let icon: IconDefinition = undefined
export let message: string | undefined = undefined
export let actions: MessageAction[] = []
export let onClick: () => void | undefined = undefined
Expand Down
19 changes: 10 additions & 9 deletions src/lib/img/customFontawesomeIcons.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { FontAwesomeIcon } from '../types'
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
import type { IconName } from '@fortawesome/fontawesome-common-types'

export const faJSONEditorExpand: FontAwesomeIcon = {
export const faJSONEditorExpand: IconDefinition = {
prefix: 'fas',
iconName: 'jsoneditor-expand',
iconName: 'jsoneditor-expand' as IconName,
icon: [
512,
512,
Expand All @@ -15,9 +16,9 @@ export const faJSONEditorExpand: FontAwesomeIcon = {
]
}

export const faJSONEditorCollapse: FontAwesomeIcon = {
export const faJSONEditorCollapse: IconDefinition = {
prefix: 'fas',
iconName: 'jsoneditor-collapse',
iconName: 'jsoneditor-collapse' as IconName,
icon: [
512,
512,
Expand All @@ -27,9 +28,9 @@ export const faJSONEditorCollapse: FontAwesomeIcon = {
]
}

export const faJSONEditorFormat: FontAwesomeIcon = {
export const faJSONEditorFormat: IconDefinition = {
prefix: 'fas',
iconName: 'jsoneditor-format',
iconName: 'jsoneditor-format' as IconName,
icon: [
512,
512,
Expand All @@ -42,9 +43,9 @@ export const faJSONEditorFormat: FontAwesomeIcon = {
]
}

export const faJSONEditorCompact: FontAwesomeIcon = {
export const faJSONEditorCompact: IconDefinition = {
prefix: 'fas',
iconName: 'jsoneditor-compact',
iconName: 'jsoneditor-compact' as IconName,
icon: [
512,
512,
Expand Down
16 changes: 8 additions & 8 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { JSONPatchDocument, JSONPath, JSONPointer, JSONValue } from 'immutable-json-patch'
import type { SvelteComponentTyped } from 'svelte'
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'

export type { JSONValue, JSONPointer, JSONPath, JSONPatchDocument } from 'immutable-json-patch'

Expand Down Expand Up @@ -114,23 +115,22 @@ export type JSONPointerMap<T> = { [pointer: JSONPointer]: T }

export type ClipboardValues = Array<{ key: string; value: JSONValue }>

export interface FontAwesomeIcon {
prefix: string
iconName: string
icon: [number, number, Array<number | string>, string | null, string]
}
/**
* @deprecated Use IconDefinition instead of FontAwesomeIcon
*/
export type FontAwesomeIcon = IconDefinition

export interface DropdownButtonItem {
text: string
onClick: () => void
icon?: FontAwesomeIcon
icon?: IconDefinition
title?: string
disabled?: boolean
}

export interface MenuButtonItem {
onClick: () => void
icon?: FontAwesomeIcon
icon?: IconDefinition
text?: string
title?: string
className?: string
Expand All @@ -150,7 +150,7 @@ export type MenuItem = MenuButtonItem | MenuSeparatorItem | MenuSpaceItem
export interface MessageAction {
text: string
title: string
icon?: FontAwesomeIcon
icon?: IconDefinition
onClick?: () => void
onMouseDown?: () => void
disabled?: boolean
Expand Down

0 comments on commit 9d693f9

Please sign in to comment.