-
Notifications
You must be signed in to change notification settings - Fork 309
docs(auto-tip): [directives] updateauto-tip and highlight-query docs and demos #2406
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,14 @@ | |
is_disabled: item.disabled, | ||
list: true | ||
}" | ||
v-auto-tip="item.disabled ? { always: true, content: item.tip } : false" | ||
v-auto-tip="item.disabled ? { always: true, content: item.disabledReason, effect: 'dark' } : false" | ||
> | ||
{{ item.text }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
<script lang="jsx"> | ||
import { AutoTip } from '@opentiny/vue-directive' | ||
|
||
export default { | ||
|
@@ -24,7 +24,19 @@ export default { | |
return { | ||
options: [ | ||
{ text: '去游泳馆游泳', disabled: false }, | ||
{ text: '去羽毛球馆打羽毛球', disabled: true, tip: '自定义提示内容' } | ||
{ text: '去羽毛球馆打羽毛球', disabled: true, disabledReason: '羽毛球拍坏了' }, | ||
{ | ||
text: '去爬山/海边沙滩', | ||
disabled: true, | ||
disabledReason: ( | ||
<span> | ||
还没有选择项目,现在去 | ||
<a href="javascript:void(0)" style="color:#f80"> | ||
选择 | ||
</a> | ||
</span> | ||
) | ||
Comment on lines
+31
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve accessibility and interactivity of the tooltip link. The tooltip contains an interactive link that needs improvements:
Consider this improvement: disabledReason: (
<span>
还没有选择项目,现在去
- <a href="javascript:void(0)" style="color:#f80">
+ <button
+ type="button"
+ onClick={() => {/* Add handler */}}
+ style={{
+ color: '#f80',
+ textDecoration: 'underline',
+ border: 'none',
+ background: 'none',
+ cursor: 'pointer',
+ padding: 0
+ }}
+ aria-label="选择项目"
+ >
选择
- </a>
+ </button>
</span>
)
|
||
} | ||
] | ||
} | ||
} | ||
|
@@ -46,5 +58,6 @@ export default { | |
} | ||
.is_disabled { | ||
cursor: not-allowed; | ||
text-decoration: line-through; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,29 +2,29 @@ | |||||||||||||||||||||||||||||||||||||||||||||
<div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div> | ||||||||||||||||||||||||||||||||||||||||||||||
关键字:<tiny-input v-model="query" placeholder="输入关键字,观察下面的高亮"></tiny-input> | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-button @click="changeList">修改内容</tiny-button> | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-button @click="changeList">修改诗的内容</tiny-button> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
<div>避免场景1: 直接包含文字节点</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div class="title">避免场景1: 直接包含文字节点,无法动态更新</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div v-highlight-query="query"> | ||||||||||||||||||||||||||||||||||||||||||||||
{{ list.join(',') }} | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<br /> | ||||||||||||||||||||||||||||||||||||||||||||||
<div>避免场景2:文字节点与其它组件混合</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div class="title">避免场景2:文字节点与其它组件混合,无法动态更新</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div v-highlight-query="query"> | ||||||||||||||||||||||||||||||||||||||||||||||
{{ list.join(',') }} | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-input></tiny-input> | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-button>混入的按钮</tiny-button> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<br /> | ||||||||||||||||||||||||||||||||||||||||||||||
<div>正确的场景1</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div class="title">正确的场景1</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div v-highlight-query="query"> | ||||||||||||||||||||||||||||||||||||||||||||||
<span> {{ list.join(',') }}</span> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<br /> | ||||||||||||||||||||||||||||||||||||||||||||||
<div>正确的场景2</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div class="title">正确的场景2</div> | ||||||||||||||||||||||||||||||||||||||||||||||
<div v-highlight-query="query"> | ||||||||||||||||||||||||||||||||||||||||||||||
<span> {{ list.join(',') }}</span> | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-input></tiny-input> | ||||||||||||||||||||||||||||||||||||||||||||||
<tiny-button>混入的按钮</tiny-button> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||
</template> | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -51,4 +51,13 @@ const changeList = () => (list.value = ['江上一笼统', '井上黑窟窿', ' | |||||||||||||||||||||||||||||||||||||||||||||
div { | ||||||||||||||||||||||||||||||||||||||||||||||
line-height: 2; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
.title { | ||||||||||||||||||||||||||||||||||||||||||||||
font-size: 18px; | ||||||||||||||||||||||||||||||||||||||||||||||
font-weight: bold; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
.tiny-button { | ||||||||||||||||||||||||||||||||||||||||||||||
margin-left: 20px; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+55
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using CSS custom properties for better maintainability The styling is clean and well-organized. Consider using CSS custom properties (variables) for values that might be reused across demos: +:root {
+ --demo-title-size: 18px;
+ --demo-title-weight: bold;
+ --demo-spacing: 20px;
+}
.title {
- font-size: 18px;
- font-weight: bold;
+ font-size: var(--demo-title-size);
+ font-weight: var(--demo-title-weight);
}
.tiny-button {
- margin-left: 20px;
+ margin-left: var(--demo-spacing);
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ test('避免用法', async ({ page }) => { | |
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('directives-highlight-query#avoid') | ||
|
||
const input = page.locator('.pc-demo-container .tiny-input-inner').first() | ||
const hlNode = page.locator('.pc-demo-container .tiny-hl-query-node') | ||
const button = page.locator('.pc-demo-container .tiny-button') | ||
const button = page.locator('.pc-demo-container .tiny-button').first() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using a more specific selector instead of .first() While - const button = page.locator('.pc-demo-container .tiny-button').first()
+ const button = page.locator('.pc-demo-container .tiny-button[data-test="highlight-toggle"]') Don't forget to add the corresponding data attribute to the button in your Vue template: <tiny-button data-test="highlight-toggle">
<!-- button content -->
</tiny-button> |
||
|
||
await expect(hlNode).toHaveCount(12) | ||
|
||
|
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.
Consider improving the link implementation.
The
javascript:void(0)
usage is not recommended as it:Consider using a proper button or handling the click event:
Add corresponding CSS: