-
-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into refactor/person/sex
- Loading branch information
Showing
36 changed files
with
1,194 additions
and
603 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,32 @@ | ||
describe('example-refresh', () => { | ||
it('should refresh the example', () => { | ||
// given | ||
cy.visit('/api/faker.html#constructor'); | ||
cy.get('.refresh').first().as('refresh'); | ||
cy.get('@refresh').next().find('code').as('codeBlock'); | ||
cy.get('@codeBlock').then(($el) => { | ||
const originalCodeText = $el.text(); | ||
|
||
cy.get('@refresh') | ||
.click() | ||
.should('not.be.disabled') // stays disabled on error | ||
.then(() => { | ||
cy.get('@codeBlock').then(($el) => { | ||
const newCodeText = $el.text(); | ||
expect(newCodeText).not.to.equal(originalCodeText); | ||
|
||
cy.get('@refresh') | ||
.click() | ||
.should('not.be.disabled') // stays disabled on error | ||
.then(() => { | ||
cy.get('@codeBlock').then(($el) => { | ||
const newCodeText2 = $el.text(); | ||
expect(newCodeText2).not.to.equal(originalCodeText); | ||
expect(newCodeText2).not.to.equal(newCodeText); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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,14 @@ | ||
export function formatResult(result: unknown): string { | ||
return result === undefined | ||
? 'undefined' | ||
: typeof result === 'bigint' | ||
? `${result}n` | ||
: JSON.stringify(result, undefined, 2) | ||
.replaceAll('\\r', '') | ||
.replaceAll('<', '<') | ||
.replaceAll( | ||
/(^ *|: )"([^'\n]*?)"(?=,?$|: )/gm, | ||
(_, p1, p2) => `${p1}'${p2.replace(/\\"/g, '"')}'` | ||
) | ||
.replaceAll(/\n */g, ' '); | ||
} |
This file contains 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 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 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,69 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
// This should probably use emit instead, but emit cannot be awaited | ||
const { refresh } = defineProps<{ refresh: () => Promise<void> }>(); | ||
const spinning = ref(false); | ||
async function onRefresh() { | ||
spinning.value = true; | ||
await Promise.all([refresh(), delay(100)]); | ||
spinning.value = false; | ||
} | ||
// Extra delay to make the spinning effect more visible | ||
// Some examples barely/don't change, so the spinning is the only visible effect | ||
function delay(ms: number) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
</script> | ||
|
||
<template> | ||
<button | ||
class="refresh" | ||
title="Refresh Examples" | ||
:disabled="spinning" | ||
@click="onRefresh" | ||
> | ||
<div :class="{ spinning: spinning }" /> | ||
</button> | ||
</template> | ||
|
||
<style scoped> | ||
button.refresh { | ||
border: 1px solid var(--vp-code-copy-code-border-color); | ||
border-radius: 4px; | ||
width: 40px; | ||
height: 40px; | ||
font-size: 25px; | ||
vertical-align: middle; | ||
} | ||
button.refresh div { | ||
background-image: url('refresh.svg'); | ||
background-position: 50%; | ||
background-size: 20px; | ||
background-repeat: no-repeat; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
button.refresh:hover { | ||
background-color: var(--vp-code-copy-code-bg); | ||
opacity: 1; | ||
} | ||
div.spinning { | ||
animation: spin 1s linear infinite; | ||
} | ||
@keyframes spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
</style> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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.