Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Add searchbar component#30

Merged
yamgent merged 3 commits intoMarkBind:masterfrom
nusjzx:162-search-for-headings
Jun 4, 2018
Merged

Add searchbar component#30
yamgent merged 3 commits intoMarkBind:masterfrom
nusjzx:162-search-for-headings

Conversation

@nusjzx
Copy link

@nusjzx nusjzx commented May 24, 2018

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [] Documentation update
• [ ] Bug fix
• [ ] New feature
• [x] Enhancement to an existing feature
• [ ] Other, please explain:

Related MarkBind/markbind#162, MarkBind/markbind#204

What is the rationale for this request?
highlighting and extracting the search result helps users to identify the results they want easily,
searching for headings and jump to the headings on click helpers users to go to website sections easily.

What changes did you make? (Give an overview)
highlightAndExtract function will extract the matching results then highlight the phrases.
for jumping to a specific heading, we have one entry for each heading(suggested by Prof Damith).
Thus, Instead of processing on a single string that combines title, keywords and headings, we match headings first, then title and keywords.

Testing instructions:

  1. in vue-strap npm run build

  2. copy paste vue-strap.min.js to markbind

  3. After cloning the CS3281 website, go to common/header.md, and replace the use of typeahead with searchbar

  4. test on 3281 website

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments while you are running searchbar.vue through eslint. :P

src/index.js Outdated
tipBox,
tooltip,
pic,
searchbar,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While @acjh mentioned in the earlier PR to move above trigger, I think it should be moved above select instead, because pic is in the wrong alphabetical order.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx reminder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx This also needs to be fixed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

filters: {
highlight (value, phrase) {
return value.replace(new RegExp('(' + phrase + ')', 'gi'), '<strong>$1</strong>')
return value.replace(new RegExp('(' + phrase + ')', 'gi'), '<mark>$1</mark>')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to override filters methods in vue? I think @acjh didn't want the method to be modified for Typeahead, so should consider overriding this method in searchbar instead if possible.

@acjh
Copy link

acjh commented May 24, 2018

Can you rebase this on master so that we can run ESLint?

@nusjzx
Copy link
Author

nusjzx commented May 24, 2018

sure, I'm doing it now.

@yamgent yamgent changed the title 162 support search for headings Add searchbar component May 24, 2018
@nusjzx nusjzx force-pushed the 162-search-for-headings branch from c487447 to e5603bb Compare May 25, 2018 03:43
import searchbarDocs from './example/searchbarDocs.vue'
import tipBoxDocs from './example/tipBoxDocs.vue'
import triggerDocs from './example/triggerDocs.vue'
import TypeaheadDocs from './example/typeaheadDocs.vue';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't use capital letters for TypeaheadDocs, should be typeaheadDocs.


export default {
components: {
TypeaheadDocs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move it below tooltipDocs.

}
</doc-code>
<!-- eslint-disable -->
</doc-section>

This comment was marked as resolved.

<template>
<doc-section
id="searchbar"
name="searchbar">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find this ideal 😕, so I think we will need to fix eslint.

Can you help us modify .eslintrc.js on your branch to add in the following lines shown below as a separate commit. Then you can put all the attributes on one line instead of having to split to one attribute each line (e.g. <doc-section id="searchbar" name="searchbar">)

diff --git a/.eslintrc.js b/.eslintrc.js
index b74d1ab1..305ef01b 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -21,5 +21,15 @@ module.exports = {
     'operator-linebreak': ['error', 'before'],
     'quote-props': 'off',
     'vue/order-in-components': 'off',
+    'vue/max-attributes-per-line': [
+      {
+        'singleline': 5,
+        'multiline':
+        {
+          'max': 5,
+          'allowFirstLine': false,
+        },
+      },
+    ],
   },
 };

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id should be searchbarDocs, name should be Searchbar.

@acjh acjh mentioned this pull request May 25, 2018
}
}
</doc-code>
<!-- eslint-disable -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be <!-- eslint-enable -->

<template>
<doc-section
id="searchbar"
name="searchbar">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id should be searchbarDocs, name should be Searchbar.


<script>
// eslint-disable-next-line import/no-unresolved
import searchbar from 'src/Searchbar.vue';

This comment was marked as outdated.

This comment was marked as resolved.

import searchbar from 'src/Searchbar.vue';
import docCode from './docCode.vue';
import docSection from './docSection.vue';

