Skip to content

Commit

Permalink
feat: adds navigation settings (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrk authored May 26, 2021
1 parent 870b0bd commit b4c1261
Show file tree
Hide file tree
Showing 5 changed files with 773 additions and 14 deletions.
36 changes: 36 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,40 @@ export const defaultState: ConfigState = {
components: [],
},
},
navigation: {
title: {
route: "/",
iconFallbackName: "circle",
},
admin: {
tabs: [],
events: {
afterLogin: "",
},
},
organizationOwner: {
tabs: [],
events: {
afterLogin: "",
},
},
developer: {
tabs: [],
events: {
afterLogin: "",
},
},
baseUser: {
tabs: [],
events: {
afterLogin: "",
},
},
anonymous: {
tabs: [],
events: {
afterLogin: "",
},
},
},
};
67 changes: 67 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,52 @@ export interface Owner {
supportUrl: string,
}

export interface TabConfig {
/** if parent will not drop one level when navigation is expanded */
fixed: boolean,
label: {
/** use iconName if `icon`. Key and fallback if `text` */
type: "text" | "icon" | "avatar",
fallback?: string,
key?: string,
iconName?: string,
},
/**
* start with `/` or `http` for route and `$` for action
* @example "https://apisuite.io"
* @example "/profile"
* @example "$logout"
*/
action: string,
backAction?: {
/**
* where to go
* @example "/profile"
*/
route: string,
/**
* Default text in case of missing i18n key
* @example "Back to Profile"
*/
fallback: string,
/**
* i18n key
* @example "profile.back"
*/
key?: string,
iconName?: string,
},
subTabs?: TabConfig[],
}

export interface NavigationRole {
tabs: TabConfig[],
events: {
/** `/` prefixed for routing - "/dashboard". Leave empty otherwise */
afterLogin: string,
},
}

export interface DefaultConfig {
portalName: string,
clientName: string,
Expand All @@ -79,6 +125,17 @@ export interface DefaultConfig {
components: [],
},
},
navigation: {
title: {
route: string,
iconFallbackName: string,
},
admin: NavigationRole,
organizationOwner: NavigationRole,
developer: NavigationRole,
baseUser: NavigationRole,
anonymous: NavigationRole,
},
}

export type i18nTranslationOptions = {
Expand All @@ -98,3 +155,13 @@ declare module "@material-ui/core/styles/createPalette" {
gradient: PaletteColor,
}
}

declare module "@material-ui/core/styles/createTypography" {
interface FontStyle {
url: string;
}

interface FontStyleOptions {
url: string;
}
}
1 change: 1 addition & 0 deletions lib/util/safeMergeDeep.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isObject } from "./isObject";

/** **WARNING**: this skips arrays */
export function safeMergeDeep<T extends Record<never, never>>(target: T, source: Partial<T>) {
const copy: T = { ...target };

Expand Down
Loading

0 comments on commit b4c1261

Please sign in to comment.