Skip to content

Commit

Permalink
refactor: move getCssNameBySize fn (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js authored Oct 29, 2023
1 parent 03047f3 commit dff092f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/components/input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HTMLInputTypeAttribute } from 'react';
import input from './input.module.scss';
import { getCssNameBySize } from '@/utils/index';

interface InputProps {
type?: HTMLInputTypeAttribute;
Expand All @@ -13,17 +14,6 @@ interface InputProps {
validationMessage?: string;
}

const getCssNameBySize = (size: 'sm' | 'md' | 'lg') => {
switch (size) {
case 'sm':
return '--small';
case 'md':
return '--medium';
case 'lg':
return '--large';
}
};

export const Input = ({
type,
minLength,
Expand Down
4 changes: 4 additions & 0 deletions src/components/input/input.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
}
}

.kraken {
background-color: green;
}

.m_invalid {
border: 1px solid rgb(255, 124, 124);

Expand Down
10 changes: 10 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const getCssNameBySize = (size: 'sm' | 'md' | 'lg') => {
switch (size) {
case 'sm':
return '--small';
case 'md':
return '--medium';
case 'lg':
return '--large';
}
};
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"paths": {
"@/components/*": ["./src/components/*"],
"@/services/*": ["./src/services/*"],
"@/pages/*": ["./src/pages/*"]
"@/pages/*": ["./src/pages/*"],
"@/utils/*": ["./src/utils/*"]
},

/* Linting */
Expand Down
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default defineConfig({
find: '@/pages',
replacement: '/src/pages',
},
{
find: '@/utils',
replacement: '/src/utils',
},
],
},
optimizeDeps: {
Expand Down

0 comments on commit dff092f

Please sign in to comment.