-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
121 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,30 @@ | ||
import { ReactNode } from 'react'; | ||
import { BoxProps } from './Box'; | ||
|
||
declare enum Direction { | ||
NORTH = 1, | ||
SOUTH = 2, | ||
EAST = 4, | ||
WEST = 8, | ||
NORTHEAST = 5, | ||
NORTHWEST = 9, | ||
SOUTHEAST = 6, | ||
SOUTHWEST = 10 | ||
} | ||
type Props = { | ||
/** Required: The path of the icon */ | ||
icon: string; | ||
/** Required: The state of the icon */ | ||
icon_state: string; | ||
} & Partial<{ | ||
/** Facing direction. See direction enum. Default is South */ | ||
direction: Direction; | ||
/** Fallback icon. */ | ||
fallback: ReactNode; | ||
/** Frame number. Default is 1 */ | ||
frame: number; | ||
/** Movement state. Default is false */ | ||
movement: any; | ||
}> & BoxProps; | ||
export declare function DmIcon(props: Props): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined; | ||
export {}; |
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,21 @@ | ||
import { jsx as u } from "react/jsx-runtime"; | ||
import { Image as $ } from "./Image.js"; | ||
function x(o) { | ||
var r; | ||
const { | ||
className: l, | ||
direction: t = 2, | ||
fallback: n, | ||
frame: c = 1, | ||
icon_state: m, | ||
icon: i, | ||
movement: s = !1, | ||
...a | ||
} = o, e = (r = Byond.iconRefMap) == null ? void 0 : r[i]; | ||
if (!e) return n; | ||
const f = `${e}?state=${m}&dir=${t}&movement=${!!s}&frame=${c}`; | ||
return /* @__PURE__ */ u($, { fixErrors: !0, src: f, ...a }); | ||
} | ||
export { | ||
x as DmIcon | ||
}; |
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,53 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { BoxProps } from './Box'; | ||
import { Image } from './Image'; | ||
|
||
enum Direction { | ||
NORTH = 1, | ||
SOUTH = 2, | ||
EAST = 4, | ||
WEST = 8, | ||
NORTHEAST = NORTH | EAST, | ||
NORTHWEST = NORTH | WEST, | ||
SOUTHEAST = SOUTH | EAST, | ||
SOUTHWEST = SOUTH | WEST, | ||
} | ||
|
||
type Props = { | ||
/** Required: The path of the icon */ | ||
icon: string; | ||
/** Required: The state of the icon */ | ||
icon_state: string; | ||
} & Partial<{ | ||
/** Facing direction. See direction enum. Default is South */ | ||
direction: Direction; | ||
/** Fallback icon. */ | ||
fallback: ReactNode; | ||
/** Frame number. Default is 1 */ | ||
frame: number; | ||
/** Movement state. Default is false */ | ||
movement: any; | ||
}> & | ||
BoxProps; | ||
|
||
export function DmIcon(props: Props) { | ||
const { | ||
className, | ||
direction = Direction.SOUTH, | ||
fallback, | ||
frame = 1, | ||
icon_state, | ||
icon, | ||
movement = false, | ||
...rest | ||
} = props; | ||
|
||
const iconRef = Byond.iconRefMap?.[icon]; | ||
|
||
if (!iconRef) return fallback; | ||
|
||
const query = `${iconRef}?state=${icon_state}&dir=${direction}&movement=${!!movement}&frame=${frame}`; | ||
|
||
return <Image fixErrors src={query} {...rest} />; | ||
} |
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