generated from bcgov/quickstart-openshift
-
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.
feat: [NMP-123] Field List Tab (#128)
- Loading branch information
1 parent
83cdb47
commit 0223a05
Showing
13 changed files
with
508 additions
and
29 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,8 @@ | ||
const RegionOptions = [ | ||
{ value: 0, label: 'Select a region' }, | ||
{ value: 1, label: 'Bulkley-Nechako' }, | ||
{ value: 2, label: 'Cariboo' }, | ||
{ value: 3, label: 'Columbia Shuswap' }, | ||
]; | ||
|
||
export default RegionOptions; |
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 React from 'react'; | ||
import { | ||
ModalWrapper, | ||
ModalContent, | ||
ModalHeader, | ||
ModalBody, | ||
ModalFooter, | ||
CloseButton, | ||
} from './modal.styles'; | ||
|
||
interface ModalProps { | ||
isVisible: boolean; | ||
title: string; | ||
children: React.ReactNode; | ||
onClose: () => void; | ||
footer?: React.ReactNode; | ||
} | ||
|
||
function Modal({ isVisible, title, children, onClose, footer }: ModalProps) { | ||
if (!isVisible) return null; | ||
|
||
return ( | ||
<ModalWrapper> | ||
<ModalContent> | ||
<ModalHeader> | ||
<h2>{title}</h2> | ||
<CloseButton onClick={onClose}>×</CloseButton> | ||
</ModalHeader> | ||
<ModalBody>{children}</ModalBody> | ||
{footer && <ModalFooter>{footer}</ModalFooter>} | ||
</ModalContent> | ||
</ModalWrapper> | ||
); | ||
} | ||
|
||
export default Modal; |
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,50 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const ModalWrapper = styled.div` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(0, 0, 0, 0.5); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 3000; | ||
`; | ||
|
||
export const ModalContent = styled.div` | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 8px; | ||
width: 500px; | ||
max-width: 100%; | ||
`; | ||
|
||
export const ModalHeader = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
border-bottom: 1px solid #ccc; | ||
padding-bottom: 10px; | ||
margin-bottom: 20px; | ||
`; | ||
|
||
export const ModalBody = styled.div` | ||
padding-bottom: 20px; | ||
`; | ||
|
||
export const ModalFooter = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
border-top: 1px solid #ccc; | ||
padding-top: 10px; | ||
margin-top: 20px; | ||
`; | ||
|
||
export const CloseButton = styled.button` | ||
background: none; | ||
border: none; | ||
font-size: 24px; | ||
cursor: pointer; | ||
`; |
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,41 @@ | ||
import React from 'react'; | ||
import { TabsWrapper, Tab, TabContent } from './tabs.styles'; | ||
|
||
interface TabProps { | ||
label: string; | ||
content: React.ReactNode; | ||
id: string; | ||
} | ||
|
||
interface TabsProps { | ||
tabs: TabProps[]; | ||
activeTab: number; | ||
setActiveTab?: (index: number) => void; | ||
} | ||
|
||
export function TabOptions({ tabs, activeTab, setActiveTab }: TabsProps) { | ||
return ( | ||
<TabsWrapper> | ||
<div> | ||
{tabs.map((tab, index) => ( | ||
<Tab | ||
key={tab.id} | ||
active={index === activeTab} | ||
onClick={() => setActiveTab && setActiveTab(index)} | ||
> | ||
{tab.label} | ||
</Tab> | ||
))} | ||
</div> | ||
</TabsWrapper> | ||
); | ||
} | ||
|
||
interface TabContentDisplayProps { | ||
tabs: TabProps[]; | ||
activeTab: number; | ||
} | ||
|
||
export function TabContentDisplay({ tabs, activeTab }: TabContentDisplayProps) { | ||
return <TabContent>{tabs[activeTab].content}</TabContent>; | ||
} |
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,27 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const TabsWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const Tab = styled.button<{ active: boolean }>` | ||
padding: 10px 20px; | ||
cursor: pointer; | ||
background-color: ${({ active }) => (active ? '#036' : '#ccc')}; | ||
color: ${({ active }) => (active ? '#fff' : '#000')}; | ||
border: none; | ||
border-bottom: ${({ active }) => (active ? '2px solid #fcba19' : 'none')}; | ||
border-radius: 5px; | ||
height: 50px; | ||
&:hover { | ||
background-color: #036; | ||
color: #fff; | ||
} | ||
`; | ||
|
||
export const TabContent = styled.div` | ||
padding: 20px; | ||
background-color: #fff; | ||
width: 100%; | ||
`; |
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 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
Oops, something went wrong.