diff --git a/.github/ISSUE_TEMPLATE/new-tool-request.md b/.github/ISSUE_TEMPLATE/new-tool-request.md index 58775d1a..a67a9cd0 100644 --- a/.github/ISSUE_TEMPLATE/new-tool-request.md +++ b/.github/ISSUE_TEMPLATE/new-tool-request.md @@ -6,8 +6,8 @@ labels: new tool assignees: CorentinTh --- -**Which tool is impacted?** -Example: the token generator +**What tool do you want?** +Example: a token generator **Describe the solution you'd like** A clear and concise description of what you want to happen. diff --git a/CHANGELOG.md b/CHANGELOG.md index 10259598..d0a1e826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## Version 2023.05.14-77f2efc + +### Features +- **list-converter**: a small converter who deals with column based data and do some stuff with it (#387) (83a7b3b) +- **new tool**: phone parser and normalizer (ce3150c) + +### Bug fixes +- **phone-parser**: use default country code (a43c546) +- **home**: prevent weird blue border on card (3f6c8f0) + +### Refactoring +- **ui**: replaced some n-input with c-input-text (77f2efc) + +### Chores +- **issues**: updated new tool request issue template (edae4c6) + +### Ui-lib +- **new-component**: added text input component in the c-lib (aad8d84) +- **button**: size variants (401f13f) + ## Version 2023.04.23-92bd835 ### Features diff --git a/components.d.ts b/components.d.ts index 78c2650c..40b805a9 100644 --- a/components.d.ts +++ b/components.d.ts @@ -26,11 +26,15 @@ declare module '@vue/runtime-core' { 'CCard.demo': typeof import('./src/ui/c-card/c-card.demo.vue')['default'] ChmodCalculator: typeof import('./src/tools/chmod-calculator/chmod-calculator.vue')['default'] Chronometer: typeof import('./src/tools/chronometer/chronometer.vue')['default'] + CInputText: typeof import('./src/ui/c-input-text/c-input-text.vue')['default'] + 'CInputText.demo': typeof import('./src/ui/c-input-text/c-input-text.demo.vue')['default'] + 'CInputText.theme': typeof import('./src/ui/c-input-text/c-input-text.theme.vue')['default'] CLink: typeof import('./src/ui/c-link/c-link.vue')['default'] 'CLink.demo': typeof import('./src/ui/c-link/c-link.demo.vue')['default'] CollapsibleToolMenu: typeof import('./src/components/CollapsibleToolMenu.vue')['default'] ColorConverter: typeof import('./src/tools/color-converter/color-converter.vue')['default'] ColoredCard: typeof import('./src/components/ColoredCard.vue')['default'] + copy: typeof import('./src/ui/c-input-text/c-input-text copy.vue')['default'] CopyableIpLike: typeof import('./src/tools/ipv4-subnet-calculator/copyable-ip-like.vue')['default'] CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default'] DateTimeConverter: typeof import('./src/tools/date-time-converter/date-time-converter.vue')['default'] @@ -52,6 +56,12 @@ declare module '@vue/runtime-core' { HtmlEntities: typeof import('./src/tools/html-entities/html-entities.vue')['default'] HtmlWysiwygEditor: typeof import('./src/tools/html-wysiwyg-editor/html-wysiwyg-editor.vue')['default'] HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default'] + IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default'] + IconMdiClose: typeof import('~icons/mdi/close')['default'] + IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default'] + IconMdiEye: typeof import('~icons/mdi/eye')['default'] + IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default'] + IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] InputCopyable: typeof import('./src/components/InputCopyable.vue')['default'] IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default'] Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default'] diff --git a/package.json b/package.json index 6f5856b0..25d4fc5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "it-tools", - "version": "2023.4.23-92bd835", + "version": "2023.5.14-77f2efc", "description": "Collection of handy online tools for developers, with great UX. ", "keywords": [ "productivity", @@ -79,6 +79,7 @@ "yaml": "^2.2.1" }, "devDependencies": { + "@iconify-json/mdi": "^1.1.50", "@playwright/test": "^1.32.3", "@rushstack/eslint-patch": "^1.2.0", "@types/bcryptjs": "^2.4.2", @@ -98,8 +99,10 @@ "@unocss/eslint-config": "^0.50.8", "@vitejs/plugin-vue": "^2.3.4", "@vitejs/plugin-vue-jsx": "^1.3.10", + "@vue/compiler-sfc": "^3.2.47", "@vue/eslint-config-prettier": "^7.1.0", "@vue/eslint-config-typescript": "^10.0.0", + "@vue/runtime-core": "^3.2.47", "@vue/test-utils": "^2.3.2", "@vue/tsconfig": "^0.1.3", "c8": "^7.13.0", @@ -116,6 +119,7 @@ "typescript": "~4.5.5", "unocss": "^0.50.8", "unplugin-auto-import": "^0.15.2", + "unplugin-icons": "^0.16.1", "unplugin-vue-components": "^0.24.1", "vite": "^2.9.15", "vite-plugin-md": "^0.12.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5813b71..68138ef0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,6 +135,9 @@ dependencies: version: 2.2.1 devDependencies: + '@iconify-json/mdi': + specifier: ^1.1.50 + version: 1.1.50 '@playwright/test': specifier: ^1.32.3 version: 1.32.3 @@ -192,12 +195,18 @@ devDependencies: '@vitejs/plugin-vue-jsx': specifier: ^1.3.10 version: 1.3.10 + '@vue/compiler-sfc': + specifier: ^3.2.47 + version: 3.2.47 '@vue/eslint-config-prettier': specifier: ^7.1.0 version: 7.1.0(eslint@8.38.0)(prettier@2.8.7) '@vue/eslint-config-typescript': specifier: ^10.0.0 version: 10.0.0(eslint-plugin-vue@8.7.1)(eslint@8.38.0)(typescript@4.5.5) + '@vue/runtime-core': + specifier: ^3.2.47 + version: 3.2.47 '@vue/test-utils': specifier: ^2.3.2 version: 2.3.2(vue@3.2.47) @@ -246,6 +255,9 @@ devDependencies: unplugin-auto-import: specifier: ^0.15.2 version: 0.15.2(@vueuse/core@8.9.4)(rollup@2.79.1) + unplugin-icons: + specifier: ^0.16.1 + version: 0.16.1(@vue/compiler-sfc@3.2.47) unplugin-vue-components: specifier: ^0.24.1 version: 0.24.1(rollup@2.79.1)(vue@3.2.47) @@ -1612,6 +1624,12 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@iconify-json/mdi@1.1.50: + resolution: {integrity: sha512-SgbT5w5eHCdOG74ZWPz7HlTGk6VsifIJhNi6lAsxj/5Nlqt6Cz4LlQmSa9eecU9p075Jub2aAx/o7YI+GCahRQ==} + dependencies: + '@iconify/types': 2.0.0 + dev: true + /@iconify/types@2.0.0: resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} dev: true @@ -7561,6 +7579,35 @@ packages: - rollup dev: true + /unplugin-icons@0.16.1(@vue/compiler-sfc@3.2.47): + resolution: {integrity: sha512-qTunFUkpAyDnwzwV7YV1ZgCWRYfLuURcCurhhXOWMy2ipY88qx1pADvral2hJu4Xymh0X0t3Zcll3BIru2AVLQ==} + peerDependencies: + '@svgr/core': '>=7.0.0' + '@vue/compiler-sfc': ^3.0.2 || ^2.7.0 + vue-template-compiler: ^2.6.12 + vue-template-es2015-compiler: ^1.9.0 + peerDependenciesMeta: + '@svgr/core': + optional: true + '@vue/compiler-sfc': + optional: true + vue-template-compiler: + optional: true + vue-template-es2015-compiler: + optional: true + dependencies: + '@antfu/install-pkg': 0.1.1 + '@antfu/utils': 0.7.2 + '@iconify/utils': 2.1.5 + '@vue/compiler-sfc': 3.2.47 + debug: 4.3.4 + kolorist: 1.7.0 + local-pkg: 0.4.3 + unplugin: 1.3.1 + transitivePeerDependencies: + - supports-color + dev: true + /unplugin-vue-components@0.24.1(rollup@2.79.1)(vue@3.2.47): resolution: {integrity: sha512-T3A8HkZoIE1Cja95xNqolwza0yD5IVlgZZ1PVAGvVCx8xthmjsv38xWRCtHtwl+rvZyL9uif42SRkDGw9aCfMA==} engines: {node: '>=14'} diff --git a/src/components/FormatTransformer.vue b/src/components/FormatTransformer.vue index dea5d56a..5b187b2b 100644 --- a/src/components/FormatTransformer.vue +++ b/src/components/FormatTransformer.vue @@ -1,26 +1,27 @@ diff --git a/src/components/InputCopyable.vue b/src/components/InputCopyable.vue index eaf29c81..cf7a42a7 100644 --- a/src/components/InputCopyable.vue +++ b/src/components/InputCopyable.vue @@ -1,21 +1,20 @@ - - diff --git a/src/composable/validation.ts b/src/composable/validation.ts index 4858110c..e7fc70c4 100644 --- a/src/composable/validation.ts +++ b/src/composable/validation.ts @@ -1,3 +1,4 @@ +import { get, type MaybeRef } from '@vueuse/core'; import _ from 'lodash'; import { reactive, watch, type Ref } from 'vue'; @@ -31,7 +32,7 @@ export function useValidation({ watch: watchRefs = [], }: { source: Ref; - rules: UseValidationRule[]; + rules: MaybeRef[]>; watch?: Ref[]; }) { const state = reactive<{ @@ -55,7 +56,7 @@ export function useValidation({ state.message = ''; state.status = undefined; - for (const rule of rules) { + for (const rule of get(rules)) { if (isFalsyOrHasThrown(() => rule.validator(source.value))) { state.message = rule.message; state.status = 'error'; diff --git a/src/tools/base64-file-converter/base64-file-converter.vue b/src/tools/base64-file-converter/base64-file-converter.vue index 55241096..de18ee3b 100644 --- a/src/tools/base64-file-converter/base64-file-converter.vue +++ b/src/tools/base64-file-converter/base64-file-converter.vue @@ -1,17 +1,19 @@ @@ -77,11 +80,6 @@ async function onUpload({ file: { file } }: { file: UploadFileInfo }) { diff --git a/src/tools/json-diff/json-diff.vue b/src/tools/json-diff/json-diff.vue index df106c63..811f7fa3 100644 --- a/src/tools/json-diff/json-diff.vue +++ b/src/tools/json-diff/json-diff.vue @@ -1,30 +1,25 @@ @@ -33,7 +28,6 @@ import JSON5 from 'json5'; import { withDefaultOnError } from '@/utils/defaults'; -import { useValidation } from '@/composable/validation'; import { isNotThrowing } from '@/utils/boolean'; import DiffsViewer from './diff-viewer/diff-viewer.vue'; @@ -43,17 +37,10 @@ const rawRightJson = ref(''); const leftJson = computed(() => withDefaultOnError(() => JSON5.parse(rawLeftJson.value), undefined)); const rightJson = computed(() => withDefaultOnError(() => JSON5.parse(rawRightJson.value), undefined)); -const createJsonValidation = (json: Ref) => - useValidation({ - source: json, - rules: [ - { - validator: (value) => value === '' || isNotThrowing(() => JSON5.parse(value)), - message: 'Invalid JSON', - }, - ], - }); - -const leftJsonValidation = createJsonValidation(rawLeftJson); -const rightJsonValidation = createJsonValidation(rawRightJson); +const jsonValidationRules = [ + { + validator: (value: string) => value === '' || isNotThrowing(() => JSON5.parse(value)), + message: 'Invalid JSON format', + }, +]; diff --git a/src/tools/list-converter/list-converter.e2e.spec.ts b/src/tools/list-converter/list-converter.e2e.spec.ts index 1634a11c..a5ac8c6d 100644 --- a/src/tools/list-converter/list-converter.e2e.spec.ts +++ b/src/tools/list-converter/list-converter.e2e.spec.ts @@ -30,8 +30,8 @@ test.describe('Tool - List converter', () => { 3 5`); await page.getByTestId('removeDuplicates').check(); - await page.getByTestId('itemPrefix').locator('input').fill("'"); - await page.getByTestId('itemSuffix').locator('input').fill("'"); + await page.getByTestId('itemPrefix').fill("'"); + await page.getByTestId('itemSuffix').fill("'"); const result = await page.getByTestId('area-content').innerText(); expect(result.trim()).toEqual("'1', '2', '4', '3', '5'"); diff --git a/src/tools/list-converter/list-converter.vue b/src/tools/list-converter/list-converter.vue index ae0b50ec..f8da070a 100644 --- a/src/tools/list-converter/list-converter.vue +++ b/src/tools/list-converter/list-converter.vue @@ -36,37 +36,39 @@ /> - - - + - - - - + + - - - - + + diff --git a/src/tools/mac-address-lookup/mac-address-lookup.vue b/src/tools/mac-address-lookup/mac-address-lookup.vue index c157dda7..095a0ee0 100644 --- a/src/tools/mac-address-lookup/mac-address-lookup.vue +++ b/src/tools/mac-address-lookup/mac-address-lookup.vue @@ -1,37 +1,37 @@ diff --git a/src/tools/meta-tag-generator/meta-tag-generator.vue b/src/tools/meta-tag-generator/meta-tag-generator.vue index ee5d8e77..73fad8b4 100644 --- a/src/tools/meta-tag-generator/meta-tag-generator.vue +++ b/src/tools/meta-tag-generator/meta-tag-generator.vue @@ -5,7 +5,7 @@ {{ label }} - +
- - - - - + + +
@@ -27,49 +31,52 @@
- - - + - - - - - - Count: - - - + - - - Padded hex: - - - +

Iteration

+ + + +
diff --git a/src/ui/c-button/c-button.theme.ts b/src/ui/c-button/c-button.theme.ts index 87ad89f3..5b4c26f7 100644 --- a/src/ui/c-button/c-button.theme.ts +++ b/src/ui/c-button/c-button.theme.ts @@ -27,6 +27,21 @@ const createTheme = ({ style }: { style: 'light' | 'dark' }) => { const theme = appThemes[style]; return { + size: { + small: { + width: '28px', + fontSize: '12px', + }, + medium: { + width: '34px', + fontSize: '14px', + }, + large: { + width: '40px', + fontSize: '16px', + }, + }, + basic: { default: createState({ textColor: theme.text.baseColor, @@ -41,10 +56,10 @@ const createTheme = ({ style }: { style: 'light' | 'dark' }) => { pressedBackground: darken(theme.primary.colorFaded, 30), }), warning: createState({ - textColor: theme.text.baseColor, - backgroundColor: theme.warning.color, - hoverBackground: theme.warning.colorHover, - pressedBackground: theme.warning.colorPressed, + textColor: theme.warning.color, + backgroundColor: theme.warning.colorFaded, + hoverBackground: lighten(theme.warning.colorFaded, 30), + pressedBackground: darken(theme.warning.colorFaded, 30), }), }, text: { @@ -61,10 +76,10 @@ const createTheme = ({ style }: { style: 'light' | 'dark' }) => { pressedBackground: darken(theme.primary.colorFaded, 30), }), warning: createState({ - textColor: theme.text.baseColor, - backgroundColor: theme.warning.color, - hoverBackground: theme.warning.colorHover, - pressedBackground: theme.warning.colorPressed, + textColor: darken(theme.warning.color, 20), + backgroundColor: 'transparent', + hoverBackground: theme.warning.colorFaded, + pressedBackground: darken(theme.warning.colorFaded, 30), }), }, }; diff --git a/src/ui/c-button/c-button.vue b/src/ui/c-button/c-button.vue index 2cbc4fd4..121a1e96 100644 --- a/src/ui/c-button/c-button.vue +++ b/src/ui/c-button/c-button.vue @@ -18,13 +18,14 @@ import { useAppTheme } from '../theme/themes'; const props = withDefaults( defineProps<{ - type?: 'default' | 'primary'; + type?: 'default' | 'primary' | 'warning'; variant?: 'basic' | 'text'; disabled?: boolean; round?: boolean; circle?: boolean; href?: string; to?: RouteLocationRaw; + size?: 'small' | 'medium' | 'large'; }>(), { type: 'default', @@ -34,9 +35,10 @@ const props = withDefaults( circle: false, href: undefined, to: undefined, + size: 'medium', }, ); -const { variant, disabled, round, circle, href, type, to } = toRefs(props); +const { variant, disabled, round, circle, href, type, to, size: sizeName } = toRefs(props); const emits = defineEmits(['click']); @@ -58,18 +60,20 @@ const tag = computed(() => { return 'button'; }); const appTheme = useAppTheme(); + +const size = computed(() => theme.value.size[sizeName.value]); diff --git a/src/ui/demo/demo-wrapper.vue b/src/ui/demo/demo-wrapper.vue index cc16a00f..8d4bae00 100644 --- a/src/ui/demo/demo-wrapper.vue +++ b/src/ui/demo/demo-wrapper.vue @@ -18,6 +18,8 @@
+

{{ componentName }}

+
@@ -25,9 +27,12 @@ diff --git a/src/ui/demo/demo.routes.ts b/src/ui/demo/demo.routes.ts index 0e9a9e4e..9ae1e77f 100644 --- a/src/ui/demo/demo.routes.ts +++ b/src/ui/demo/demo.routes.ts @@ -6,8 +6,6 @@ export const demoRoutes = Object.keys(demoPages).map((path) => { const [, , fileName] = path.split('/'); const name = fileName.split('.').shift(); - console.log(path); - return { path: name, name, diff --git a/src/ui/theme/themes.ts b/src/ui/theme/themes.ts index 18b2c8d0..81d7ddfd 100644 --- a/src/ui/theme/themes.ts +++ b/src/ui/theme/themes.ts @@ -21,6 +21,7 @@ export const { themes: appThemes, useTheme: useAppTheme } = defineThemes({ color: '#f59e0b', colorHover: '#f59e0b', colorPressed: '#f59e0b', + colorFaded: '#f59e0b2f', }, success: { color: '#18a058', @@ -55,6 +56,7 @@ export const { themes: appThemes, useTheme: useAppTheme } = defineThemes({ color: '#f59e0b', colorHover: '#f59e0b', colorPressed: '#f59e0b', + colorFaded: '#f59e0b2f', }, success: { color: '#18a058', diff --git a/src/utils/macAddress.ts b/src/utils/macAddress.ts index ff6000cb..89f12d32 100644 --- a/src/utils/macAddress.ts +++ b/src/utils/macAddress.ts @@ -1,16 +1,18 @@ import { useValidation } from '@/composable/validation'; import type { Ref } from 'vue'; +const macAddressValidationRules = [ + { + message: 'Invalid MAC address', + validator: (value: string) => value.trim().match(/^([0-9A-Fa-f]{2}[:-]){2,5}([0-9A-Fa-f]{2})$/), + }, +]; + function macAddressValidation(value: Ref) { return useValidation({ source: value, - rules: [ - { - message: 'Invalid MAC address', - validator: (value) => value.trim().match(/^([0-9A-Fa-f]{2}[:-]){2,5}([0-9A-Fa-f]{2})$/), - }, - ], + rules: macAddressValidationRules, }); } -export { macAddressValidation }; +export { macAddressValidation, macAddressValidationRules }; diff --git a/src/utils/random.ts b/src/utils/random.ts index 6df941db..3a13be50 100644 --- a/src/utils/random.ts +++ b/src/utils/random.ts @@ -18,4 +18,14 @@ const shuffleArray = (array: T[]): T[] => shuffleArrayMutate([...array]); const shuffleString = (str: string, delimiter = ''): string => shuffleArrayMutate(str.split(delimiter)).join(delimiter); -export { randFromArray, randIntFromInterval, random, shuffleArray, shuffleArrayMutate, shuffleString }; +const generateRandomId = () => `id-${random().toString(36).substring(2, 12)}`; + +export { + randFromArray, + randIntFromInterval, + random, + shuffleArray, + shuffleArrayMutate, + shuffleString, + generateRandomId, +}; diff --git a/tsconfig.app.json b/tsconfig.app.json index 45ddfca0..ceea5615 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -9,6 +9,6 @@ "paths": { "@/*": ["./src/*"] }, - "types": ["naive-ui/volar"] + "types": ["naive-ui/volar", "unplugin-icons/types/vue"] } } diff --git a/vite.config.ts b/vite.config.ts index 0112ebd2..bca5bf6c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,6 +10,9 @@ import AutoImport from 'unplugin-auto-import/vite'; import Components from 'unplugin-vue-components/vite'; import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'; import Unocss from 'unocss/vite'; +import { configDefaults } from 'vitest/config'; +import Icons from 'unplugin-icons/vite'; +import IconsResolver from 'unplugin-icons/resolver'; // https://vitejs.dev/config/ export default defineConfig({ @@ -28,7 +31,7 @@ export default defineConfig({ enabled: true, }, }), - + Icons({ compiler: 'vue3' }), vue({ include: [/\.vue$/, /\.md$/], }), @@ -76,7 +79,7 @@ export default defineConfig({ dirs: ['src/'], extensions: ['vue', 'md'], include: [/\.vue$/, /\.vue\?vue/, /\.md$/], - resolvers: [NaiveUiResolver()], + resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })], }), Unocss(), ], @@ -88,4 +91,7 @@ export default defineConfig({ define: { 'import.meta.env.PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version), }, + test: { + exclude: [...configDefaults.exclude, '**/*.e2e.spec.ts'], + }, }); diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index 1c0d1e52..00000000 --- a/vitest.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { configDefaults, defineConfig } from 'vitest/config'; -import path from 'path'; - -export default defineConfig({ - resolve: { - alias: { - '@': path.resolve(__dirname, './src'), - }, - }, - test: { - exclude: [...configDefaults.exclude, '**/*.e2e.spec.ts'], - }, -});