-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create TabsHeader and TabsManager * Create cycle component * Update Event * Remove gap * Update tabs header * Add groups to event page * Fixes * join tabs components --------- Co-authored-by: Diego Alzate <[email protected]>
- Loading branch information
1 parent
f74069e
commit 85c263a
Showing
12 changed files
with
189 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import styled from 'styled-components'; | ||
import { FlexRowToColumn } from '../containers/FlexRowToColumn.styled'; | ||
|
||
export const CycleContainer = styled(FlexRowToColumn)` | ||
border: 1px solid var(--color-black); | ||
padding: 2rem; | ||
justify-content: space-between; | ||
border-radius: 0.5rem; | ||
`; |
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,32 @@ | ||
import { GetCycleResponse } from 'api'; | ||
import { Body } from '../typography/Body.styled'; | ||
import { CycleContainer } from './Cycles.styled'; | ||
|
||
type CyclesProps = { | ||
cycles: GetCycleResponse[] | undefined; | ||
errorMessage: string; | ||
}; | ||
|
||
function Cycles({ cycles, errorMessage }: CyclesProps) { | ||
const formatDate = (date: string) => { | ||
const eventEndDate = new Date(date); | ||
return eventEndDate.toLocaleDateString(); | ||
}; | ||
|
||
return ( | ||
<> | ||
{cycles?.length ? ( | ||
cycles.map((cycle) => ( | ||
<CycleContainer key={cycle.id}> | ||
<Body>{cycle.forumQuestions[0]?.questionTitle}</Body> | ||
<Body>{formatDate(cycle.endAt)}</Body> | ||
</CycleContainer> | ||
)) | ||
) : ( | ||
<Body>{errorMessage}</Body> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default Cycles; |
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 @@ | ||
export { default } from './Cycles'; |
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
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import styled from 'styled-components'; | ||
import { Body } from '../typography/Body.styled'; | ||
import { FlexRow } from '../containers/FlexRow.styled'; | ||
|
||
export const Tabs = styled(FlexRow)` | ||
justify-content: flex-start; | ||
@media (min-width: 600px) { | ||
justify-content: flex-end; | ||
} | ||
`; | ||
|
||
export const Tab = styled(Body)` | ||
cursor: pointer; | ||
text-transform: capitalize; | ||
&.active { | ||
font-weight: 600; | ||
text-decoration: underline; | ||
} | ||
`; |
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,36 @@ | ||
import { Fragment, useState } from 'react'; | ||
import { Body } from '../typography/Body.styled'; | ||
import { Tab, Tabs } from './TabsHeader.styled'; | ||
|
||
type TabsHeaderProps = { | ||
tabNames: string[]; | ||
initialTab?: string; | ||
onTabChange?: (tab: string) => void; | ||
}; | ||
|
||
export function TabsHeader({ tabNames, initialTab, onTabChange }: TabsHeaderProps) { | ||
const [activeTab, setActiveTab] = useState<string>(initialTab || tabNames[0]); | ||
|
||
const handleTabClick = (tab: string) => { | ||
setActiveTab(tab); | ||
if (onTabChange) { | ||
onTabChange(tab); | ||
} | ||
}; | ||
|
||
return ( | ||
<Tabs $gap="0.5rem"> | ||
{tabNames.map((tabName, index) => ( | ||
<Fragment key={tabName}> | ||
<Tab | ||
className={activeTab === tabName ? 'active' : ''} | ||
onClick={() => handleTabClick(tabName)} | ||
> | ||
{tabName} | ||
</Tab> | ||
{index < tabNames.length - 1 && <Body>/</Body>} | ||
</Fragment> | ||
))} | ||
</Tabs> | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
...src/components/tab-manager/TabManager.tsx → ...erlin/src/components/tabs/TabsManager.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
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,2 @@ | ||
export * from './TabsHeader'; | ||
export * from './TabsManager'; |
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