Skip to content

Instantly share code, notes, and snippets.

@kaareloun
Last active June 7, 2023 06:56
Show Gist options
  • Save kaareloun/1822c2ddfb3939d923a0ea78c3700be7 to your computer and use it in GitHub Desktop.
Save kaareloun/1822c2ddfb3939d923a0ea78c3700be7 to your computer and use it in GitHub Desktop.
Laravel Nova Typescript types
export enum NovaMenuSlug {
Header = 'header',
Footer = 'footer'
}
export type NovaMenu = {
id: number
name: string
slug: NovaMenuSlug
locale: string
menuItems: NovaMenuItem[]
}
export enum MenuItemTypes {
STATIC_URL = 'static-url',
TEXT = 'text',
PAGE = 'page',
}
export type NovaMenuItem = {
id: number
name: string
type: MenuItemTypes
value: string
target: HTMLAttributeAnchorTarget
enabled: boolean
data: any
children: NovaMenuItem[]
}
export type NovaPage = {
id: number
data?: {
en: Record<string, any>
}
name: string
slug: string
path: {
en: string
}
template: string
}
export type NovaRegion<T> = {
name: string
data: {
en: T
}
template: string
}
export type NovaFlexibleLayout<K extends string, T> = {
key: string
layout: K
attributes: Partial<T> // All nova page manager fields are optional
}
export type FactsAndFiguresBlock = NovaFlexibleLayout<
'facts_and_figures_block',
{
cards?: NovaFlexibleLayout<
'card',
{
icon: Image
text: string
number: number
symbol: string
}
>[]
}
>
export enum ImageSize {
Original = 'original', // 2000 x 2000
Icon = 'icon', // 24 x 24
ExtraSmall = 'extra-small', // 200 x 200
Small = 'small', // 400 x 400
Medium = 'medium', // 800 x 800
Large = 'large', // 1200 x 1200
}
export type Image = {
id: number
alt: string | null
mime_type: string
is_video: boolean
title: string | null
file_name?: string
files: {
[key in ImageSize]: {
url: string
webp: string
} & {
smart: {
url: string
webp: string
}
}
}
}
// Meilisearch
export type Countable<K> = {
hits: K[]
total: number
count: number
}
export type SearchResponse = {
clients?: Countable<ClientModel>
total: number
count: number
}
export type ClientModel = {
id: number
firstName: string
lastName: string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment