-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor contact module according to design
- Loading branch information
Showing
6 changed files
with
161 additions
and
121 deletions.
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.
5 changes: 0 additions & 5 deletions
5
src/components/customerCases/customerCase/customerCase.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