This comment was marked as resolved.

export default {
components: {
docCode,
docSection,

This comment was marked as resolved.

Copy link

@acjh acjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I get a padding-top: 555px; on <body>:

  • And a fixed-height list:

'title': '',
},
],
searchTemplate: '<span v-html="item.title | highlight value" /><br />'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Let's do <span></span> as it's not a proper empty element:

  • Let's modify the relevant rule:

    'vue/html-self-closing': [
      'error',
      {
        'html': {
          'void': 'always',
          'normal': 'never',
        },
      },
    ],

template-name="search"
/>
</doc-code>
<!-- eslint-disable -->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's disable specific rules, and do it inside <doc-code>:

<doc-code language="javascript">
  <!-- eslint-disable vue/html-indent, vue/no-parsing-error, vue/valid-v-html -->
  new Vue {
    ...
  }
  <!-- eslint-enable vue/html-indent, vue/no-parsing-error, vue/valid-v-html -->
</doc-code>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to remove this <!-- eslint-disable --> after adding the one inside. :P

src/index.js Outdated
tipBox,
tooltip,
pic,
searchbar,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

overflow: scroll;
overflow-x: hidden;
}
</style> No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline at end of file.

.search-dropdown-menu {
height: 30em;
overflow: scroll;
overflow-x: hidden;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- overflow: scroll;
  overflow-x: hidden;
+ overflow-y: scroll;

<template>
<doc-section
id="searchbarDocs"
name="searchbar">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As @yamgent suggested, let's modify .eslintrc.js (it should be committed):

    'vue/max-attributes-per-line': [
      'error',
      {
        'singleline': 2,
        'multiline': {
          'max': 1,
          'allowFirstLine': false,
        },
      },
    ],

    Let's keep it strict.

  • Capitalize S in name="searchbar":

    <doc-section id="searchbarDocs" name="Searchbar">

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize S in name="searchbar"

Because it's used in sidebar and heading.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Also reminder to update the eslint.js on your branch as suggested by Aaron.

template-name="search"
/>
</doc-code>
<!-- eslint-disable -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to remove this <!-- eslint-disable --> after adding the one inside. :P

src/index.js Outdated
tipBox,
tooltip,
pic,
searchbar,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx reminder

@acjh
Copy link

acjh commented May 25, 2018

@nusjzx Did you miss this:

  • Let's modify the relevant rule:
'vue/html-self-closing': [
  'error',
  {
    'html': {
      'void': 'always',
      'normal': 'never',
    },
  },
],

popoverDocs,
retrieverDocs,
selectDocs,
searchbarDocs,

This comment was marked as resolved.

.eslintrc.js Outdated
{
'singleline': 2,
'multiline': {
'max': 2,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'max': 2? Let's not modify 'multiline':

'vue/max-attributes-per-line': ['error', { 'singleline': 2 }],

<div>
<p>template</p>
<p><code>String</code></p>
<p><code>&lt;span v-html=&quot;$value | highlight query&quot;&gt;&lt;/span&gt;</code></p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only &lt; has to be encoded.

<p><code>&lt;span v-html=&quot;$value | highlight query&quot;&gt;&lt;/span&gt;</code></p>
<p>Used to render suggestion.</p>
</div>
</doc-table>

This comment was marked as resolved.

</div>
</doc-table>
</doc-section>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.


<script>
// eslint-disable-next-line import/no-unresolved
import searchbar from 'src/Searchbar.vue';

This comment was marked as resolved.

import docSection from './docSection.vue';
import docTable from './docTable.vue';


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove one empty line.

'feature-list': 'Feature list',
},
'title': 'Hello World',
'src': 'index.md',

This comment was marked as resolved.

},
],
searchTemplate: '<span v-html="item.title | highlight value"></span>><br />'
+ '<span v-if="item.keywords" v-html="item.keywords | highlightAndExtract value <br />"></span>'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Extra > in </span>>.
  • Standardize <br /> after span.
  • Can we do "item.keywords | extract value | highlight value" for code reuse and consistency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part need to be changed if we want inconsecutive keywords match.May I change it in that PR

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we shouldn't compromise this PR.

<p>The local data source for suggestions. Expected to be a primitive array.</p>
</div>
<div>
<p>on-hit</p>

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as resolved.

This comment was marked as outdated.

