diff --git a/client/web/compose/src/assets/PageBlocks/Navigation.png b/client/web/compose/src/assets/PageBlocks/Navigation.png new file mode 100644 index 000000000..57ec0c240 Binary files /dev/null and b/client/web/compose/src/assets/PageBlocks/Navigation.png differ diff --git a/client/web/compose/src/assets/PageBlocks/index.js b/client/web/compose/src/assets/PageBlocks/index.js index 25e00db23..5cbb221c9 100644 --- a/client/web/compose/src/assets/PageBlocks/index.js +++ b/client/web/compose/src/assets/PageBlocks/index.js @@ -15,3 +15,4 @@ export const Report = require('./Report.png') export const Progress = require('./Progress.png') export const Nylas = require('./Nylas.jpg') export const Geometry = require('./Geometry.png') +export const Navigation = require('./Navigation.png') diff --git a/client/web/compose/src/components/Admin/Page/Builder/Selector.vue b/client/web/compose/src/components/Admin/Page/Builder/Selector.vue index 6638dd148..ca4a8aaff 100644 --- a/client/web/compose/src/components/Admin/Page/Builder/Selector.vue +++ b/client/web/compose/src/components/Admin/Page/Builder/Selector.vue @@ -149,6 +149,11 @@ export default { block: new compose.PageBlockGeometry(), image: images.Geometry, }, + { + label: this.$t('navigation.label'), + block: new compose.PageBlockNavigation(), + image: images.Navigation, + }, ], } }, diff --git a/client/web/compose/src/components/PageBlocks/Navigation/Base.vue b/client/web/compose/src/components/PageBlocks/Navigation/Base.vue new file mode 100644 index 000000000..d4941f45c --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/Base.vue @@ -0,0 +1,158 @@ + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/Configurator.vue b/client/web/compose/src/components/PageBlocks/Navigation/Configurator.vue new file mode 100644 index 000000000..f12c9e902 --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/Configurator.vue @@ -0,0 +1,274 @@ + + + + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/ComposePage.vue b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/ComposePage.vue new file mode 100644 index 000000000..10d3a2fc7 --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/ComposePage.vue @@ -0,0 +1,115 @@ + + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Dropdown.vue b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Dropdown.vue new file mode 100644 index 000000000..a6f7fc1de --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Dropdown.vue @@ -0,0 +1,148 @@ + + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Text.vue b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Text.vue new file mode 100644 index 000000000..4d890acf5 --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Text.vue @@ -0,0 +1,21 @@ + + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Url.vue b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Url.vue new file mode 100644 index 000000000..0328bbed5 --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/Url.vue @@ -0,0 +1,47 @@ + + + diff --git a/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/base.vue b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/base.vue new file mode 100644 index 000000000..5ba7783cf --- /dev/null +++ b/client/web/compose/src/components/PageBlocks/Navigation/NavTypes/base.vue @@ -0,0 +1,25 @@ + diff --git a/client/web/compose/src/components/PageBlocks/base.vue b/client/web/compose/src/components/PageBlocks/base.vue index e1aedd1c2..7b0140421 100644 --- a/client/web/compose/src/components/PageBlocks/base.vue +++ b/client/web/compose/src/components/PageBlocks/base.vue @@ -75,7 +75,6 @@ export default { get () { return this.block.options }, - set (options) { this.block.options = options }, diff --git a/client/web/compose/src/components/PageBlocks/index.js b/client/web/compose/src/components/PageBlocks/index.js index d71bb41d3..e4082b1d0 100644 --- a/client/web/compose/src/components/PageBlocks/index.js +++ b/client/web/compose/src/components/PageBlocks/index.js @@ -36,6 +36,8 @@ import NylasBase from './Nylas/NylasBase' import NylasConfigurator from './Nylas/NylasConfigurator' import GeometryBase from './GeometryBase' import GeometryConfigurator from './GeometryConfigurator/index' +import NavigationConfigurator from './Navigation/Configurator' +import NavigationBase from './Navigation/Base' /** * List of all known page block components @@ -77,6 +79,8 @@ const Registry = { NylasConfigurator, GeometryBase, GeometryConfigurator, + NavigationConfigurator, + NavigationBase, } const defaultMode = 'Base' diff --git a/lib/js/src/compose/types/page-block/index.ts b/lib/js/src/compose/types/page-block/index.ts index c982059ea..c99b6789d 100644 --- a/lib/js/src/compose/types/page-block/index.ts +++ b/lib/js/src/compose/types/page-block/index.ts @@ -16,7 +16,7 @@ export { PageBlockReport } from './report' export { PageBlockProgress } from './progress' export { PageBlockNylas } from './nylas' export { PageBlockGeometry } from './geometry' - +export { PageBlockNavigation } from './navigation' export function PageBlockMaker (i: { kind: string }): T { const PageBlockTemp = Registry.get(i.kind) diff --git a/lib/js/src/compose/types/page-block/navigation/index.ts b/lib/js/src/compose/types/page-block/navigation/index.ts new file mode 100644 index 000000000..d68e9e9b2 --- /dev/null +++ b/lib/js/src/compose/types/page-block/navigation/index.ts @@ -0,0 +1,51 @@ +import { PageBlock, PageBlockInput, Registry } from '../base' +import NavigationItem, { NavigationItemInput } from './navigation-item' + +const kind = 'Navigation' + +interface DisplayOptions { + appearance: string; + alignment: string; + fillJustify: string; +} + +interface Options { + display: DisplayOptions; + navigationItems: NavigationItem[]; +} + +const defaults: Readonly = Object.freeze({ + display: { + appearance: 'tabs', + alignment: 'center', + fillJustify: 'justify', + }, + navigationItems: [], +}) + +export class PageBlockNavigation extends PageBlock { + readonly kind = kind; + + options: Options = { ...defaults }; + + constructor (i?: PageBlockInput) { + super(i) + this.applyOptions(i?.options as Partial) + } + + applyOptions (o?: Partial): void { + if (!o) return + + this.options.navigationItems = (o.navigationItems || []).map(f => new NavigationItem(f)) + + if (o.display) { + this.options.display = o.display + } + } + + static makeNavigationItem (item?: NavigationItemInput): NavigationItem { + return new NavigationItem(item) + } +} + +Registry.set(kind, PageBlockNavigation) diff --git a/lib/js/src/compose/types/page-block/navigation/navigation-item.ts b/lib/js/src/compose/types/page-block/navigation/navigation-item.ts new file mode 100644 index 000000000..34ed75b10 --- /dev/null +++ b/lib/js/src/compose/types/page-block/navigation/navigation-item.ts @@ -0,0 +1,72 @@ +import { Apply } from '../../../../cast' + +interface DropdownItem { + label: string; + url: string; + delimiter: boolean; + target: string; +} + +interface Dropdown { + label: string; + items: DropdownItem[] +} + +interface ItemOptions { + label: string; + url: string; + target: string; + delimiter: boolean; + pageID: string; + displaySubPages: boolean; + dropdown: Dropdown; + align: string; +} + +interface NavigationItemOptions { + enabled: boolean; + textColor: string; + backgroundColor: string; + item: ItemOptions; +} + +export type NavigationItemInput = Partial | NavigationItem + +const defOptions = { + enabled: true, + textColor: '#0B344E', + backgroundColor: '', + item: { + label: '', + url: '', + target: '', + delimiter: false, + pageID: '', + displaySubPages: false, + align: 'bottom', + dropdown: { + label: "", + items: [] + }, + }, +} + +export default class NavigationItem { + public type = '' + + public options: NavigationItemOptions = { ...defOptions } + + constructor (i?: NavigationItemInput) { + this.apply(i) + } + + apply (i?: NavigationItemInput): void { + if (!i) return + + Apply(this, i, String, 'type') + + if (i.options) { + this.options = { ...this.options, ...i.options } + } + } +} diff --git a/locale/en/corteza-webapp-compose/block.yaml b/locale/en/corteza-webapp-compose/block.yaml index 4598f6877..ec388deac 100644 --- a/locale/en/corteza-webapp-compose/block.yaml +++ b/locale/en/corteza-webapp-compose/block.yaml @@ -505,6 +505,56 @@ comment: footnote: 'Field value will be used as reference' navigation: chart: Charts + label: Navigation + displayOptions: Display options + appearance: Appearance + alignment: Alignment + fillJustify: Fill and Justify + fieldLabel: Label + enabled: Enabled + openIn: Open in + navigationItems: Navigation items + type: Type + disabled: Disabled + color: Color + background: Background + url: URL + drop: Dropdown position + add: Add + composePage: Compose page + tabs: Tabs + pills: Pills + small: Small + center: Center + left: Left + right: Right + bottom: Bottom + top: Top + fill: Fill + justify: Justify + primary: Primary + secondary: Secondary + success: Success + warning: Warning + danger: Danger + info: Info + text: Text + dropdown: Dropdown + multi: Multiline + sameTab: Same tab + selectOpenInType: Select open in type + newTab: New tab + dropdownItems: Dropdown items + delimiter: Delimiter + none: None + displaySubPages: Display sub-pages + selectBackground: Select background + preview: + preview: Preview + label: Label + home: Home + dropdown: dropdown + about: about report: label: Report scenario: