From 7abefcd9138a6e976e90714d11c7ec920661fcd7 Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Wed, 9 Aug 2023 23:27:59 +0200 Subject: [PATCH] refactor(case converter): config based case changes --- src/tools/case-converter/case-converter.vue | 131 ++++++++++++-------- unocss.config.ts | 1 + 2 files changed, 77 insertions(+), 55 deletions(-) diff --git a/src/tools/case-converter/case-converter.vue b/src/tools/case-converter/case-converter.vue index cca06063..e43744ca 100644 --- a/src/tools/case-converter/case-converter.vue +++ b/src/tools/case-converter/case-converter.vue @@ -20,66 +20,87 @@ const baseConfig = { const input = ref('lorem ipsum dolor sit amet'); -// Using noCase to convert to lowercase and uppercase to ensure consistent splitting -const toLowerCase = (str: string) => noCase(str, baseConfig).toLocaleLowerCase(); -const toUpperCase = (str: string) => noCase(str, baseConfig).toLocaleUpperCase(); +const formats = computed(() => [ + { + label: 'Lowercase:', + value: noCase(input.value, baseConfig).toLocaleLowerCase(), + }, + { + label: 'Uppercase:', + value: noCase(input.value, baseConfig).toLocaleUpperCase(), + }, + { + label: 'Camelcase:', + value: camelCase(input.value, baseConfig), + }, + { + label: 'Capitalcase:', + value: capitalCase(input.value, baseConfig), + }, + { + label: 'Constantcase:', + value: constantCase(input.value, baseConfig), + }, + { + label: 'Dotcase:', + value: dotCase(input.value, baseConfig), + }, + { + label: 'Headercase:', + value: headerCase(input.value, baseConfig), + }, + { + label: 'Nocase:', + value: noCase(input.value, baseConfig), + }, + { + label: 'Paramcase:', + value: paramCase(input.value, baseConfig), + }, + { + label: 'Pascalcase:', + value: pascalCase(input.value, baseConfig), + }, + { + label: 'Pathcase:', + value: pathCase(input.value, baseConfig), + }, + { + label: 'Sentencecase:', + value: sentenceCase(input.value, baseConfig), + }, + { + label: 'Snakecase:', + value: snakeCase(input.value, baseConfig), + }, +]); + +const inputLabelAlignmentConfig = { + labelPosition: 'left', + labelWidth: '120px', + labelAlign: 'right', +}; - - diff --git a/unocss.config.ts b/unocss.config.ts index 0ce8f705..6da68739 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -19,5 +19,6 @@ export default defineConfig({ }, shortcuts: { 'pretty-scrollbar': 'scrollbar scrollbar-rounded scrollbar-thumb-color-gray-300 scrollbar-track-color-gray-100 dark:scrollbar-thumb-color-#424242 dark:scrollbar-track-color-#686868', + 'divider': 'h-1px bg-current op-10', }, });