.eslintrc.js Outdated
'allowFirstLine': false,
},
},
],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not modify 'multiline':

'vue/max-attributes-per-line': ['error', { 'singleline': 2 }],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx reminder. Some of the comments are yet to be resolved as well.

'feature-list': 'Feature list',
},
'title': 'Hello World',
'src': 'index.md',

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

<p>template-name</p>
<p><code>String</code></p>
<p></p>
<p>Used to specify name of the template</p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End with a period for consistency.

</div>
</doc-table>
</doc-section>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.


return matches;
}
return {};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring primitiveData().

Iteration 1:

  • Early return.
  • Rename value to entry as there's this.value.
  • Rename query to regex as there's this.query.
  • Reorder destructuring of entry alphabetically.
  • Reorder const before let.
  • Remove unnecessary if (Object.keys(headings).length !== 0).
  • Use regex.test(text) instead of text.search(query) !== -1.
  • Reorder properties of object in matches.push(object) alphabetically.
  • Replaced words.search(query) !== -1 with regex.test(title) || regex.test(keywords).
if (!this.data) {
  return {};
}
const matches = [];
this.data.forEach((entry) => {
  const { headings, src, title } = entry;
  const keywords = entry.keywords || '';
  const regex = new RegExp(this.value, 'i');
  let hasMatchingHeading = false;
  Object.entries(headings).forEach(([id, text]) => {
    if (regex.test(text)) {
      hasMatchingHeading = true;
      matches.push({
        heading: { id, text },
        keywords,
        src,
        title,
      });
    }
  });
  if (!hasMatchingHeading) {
    if (regex.test(title) || regex.test(keywords)) {
      matches.push(entry);
    }
  }
});
return matches;

Now trying Array.prototype.reduce().

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iteration 2:

  • Return early with undefined.
  • Assign regex outside forEach.
if (!this.data) {
  return undefined;
}
const matches = [];
const regex = new RegExp(this.value, 'i');
this.data.forEach((entry) => {
  const { headings, src, title } = entry;
  const keywords = entry.keywords || '';
  let hasMatchingHeading = false;
  Object.entries(headings).forEach(([id, text]) => {
    if (regex.test(text)) {
      hasMatchingHeading = true;
      matches.push({
        heading: { id, text },
        keywords,
        src,
        title,
      });
    }
  });
  if (!hasMatchingHeading) {
    if (regex.test(title) || regex.test(keywords)) {
      matches.push(entry);
    }
  }
});
return matches;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An attempt at reduce that's less appealing:

if (!this.data) {
  return undefined;
}
const regex = new RegExp(this.value, 'i');
return this.data.reduce((matches, entry) => {
  const { headings, src, title } = entry;
  const keywords = entry.keywords || '';
  const headingMatches = Object.entries(headings).reduce((acc, [id, text]) => {
    if (regex.test(text)) {
      acc.push({
        heading: { id, text },
        keywords,
        src,
        title,
      });
    }
    return acc;
  }, []);
  if (headingMatches.length) {
    return matches.concat(headingMatches);
  }
  if (regex.test(title) || regex.test(keywords)) {
    matches.push(entry);
  }
  return matches;
}, []);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Iteration 2 is more appealing.

'src': 'bugs/index.md',
'title': 'Open Bugs',
},
{

This comment was marked as resolved.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job. Just one minor nit left, then I think we are good to go. 👍

highlightAndExtract(value, phrase) {
const words = value.split(',').map(word => word.trim());
return words.reduce((pre, next) => {
const regex = new RegExp(`(${phrase})`, 'gi');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the regex constant out of the reduce method, like so:

    highlightAndExtract(value, phrase) {
      const regex = new RegExp(`(${phrase})`, 'gi');
      const words = value.split(',').map(word => word.trim());
      return words.reduce((pre, next) => {
        const isMatch = next.match(regex);
        return pre + (isMatch ? `${next.replace(regex, '<mark>$1</mark>')} ` : '');
      }, '');
    },

'feature-list': 'Feature list',
},
'title': 'Hello World',
'src': 'index.md',

This comment was marked as resolved.

src/index.js Outdated
tipBox,
tooltip,
pic,
searchbar,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

'title': '',
},
],
searchTemplate: '<span v-html="item.title | highlight value"></span><br />'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent with doc-code.

defaultCallback(items) {
console.log(items);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix eslint errors and warnings.
  • Should be singular item.
  • Let's rename it consoleCallback as it's not a default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint doesn't allow console.log()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it to other callback

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you have a better idea:

// eslint-disable-next-line no-console

},
],
searchTemplate: '<span v-html="item.title | highlight value <br />"></span>'
+ '<span v-if="item.keywords" v-html="item.keywords | highlightAndExtract value <br />"></span>'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #30 (comment):

  • Can we do "item.keywords | extract value | highlight value" for code reuse and consistency?

