-
Notifications
You must be signed in to change notification settings - Fork 11
feat(my-space): update company info banner to match new design #3168
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
Changes from all commits
2704309
e529bf2
cce8f2b
0112bcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| .banner { | ||
| background-color: var(--background-alt-blue-france); | ||
| } | ||
|
|
||
| .infoRow { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| gap: 0.5rem 1.5rem; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .datapoint { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| gap: 0.25rem; | ||
| margin: 0; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||
| // Addresses from INSEE/Weez come fully uppercased. Render them in title case | ||||||||||||||||||||||||||||||||||||||
| // while keeping digits and short connector words (de, du, la, le, les…) lowercase. | ||||||||||||||||||||||||||||||||||||||
| const LOWERCASE_WORDS = new Set([ | ||||||||||||||||||||||||||||||||||||||
| "de", | ||||||||||||||||||||||||||||||||||||||
| "du", | ||||||||||||||||||||||||||||||||||||||
| "des", | ||||||||||||||||||||||||||||||||||||||
| "la", | ||||||||||||||||||||||||||||||||||||||
| "le", | ||||||||||||||||||||||||||||||||||||||
| "les", | ||||||||||||||||||||||||||||||||||||||
| "et", | ||||||||||||||||||||||||||||||||||||||
| "en", | ||||||||||||||||||||||||||||||||||||||
| "aux", | ||||||||||||||||||||||||||||||||||||||
| "sur", | ||||||||||||||||||||||||||||||||||||||
| "sous", | ||||||||||||||||||||||||||||||||||||||
| "d", | ||||||||||||||||||||||||||||||||||||||
| "l", | ||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||
| * Converts a fully-uppercased INSEE/Weez address to title case. | ||||||||||||||||||||||||||||||||||||||
| * Short French connector words (de, du, la, le, …) are kept lowercase | ||||||||||||||||||||||||||||||||||||||
| * unless they appear as the first word of the address. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * @param address - The raw uppercase address string. | ||||||||||||||||||||||||||||||||||||||
| * @returns The address formatted in title case. | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| export function formatAddress(address: string): string { | ||||||||||||||||||||||||||||||||||||||
| return address | ||||||||||||||||||||||||||||||||||||||
| .toLocaleLowerCase("fr-FR") | ||||||||||||||||||||||||||||||||||||||
| .replace(/\p{L}+/gu, (word, offset: number) => { | ||||||||||||||||||||||||||||||||||||||
| if (offset > 0 && LOWERCASE_WORDS.has(word)) return word; | ||||||||||||||||||||||||||||||||||||||
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+34
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [CRITICAL]
|
||||||||||||||||||||||||||||||||||||||
| export function formatAddress(address: string): string { | |
| return address | |
| .toLocaleLowerCase("fr-FR") | |
| .replace(/\p{L}+/gu, (word, offset: number) => { | |
| if (offset > 0 && LOWERCASE_WORDS.has(word)) return word; | |
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | |
| }); | |
| } | |
| export function formatAddress(address: string): string { | |
| let firstWordCapitalised = false; | |
| return address | |
| .toLocaleLowerCase("fr-FR") | |
| .replace(/\p{L}+/gu, (word) => { | |
| if (firstWordCapitalised && LOWERCASE_WORDS.has(word)) return word; | |
| firstWordCapitalised = true; | |
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | |
| }); | |
| } |
This correctly capitalises the first alphabetic word regardless of any leading digits/punctuation, and keeps connector words lowercase thereafter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False positive: rue is not in LOWERCASE_WORDS (only connectors like de, du, la, le, les, et, en, aux, sur, sous, d, l). The existing test "12 RUE DE PARIS, 75001 PARIS" → "12 Rue de Paris, 75001 Paris" passes. The offset > 0 guard exists to capitalize a connector when it's the very first word (e.g. "LE MANS" → "Le Mans").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMPORTANT] Missing JSDoc on exported public function
Why it matters:
formatAddressis exported and non-trivial (locale-aware title-casing with a connector-word allowlist), so future readers benefit from a brief description.Proposed addition: