Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix phone input height #585

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions client/components/forms/PhoneInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<v-select
v-model="selectedCountryCode"
class="w-[130px]"
:class="theme.PhoneInput.countrySelectWidth"
dropdown-class="max-w-[300px]"
input-class="rounded-r-none"
:data="countries"
Expand Down Expand Up @@ -41,13 +41,14 @@
<template #selected="props">
<div
class="flex items-center space-x-2 justify-center overflow-hidden"
:class="theme.PhoneInput.maxHeight"
>
<country-flag
size="normal"
class="!-mt-[9px] rounded"
:country="props.option.code"
/>
<span>{{ props.option.dial_code }}</span>
<span class="text-sm">{{ props.option.dial_code }}</span>
</div>
</template>
</v-select>
Expand All @@ -57,11 +58,11 @@
class="inline-flex-grow !border-l-0 !rounded-l-none"
:disabled="disabled ? true : null"
:class="[
theme.default.input,
theme.default.spacing.horizontal,
theme.default.spacing.vertical,
theme.default.fontSize,
theme.default.borderRadius,
theme.PhoneInput.input,
theme.PhoneInput.spacing.horizontal,
theme.PhoneInput.spacing.vertical,
theme.PhoneInput.fontSize,
theme.PhoneInput.borderRadius,
{
'!ring-red-500 !ring-2': hasError,
'!cursor-not-allowed !bg-gray-200': disabled,
Expand Down
84 changes: 75 additions & 9 deletions client/lib/forms/themes/form-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,40 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
Comment on lines +76 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider refactoring duplicated PhoneInput configurations

The PhoneInput configurations added to the default theme are identical to those in the simple (lines 227-248) and notion (lines 372-393) themes. To improve maintainability and reduce redundancy, consider extracting the common PhoneInput settings into a shared base configuration that can be reused across all themes.

You can create a base configuration like this:

+// Define a base PhoneInput configuration
const basePhoneInputConfig = {
  countrySelectWidth: {
    sm: 'w-[100px]',
    md: 'w-[120px]',
    lg: 'w-[120px]',
  },
  flag: {
    sm: '!-mt-[14px]',
    md: '!-mt-[9px] rounded',
    lg: '!-mt-[9px] rounded',
  },
  flagSize: {
    sm: 'small',
    md: 'normal',
    lg: 'normal',
  },
  maxHeight: {
    sm: 'max-h-[20px]',
    md: 'max-h-[24px]',
    lg: 'max-h-[28px]',
  },
};

And then reference it within each theme:

 default: {
   // ... other configurations
-  PhoneInput: { /* existing configuration */ },
+  PhoneInput: basePhoneInputConfig,
   // ... other configurations
 },
 simple: {
   // ... other configurations
-  PhoneInput: { /* existing configuration */ },
+  PhoneInput: basePhoneInputConfig,
   // ... other configurations
 },
 notion: {
   // ... other configurations
-  PhoneInput: { /* existing configuration */ },
+  PhoneInput: basePhoneInputConfig,
   // ... other configurations
 },

Committable suggestion was skipped due to low confidence.

DateInput: {
input:
'flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10 p-0.5',
md: 'h-6 w-12 p-1',
Expand All @@ -101,7 +123,7 @@ export const themes = {
lg: 'translate-x-6'
}
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down Expand Up @@ -202,17 +224,39 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
DateInput: {
input: 'flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 placeholder-gray-400 text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10',
md: 'h-6 w-12',
Expand All @@ -224,7 +268,7 @@ export const themes = {
lg: 'h-4 w-4'
},
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down Expand Up @@ -325,17 +369,39 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
DateInput: {
input: 'shadow-inner-notion border-transparent focus:border-transparent flex-1 appearance-none w-full bg-notion-input-background dark:bg-notion-dark-light text-gray-900 dark:text-gray-100 placeholder-gray-400 text-base focus:outline-none focus:ring-0 focus:border-transparent focus:shadow-focus-notion p-[1px]'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10',
md: 'h-6 w-12',
Expand All @@ -347,7 +413,7 @@ export const themes = {
lg: 'h-4 w-4'
},
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down
Loading