-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor contact module according to design #954
Merged
Merged
Changes from all commits
Commits
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
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
75 changes: 75 additions & 0 deletions
75
src/components/customerCases/customerCase/contactInformation/ContactSelector.tsx
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,75 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
|
||
import EmployeeCard from "src/components/employeeCard/EmployeeCard"; | ||
import { Tag } from "src/components/tag"; | ||
import { ChewbaccaEmployee } from "src/types/employees"; | ||
import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; | ||
|
||
import styles from "./contactInformation.module.css"; | ||
|
||
export type ContactByLocationMap = { | ||
[locationId: string]: ChewbaccaEmployee; | ||
}; | ||
|
||
export interface ContactSelectorProps { | ||
language: string; | ||
locations: CompanyLocation[]; | ||
contactByLocation: ContactByLocationMap; | ||
employeePageSlug?: string; | ||
background: "dark" | "light"; | ||
} | ||
|
||
export default function ContactSelector({ | ||
language, | ||
locations, | ||
contactByLocation, | ||
employeePageSlug, | ||
background = "light", | ||
}: ContactSelectorProps) { | ||
const locationIds = Object.keys(contactByLocation); | ||
|
||
const [selectedLocationId, setSelectedLocationId] = useState<string | null>( | ||
locationIds[0], | ||
); | ||
|
||
if (locationIds.length === 0) { | ||
return; | ||
} | ||
|
||
const selectedOrDefaultLocationId = selectedLocationId ?? locationIds[0]; | ||
console.log(selectedLocationId); | ||
|
||
return ( | ||
<> | ||
<div className={styles.contactSelector}> | ||
<div className={styles.tagList} role="tablist"> | ||
{locations.map((location) => ( | ||
<Tag | ||
key={location._id} | ||
type="button" | ||
role="tab" | ||
background={background} | ||
aria-selected={selectedLocationId === location._id} | ||
aria-controls={`panel-${location._id}`} | ||
id={`tab-${location._id}`} | ||
active={selectedLocationId === location._id} | ||
onClick={() => setSelectedLocationId(location._id)} | ||
text={location.companyLocationName} | ||
/> | ||
))} | ||
</div> | ||
<div className={styles.employeeCard}> | ||
<div> | ||
<EmployeeCard | ||
language={language} | ||
employee={contactByLocation[selectedOrDefaultLocationId]} | ||
employeePageSlug={employeePageSlug} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
76 changes: 59 additions & 17 deletions
76
src/components/customerCases/customerCase/contactInformation/contactInformation.module.css
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 |
---|---|---|
@@ -1,32 +1,74 @@ | ||
.wrapper { | ||
display: flex; | ||
.contactBox { | ||
max-width: var(--max-content-width-large); | ||
} | ||
|
||
.contactBox__inner { | ||
--_contactBox__background: var(--background-bg-dark); | ||
--_contactBox__color: var(--text-primary-light); | ||
|
||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); | ||
|
||
padding: 1.5rem 3rem; | ||
flex-direction: column; | ||
margin: 4rem 0; | ||
justify-content: flex-end; | ||
align-items: flex-start; | ||
gap: var(--Padding-l, 48px); | ||
align-self: stretch; | ||
|
||
@media (min-width: 1024px) { | ||
align-items: center; | ||
} | ||
border-radius: var(--radius-small); | ||
background: var(--_contactBox__background); | ||
color: var(--_contactBox__color); | ||
} | ||
.contactBox__inner--light { | ||
--_contactBox__background: var(--background-bg-light-secondary); | ||
--_contactBox__color: var(--text-primary); | ||
} | ||
|
||
.content { | ||
.textContent { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
flex-direction: column; | ||
gap: 1rem; | ||
max-width: 960px; | ||
|
||
@media (max-width: 1024px) { | ||
flex-direction: column; | ||
gap: 2rem; | ||
} | ||
justify-content: flex-end; | ||
} | ||
|
||
.titleSection { | ||
.contactSelectorWrapper { | ||
container-type: inline-size; | ||
container-name: contactSelectorWrapper; | ||
} | ||
|
||
.contactSelector { | ||
display: flex; | ||
gap: 1rem; | ||
} | ||
|
||
.tagList { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.75rem; | ||
|
||
align-items: flex-start; | ||
min-width: 120px; | ||
} | ||
|
||
.contactSection { | ||
display: flex; | ||
gap: 1.5rem; | ||
.employeeCard { | ||
flex: 1; | ||
} | ||
|
||
@media (max-width: 400px) { | ||
.contactBox__inner { | ||
padding: 1rem 1rem; | ||
} | ||
} | ||
|
||
@container contactSelectorWrapper (max-width: 350px) { | ||
.contactSelector { | ||
flex-direction: column; | ||
} | ||
|
||
.tagList { | ||
flex-direction: row; | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
...ponents/customerCases/customerCase/contactInformation/contactSelector/ContactSelector.tsx
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
.../customerCases/customerCase/contactInformation/contactSelector/contactSelector.module.css
This file was deleted.
Oops, something went wrong.
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.
This shouldn't be awaited, but left a promise to utilise streaming and lazy loading of content (quicker load time)
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.
What do you mean? Should I not use Suspense?
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.
Like this
This will make the data be streamed from the server to the client but not have it block loading