Skip to content

Commit

Permalink
Added the option to display optional phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
mar2n committed Aug 26, 2024
1 parent 572fc31 commit 8dcd815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "0.0.47",
"version": "0.0.48",
"name": "@vygruppen/docs",
"description": "The Spor documentation",
"license": "MIT",
Expand Down
10 changes: 9 additions & 1 deletion packages/spor-react/src/input/PhoneNumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type PhoneNumberInputProps = Omit<BoxProps, "onChange"> & {
/** The optional value of the country code and phone number */
value?: CountryCodeAndPhoneNumber;
variant?: "base" | "floating";
isOptional?: boolean;
};
/**
* A component for entering phone numbers.
Expand All @@ -51,12 +52,13 @@ export const PhoneNumberInput = forwardRef<PhoneNumberInputProps, As>(
value: externalValue,
onChange: externalOnChange,
variant,
isOptional,
...boxProps
},
ref,
) => {
const { t } = useTranslation();
const label = externalLabel ?? t(texts.phoneNumber);
const label = externalLabel ?? isOptional ? t(texts.phoneNumberOptional) : t(texts.phoneNumber);
const [value, onChange] = useControllableState({
value: externalValue,
onChange: externalOnChange,
Expand Down Expand Up @@ -125,6 +127,12 @@ const texts = createTexts({
en: "Phone number",
sv: "Telefonnummer",
},
phoneNumberOptional: {
nb: "Telefonnummer (valgfritt)",
nn: "Telefonnummer (valgfritt)",
en: "Phone number (optional)",
sv: "Telefonnummer (valfritt)",
},
countryCodeLabel: {
nb: "Landskode",
nn: "Landskode",
Expand Down

0 comments on commit 8dcd815

Please sign in to comment.