mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 21:37:11 -04:00
feat(new tool): CSS <> XPath converter
Convert CSS Selectors from/to XPath expressions
This commit is contained in:
parent
318fb6efb9
commit
be60b042bd
8 changed files with 120 additions and 8 deletions
71
src/tools/css-xpath-converter/css-xpath-converter.vue
Normal file
71
src/tools/css-xpath-converter/css-xpath-converter.vue
Normal file
|
@ -0,0 +1,71 @@
|
|||
<script setup lang="ts">
|
||||
import xPathToCss from 'xpath-to-css';
|
||||
import cssToXpath from 'csstoxpath';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
|
||||
const cssInput = ref('');
|
||||
const xpathOutput = computed(
|
||||
() => {
|
||||
try {
|
||||
return cssToXpath(cssInput.value);
|
||||
}
|
||||
catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const xpathInput = ref('');
|
||||
const cssOutput = computed(
|
||||
() => {
|
||||
try {
|
||||
return xPathToCss(xpathInput.value);
|
||||
}
|
||||
catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div max-w-600>
|
||||
<c-card title="CSS to XPath">
|
||||
<c-input-text
|
||||
v-model:value="cssInput"
|
||||
placeholder="Put your CSS selector here..."
|
||||
label="CSS selector to convert"
|
||||
raw-text
|
||||
mb-5
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<TextareaCopyable
|
||||
label="XPath expression"
|
||||
:value="xpathOutput"
|
||||
readonly
|
||||
mb-5
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<c-card title="XPath to CSS" mt-5>
|
||||
<c-input-text
|
||||
v-model:value="xpathInput"
|
||||
placeholder="Put your XPath expression here..."
|
||||
label="XPath expression to convert"
|
||||
raw-text
|
||||
mb-5
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<TextareaCopyable
|
||||
label="CSS Selector"
|
||||
:value="cssOutput"
|
||||
readonly
|
||||
mb-5
|
||||
/>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue