From 36ff649bb589dc39becdae2b4e588175265c70dc Mon Sep 17 00:00:00 2001
From: Stefan Kofler <4400664+stkofler@users.noreply.github.com>
Date: Fri, 7 May 2021 10:22:54 +0100
Subject: [PATCH] feat(search): add search bar #547
---
e2e/src/daily-summary.e2e.ts | 2 +-
e2e/src/project-bookmark.e2e.ts | 2 +-
e2e/src/work-view.e2e.ts | 2 +-
src/_variables.scss | 16 +-
src/app/app.component.html | 8 +-
src/app/app.component.scss | 11 +-
src/app/app.component.ts | 3 +-
src/app/app.module.ts | 2 +
src/app/core-ui/layout/layout.service.ts | 19 ++
.../core-ui/layout/store/layout.actions.ts | 6 +
.../core-ui/layout/store/layout.reducer.ts | 19 ++
.../main-header/main-header.component.html | 9 +
src/app/core-ui/shortcut/shortcut.service.ts | 3 +
.../config/default-global-config.const.ts | 1 +
.../config/form-cfgs/keyboard-form.const.ts | 7 +
.../features/config/keyboard-config.model.ts | 1 +
.../search-bar/search-bar.component.html | 55 +++++
.../search-bar/search-bar.component.scss | 191 +++++++++++++++++
.../search-bar/search-bar.component.ts | 192 ++++++++++++++++++
.../features/search-bar/search-bar.model.ts | 19 ++
.../features/search-bar/search-bar.module.ts | 13 ++
.../add-task-bar/add-task-bar.component.html | 1 +
.../add-task-bar/add-task-bar.component.ts | 3 +-
src/app/features/tasks/task/task.component.ts | 10 +
.../work-view/split/split.component.ts | 15 +-
src/app/t.const.ts | 5 +
src/app/ui/animations/blend-in-out.ani.ts | 8 +-
src/assets/i18n/en.json | 7 +-
28 files changed, 602 insertions(+), 28 deletions(-)
create mode 100644 src/app/features/search-bar/search-bar.component.html
create mode 100644 src/app/features/search-bar/search-bar.component.scss
create mode 100644 src/app/features/search-bar/search-bar.component.ts
create mode 100644 src/app/features/search-bar/search-bar.model.ts
create mode 100644 src/app/features/search-bar/search-bar.module.ts
diff --git a/e2e/src/daily-summary.e2e.ts b/e2e/src/daily-summary.e2e.ts
index b5a12957ec..265910222d 100644
--- a/e2e/src/daily-summary.e2e.ts
+++ b/e2e/src/daily-summary.e2e.ts
@@ -2,7 +2,7 @@ import { BASE } from '../e2e.const';
import { NBrowser } from '../n-browser-interface';
const URL = `${BASE}/#/tag/TODAY/daily-summary`;
-const ADD_TASK_BTN_SEL = '.action-nav > button:first-child';
+const ADD_TASK_BTN_SEL = '.action-nav > button:nth-child(2)';
const ADD_TASK_GLOBAL_SEL = 'add-task-bar.global input';
module.exports = {
diff --git a/e2e/src/project-bookmark.e2e.ts b/e2e/src/project-bookmark.e2e.ts
index 052f97067c..d253c79e9f 100644
--- a/e2e/src/project-bookmark.e2e.ts
+++ b/e2e/src/project-bookmark.e2e.ts
@@ -1,6 +1,6 @@
import { NBrowser } from '../n-browser-interface';
-const TOGGLE_BOOKMARK_BAR_BTN = '.action-nav button:nth-child(2)';
+const TOGGLE_BOOKMARK_BAR_BTN = '.action-nav button:nth-child(3)';
const BOOKMARK_BAR_OPTS_BTN = 'bookmark-bar .list-controls button:first-of-type';
const ADD_BOOKMARK_BTN = '.mat-menu-panel .mat-menu-item:first-of-type';
diff --git a/e2e/src/work-view.e2e.ts b/e2e/src/work-view.e2e.ts
index cdf1eb5868..00f7fb47ee 100644
--- a/e2e/src/work-view.e2e.ts
+++ b/e2e/src/work-view.e2e.ts
@@ -4,7 +4,7 @@ import { NBrowser } from '../n-browser-interface';
const ADD_TASK_INITIAL = 'add-task-bar:not(.global) input';
const ADD_TASK_GLOBAL = 'add-task-bar.global input';
const TASK = 'task';
-const ADD_TASK_BTN = '.action-nav > button:first-child';
+const ADD_TASK_BTN = '.action-nav > button:nth-child(2)';
const WORK_VIEW_URL = `${BASE}/`;
const READY_TO_WORK_BTN = '.ready-to-work-btn';
diff --git a/src/_variables.scss b/src/_variables.scss
index 1fdf63f721..40764112ab 100644
--- a/src/_variables.scss
+++ b/src/_variables.scss
@@ -40,7 +40,6 @@ $dark12: rgb(51, 51, 51);
$dark16: rgb(52, 52, 52);
$dark24: rgb(56, 56, 56);
-
$dark-theme-bg: $dark0;
$dark-theme-bg-darker: $dark0;
$dark-theme-bg-slightly-lighter: $dark4;
@@ -73,7 +72,6 @@ $dark-theme-extra-border-color: rgba(255, 255, 255, 0.12);
$light-theme-separator-color: rgba(18, 18, 18, 0.3);
$dark-theme-separator-color: rgba(255, 255, 255, 0.3);
-
$c-accent: mat-css-color-accent();
$c-warn: mat-css-color-warn();
@@ -112,7 +110,6 @@ $component-max-width: 800px;
$side-nav-width: 200px;
//$main-header-height: $s*7;
-
$bar-height-large: 56px;
$bar-height: 48px;
$bar-height-small: 40px;
@@ -129,7 +126,7 @@ $z-main-header: 10;
$z-bookmarks: 9;
$z-backdrop: 222;
$z-add-task-bar: 10000;
-
+$z-search-bar: 10000;
// COMPONENTS
// ----------
@@ -138,16 +135,15 @@ $standard-note-fg-light: $light-theme-text-color;
$standard-note-bg-dark: $dark-theme-bg-lightest;
$standard-note-fg-dark: #eeeeee;
-
// ANIMATIONS
// ----------
// https://github.com/material-components/material-components-web/blob/master/packages/mdc-animation/_variables.scss
-$ani-standard-timing: cubic-bezier(.4, 0, .2, 1) !default;
-$ani-enter-timing: cubic-bezier(0, 0, .2, 1) !default;
-$ani-leave-timing: cubic-bezier(.4, 0, 1, 1) !default;
-$ani-sharp-timing: cubic-bezier(.4, 0, .6, 1) !default;
+$ani-standard-timing: cubic-bezier(0.4, 0, 0.2, 1) !default;
+$ani-enter-timing: cubic-bezier(0, 0, 0.2, 1) !default;
+$ani-leave-timing: cubic-bezier(0.4, 0, 1, 1) !default;
+$ani-sharp-timing: cubic-bezier(0.4, 0, 0.6, 1) !default;
-$ease-in-out-quint: cubic-bezier(.38, .04, .35, .96);
+$ease-in-out-quint: cubic-bezier(0.38, 0.04, 0.35, 0.96);
$transition-duration-xs: 90ms;
$transition-duration-s: 150ms;
$transition-duration-m: 225ms;
diff --git a/src/app/app.component.html b/src/app/app.component.html
index 26f34a2ad4..a598e64079 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -11,11 +11,17 @@
+
+
@@ -74,6 +75,7 @@ export const createTranslateLoader = (http: HttpClient) =>
SyncModule,
InitialDialogModule,
MaterialCssVarsModule.forRoot(),
+ SearchBarModule,
// External
BrowserModule,
diff --git a/src/app/core-ui/layout/layout.service.ts b/src/app/core-ui/layout/layout.service.ts
index 34b63203ec..fd29ed29c7 100644
--- a/src/app/core-ui/layout/layout.service.ts
+++ b/src/app/core-ui/layout/layout.service.ts
@@ -2,9 +2,12 @@ import { Injectable } from '@angular/core';
import {
hideAddTaskBar,
hideNotes,
+ hideSearchBar,
hideSideNav,
showAddTaskBar,
+ showSearchBar,
toggleAddTaskBar,
+ toggleSearchBar,
toggleShowNotes,
toggleSideNav,
} from './store/layout.actions';
@@ -13,6 +16,7 @@ import { select, Store } from '@ngrx/store';
import {
LayoutState,
selectIsShowAddTaskBar,
+ selectIsShowSearchBar,
selectIsShowSideNav,
} from './store/layout.reducer';
import { filter, map, switchMap, withLatestFrom } from 'rxjs/operators';
@@ -36,6 +40,9 @@ export class LayoutService {
isShowAddTaskBar$: Observable = this._store$.pipe(
select(selectIsShowAddTaskBar),
);
+ isShowSearchBar$: Observable = this._store$.pipe(
+ select(selectIsShowSearchBar),
+ );
isNavAlwaysVisible$: Observable = this._breakPointObserver
.observe([`(min-width: ${NAV_ALWAYS_VISIBLE}px)`])
.pipe(map((result) => result.matches));
@@ -102,6 +109,18 @@ export class LayoutService {
this._store$.dispatch(toggleAddTaskBar());
}
+ showSearchBar() {
+ this._store$.dispatch(showSearchBar());
+ }
+
+ hideSearchBar() {
+ this._store$.dispatch(hideSearchBar());
+ }
+
+ toggleSearchBar() {
+ this._store$.dispatch(toggleSearchBar());
+ }
+
toggleSideNav() {
this._store$.dispatch(toggleSideNav());
}
diff --git a/src/app/core-ui/layout/store/layout.actions.ts b/src/app/core-ui/layout/store/layout.actions.ts
index 35edaeecdb..70459f2796 100644
--- a/src/app/core-ui/layout/store/layout.actions.ts
+++ b/src/app/core-ui/layout/store/layout.actions.ts
@@ -6,6 +6,12 @@ export const hideAddTaskBar = createAction('[Layout] Hide AddTaskBar');
export const toggleAddTaskBar = createAction('[Layout] Toggle AddTaskBar');
+export const showSearchBar = createAction('[Layout] Show SearchBar');
+
+export const hideSearchBar = createAction('[Layout] Hide SearchBar');
+
+export const toggleSearchBar = createAction('[Layout] Toggle SearchBar');
+
export const hideSideNav = createAction('[Layout] Hide SideBar');
export const toggleSideNav = createAction('[Layout] Toggle SideBar');
diff --git a/src/app/core-ui/layout/store/layout.reducer.ts b/src/app/core-ui/layout/store/layout.reducer.ts
index 7f521c86f3..970dd66233 100644
--- a/src/app/core-ui/layout/store/layout.reducer.ts
+++ b/src/app/core-ui/layout/store/layout.reducer.ts
@@ -1,9 +1,12 @@
import {
hideAddTaskBar,
hideNotes,
+ hideSearchBar,
hideSideNav,
showAddTaskBar,
+ showSearchBar,
toggleAddTaskBar,
+ toggleSearchBar,
toggleShowNotes,
toggleSideNav,
} from './layout.actions';
@@ -21,6 +24,7 @@ export interface LayoutState {
isShowAddTaskBar: boolean;
isShowBookmarkBar: boolean;
isShowNotes: boolean;
+ isShowSearchBar: boolean;
isShowSideNav: boolean;
}
@@ -28,6 +32,7 @@ const _initialLayoutState: LayoutState = {
isShowAddTaskBar: false,
isShowBookmarkBar: false,
isShowSideNav: false,
+ isShowSearchBar: false,
isShowNotes: false,
};
@@ -50,6 +55,11 @@ export const selectIsShowNotes = createSelector(
(state) => state.isShowNotes,
);
+export const selectIsShowSearchBar = createSelector(
+ selectLayoutFeatureState,
+ (state) => state.isShowSearchBar,
+);
+
const _reducer = createReducer(
_initialLayoutState,
@@ -62,6 +72,15 @@ const _reducer = createReducer(
isShowAddTaskBar: !state.isShowAddTaskBar,
})),
+ on(showSearchBar, (state) => ({ ...state, isShowSearchBar: true })),
+
+ on(hideSearchBar, (state) => ({ ...state, isShowSearchBar: false })),
+
+ on(toggleSearchBar, (state) => ({
+ ...state,
+ isShowSearchBar: !state.isShowSearchBar,
+ })),
+
on(hideSideNav, (state) => ({ ...state, isShowSideNav: false })),
on(toggleSideNav, (state) => ({ ...state, isShowSideNav: !state.isShowSideNav })),
diff --git a/src/app/core-ui/main-header/main-header.component.html b/src/app/core-ui/main-header/main-header.component.html
index e178341062..a24054b906 100644
--- a/src/app/core-ui/main-header/main-header.component.html
+++ b/src/app/core-ui/main-header/main-header.component.html
@@ -40,6 +40,15 @@