cosmo-ui
Version:
Common React components
37 lines (29 loc) • 990 B
text/typescript
import {
OPEN_TRAY_ITEM,
CLOSE_TRAY_ITEM,
TOGGLE_TRAY_ITEM,
} from '../constants'
export interface OpenTrayItemAction {
type: '@@cosmo-ui/OPEN_TRAY_ITEM'
trayName: string
itemName: string
}
export interface CloseTrayItemAction {
type: '@@cosmo-ui/CLOSE_TRAY_ITEM'
trayName: string
itemName: string
}
export interface ToggleTrayItemAction {
type: '@@cosmo-ui/TOGGLE_TRAY_ITEM'
trayName: string
itemName: string
}
export type TrayAction = ToggleTrayItemAction
| OpenTrayItemAction
| CloseTrayItemAction
export const openTrayItem = (trayName: string, itemName: string): OpenTrayItemAction =>
({ trayName, itemName, type: OPEN_TRAY_ITEM })
export const closeTrayItem = (trayName: string, itemName: string): CloseTrayItemAction =>
({ trayName, itemName, type: CLOSE_TRAY_ITEM })
export const toggleTrayItem = (trayName: string, itemName: string): ToggleTrayItemAction =>
({ trayName, itemName, type: TOGGLE_TRAY_ITEM })