Skip to content

Latest commit

 

History

History
82 lines (60 loc) · 5.64 KB

presentation.md

File metadata and controls

82 lines (60 loc) · 5.64 KB

Presentation layer

Presentation layer consists of UI-related code. It uses Vue.js as JavaScript framework and includes Vue.js components. It also includes Electron to provide functionality to desktop application.

It's designed event-driven from bottom to top. It listens user events (from top) and state events (from bottom) to update state or the GUI.

📖 Refer to architecture.md (Layered Application) to read more about the layered architecture.

Structure

  • /src/ presentation/: Contains all presentation related code including Vue and Electron configurations
    • bootstrapping/: Registers Vue global objects including components and plugins.
    • components/: Contains all Vue components and their helper classes.
      • Shared/: Contains Vue components and component helpers that other components share.
    • assets/: Contains assets that webpack will process.
      • fonts/: Contains fonts
      • styles/: Contains shared styles used throughout different components.
        • components/: Contains reusable styles coupled to a Vue/HTML component.
        • vendors-extensions/: Contains styles that override third-party components used.
        • main.scss: Primary Sass file, passes along all other styles, should be the single file used from other components.
    • main.ts: Application entry point that mounts and starts Vue application.
    • electron/: Electron configuration for the desktop application.
      • main.ts: Main process of Electron, started as first thing when app starts.
  • /public/: Contains static assets that are directly copied and do not go through webpack.
  • /vue.config.js: Global Vue CLI configurations loaded by @vue/cli-service.
  • /postcss.config.js: PostCSS configurations used by Vue CLI internally.
  • /babel.config.js: Babel configurations for polyfills used by @vue/cli-plugin-babel.

Application data

Components (should) use ApplicationFactory singleton to reach the application domain to avoid parsing and compiling the application again.

Application.ts is an immutable domain model that represents application state. It includes:

You can read more about how application layer provides application data to he presentation in application.md | Application data.

Application state

Inheritance of a Vue components marks whether it uses application state . Components that does not handle application state extends Vue. Stateful components mutate or/and react to state changes (such as user selection or search queries) in ApplicationContext extend StatefulVue class to access the context / state.

StatefulVue functions include:

  • Creating a singleton of the state and makes it available to presentation layer as single source of truth.
  • Providing virtual abstract handleCollectionState callback that it calls when
    • the Vue loads the component,
    • and also every time when state changes.
  • Providing events member to make lifecycling of state subscriptions events easier because it ensures that components unsubscribe from listening to state events when

📖 Refer to architecture.md | Application State to get an overview of event handling and application.md | Application State for deeper look into how the application layer manages state.

Modals

Dialog.vue is a shared component that other components used to show modal windows.

You can use it by wrapping the content inside of its slot and call .show() function on its reference. For example:

  <Dialog ref="testDialog">
    <div>Hello world</div>
  </Dialog>
  <div @click="$refs.testDialog.show()">Show dialog</div>

Sass naming convention

  • Use lowercase for variables/functions/mixins, e.g.:
    • Variable: $variable: value;
    • Function: @function function() {}
    • Mixin: @mixin mixin() {}
  • Use - for a phrase/compound word, e.g.:
    • Variable: $some-variable: value;
    • Function: @function some-function() {}
    • Mixin: @mixin some-mixin() {}
  • Grouping and name variables from generic to specific, e.g.:
    • $border-blue, $border-blue-light, $border-blue-lightest, $border-red
    • $blue-border, $light-blue-border, $lightest-blue-border, $red-border