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.
/src/
presentation/
: Contains all presentation related code including Vue and Electron configurationsbootstrapping/
: 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 fontsstyles/
: 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
.
Add visual clues for clickable items. It should be as clear as possible that they're interactable at first look without hovering. They should also have different visual state when hovering/touching on them that indicates that they are being clicked, which helps with accessibility.
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:
- available scripts, collections as defined in collection files,
- package information as defined in
package.json
.
You can read more about how application layer provides application data to he presentation in application.md | Application data.
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- the component is no longer used (destroyed),
- an if ApplicationContext changes the active collection to a different one.
📖 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.
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>
- Use lowercase for variables/functions/mixins, e.g.:
- Variable:
$variable: value;
- Function:
@function function() {}
- Mixin:
@mixin mixin() {}
- Variable:
- Use - for a phrase/compound word, e.g.:
- Variable:
$some-variable: value;
- Function:
@function some-function() {}
- Mixin:
@mixin some-mixin() {}
- Variable:
- 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
- ✅