React Bricks

Types


These are all types exported by React Bricks, as a reference.

Enums

BlockSuperType

enum BlockSuperType {
  Single = 'SINGLE',
  Repeater = 'REPEATER',
}

SideEditPropType

enum SideEditPropType {
  Text = 'TEXT',
  Number = 'NUMBER',
  Date = 'DATE',
  Range = 'RANGE',
  Boolean = 'BOOLEAN',
  Select = 'SELECT',
  Image = 'IMAGE',
}

RichTextFeatures

enum RichTextFeatures {
  Bold = 'BOLD',
  Italic = 'ITALIC',
  Code = 'CODE',
  Highlight = 'HIGHLIGHT',
  Link = 'LINK',
  UnorderedList = 'UL',
  OrderedList = 'OL',
}

SortDirection

enum SortDirection {
  Up = 'UP',
  Down = 'DOWN',
}

OptionsDisplay

enum OptionsDisplay {
  Select = 'SELECT',
  Radio = 'RADIO',
  Color = 'COLOR',
}

PageStatus

enum PageStatus {
  Draft = 'DRAFT',
  Published = 'PUBLISHED',
}

PlaygroundSelectedItemType

enum PlaygroundSelectedItemType {
    Block = 'BLOCK',
    Page = 'PAGE',
  }

Types

User

type User = {
  email: string
  firstName: string
  lastName: string
  isAdmin: boolean
  token: string
  appName: string
  deployHookUrl?: string
  deployHookMethod: string
} | null

Page

type Page = {
  id: string
  type: string
  name: string
  slug: string
  meta: IMeta
  content: IContentBlock[]
  invalidBlocksTypes?: string[]
  status: PageStatus
  isLocked: boolean
  tags: string[]
}

RenderLocalLink

type RenderLocalLink = ({
    href,
    target,
    className,
    activeClassName,
    isAdmin,
    children,
  }: {
    href: string
    target?: string
    className?: string
    activeClassName?: string
    isAdmin?: boolean
    children: React.ReactNode
  }) => React.ReactElement

Props

type Props = { [key: string]: any }

Interfaces

IBlockType

interface IBlockType {
  name: string
  label: string
  superType: BlockSuperType
  render: (props: Props) => React.ReactElement
  getDefaultProps: () => object
  hideFromAddMenu?: boolean
  sideEditProps?: ISideEditProp[]
  textEditProps?: string[]
  itemsType?: string
  addItemText?: string
  removeItemText?: string
}

IContentBlock

interface IContentBlock {
  id: string
  type: string
  props: Props
}

IOption

interface IOption {
  value: any
  label: string
}

ISideEditProp

interface ISideEditProp {
  name: string
  label: string
  type: SideEditPropType
  validate?: (value: any, props?: Props) => boolean
  show?: (props: Props) => boolean
  imageOptions?: {
    maxWidth: number
  }
  rangeOptions?: {
    min: number
    max: number
    step: number
  }
  selectOptions?: {
    options: IOption[]
    display: OptionsDisplay
  }
}

IFocused

interface IFocused {
  blockId: string
  itemId: string
}

IImageSource

interface IImageSource {
  src: string
  placeholderSrc?: string
  srcSet?: string
}

IPageType

interface IPageType {
  name: string
  pluralName: string
  allowedBlockTypes?: string[]
  excludedBlockTypes?: string[]
  defaultLocked?: boolean
  defaultStatus?: PageStatus
  defaultLanguage?: string
  getDefaultContent?: () => IContentBlock[]
}

ICleanBlocks

interface ICleanBlocks {
  blocks: IContentBlock[]
  invalidBlocksTypes: string[]
}

ILoginCredentials

interface ILoginCredentials {
  email: string
  password: string
  appId: string
}

IReactBricksContext

interface IReactBricksContext {
  appId: string
  apiKey: string
  blockTypeSchema: IBlockType[]
  pageTypeSchema: IPageType[]
  logo: string
  contentClassName: string
  renderLocalLink: RenderLocalLink
  navigate: (path: string) => void
  loginPath: string
  editorPath: string
  playgroundPath: string
  appSettingsPath: string
}

IAdminContext

interface IAdminContext {
  user: User | null
  setUser: (user: User) => void
  currentPage: string
  setCurrentPage: (page: string) => void
  previewMode: boolean
  setPreviewMode: (previewMode: boolean) => void
  sidebarCollapsed: boolean
  setSidebarCollapsed: (sidebarCollapsed: boolean) => void
}

INewPage

interface INewPage {
  id?: string
  type: string
  name: string
  slug?: string
  meta?: IMeta
  content?: IContentBlock[]
  status?: PageStatus
  isLocked?: boolean
}

IPlaygroundSelectedItem

interface IPlaygroundSelectedItem {
  type: PlaygroundSelectedItemType
  name: string
  label: string
}

IPlaygroundContext

interface IPlaygroundContext {
  selectedItem: IPlaygroundSelectedItem | null
  setSelectedItem: (selectedItem: any) => void
}

IMeta

interface IMeta {
  title?: string
  description?: string
  language?: string
}