Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSoC] Quick navigation UI #396

Merged
merged 72 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f810a32
feat - Initial commit with quick navigation algorithm
sofiaromorales Jun 18, 2022
616a78a
Fuzzy match algorithm made with regex only
sofiaromorales Jun 27, 2022
7140bae
Tests for quick navigation component
sofiaromorales Jun 27, 2022
988ac70
Merge branch 'main' into sr/quick-navigation/algorithm
sofiaromorales Jun 27, 2022
24115c8
feat: Fuzzy search algorithm and basic functionality for Quick naviga…
sofiaromorales Jun 29, 2022
a3c7271
fix: Reversed changes of package-lock.json
sofiaromorales Jun 29, 2022
bf6823a
fix: `inputCoincidencesRegexPattern` now only matches the first appea…
sofiaromorales Jun 30, 2022
2fd6f7b
fix: Remove hard coded items inside flatten Index state + fixed typo
sofiaromorales Jun 30, 2022
1e8f806
Merge branch 'main' into sr/quick-navigation/algorithm
sofiaromorales Jun 30, 2022
6d545cd
Merge branch 'main' into sr/quick-navigation/algorithm
sofiaromorales Jun 30, 2022
4e6b434
Merge branch 'sr/quick-navigation/algorithm' of https://github.com/so…
sofiaromorales Jun 30, 2022
c2d8214
fix: Fuzzy match highlighting
sofiaromorales Jul 4, 2022
a3170fe
feat: Quick navigation UI
sofiaromorales Jul 18, 2022
86b4715
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Jul 18, 2022
0ab2e19
feat: Quick navigation unit tests
sofiaromorales Jul 25, 2022
45aa06a
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Jul 25, 2022
73fdb01
fix: Code cleanup
sofiaromorales Jul 28, 2022
a18c5fe
fix: cleanup
sofiaromorales Jul 28, 2022
b977af9
fix: tests updated
sofiaromorales Jul 28, 2022
83c9145
feat: AX keyboard nav improvements
sofiaromorales Aug 7, 2022
bfc319f
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Aug 7, 2022
34e2bd4
fix: Code cleanup
sofiaromorales Aug 8, 2022
aaa7e4f
fix: Requested changes
sofiaromorales Aug 16, 2022
293c3a9
fix: Performance improvements
sofiaromorales Aug 18, 2022
10df1bc
refactor: Code cleanup and changes from pitch feedback
sofiaromorales Aug 19, 2022
155ef51
feat: New component to open Quick Navigation modal
sofiaromorales Aug 22, 2022
eb48410
fix: Reused `FilterInput` for modal input
sofiaromorales Aug 24, 2022
5c4e4d0
fix: Unused code cleanup
sofiaromorales Aug 24, 2022
f39c127
fix: Code cleanup and bug fixing
sofiaromorales Aug 25, 2022
01b17dc
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Aug 25, 2022
67a88ea
refactor: `symbolTreeNavigator` adopted by `NavigatorCard`
sofiaromorales Aug 26, 2022
f265fd5
fix: Moved QN open button to the end of `DocumentationNav`
sofiaromorales Aug 29, 2022
63fe401
WIP
sofiaromorales Aug 29, 2022
9a7d380
feat: Open Q.N button converted to magnifier icon
sofiaromorales Aug 30, 2022
54a559e
refactor: Pr requested changes and AX fixes
sofiaromorales Aug 31, 2022
bedd4e0
refactor: `NavigatorDataProvider` as prov. for QN
sofiaromorales Sep 2, 2022
9aabea4
fix: X icon AX circle centered + 🔎 blue on input
sofiaromorales Sep 2, 2022
98a6436
fix: Tests updated
sofiaromorales Sep 2, 2022
5092a0b
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Sep 2, 2022
62db4a6
fix: Code cleanup
sofiaromorales Sep 5, 2022
25e08fe
fix: New logic added to drop misused id `MatchId`
sofiaromorales Sep 5, 2022
3aaf55f
refactor: Added `GenericModal directly in `QuickNavigationModal`
sofiaromorales Sep 6, 2022
0e1f5cf
refactor: `SymbolTreeNavigator` converted to utils
sofiaromorales Sep 9, 2022
4bd2fd1
fix: Code quality improvements
sofiaromorales Sep 9, 2022
f905ee9
refactor: Single `NavigatorDataProvider` for `DocumentationTopic`
sofiaromorales Sep 14, 2022
2e5a920
refactor: new `styleProps` to add custom styling to generic modal
sofiaromorales Sep 14, 2022
19e9fcd
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Sep 14, 2022
28c8ada
Code cleanup + fix when clicking enter with input focused (redirect t…
sofiaromorales Sep 15, 2022
2dfc53e
fix: `ClearRoundIcon` path centered
sofiaromorales Sep 15, 2022
19f9232
fix: Removed `eslint disable line` and added proper const assignment
sofiaromorales Sep 20, 2022
3814053
fix: Focus style for the FilterInput in the QuickNavigation now match…
sofiaromorales Sep 20, 2022
32b8042
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Sep 20, 2022
ee23f49
fix: Added `width` prop back into `Generic Modal`
sofiaromorales Sep 21, 2022
dccfec7
fix: Consistent spacing between icons on `FilterInput`
sofiaromorales Sep 26, 2022
85e21bd
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Sep 26, 2022
ed6b412
fix: quick navigation container border radius restored
sofiaromorales Sep 27, 2022
12ac89c
fix: Set correct license header
sofiaromorales Sep 27, 2022
4038fea
refactor: `NavigatorDataProvider` is rendered conditionally depending…
sofiaromorales Sep 29, 2022
c17ff68
refactor: Moved methods related to the navigator index data provider …
sofiaromorales Sep 29, 2022
6c037be
fix: Consistent margins on `FilterInput` and resize of clear icon
sofiaromorales Sep 29, 2022
26171b6
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Sep 29, 2022
e37e2f4
fix failing test
sofiaromorales Sep 29, 2022
b09c7b3
fix: Tests updated and obsolete snapshots removed
sofiaromorales Oct 4, 2022
0b98f4c
refactor: Code quality improvements and test cleanup
sofiaromorales Oct 4, 2022
2fa4743
refactor: Styling for modal applied using /deep/ selector
sofiaromorales Oct 5, 2022
c83834b
refactor: Merged similar util files + code cleanup
sofiaromorales Oct 5, 2022
4126b21
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Oct 20, 2022
39f81c6
refactor: Added `processedUserInput` computed property to transform u…
sofiaromorales Oct 27, 2022
e39a36f
fix: Minor UI fixes, code cleanup, and file renaming
sofiaromorales Oct 27, 2022
76dfe47
fix: Prevent content shifting when the scrollbar is visible
sofiaromorales Oct 27, 2022
b0646d5
Merge branch 'main' into sr/quick-navigation/ui
sofiaromorales Oct 27, 2022
6cc23bd
Merge branch 'main' into sr/quick-navigation/ui
marinaaisa Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/components/Filter/FilterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:aria-labelledby="searchAriaLabelledBy"
:class="{ 'focus': showSuggestedTags }"
@blur.capture="handleBlur"
@focus.capture="showSuggestedTags = true"
@focus.capture="handleFocus"
>
<div :class="['filter__wrapper', { 'filter__wrapper--reversed': positionReversed }]">
<div class="filter__top-wrapper">
Expand Down Expand Up @@ -76,7 +76,7 @@
@keydown.left="leftKeyInputHandler"
@keydown.right="rightKeyInputHandler"
@keydown.delete="deleteHandler"
@keydown.meta.a.prevent="selectInputAndTags"
@keydown.meta.a.prevent.stop="selectInputAndTags"
sofiaromorales marked this conversation as resolved.
Show resolved Hide resolved
@keydown.ctrl.a.prevent="selectInputAndTags"
@keydown.exact="inputKeydownHandler"
@keydown.enter.exact="enterHandler"
Expand All @@ -93,6 +93,7 @@
aria-label="Reset Filter"
class="filter__delete-button"
@click="resetFilters(true)"
@keydown.enter.exact.stop="resetFilters(true)"
dobromir-hristov marked this conversation as resolved.
Show resolved Hide resolved
@mousedown.prevent
>
<ClearRoundedIcon />
Expand Down Expand Up @@ -194,6 +195,10 @@ export default {
type: Boolean,
default: false,
},
focusInputWhenEmpty: {
type: Boolean,
default: false,
},
clearFilterOnTagSelect: {
type: Boolean,
default: true,
Expand Down Expand Up @@ -395,12 +400,15 @@ export default {
this.$emit('focus-prev');
}
},
handleFocus() {
this.showSuggestedTags = true;
},
},
created() {
if (
this.focusInputWhenCreated
&& document.activeElement !== this.$refs.input
&& this.inputIsNotEmpty
sofiaromorales marked this conversation as resolved.
Show resolved Hide resolved
&& (this.inputIsNotEmpty || this.focusInputWhenEmpty)
) {
this.focusInput();
}
Expand Down Expand Up @@ -437,9 +445,9 @@ $input-height: rem(28px);

&__filter-button {
position: relative;
margin-left: rem(10px);
z-index: 1;
cursor: text;
margin-left: rem(10px);
margin-right: rem(3px);

@include breakpoint(small) {
Expand Down Expand Up @@ -531,17 +539,19 @@ $input-height: rem(28px);
border-radius: 100%;

.clear-rounded-icon {
height: $icon-size-default;
width: $icon-size-default;
height: rem(14px);
width: rem(14px);
fill: var(--input-text);
display: block;
padding: rem(5px);
}
}

&__delete-button-wrapper {
display: flex;
align-items: center;
padding: 0 10px;
padding-right: rem(10px);
padding-left: rem(3px);
border-top-right-radius: $small-border-radius;
border-bottom-right-radius: $small-border-radius;
}
Expand Down
17 changes: 16 additions & 1 deletion src/components/GenericModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
:style="modalColors"
>
<div class="backdrop" @click="onClickOutside" />
<div class="container" ref="container" :style="{ width }">
<div
class="container"
ref="container"
:style="modalStyle"
>
<button
v-if="showClose"
class="close"
Expand Down Expand Up @@ -87,6 +91,10 @@ export default {
type: Boolean,
default: true,
},
styleProps: {
sofiaromorales marked this conversation as resolved.
Show resolved Hide resolved
type: Object,
default: null,
},
},
data() {
return {
Expand All @@ -107,6 +115,12 @@ export default {
'--background': this.codeBackgroundColorOverride,
};
},
modalStyle({ styleProps, width }) {
return ({
width,
...styleProps,
});
},
themeClass({ theme, prefersDarkStyle, isThemeDynamic }) {
let dynamicThemeClasses = {};
// if we use the `dynamic` theme, use the OS darkmode preference.
Expand Down Expand Up @@ -223,6 +237,7 @@ export default {
this.selectContent();
}
if (key !== 'Escape') return;
event.preventDefault();
dobromir-hristov marked this conversation as resolved.
Show resolved Hide resolved
this.closeModal();
},
/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icons/ClearRoundedIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
themeId="clear-rounded"
>
<title>Clear</title>
<path d="M9.864,3.5l.636.636L7.632,7l2.862,2.861-.636.636L7,7.639,4.142,10.494l-.636-.636L6.36,7,3.5,4.142l.636-.636L7,6.367Z" fill-rule="evenodd"/>
<path d="M14.55,0l1.45,1.45-6.56,6.55,6.54,6.54-1.45,1.45-6.53-6.53L1.47,15.99,.01,14.53l6.52-6.53L0,1.47,1.45,.02l6.55,6.54L14.55,0Z" fill-rule="evenodd"/>
</SVGIcon>
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/components/Icons/MagnifierIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import SVGIcon from 'docc-render/components/SVGIcon.vue';

export default {
name: 'MafnifierIcon',
name: 'MagnifierIcon',
components: { SVGIcon },
};
</script>
104 changes: 4 additions & 100 deletions src/components/Navigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
:render-filter-on-top="renderFilterOnTop"
:api-changes="apiChanges"
:allow-hiding="allowHiding"
:enableQuickNavigation="enableQuickNavigation"
:navigator-references="navigatorReferences"
@close="$emit('close')"
/>
Expand All @@ -42,13 +41,11 @@
</template>

<script>
import QuickNavigationStore from 'docc-render/stores/QuickNavigationStore';
import NavigatorCard from 'theme/components/Navigator/NavigatorCard.vue';
import SpinnerIcon from 'theme/components/Icons/SpinnerIcon.vue';
import NavigatorCardInner from 'docc-render/components/Navigator/NavigatorCardInner.vue';
import { INDEX_ROOT_KEY } from 'docc-render/constants/sidebar';
import { TopicTypes } from 'docc-render/constants/TopicTypes';
import { getSetting } from 'docc-render/utils/theme-settings';

/**
* @typedef NavigatorFlatItem
Expand Down Expand Up @@ -82,10 +79,13 @@ export default {
data() {
return {
INDEX_ROOT_KEY,
store: QuickNavigationStore,
};
},
props: {
flatChildren: {
type: Array,
required: true,
},
parentTopicIdentifiers: {
type: Array,
required: true,
Expand Down Expand Up @@ -127,9 +127,6 @@ export default {
default: true,
},
},
provide() {
return { store: this.store };
},
computed: {
// gets the paths for each parent in the breadcrumbs
parentTopicReferences({ references, parentTopicIdentifiers }) {
Expand All @@ -155,104 +152,11 @@ export default {
}
return parentTopicReferences.slice(itemsToSlice).map(r => r.url).concat(path);
},
enableQuickNavigation: () => (
getSetting(['features', 'docs', 'quickNavigation', 'enable'], false)
),
/**
* Recomputes the list of flat children.
* @return NavigatorFlatItem[]
*/
flatChildren: ({
enableQuickNavigation, flattenNestedData, technology = {}, store,
}) => {
const flatIndex = flattenNestedData(technology.children || [], null, 0, technology.beta);
if (enableQuickNavigation) {
store.setFlattenIndex(flatIndex);
}
return flatIndex;
},
/**
* The root item is always a module
*/
type: () => TopicTypes.module,
},
methods: {
/**
* Generates a unique hash, from a string, generating a signed number.
* @returns Number
*/
hashCode(str) {
return str.split('').reduce((prevHash, currVal) => (
// eslint-disable-next-line no-bitwise
(((prevHash << 5) - prevHash) + currVal.charCodeAt(0)) | 0
), 0);
},
/**
* @param {{path: string, type: string, title: string, children?: [] }[]} childrenNodes
* @param {NavigatorFlatItem | null} parent
* @param {Number} depth
* @param {Boolean} parentBetaStatus
* @return {NavigatorFlatItem[]}
*/
flattenNestedData(childrenNodes, parent = null, depth = 0, parentBetaStatus = false) {
let items = [];
const len = childrenNodes.length;
let index;
// reference to the last label node
let groupMarkerNode = null;
for (index = 0; index < len; index += 1) {
// get the children
const { children, ...node } = childrenNodes[index];
// generate the extra properties
const { uid: parentUID = INDEX_ROOT_KEY } = parent || {};
// generate a uid to track by
node.uid = this.hashCode(`${parentUID}+${node.path}_${depth}_${index}`);
// store the parent uid
node.parent = parentUID;
// store the current groupMarker reference
if (node.type === TopicTypes.groupMarker) {
node.deprecatedChildrenCount = 0;
groupMarkerNode = node;
} else if (groupMarkerNode) {
// push the current node to the group marker before it
groupMarkerNode.childUIDs.push(node.uid);
// store the groupMarker UID for each item
node.groupMarkerUID = groupMarkerNode.uid;
if (node.deprecated) {
// count deprecated children, so we can hide the entire group when filtering
groupMarkerNode.deprecatedChildrenCount += 1;
}
}
// store which item it is
node.index = index;
// store how many siblings it has
node.siblingsCount = len;
// store the depth
node.depth = depth;
// store child UIDs
node.childUIDs = [];
// if the parent is not the root, push to its childUIDs the current node uid
if (parent) {
// push child to parent
parent.childUIDs.push(node.uid);
}
// if the parent or the entire technology are marked as `Beta`,
// child elements do not get marked as `Beta`.
if (node.beta && parentBetaStatus) {
node.beta = false;
}

items.push(node);
if (children) {
// return the children to the parent
items = items.concat(this.flattenNestedData(
children, node, depth + 1, parentBetaStatus || node.beta,
));
}
}
return items;
},
},
};
</script>

Expand Down
Loading