-
-
Notifications
You must be signed in to change notification settings - Fork 681
Improved rule list doc #1860
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
Merged
Improved rule list doc #1860
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29143f7
Improved rule list doc
ota-meshi a6e28ad
update markdownlint config
ota-meshi b262fdf
Update tools/update-docs-rules-index.js
ota-meshi bc69178
Update docs/.vuepress/components/rules-table.vue
ota-meshi 0e60e3a
Update docs/.vuepress/components/rules-table.vue
ota-meshi f371d73
Update tools/update-docs-rules-index.js
ota-meshi 881fc43
Update tools/update-docs-rules-index.js
ota-meshi 8dbb92f
Update tools/lib/utils.js
ota-meshi 38b40e2
Update tools/lib/utils.js
ota-meshi 1b2bd6c
Update tools/update-docs-rules-index.js
ota-meshi 8415be2
Merge commit 'c43e04f511350b2d4b8bd5c90e1ce302cce630a6' into rule-list
ota-meshi 061b699
update
ota-meshi 5584fcb
update markdownlint config
ota-meshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div> | ||
<div v-if="kindMarks.length > 1" class="filter-tool"> | ||
Highlight: | ||
<label v-for="kindMark in kindMarks" :key="kindMark"> | ||
<input type="checkbox" :value="kindMark" v-model="checkedKindMarks" /> | ||
<span class="emoji">{{ kindMark }}</span> | ||
</label> | ||
</div> | ||
<div class="table-root" ref="tableRoot"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
const emojis = ['3️⃣', '2️⃣', '⚠️'] | ||
|
||
export default { | ||
data() { | ||
return { | ||
kindMarks: [], | ||
checkedKindMarks: [] | ||
} | ||
}, | ||
mounted() { | ||
this.setup() | ||
}, | ||
watch: { | ||
checkedKindMarks: { | ||
handler: 'filterTable', | ||
deep: true | ||
} | ||
}, | ||
methods: { | ||
setup() { | ||
const kindMarks = new Set() | ||
const table = this.getTable() | ||
for (const row of table.rows) { | ||
row.cells[3].classList.add('emoji') | ||
const trimmed = row.cells[3].textContent.trim() | ||
if (!trimmed) { | ||
continue | ||
} | ||
const chars = | ||
trimmed.match(new RegExp(`${emojis.join('|')}|.`, 'ug')) || [] | ||
for (const mark of chars) { | ||
kindMarks.add(mark) | ||
} | ||
} | ||
this.kindMarks = [...kindMarks] | ||
}, | ||
getTable() { | ||
return this.$refs.tableRoot.querySelector('table') | ||
}, | ||
filterTable() { | ||
const table = this.getTable() | ||
if (this.checkedKindMarks.length === 0) { | ||
table.classList.remove('highlighting') | ||
return | ||
} | ||
table.classList.add('highlighting') | ||
for (const row of table.rows) { | ||
if (row.cells[0].tagName === 'TH') { | ||
row.classList.add('highlight') | ||
continue | ||
} | ||
const rowMarks = row.cells[3].textContent | ||
const highlight = this.checkedKindMarks.every((mark) => | ||
rowMarks.includes(mark) | ||
) | ||
row.classList.toggle('highlight', highlight) | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.table-root ::v-deep .highlighting tr { | ||
opacity: 0.3; | ||
} | ||
.table-root ::v-deep .highlighting .highlight { | ||
opacity: 1; | ||
} | ||
.filter-tool label { | ||
display: inline-flex; | ||
margin-right: 0.5ex; | ||
} | ||
</style> | ||
ota-meshi marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module.exports = { getPresetIds, formatItems } | ||
|
||
const presetCategories = { | ||
base: null, | ||
essential: 'base', | ||
'vue3-essential': 'base', | ||
'strongly-recommended': 'essential', | ||
'vue3-strongly-recommended': 'vue3-essential', | ||
recommended: 'strongly-recommended', | ||
'vue3-recommended': 'vue3-strongly-recommended' | ||
// 'use-with-caution': 'recommended', | ||
// 'vue3-use-with-caution': 'vue3-recommended' | ||
} | ||
|
||
function formatItems(items, suffix) { | ||
if (items.length === 1) { | ||
return `${items[0]}${suffix ? ` ${suffix[0]}` : ''}` | ||
} | ||
if (items.length === 2) { | ||
return `${items.join(' and ')}${suffix ? ` ${suffix[1]}` : ''}` | ||
} | ||
return `all of ${items.slice(0, -1).join(', ')} and ${[...items].pop()}${ | ||
suffix ? ` ${suffix[1]}` : '' | ||
}` | ||
} | ||
|
||
function getPresetIds(categoryIds) { | ||
const subsetCategoryIds = [] | ||
for (const categoryId of categoryIds) { | ||
for (const [subsetCategoryId, supersetCategoryId] of Object.entries( | ||
presetCategories | ||
)) { | ||
if (supersetCategoryId === categoryId) { | ||
subsetCategoryIds.push(subsetCategoryId) | ||
} | ||
} | ||
} | ||
if (subsetCategoryIds.length === 0) { | ||
return categoryIds | ||
} | ||
return [...new Set([...categoryIds, ...getPresetIds(subsetCategoryIds)])] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intl.Segmenter
is required to properly split these emojis, but FireFox doesn't support it, so we'll handle it ourselves.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter