Skip to content

Commit

Permalink
refactor(fe): add hide spin button util style (#2109)
Browse files Browse the repository at this point in the history
* refactor(fe): add hide spin button util style, delete hide scroll bar plugin

* fix(fe): fix pnpm lock file

* chore(fe): add import type declaration
  • Loading branch information
B0XERCAT authored Sep 24, 2024
1 parent 811fa44 commit 3176a9f
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default function RegisterButton({
})}
type="number"
className={cn(
'h-12 w-full [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',
'hide-spin-button h-12 w-full',
errors.invitationCode &&
'border-red-500 focus-visible:ring-red-500'
)}
Expand Down
6 changes: 1 addition & 5 deletions apps/frontend/app/admin/_components/SwitchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ export default function SwitchField({
id={name}
type={type}
placeholder={placeholder}
className={cn(
inputStyle,
'h-[36px] w-[380px]',
'[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none'
)}
className={cn(inputStyle, 'hide-spin-button h-[36px] w-[380px]')}
{...register(name, {
onChange: () => trigger(name)
})}
Expand Down
6 changes: 1 addition & 5 deletions apps/frontend/app/admin/contest/[id]/_components/Columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import OptionSelect from '@/components/OptionSelect'
import { Badge } from '@/components/ui/badge'
import { Input } from '@/components/ui/input'
import { GET_BELONGED_CONTESTS } from '@/graphql/contest/queries'
import { cn } from '@/lib/utils'
import type { Level } from '@/types/type'
import { useQuery } from '@apollo/client'
import type { ColumnDef, Row } from '@tanstack/react-table'
Expand Down Expand Up @@ -72,10 +71,7 @@ export const columns = (
<div className="flex justify-center">
<Input
defaultValue={row.getValue('score')}
className={cn(
'w-[70px] focus-visible:ring-0',
'[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none'
)}
className="hide-spin-button w-[70px] focus-visible:ring-0"
type="number"
min={0}
onKeyDown={(e) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend/app/admin/problem/_components/TestcaseItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ export default function TestcaseItem({
type="number"
min={0}
className={cn(
'h-5 w-8 rounded-sm border text-center text-xs',
'[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',
'hide-spin-button h-5 w-8 rounded-sm border text-center text-xs',
isInvalid(getValues('testcases')[index].scoreWeight)
? 'border-red-500'
: 'border-gray-300'
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/components/auth/ResetPasswordEmailVerify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default function ResetPasswordEmailVerify() {
<Input
type="number"
className={cn(
'[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',
'hide-spin-button',
inputFocused && 'ring-1 focus-visible:ring-1 disabled:ring-0',
errors.verificationCode || codeError
? 'ring-red-500 focus-visible:ring-red-500'
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/components/auth/SignUpEmailVerify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default function SignUpEmailVerify() {
<Input
type="number"
className={cn(
'mt-2 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',
'hide-spin-button mt-2',
'focus-visible:border-primary w-full focus-visible:ring-0',
(errors.verificationCode || expired || codeError) &&
'border-red-500 focus-visible:border-red-500'
Expand Down
1 change: 0 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"msw": "^2.4.1",
"postcss": "^8.4.41",
"tailwind-merge": "^2.5.2",
"tailwind-scrollbar-hide": "^1.1.7",
"tailwindcss": "^3.4.10",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.5.4",
Expand Down
19 changes: 18 additions & 1 deletion apps/frontend/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import typography from '@tailwindcss/typography'
import type { Config } from 'tailwindcss'
import animate from 'tailwindcss-animate'
import defaultTheme from 'tailwindcss/defaultTheme'
import type { PluginAPI } from 'tailwindcss/types/config'

export default {
darkMode: ['class'],
Expand Down Expand Up @@ -70,5 +71,21 @@ export default {
}
}
},
plugins: [animate, typography, require('tailwind-scrollbar-hide')]
plugins: [
animate,
typography,
function ({ addUtilities }: { addUtilities: PluginAPI['addUtilities'] }) {
addUtilities({
'.hide-spin-button': {
appearance: 'textfield',
'&::-webkit-inner-spin-button': {
appearance: 'none'
},
'&::-webkit-outer-spin-button': {
appearance: 'none'
}
}
})
}
]
} satisfies Config
108 changes: 81 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3176a9f

Please sign in to comment.