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

fix(docs): [anchor] Optimize the anchor document. #2495

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/anchor/change-composition-api.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script setup>
import { ref } from 'vue'
import { TinyAnchor, TinyModal } from '@opentiny/vue'
import { TinyAnchor } from '@opentiny/vue'

const links = ref([
{
Expand Down Expand Up @@ -42,6 +42,6 @@ const links = ref([
])

function handleChange(link) {
TinyModal.message({ message: `change${link}`, status: 'info' })
console.log(`当前锚点${link}`)
}
</script>
17 changes: 12 additions & 5 deletions examples/sites/demos/pc/app/anchor/change.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ test('change事件', async ({ page }) => {
await page.goto('anchor#change')

const anchor = page.locator('.tiny-anchor')
const link1 = anchor.getByRole('link', { name: '演示' })
const link1 = anchor.getByRole('link', { name: '基本用法' })
const link2 = anchor.getByRole('link', { name: 'change 事件' })
const modal = page.locator('.tiny-modal')

const values = [] as string[]
page.on('console', async (msg) => {
for (const arg of msg.args()) {
const text = await arg.jsonValue()
if (text.includes('当前锚点')) {
values.push(text)
}
}
})
await link1.click()
await expect(modal).toHaveCount(1)
await link2.click()
await expect(modal).toHaveCount(2)
await expect(modal.last()).toHaveText(/#change/)
expect(values.length).toBe(2)
expect(values[0].startsWith('当前锚点#basic-usage')).toBeTruthy()
})
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/anchor/change.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import { TinyAnchor, TinyModal } from '@opentiny/vue'
import { TinyAnchor } from '@opentiny/vue'

export default {
components: {
Expand Down Expand Up @@ -49,7 +49,7 @@ export default {
},
methods: {
handleChange(link) {
TinyModal.message({ message: `change${link}`, status: 'info' })
console.log(`当前锚点${link}`)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,29 @@ function handleClick(e, link) {
.scroll-container {
height: 40vh;
overflow: auto;
text-align: center;
font-size: 24px;
}
.scroll-container > div {
padding-top: 20%;
}
.sec-1 {
height: 50vh;
background: rgba(135, 206, 235, 0.1);
background: #b6d4f2;
}
.sec-2 {
height: 50vh;
background: rgba(135, 206, 235, 0.3);
background: #c2c2c2;
}
.sec-3 {
background: rgba(135, 206, 235, 0.6);
padding-top: 20vh;
background: #fff4e8;
}
.sec-3-1 {
height: 50vh;
background: rgba(135, 206, 235, 0.8);
background: #b9e683;
}
.sec-3-2 {
height: 50vh;
background: rgba(135, 206, 235, 1);
background: #f2c5c2;
}
</style>
16 changes: 10 additions & 6 deletions examples/sites/demos/pc/app/anchor/set-container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,29 @@ export default {
.scroll-container {
height: 40vh;
overflow: auto;
text-align: center;
font-size: 24px;
}
.scroll-container > div {
padding-top: 20%;
}
.sec-1 {
height: 50vh;
background: rgba(135, 206, 235, 0.1);
background: #b6d4f2;
}
.sec-2 {
height: 50vh;
background: rgba(135, 206, 235, 0.3);
background: #c2c2c2;
}
.sec-3 {
background: rgba(135, 206, 235, 0.6);
padding-top: 20vh;
background: #fff4e8;
}
.sec-3-1 {
height: 50vh;
background: rgba(135, 206, 235, 0.8);
background: #b9e683;
}
.sec-3-2 {
height: 50vh;
background: rgba(135, 206, 235, 1);
background: #f2c5c2;
}
</style>
Loading