-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(form-admin-app): implement form support topics
- Loading branch information
Showing
9 changed files
with
255 additions
and
131 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,11 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const ActionsForm = styled.form` | ||
background: var(--goa-color-greyscale-100); | ||
border-top: 1px solid var(--goa-color-greyscale-200); | ||
flex: 0; | ||
padding-top: var(--goa-space-m); | ||
padding-bottom: var(--goa-space-s); | ||
padding-left: var(--goa-space-s); | ||
padding-right: var(--goa-space-s); | ||
`; |
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,73 @@ | ||
import { FunctionComponent, ReactNode, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
interface TabProps { | ||
heading: string; | ||
hide?: boolean; | ||
children: ReactNode; | ||
} | ||
export const Tab: FunctionComponent<TabProps> = ({ children }) => { | ||
return children; | ||
}; | ||
|
||
const TabContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 0; | ||
& > .heading { | ||
flex: 0; | ||
border-bottom: 1px solid var(--goa-color-greyscale-100); | ||
> button { | ||
border: none; | ||
padding: var(--goa-space-s); | ||
margin-right: var(--goa-space-xs); | ||
cursor: pointer; | ||
font: var(--goa-typography-body-m); | ||
} | ||
> button:hover, | ||
button[data-selected='true'] { | ||
border-bottom: 3px solid var(--goa-color-interactive-default); | ||
font: var(--goa-typography-heading-s); | ||
} | ||
} | ||
& > .content { | ||
flex: 1; | ||
min-height: 0; | ||
position: relative; | ||
> * { | ||
position: absolute; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
} | ||
> .content[data-selected='false'] { | ||
display: none; | ||
} | ||
`; | ||
|
||
interface TabsProps { | ||
children: React.ReactElement<TabProps>[]; | ||
} | ||
export const Tabs: FunctionComponent<TabsProps> = ({ children }) => { | ||
const [selected, setSelected] = useState(0); | ||
|
||
const available = children.filter((child) => !child.props.hide); | ||
|
||
return ( | ||
<TabContainer> | ||
<div className="heading"> | ||
{available.length > 1 && | ||
available.map((child, idx) => ( | ||
<button key={child.props.heading} data-selected={idx === selected} onClick={() => setSelected(idx)}> | ||
{child.props.heading} | ||
</button> | ||
))} | ||
</div> | ||
{available.map((child, idx) => ( | ||
<div className="content" data-selected={idx === selected}> | ||
{child} | ||
</div> | ||
))} | ||
</TabContainer> | ||
); | ||
}; |
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.