this part need to be changed if we want inconsecutive keywords match.May I change it in that PR

No, we shouldn't compromise this PR.

@nusjzx nusjzx force-pushed the 162-search-for-headings branch from e22092e to 5ec7d21 Compare May 28, 2018 07:25
'title': '',
},
],
searchTemplate: '<span v-html="item.title | highlight value"></span>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acjh Should we just consider using this value as the default? I think the logic in searchbar now assumes that the structure of item will always include title, keywords and a list of heading. Seems to be reasonable to give the user a default search template in that case.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, especially if we would be using the same. Let's do that.

  • Let's have a more realistic consoleCallback, which shows the use of .src and .heading.id:

    consoleCallback(match) {
      const page = `/${match.src.replace('.md', '.html')}`;
      const anchor = match.heading ? `#${match.heading.id}` : '';
      console.log(`${page}${anchor}`);
    },
  • Should keywords and heading be <small> instead of <span>?
    So that title stands out, rather than just three lines of words.

highlight(value, phrase) {
return value.replace(new RegExp(`(${phrase})`, 'gi'), '<mark>$1</mark>');
},
extract(value, phrase) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can consider removing this method since it is no longer used.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

'title': '',
},
],
searchTemplate: '<span v-html="item.title | highlight value"></span>'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, especially if we would be using the same. Let's do that.

  • Let's have a more realistic consoleCallback, which shows the use of .src and .heading.id:

    consoleCallback(match) {
      const page = `/${match.src.replace('.md', '.html')}`;
      const anchor = match.heading ? `#${match.heading.id}` : '';
      console.log(`${page}${anchor}`);
    },
  • Should keywords and heading be <small> instead of <span>?
    So that title stands out, rather than just three lines of words.

'keywords': 'k1, k2, k3',
'src': 'index.md',
'title': 'Hello World',

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line (to be consistent with code).

