-
Notifications
You must be signed in to change notification settings - Fork 3
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
Contacts flow #60
Merged
Merged
Contacts flow #60
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
969ca57
chore: create contacts page
cryptosalomao 571cbd7
chore: add imperative translation
cryptosalomao c7aff91
chore: create notifications list
cryptosalomao 3446df0
chore: create Overview and Create Contact screens
cryptosalomao 959d3e6
Merge branch 'main' into flow/contacts
cryptosalomao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { useState } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { FormattedMessage } from "react-intl"; | ||
import { ChevronDownIcon, ChevronLeftIcon, SearchIcon } from "lucide-react"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { | ||
Select, | ||
SelectGroup, | ||
SelectValue, | ||
SelectTrigger, | ||
SelectContent, | ||
SelectItem, | ||
} from "@/components/ui/select"; | ||
import routes from "@/constants/routes"; | ||
|
||
function Header() { | ||
return ( | ||
<div className="flex flex-col gap-5 w-full"> | ||
<button className="flex items-center justify-center w-8 h-8 bg-[#1B0F00]/20 rounded-full border-[1px] border-[#1B0F00]/6"> | ||
<ChevronLeftIcon width={16} strokeWidth={1} color="#1B0F00" /> | ||
</button> | ||
<div className="flex justify-between items-center"> | ||
<h1 className="text-text-300 text-xl font-medium"> | ||
<FormattedMessage | ||
id="pages.createContact.header.title" | ||
defaultMessage="New contact" | ||
description="Title for create contact page" | ||
/> | ||
</h1> | ||
|
||
<Button | ||
className="gap-1 w-fit text-text-300 bg-transparent text-sm font-medium p-0 border-none hover:bg-transparent" | ||
variant="outline" | ||
> | ||
<SearchIcon className="w-4 h-4 text-text-300" /> | ||
<FormattedMessage | ||
id="pages.createContact.search" | ||
defaultMessage="Search contacts" | ||
description="Search contacts button" | ||
/> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function Form() { | ||
const [isExtraFieldsVisible, setIsExtraFieldsVisible] = useState(false); | ||
|
||
return ( | ||
<div className="flex-1 flex flex-col gap-3 w-full"> | ||
<Input id="name" label="Name" required /> | ||
<Input id="email" label="Email address" required /> | ||
<Input id="address" label="Postal address" required /> | ||
|
||
<Button | ||
className={`gap-1 w-fit text-text-200 bg-transparent text-sm font-medium p-0 border-none hover:bg-transparent mx-auto ${ | ||
isExtraFieldsVisible ? "hidden" : "flex" | ||
}`} | ||
variant="outline" | ||
onClick={() => setIsExtraFieldsVisible(!isExtraFieldsVisible)} | ||
> | ||
<FormattedMessage | ||
id="pages.createContact.viewAllFields" | ||
defaultMessage="View more" | ||
description="View more fields button" | ||
/> | ||
<ChevronDownIcon className="w-4 h-4 text-text-200" /> | ||
</Button> | ||
|
||
<div | ||
className={`flex flex-col gap-3 ${ | ||
isExtraFieldsVisible ? "block" : "hidden" | ||
}`} | ||
> | ||
<Input id="dateOfBirth" label="Date of birth (MM/DD/YYYY" /> | ||
<Select> | ||
<SelectTrigger label="Country of issuing" id="countryOfIssuing"> | ||
<SelectValue placeholder="Select an option" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
<SelectItem value="option1">Afghanistan</SelectItem> | ||
<SelectItem value="option2">Albania</SelectItem> | ||
<SelectItem value="option3">Algeria</SelectItem> | ||
<SelectItem value="option4">Andorra</SelectItem> | ||
<SelectItem value="option5">Angola</SelectItem> | ||
<SelectItem value="option6">Antigua and Barbuda</SelectItem> | ||
<SelectItem value="option7">Argentina</SelectItem> | ||
<SelectItem value="option8">Armenia</SelectItem> | ||
<SelectItem value="option9">Australia</SelectItem> | ||
<SelectItem value="option10">Austria</SelectItem> | ||
<SelectItem value="option11">Azerbaijan</SelectItem> | ||
<SelectItem value="option12">Bahamas</SelectItem> | ||
<SelectItem value="option13">Bahrain</SelectItem> | ||
<SelectItem value="option14">Bangladesh</SelectItem> | ||
<SelectItem value="option15">Barbados</SelectItem> | ||
<SelectItem value="option16">Belarus</SelectItem> | ||
<SelectItem value="option17">Belgium</SelectItem> | ||
<SelectItem value="option18">Belize</SelectItem> | ||
<SelectItem value="option19">Benin</SelectItem> | ||
<SelectItem value="option20">Bhutan</SelectItem> | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
|
||
<Input id="cityOfIssuing" label="City of birth" /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function Create() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="flex flex-col justify-between items-center gap-6 w-full min-h-fit h-screen py-4 px-5"> | ||
<Header /> | ||
<Form /> | ||
|
||
<div className="flex justify-between w-full gap-3"> | ||
<Button | ||
className="flex-1 w-full text-text-300 bg-transparent text-sm font-medium border-text-300 rounded-[8px] py-3 px-6 hover:bg-transparent" | ||
variant="outline" | ||
onClick={() => navigate(routes.CONTACTS)} | ||
> | ||
<FormattedMessage | ||
id="pages.createContact.cancel" | ||
defaultMessage="Cancel" | ||
description="Cancel contact creation button" | ||
/> | ||
</Button> | ||
|
||
<Button | ||
className="flex-1 w-full bg-text-300 text-white font-medium rounded-[8px] py-3 px-6" | ||
onClick={() => navigate(routes.CONTACTS)} | ||
> | ||
<FormattedMessage | ||
id="pages.createContact.save" | ||
defaultMessage="Save" | ||
description="Save contact button" | ||
/> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { useRef } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useIntl, FormattedMessage } from "react-intl"; | ||
import { EllipsisIcon, PlusIcon, SearchIcon } from "lucide-react"; | ||
import { Button } from "@/components/ui/button"; | ||
import routes from "@/constants/routes"; | ||
import contactsIllustration from "@/assets/contacts-illustration.svg"; | ||
|
||
function Search() { | ||
const intl = useIntl(); | ||
const searchFieldRef = useRef<HTMLInputElement>(null); | ||
|
||
const focusSearchField = () => { | ||
searchFieldRef.current?.focus(); | ||
}; | ||
|
||
return ( | ||
<div | ||
onClick={focusSearchField} | ||
className="flex items-center gap-2 h-[46px] py-[14px] px-4 border-[1px] border-divider-75 rounded-[8px]" | ||
> | ||
<SearchIcon className="w-4 h-4 text-text-300" /> | ||
|
||
<input | ||
ref={searchFieldRef} | ||
type="text" | ||
placeholder={intl.formatMessage({ | ||
id: "contacts.search.placeholder", | ||
defaultMessage: "Search for contacts...", | ||
description: "Placeholder text for search input", | ||
})} | ||
className="w-full bg-transparent text-text-300 text-sm font-medium placeholder-text-300 focus:outline-none" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
function Header() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="flex flex-col gap-3 w-full"> | ||
<div className="flex justify-between items-center"> | ||
<h1 className="text-text-300 text-xl font-medium"> | ||
<FormattedMessage | ||
id="contacts.header.title" | ||
defaultMessage="Contacts" | ||
description="Title for contacts page" | ||
/> | ||
</h1> | ||
|
||
<Button | ||
className="gap-1 p-0 h-fit text-text-300 text-xs font-medium no-underline hover:no-underline leading-[18px]" | ||
variant="link" | ||
onClick={() => navigate(routes.CREATE_CONTACT)} | ||
> | ||
<PlusIcon className="w-4 h-4 text-text-300" /> | ||
<FormattedMessage | ||
id="contacts.header.create" | ||
defaultMessage="New contact" | ||
description="Create contact button" | ||
/> | ||
</Button> | ||
</div> | ||
|
||
<Search /> | ||
</div> | ||
); | ||
} | ||
|
||
function Contact() { | ||
return ( | ||
<div className="flex justify-between items-center bg-elevation-200 py-4 px-5 rounded-[12px] select-none"> | ||
<div className="flex gap-3"> | ||
<div className="flex justify-center items-center bg-brand-100 h-9 w-9 rounded-full"> | ||
<span className="text-brand-200 text-xs font-medium">PH</span> | ||
</div> | ||
|
||
<div className="flex flex-col"> | ||
<span className="text-text-300 text-base font-medium leading-6"> | ||
Phoenix Baker | ||
</span> | ||
<span className="text-text-200 text-xs leading-[18px]">Catelog</span> | ||
</div> | ||
</div> | ||
|
||
<Button | ||
className="gap-1 p-0 h-fit text-text-300 text-xs font-medium no-underline hover:no-underline leading-[18px]" | ||
variant="link" | ||
> | ||
<EllipsisIcon className="w-6 h-6 text-text-300" /> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
function ContactsList() { | ||
return ( | ||
<div className="flex-1 flex flex-col gap-2 w-full"> | ||
<Contact /> | ||
<Contact /> | ||
<Contact /> | ||
<Contact /> | ||
</div> | ||
); | ||
} | ||
|
||
function EmptyList() { | ||
return ( | ||
<div className="flex-1 flex flex-col items-center justify-center w-52"> | ||
<img src={contactsIllustration} className="w-18 h-18 mx-auto mb-5" /> | ||
|
||
<div className="flex flex-col items-center gap-2 text-center mb-4"> | ||
<h2 className="text-text-300 text-xl font-medium leading-[30px]"> | ||
<FormattedMessage | ||
id="contacts.empty.title" | ||
defaultMessage="No contacts yet" | ||
description="Title for empty contacts list" | ||
/> | ||
</h2> | ||
|
||
<span className="text-text-200 text-md leading-6"> | ||
<FormattedMessage | ||
id="contacts.empty.description" | ||
defaultMessage="Create your first contact to start a relation" | ||
description="Description for empty contacts list" | ||
/> | ||
</span> | ||
</div> | ||
|
||
<Button | ||
className="w-fit text-text-300 bg-transparent text-sm font-medium border-text-300 rounded-[8px] py-3 px-6 hover:bg-transparent" | ||
variant="outline" | ||
> | ||
<FormattedMessage | ||
id="contacts.empty.create" | ||
defaultMessage="Create contact" | ||
description="Create contact button" | ||
/> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export default function Overview() { | ||
return ( | ||
<div className="flex flex-col justify-between items-center gap-6 w-full min-h-fit h-screen py-4 px-5"> | ||
<Header /> | ||
<ContactsList /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should placeholders already be localized with
FormattedMessage
?This applies to other non-translated fields/placeholders/etc. in this file.
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.
@mjkeaton just FYI please check #85
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.
Good catch, thank you! I'm gonna replace that. In this case, we must use the imperative API so we don't have to change the typedef for the component.
Ref: https://formatjs.github.io/docs/react-intl/api/#useintl-hook