-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from dabapps/app-root-component
App root component interacts with NavBar and Footer
- Loading branch information
Showing
33 changed files
with
909 additions
and
101 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
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 @@ | ||
last 10 Chrome versions | ||
last 10 Firefox versions | ||
last 10 Edge versions | ||
last 10 iOS versions | ||
last 10 Android versions | ||
last 10 Opera versions | ||
last 10 Safari versions | ||
last 10 ExplorerMobile versions | ||
Explorer >= 9 |
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,111 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { | ||
AppRoot, | ||
Button, | ||
Column, | ||
Container, | ||
ContentBox, | ||
ContentBoxFooter, | ||
ContentBoxHeader, | ||
DabIpsum, | ||
Footer, | ||
NavBar, | ||
Row, | ||
Section, | ||
SpacedGroup, | ||
} from '../src/ts'; | ||
|
||
const app = document.createElement('app'); | ||
|
||
document.body.appendChild(app); | ||
|
||
ReactDOM.render( | ||
( | ||
<AppRoot> | ||
<NavBar shy> | ||
<Container> | ||
<h1 className="display-inline font-size-large"> | ||
NavBar | ||
</h1> | ||
|
||
<SpacedGroup className="float-right"> | ||
<Button> | ||
Login | ||
</Button> | ||
</SpacedGroup> | ||
</Container> | ||
</NavBar> | ||
|
||
<Container> | ||
<h1> | ||
Example | ||
</h1> | ||
|
||
<DabIpsum /> | ||
|
||
<ContentBox> | ||
<ContentBoxHeader> | ||
<h2> | ||
Example | ||
</h2> | ||
</ContentBoxHeader> | ||
|
||
<Section> | ||
<Row> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
</Row> | ||
</Section> | ||
|
||
<Section> | ||
<Row> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
<Column sm={6} md={3}> | ||
Column 1 | ||
</Column> | ||
</Row> | ||
</Section> | ||
|
||
<ContentBoxFooter> | ||
<SpacedGroup block className="padding-vertical-base"> | ||
<Button> | ||
Cancel | ||
</Button> | ||
<Button className="primary"> | ||
Submit | ||
</Button> | ||
</SpacedGroup> | ||
</ContentBoxFooter> | ||
</ContentBox> | ||
</Container> | ||
|
||
<Footer sticky> | ||
<Container> | ||
<p> | ||
Footer | ||
</p> | ||
</Container> | ||
</Footer> | ||
</AppRoot> | ||
), | ||
app | ||
); |
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,3 @@ | ||
{ | ||
"extends": "../tsconfig.json" | ||
} |
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,4 @@ | ||
.app-root { | ||
position: relative; | ||
min-height: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.footer { | ||
height: @footer-height; | ||
background-color: @footer-background; | ||
border-top: @footer-border; | ||
|
||
&.sticky { | ||
position: absolute; | ||
left: 0; | ||
bottom: 0; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
body.with-fixed-nav-bar { | ||
padding-top: @nav-bar-height; | ||
} | ||
|
||
.nav-bar { | ||
.clearfix(); | ||
padding: @padding-base 0; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#### Example | ||
|
||
```js static | ||
<AppRoot> | ||
<NavBar shy> | ||
<Container> | ||
NavBar | ||
</Container> | ||
</NavBar> | ||
|
||
<Container> | ||
<h1> | ||
Content | ||
</h1> | ||
</Container> | ||
|
||
<Footer sticky> | ||
<Container> | ||
Footer | ||
</Container> | ||
</Footer> | ||
</AppRoot> | ||
``` |
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,53 @@ | ||
import * as classNames from 'classnames'; | ||
import * as React from 'react'; | ||
import { HTMLProps, PureComponent } from 'react'; | ||
import store, { StoreState } from '../../store'; | ||
import { ComponentProps } from '../../types'; | ||
|
||
export type AppRootProps = HTMLProps<HTMLElement> & ComponentProps & StoreState; | ||
|
||
/** | ||
* This is the most important part of your app. | ||
* This component interacts with other Roe components to adjust styles at the root level. | ||
* Your app must have an AppRoot if you wish to used a fixed / shy NavBar or sticky Footer. | ||
*/ | ||
export class AppRootUnconnected extends PureComponent<AppRootProps, {}> { | ||
public render () { | ||
const { | ||
component: Component = 'div', | ||
children, | ||
className, | ||
hasStickyFooter, | ||
hasFixedNavBar, | ||
navBarHeight, | ||
footerHeight, | ||
...remainingProps, | ||
} = this.props; | ||
|
||
const myClassNames = [ | ||
'app-root', | ||
hasStickyFooter && 'has-sticky-footer' || null, | ||
hasFixedNavBar && 'has-fixed-nav-bar' || null, | ||
className, | ||
]; | ||
|
||
const style = { | ||
paddingTop: hasFixedNavBar && navBarHeight, | ||
paddingBottom: hasStickyFooter && footerHeight, | ||
}; | ||
|
||
return ( | ||
<Component | ||
{...remainingProps} | ||
className={classNames(myClassNames)} | ||
style={style} | ||
> | ||
{children} | ||
</Component> | ||
); | ||
} | ||
} | ||
|
||
export const AppRoot = store.connect(AppRootUnconnected); | ||
|
||
export default AppRoot; |
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,17 @@ | ||
#### Example | ||
|
||
```js | ||
<Footer> | ||
<p> | ||
Footer | ||
</p> | ||
</Footer> | ||
``` | ||
|
||
#### Less variables | ||
|
||
```less | ||
@footer-background: @body-background; | ||
@footer-border: @border-base; | ||
@footer-height: auto; | ||
``` |
Oops, something went wrong.