{
'headings': {
'popover-initiated-by-trigger-honor-trigger-attribute':
'popover initiated by trigger: honor trigger attribute',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent by 2 spaces (to be consistent with code).

methods: {
consoleCallback(item) {
console.log(item);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma (to be consistent with code).

src/index.js Outdated
@@ -49,7 +51,7 @@ const components = {
tooltip,
pic,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you reordered the import statements, let's reorder these as well.

<doc-code language="markup">
<searchbar
:data="searchData"
:template="searchTemplate"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add :on-hit (to be consistent with code).

},
'keywords': 'k7, k8, k9',
'src': 'sub_site/index.md',
'title': '',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We expect title to not be empty, since we don't use v-if.

consoleCallback(match) {
const page = `/${match.src.replace('.md', '.html')}`;
const anchor = match.heading ? `#${match.heading.id}` : '';
console.log(`${page}${anchor}`);

This comment was marked as resolved.

+ '<br v-if="item.keywords" />'
+ '<span v-if="item.keywords" v-html="item.keywords | highlight value"></span>'
+ '<br v-if="item.heading" />'
+ '<span v-if="item.heading" v-html="item.heading.text | highlight value"></span>',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove searchTemplate.

+ '<br v-if="item.keywords" />'
+ '<span v-if="item.keywords" v-html="item.keywords | highlight value"></span>'
+ '<br v-if="item.heading" />'
+ '<span v-if="item.heading" v-html="item.heading.text | highlight value"></span>',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #30 (comment):

  • Should keywords and heading be <small> instead of <span>?
    So that title stands out, rather than just three lines of words.

highlight(value, phrase) {
return value.replace(new RegExp(`(${phrase})`, 'gi'), '<mark>$1</mark>');
},
extract(value, phrase) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nusjzx Did you miss this?

<div>
<p>template</p>
<p><code>String</code></p>
<p><code>&lt;span v-html="$value | highlight query">&lt;/span></code></p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated. Perhaps:

  <div>
    <p>template</p>
    <p><code>String</code></p>
    <p>See below.</p>
    <p>Used to render suggestion.</p>
  </div>
  <div>
    <p>template-name</p>
    <p><code>String</code></p>
    <p></p>
    <p>Used to specify name of the template.</p>
  </div>
</doc-table>
Default template:
<doc-code>
  <span v-html="item.title | highlight value"></span>
  <br v-if="item.keywords" />
  <span v-if="item.keywords" v-html="item.keywords | highlight value"></span>
  <br v-if="item.heading" />
  <span v-if="item.heading" v-html="item.heading.text | highlight value"></span>
</doc-code>

vue-strap 30-4

Copy link

@acjh acjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always check your work.

<doc-code>
<span v-html="item.title | highlight value"></span>
<br v-if="item.keywords" />
<span v-if="item.keywords" v-html="item.keywords | highlight value"></span>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<small>

</doc-table>
Default template:
<doc-code>
<span v-html="item.title | highlight value"></span>

This comment was marked as resolved.

<div>
<p>template</p>
<p><code>String</code></p>
<p><code>See below.</code></p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't wrap in <code>.

<p></p>
<p>Used to specify name of the template.</p>
</div>
<!-- eslint-disable vue/no-parsing-error, vue/valid-v-html -->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I commented on Line 97, not Line 94.
  • Remember the corresponding eslint-enable.

@acjh
Copy link

acjh commented May 30, 2018

Looks fine now. Please squash the commits.

@yamgent
Copy link
Member

yamgent commented May 30, 2018

Just a query: What is the purpose of template-name? Is it useful to have that attribute?

@acjh
Copy link

acjh commented May 30, 2018

It's used to register a partial:

// register a partial:
if (this.templateName && this.templateName !== 'default') {
Vue.partial(this.templateName, this.template)
}

@nusjzx nusjzx force-pushed the 162-search-for-headings branch from 5daa5c2 to bf88b1d Compare May 30, 2018 05:54
@yamgent
Copy link
Member

yamgent commented May 30, 2018

Nice job squashing the commits, the commit message title can be improved as follows:

  • 2nd commit: Add search-dropdown-menu class to template typeahead's dropdown
  • 4th commit: Reorder import statements (capital at the start, missing 's' at the end)

@nusjzx nusjzx force-pushed the 162-search-for-headings branch from bf88b1d to d415696 Compare May 30, 2018 08:28
@blur="showDropdown = false"
/>
<ul class="dropdown-menu" v-el:dropdown>
<ul class="dropdown-menu search-dropdown-menu" v-el:dropdown>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying Typeahead.vue, let's add this in Searchbar.vue:

mounted() {
  this.$els.dropdown.classList.add('search-dropdown-menu');
},

You can add it between extends and partials.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mounted doesn't seem to work in Vue 1 (even with this.$nextTick); let's use ready.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@@ -0,0 +1,57 @@
<script>
import Typeahead from './Typeahead.vue';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Lowercase for imported variable:

    import typeahead from './Typeahead.vue';
  • Uppercase for the name of this file: Searchbar.vue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but all other files in that folder is lowercase.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I was looking at the docs files...

<doc-code>
<!-- eslint-disable vue/no-parsing-error, vue/valid-v-html -->
<span v-html="item.title | highlight value"></span>
<br v-if="item.keywords" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't seem to render the ending '/' in the documentation.

missing slash

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acjh The alternative is to not render it as a HTML snippet, but I think that's a bit extreme just to fix a missing slash. I suggest we just live with the flaw? :P

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fine for now.

'src': 'sub_site/index.md',
'title': 'Feature Page',
},
],

This comment was marked as resolved.

docTable,
searchbar,
},
partials: {},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

Copy link
Member

@yamgent yamgent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am good with this, @acjh any other major issues you wish to raise?

@acjh
Copy link

acjh commented Jun 4, 2018

Nope. Squash commits and can merge.

@acjh
Copy link

acjh commented Jun 4, 2018

Publish this (and update) before merging the MarkBind one.

@nusjzx nusjzx force-pushed the 162-search-for-headings branch from cf63641 to 65c41f0 Compare June 4, 2018 05:44
@yamgent yamgent merged commit 433b05d into MarkBind:master Jun 4, 2018
@yamgent yamgent added this to the v1.1.37-markbind.9 milestone Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants