Skip to content

UI Actions ​

Use ui.actions to connect the platform's call-to-action buttons (login, subscribe, share…) to your site's own modals or flows.


js
MindtrainingPlatform.init('mindtraining', {
  ui: {
    mode: 'web', // 'web' (default) | 'app'
    actions: {
      shouldShowAccessPaywall: function (context) {
        // Legacy fallback for blocked flows that explicitly allow route continuation.
        return context.mode === 'web'
      },
      openLogin: function () {
        // open your login modal
      },
      openRegister: function () {
        // open your registration modal
      },
      openSubscribe: function () {
        // open your subscription page or modal
      },
      openUrl: function (url) {
        window.open(url, '_blank')
      },
      share: function (payload) {
        // payload: { url?: string, title?: string }
        navigator.share({ url: payload.url, title: payload.title })
      },
    },
  },
})

Every resolved blocked surface uses the same fallback: when the matching host action exists, the SDK calls openLogin for login_required or openSubscribe for subscription and usage limits. Without a matching host action, it shows the SDK access dialog. A blocked Home game with categories may still open its Subhome first so the user can choose a category before resolving access.

When configured, shouldShowAccessPaywall runs whenever the SDK resolves a blocked surface, including Home, Subhome, in-place surfaces, direct routes, minimal embeds and runtime permission updates. Returning true shows the SDK paywall. Returning false calls the matching host action: openLogin for login_required, or openSubscribe for subscription and usage limits. In-place surfaces close before the host action runs.

The callback receives { action, mode, surface, reason, limit, gameType, variant }. If it is omitted or throws, every resolved surface uses the shared fallback described above. Returning false without a matching host action safely continues to the SDK paywall. Buttons inside that paywall always call openLogin, openRegister, or openSubscribe directly without consulting the callback again.

ui.mode provides host integration context to the callback. It does not hide or compact SDK headers by itself.

Back Navigation ​

showBackNavigation is an optional top-level boolean that controls the visibility of in-app back navigation buttons. It defaults to true.

Set it to false when the host provides its own back/forward navigation:

js
MindtrainingPlatform.init('mindtraining', {
  showBackNavigation: false,
})

This hides back buttons in the game, subhome, archive, statistics, and page-based game panels. It does not disable browser history or change navigation events, access rules, or the controls used to close dialogs and drawers.

The host must provide a way to return from these screens. To show the buttons again, use updateConfig():

js
MindtrainingPlatform.updateConfig({ showBackNavigation: true })

Unrelated updateConfig() calls preserve the current value. setConfig() replaces the configuration, so omitting this option resets it to true.

Color scheme ​

ui.colorScheme selects the color palette for all sites.

  • 'light' (default): forces the light palette.
  • 'dark': forces the dark palette.
  • 'system': follows the device preference through prefers-color-scheme and responds to changes while the platform is in use.

Set the initial preference when initializing the platform:

js
MindtrainingPlatform.init('mindtraining', {
  ui: { colorScheme: 'system' },
})

The host can change it at runtime with updateConfig():

js
MindtrainingPlatform.updateConfig({ ui: { colorScheme: 'dark' } })
MindtrainingPlatform.updateConfig({ ui: { colorScheme: 'light' } })
MindtrainingPlatform.updateConfig({ ui: { colorScheme: 'system' } })

The platform does not add theme buttons or selectors; the host controls the preference and any UI used to change it. This property is independent of ui.mode ('web' / 'app'). Sites without color scheme support keep their existing presentation.

Unrelated updateConfig() calls preserve the selected preference. setConfig() replaces the configuration, so omitting ui.colorScheme returns to 'light'.

Light and dark palettes are edited separately in the admin. Existing configurations initially use the same colors for both modes, so selecting dark mode does not automatically darken the palette; customize its colors in the admin.

Game screen visibility ​

These optional top-level booleans default to true in supported game layouts.

showMobileGameHeader: false hides the mobile title/date bar below the game controls. The desktop title and game controls stay visible.

showOtherGames: false hides the other-games section below the board at every container width, including its reserved space. Directories on other screens and completion recommendations are unaffected.

Both options are independent of ui.mode and access permissions. Layouts without support keep their existing presentation.

js
MindtrainingPlatform.init('mindtraining', {
  showMobileGameHeader: false,
  showOtherGames: false,
})

Use updateConfig() to change either option. Unrelated updates preserve both values. setConfig() replaces the configuration; omitted options reset to true.

js
MindtrainingPlatform.updateConfig({
  showMobileGameHeader: true,
  showOtherGames: true,
})

All sites inherit the optional ui.actions.navigate callback. It receives a serializable request before SDK navigation. It works in both web and app modes. Navigation interception.

ui.useHostShare ​

Optional boolean in ui. Set true to delegate sharing to ui.actions.share in app and web, or false to use SDK sharing even with a registered callback. Omission preserves the app-only default. Without a callback, the SDK uses its existing sharing options. The callback return value is ignored. Change the option with updateConfig() without calling init() again or re-registering the callback. Omitting it in setConfig() restores the default.

js
MindtrainingPlatform.updateConfig({ ui: { useHostShare: true } })
MindtrainingPlatform.updateConfig({ ui: { useHostShare: false } })

Client integration documentation maintained in-repo.