From 85ee235821d0a2353ff1d5be39a50f987b670f73 Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Tue, 20 Jan 2026 12:24:44 +0545 Subject: [PATCH 1/5] refactor(ui/country): update css --- .../CountryDisplay/CountryDisplayDemo.tsx | 4 +- apps/demo/src/assets/css/country.css | 19 ++---- packages/ui/src/CountryDisplay/index.tsx | 31 ++++++---- .../ui/src/assets/css/country-display.css | 62 ++++++++++++------- 4 files changed, 64 insertions(+), 52 deletions(-) diff --git a/apps/demo/src/Views/Ui/components/CountryDisplay/CountryDisplayDemo.tsx b/apps/demo/src/Views/Ui/components/CountryDisplay/CountryDisplayDemo.tsx index 4e1200e2e..a3d612880 100644 --- a/apps/demo/src/Views/Ui/components/CountryDisplay/CountryDisplayDemo.tsx +++ b/apps/demo/src/Views/Ui/components/CountryDisplay/CountryDisplayDemo.tsx @@ -235,7 +235,7 @@ fallbackLocale = np; ( -
+
@@ -250,7 +250,7 @@ fallbackLocale = np; ( -
+
{label}
diff --git a/apps/demo/src/assets/css/country.css b/apps/demo/src/assets/css/country.css index 3f877a2d8..f405bdfad 100644 --- a/apps/demo/src/assets/css/country.css +++ b/apps/demo/src/assets/css/country.css @@ -1,17 +1,10 @@ -.country-wrapper { - display: flex; - flex-direction: column; - gap: 0.25rem; -} - -.custom-style { +.country-display .custom-render { + background-color: #eef2ff; + border: 1px solid var(--border-color, #e2e8f0); + border-radius: 1rem; display: inline-flex; align-items: center; - gap: 8px; - background: #eef2ff; - padding: 4px 12px; - border-radius: 20px; - border: 1px solid #c7d2fe; - color: #3730a3; + gap: 0.5rem; + padding: 0.25rem 1rem; width: 8rem; } diff --git a/packages/ui/src/CountryDisplay/index.tsx b/packages/ui/src/CountryDisplay/index.tsx index bebcb5e9b..7fcd270f7 100644 --- a/packages/ui/src/CountryDisplay/index.tsx +++ b/packages/ui/src/CountryDisplay/index.tsx @@ -4,6 +4,8 @@ import { getFallbackTranslation, getFlagClass } from "../utils/country-picker"; import type { Locales } from "../types"; +import "../assets/css/country-display.css"; + interface CountryDisplayProperties { className?: string; code: string; @@ -45,12 +47,11 @@ export const Country: React.FC = ({ ); }, [countryCode, locale, fallbackLocale, locales]); - const flagClass = useMemo( - () => getFlagClass(countryCode, flagsPosition, flagsStyle), - [countryCode, flagsPosition, flagsStyle], - ); + const flagClass = useMemo(() => { + return getFlagClass(countryCode, flagsPosition, flagsStyle); + }, [countryCode, flagsPosition, flagsStyle]); - const getFlagElement = () => { + const renderFlag = () => { if (!showFlag || !countryCode || countryLabel === countryCode) { return null; } @@ -69,16 +70,20 @@ export const Country: React.FC = ({ return ; }; - return renderOption && countryCode && countryLabel ? ( - renderOption(countryCode, countryLabel) - ) : ( - - {getFlagElement()} - {countryLabel ?? "-"} - + {renderOption && countryCode && countryLabel ? ( + renderOption(countryCode, countryLabel) + ) : ( +
+ {renderFlag()} + {countryLabel ?? "-"} +
+ )} +
); }; diff --git a/packages/ui/src/assets/css/country-display.css b/packages/ui/src/assets/css/country-display.css index 48e16689c..330c49534 100644 --- a/packages/ui/src/assets/css/country-display.css +++ b/packages/ui/src/assets/css/country-display.css @@ -1,41 +1,55 @@ -.country { - align-items: center; - display: inline-flex; - width: 100%; +.country-display { + overflow: hidden; + max-width: 100%; + white-space: nowrap; + text-overflow: ellipsis; + display: inline-block; vertical-align: middle; } -.country.is-code-only .flag-icon { - display: none; +.country-display > .country-content { + display: flex; + align-items: center; + gap: 0.5rem; + width: 100%; } -.country-label { - display: block; - flex: 0 1 auto; +.country-display > .country-content > .country-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - order: 1; } -.country .flag-icon { - margin-right: 0.5rem; - order: 0; - flex-shrink: 0; +.country-display > .country-content:has(.flag-icon-right) { + flex-direction: row-reverse; + justify-content: flex-end; +} + +.country-display :has(.flag-icon-right-edge) { + flex-direction: row-reverse; + justify-content: space-between; +} + +.country-display > .country-content > .flag-icon { + line-height: inherit; + min-width: 1.5rem; background-size: cover; background-position: center; - min-width: 1.5rem; - line-height: inherit; + flex-shrink: 0; } -.country .flag-icon-right { - margin-right: 0; - margin-left: 0.5rem; - order: 2; +.country-display > .country-content > .flag-icon-rounded, +.country-display > .country-content > .flag-icon-circle { + border-radius: 50%; + object-fit: cover; + width: 1.5rem; + height: 1.5rem; } -.country .flag-icon-right-edge { - margin-right: 0; - margin-left: auto; - order: 2; +.country-display > .country-content > .flag-icon-squared, +.country-display > .country-content > .flag-icon-square { + border-radius: 0; + object-fit: cover; + width: 1.5rem; + height: 1.5rem; } From 8eeee926dfdb31fa78ce0aba2ee491d36b573896 Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Tue, 20 Jan 2026 12:37:25 +0545 Subject: [PATCH 2/5] refactor(ui/country): update css --- .../ui/src/assets/css/country-display.css | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/assets/css/country-display.css b/packages/ui/src/assets/css/country-display.css index 330c49534..d697ed05d 100644 --- a/packages/ui/src/assets/css/country-display.css +++ b/packages/ui/src/assets/css/country-display.css @@ -7,47 +7,51 @@ vertical-align: middle; } -.country-display > .country-content { +.country-display > div { display: flex; align-items: center; gap: 0.5rem; width: 100%; } -.country-display > .country-content > .country-label { +.country-display .country-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.country-display > .country-content:has(.flag-icon-right) { +.country-display > div:has(.flag-icon-right), +.country-display > div:has(.flag-icon-right-edge) { flex-direction: row-reverse; - justify-content: flex-end; } -.country-display :has(.flag-icon-right-edge) { - flex-direction: row-reverse; +.country-display > div:has(.flag-icon-right-edge) { justify-content: space-between; } -.country-display > .country-content > .flag-icon { +.country-display .flag-icon { + display: inline-block; line-height: inherit; + width: 2rem; + height: 1.5rem; min-width: 1.5rem; background-size: cover; background-position: center; + background-repeat: no-repeat; flex-shrink: 0; + vertical-align: middle; } -.country-display > .country-content > .flag-icon-rounded, -.country-display > .country-content > .flag-icon-circle { +.country-display .flag-icon-rounded, +.country-display .flag-icon-circle { border-radius: 50%; object-fit: cover; width: 1.5rem; height: 1.5rem; } -.country-display > .country-content > .flag-icon-squared, -.country-display > .country-content > .flag-icon-square { +.country-display .flag-icon-squared, +.country-display .flag-icon-square { border-radius: 0; object-fit: cover; width: 1.5rem; From 42a2dd4e5e1481d147e9ea0a195a0a3ffb0bc60b Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Tue, 20 Jan 2026 16:46:08 +0545 Subject: [PATCH 3/5] refactor(ui/country): adjust css --- packages/ui/src/assets/css/country-display.css | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/assets/css/country-display.css b/packages/ui/src/assets/css/country-display.css index d697ed05d..18c55a5f0 100644 --- a/packages/ui/src/assets/css/country-display.css +++ b/packages/ui/src/assets/css/country-display.css @@ -25,6 +25,10 @@ flex-direction: row-reverse; } +.country-display > div:has(.flag-icon-right) { + justify-content: flex-end; +} + .country-display > div:has(.flag-icon-right-edge) { justify-content: space-between; } @@ -32,10 +36,7 @@ .country-display .flag-icon { display: inline-block; line-height: inherit; - width: 2rem; - height: 1.5rem; min-width: 1.5rem; - background-size: cover; background-position: center; background-repeat: no-repeat; flex-shrink: 0; @@ -46,14 +47,10 @@ .country-display .flag-icon-circle { border-radius: 50%; object-fit: cover; - width: 1.5rem; - height: 1.5rem; } .country-display .flag-icon-squared, .country-display .flag-icon-square { border-radius: 0; object-fit: cover; - width: 1.5rem; - height: 1.5rem; } From 91327d10f0ca886e2af4521810dfd94d98309dbb Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Wed, 21 Jan 2026 08:32:58 +0545 Subject: [PATCH 4/5] refactor(ui/country): sync css with vue --- packages/ui/src/CountryDisplay/index.tsx | 18 +++++++------ .../ui/src/assets/css/country-display.css | 25 ++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/ui/src/CountryDisplay/index.tsx b/packages/ui/src/CountryDisplay/index.tsx index 7fcd270f7..8d3c6f546 100644 --- a/packages/ui/src/CountryDisplay/index.tsx +++ b/packages/ui/src/CountryDisplay/index.tsx @@ -75,14 +75,16 @@ export const Country: React.FC = ({ className={`country-display ${className}`.trim()} data-country-code={countryCode} > - {renderOption && countryCode && countryLabel ? ( - renderOption(countryCode, countryLabel) - ) : ( -
- {renderFlag()} - {countryLabel ?? "-"} -
- )} +
+ {renderOption && countryCode && countryLabel ? ( + renderOption(countryCode, countryLabel) + ) : ( + <> + {renderFlag()} + {countryLabel ?? "-"} + + )} +
); }; diff --git a/packages/ui/src/assets/css/country-display.css b/packages/ui/src/assets/css/country-display.css index 18c55a5f0..1bc225826 100644 --- a/packages/ui/src/assets/css/country-display.css +++ b/packages/ui/src/assets/css/country-display.css @@ -1,15 +1,15 @@ .country-display { - overflow: hidden; + display: inline-block; max-width: 100%; - white-space: nowrap; + overflow: hidden; text-overflow: ellipsis; - display: inline-block; vertical-align: middle; + white-space: nowrap; } -.country-display > div { - display: flex; +.country-display > .country-content { align-items: center; + display: flex; gap: 0.5rem; width: 100%; } @@ -20,26 +20,23 @@ white-space: nowrap; } -.country-display > div:has(.flag-icon-right), -.country-display > div:has(.flag-icon-right-edge) { +.country-display > .country-content:has(.flag-icon-right) { flex-direction: row-reverse; -} - -.country-display > div:has(.flag-icon-right) { justify-content: flex-end; } -.country-display > div:has(.flag-icon-right-edge) { +.country-display > .country-content:has(.flag-icon-right-edge) { + flex-direction: row-reverse; justify-content: space-between; } .country-display .flag-icon { - display: inline-block; - line-height: inherit; - min-width: 1.5rem; background-position: center; background-repeat: no-repeat; + display: inline-block; flex-shrink: 0; + line-height: inherit; + min-width: 1.5rem; vertical-align: middle; } From 9017ea43084e71cbd8a2d6ac4f3dc99b1ef03880 Mon Sep 17 00:00:00 2001 From: Utsav Luintel Date: Thu, 22 Jan 2026 11:21:58 +0545 Subject: [PATCH 5/5] refactor(ui/country): remove unwanted css --- packages/ui/src/assets/css/country-display.css | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/ui/src/assets/css/country-display.css b/packages/ui/src/assets/css/country-display.css index 1bc225826..029ef8d9a 100644 --- a/packages/ui/src/assets/css/country-display.css +++ b/packages/ui/src/assets/css/country-display.css @@ -1,9 +1,7 @@ .country-display { - display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; - vertical-align: middle; white-space: nowrap; } @@ -31,23 +29,14 @@ } .country-display .flag-icon { - background-position: center; - background-repeat: no-repeat; - display: inline-block; - flex-shrink: 0; line-height: inherit; min-width: 1.5rem; - vertical-align: middle; } -.country-display .flag-icon-rounded, -.country-display .flag-icon-circle { - border-radius: 50%; +.country-display .flag-icon-rounded { object-fit: cover; } -.country-display .flag-icon-squared, -.country-display .flag-icon-square { +.country-display .flag-icon-squared { border-radius: 0; - object-fit: cover; }