1- /* eslint react/no-did-mount-set-state: 0 */
2-
31import React from 'react' ;
4- import ReactDOM from 'react-dom' ;
5- import getOffset from 'dom-helpers/query/offset' ;
6- import css from 'dom-helpers/style' ;
2+ import AutoAffix from 'react-overlays/lib/AutoAffix' ;
73
8- import Affix from '../../src/Affix' ;
94import Nav from '../../src/Nav' ;
10- import SubNav from '../../src/SubNav' ;
115import NavItem from '../../src/NavItem' ;
126
137import NavMain from './NavMain' ;
@@ -17,32 +11,31 @@ import PageFooter from './PageFooter';
1711import ReactPlayground from './ReactPlayground' ;
1812import Samples from './Samples' ;
1913import Anchor from './Anchor' ;
14+ import SubNav from './SubNav' ;
2015
2116const ComponentsPage = React . createClass ( {
2217 getInitialState ( ) {
2318 return {
24- activeNavItemHref : null ,
25- navOffsetTop : null
19+ activeNavItemHref : null
2620 } ;
2721 } ,
2822
29- handleNavItemSelect ( key , href ) {
30- this . setState ( {
31- activeNavItemHref : href
32- } ) ;
23+ getMain ( ) {
24+ return this . refs . main ;
25+ } ,
3326
27+ handleNavItemSelect ( key , href ) {
3428 window . location = href ;
29+ this . setActiveNavItem ( ) ;
3530 } ,
3631
3732 componentDidMount ( ) {
38- let elem = ReactDOM . findDOMNode ( this . refs . sideNav ) ;
39- let sideNavOffsetTop = getOffset ( elem ) . top ;
40- let sideNavMarginTop = parseInt ( css ( elem . firstChild , 'marginTop' ) , 10 ) ;
41- let topNavHeight = ReactDOM . findDOMNode ( this . refs . topNav ) . offsetHeight ;
33+ this . setActiveNavItem ( ) ;
34+ } ,
4235
36+ setActiveNavItem ( ) {
4337 this . setState ( {
44- navOffsetTop : sideNavOffsetTop - topNavHeight - sideNavMarginTop ,
45- navOffsetBottom : ReactDOM . findDOMNode ( this . refs . footer ) . offsetHeight
38+ activeNavItemHref : window . location . hash
4639 } ) ;
4740 } ,
4841
@@ -55,7 +48,7 @@ const ComponentsPage = React.createClass({
5548 title = "Components"
5649 subTitle = "" />
5750
58- < div className = "container bs-docs-container" >
51+ < div ref = "main" className = "container bs-docs-container" >
5952 < div className = "row" >
6053 < div className = "col-md-9" role = "main" >
6154
@@ -965,58 +958,87 @@ const ComponentsPage = React.createClass({
965958 < h4 > < Anchor id = "utilities-fade-props" > Props</ Anchor > </ h4 >
966959 < PropTable component = "Fade" />
967960 </ div >
961+
962+ { /* Missing components */ }
963+ < div className = "bs-docs-section" >
964+ < h1 className = "page-header" > < Anchor id = "missing" > Missing components</ Anchor > </ h1 >
965+
966+ < p className = "lead" > We've intentionally omitted a few components from React-Bootstrap. Don't worry, though – we cover what to do in this section.</ p >
967+ </ div >
968+
969+ < div className = "bs-docs-section" >
970+ < h2 className = "page-header" > < Anchor id = "affix" > Affix</ Anchor > </ h2 >
971+
972+ < p > Use < a href = "http://react-bootstrap.github.io/react-overlays/examples/#affixes" > < code > { '<AutoAffix>' } </ code > or < code > { '<Affix>' } </ code > from react-overlays</ a > .</ p >
973+ < p > There isn't really any additional Bootstrap markup associated with affixes, so we didn't add a Bootstrap-specific affix class. The upstream ones already give you everything you need.</ p >
974+ </ div >
975+
976+ < div className = "bs-docs-section" >
977+ < h2 className = "page-header" > < Anchor id = "scrollspy" > Scrollspy</ Anchor > </ h2 >
978+
979+ < p > Setting up a scrollspy in idiomatic React requires wiring up a number of components across your entire page, both to handle elements scrolling in and to wire that up to the navigation. It's a poor fit for a component library, because it's not a standalone component.</ p >
980+ < p > To implement this functionality, use a library like < a href = "http://brigade.github.io/react-waypoint/" > React Waypoint</ a > along with a bit of your own state management.</ p >
981+ </ div >
968982 </ div >
969983
970984
971- < div className = "col-md-3" >
972- < Affix
973- className = "bs-docs-sidebar hidden-print"
974- role = "complementary"
975- offsetTop = { this . state . navOffsetTop }
976- offsetBottom = { this . state . navOffsetBottom } >
977- < Nav
978- className = "bs-docs-sidenav"
979- activeHref = { this . state . activeNavItemHref }
980- onSelect = { this . handleNavItemSelect }
981- ref = "sideNav" >
982- < SubNav href = "#buttons" key = { 1 } text = "Buttons" >
983- < NavItem href = "#btn-groups" key = { 2 } > Button groups</ NavItem >
984- < NavItem href = "#btn-dropdowns" key = { 3 } > Button dropdowns</ NavItem >
985- < NavItem href = "#menu-item" key = { 25 } > Menu Item</ NavItem >
986- </ SubNav >
987- < NavItem href = "#panels" key = { 4 } > Panels</ NavItem >
988- < NavItem href = "#modals" key = { 5 } > Modals</ NavItem >
989- < NavItem href = "#tooltips" key = { 6 } > Tooltips</ NavItem >
990- < NavItem href = "#popovers" key = { 7 } > Popovers</ NavItem >
991- < NavItem href = "#overlays" key = { 27 } > Overlays</ NavItem >
992- < NavItem href = "#progress" key = { 8 } > Progress bars</ NavItem >
993- < NavItem href = "#navs" key = { 9 } > Navs</ NavItem >
994- < NavItem href = "#navbars" key = { 10 } > Navbars</ NavItem >
995- < NavItem href = "#breadcrumbs" key = { 30 } > Breadcrumbs</ NavItem >
996- < NavItem href = "#tabs" key = { 11 } > Tabs</ NavItem >
997- < NavItem href = "#pager" key = { 12 } > Pager</ NavItem >
998- < NavItem href = "#pagination" key = { 13 } > Pagination</ NavItem >
999- < NavItem href = "#alerts" key = { 14 } > Alerts</ NavItem >
1000- < NavItem href = "#carousels" key = { 15 } > Carousels</ NavItem >
1001- < NavItem href = "#grids" key = { 16 } > Grids</ NavItem >
1002- < NavItem href = "#images" key = { 29 } > Images</ NavItem >
1003- < NavItem href = "#thumbnail" key = { 17 } > Thumbnail</ NavItem >
1004- < NavItem href = "#listgroup" key = { 18 } > List group</ NavItem >
1005- < NavItem href = "#labels" key = { 19 } > Labels</ NavItem >
1006- < NavItem href = "#badges" key = { 20 } > Badges</ NavItem >
1007- < NavItem href = "#jumbotron" key = { 21 } > Jumbotron</ NavItem >
1008- < NavItem href = "#page-header" key = { 22 } > Page Header</ NavItem >
1009- < NavItem href = "#responsive-embed" key = { 31 } > Responsive embed</ NavItem >
1010- < NavItem href = "#wells" key = { 23 } > Wells</ NavItem >
1011- < NavItem href = "#glyphicons" key = { 24 } > Glyphicons</ NavItem >
1012- < NavItem href = "#tables" key = { 25 } > Tables</ NavItem >
1013- < NavItem href = "#input" key = { 26 } > Input</ NavItem >
1014- < NavItem href = "#utilities" key = { 28 } > Utilities</ NavItem >
1015- </ Nav >
1016- < a className = "back-to-top" href = "#top" >
1017- Back to top
1018- </ a >
1019- </ Affix >
985+ < div className = "col-md-3 bs-docs-sidebar-holder" >
986+ < AutoAffix
987+ viewportOffsetTop = { 20 }
988+ container = { this . getMain }
989+ >
990+ < div
991+ className = "bs-docs-sidebar hidden-print"
992+ role = "complementary"
993+ >
994+ < Nav
995+ className = "bs-docs-sidenav"
996+ activeHref = { this . state . activeNavItemHref }
997+ onSelect = { this . handleNavItemSelect }
998+ >
999+ < SubNav href = "#buttons" key = { 1 } text = "Buttons" >
1000+ < NavItem href = "#btn-groups" key = { 2 } > Button groups</ NavItem >
1001+ < NavItem href = "#btn-dropdowns" key = { 3 } > Button dropdowns</ NavItem >
1002+ < NavItem href = "#menu-item" key = { 25 } > Menu Item</ NavItem >
1003+ </ SubNav >
1004+ < NavItem href = "#panels" key = { 4 } > Panels</ NavItem >
1005+ < NavItem href = "#modals" key = { 5 } > Modals</ NavItem >
1006+ < NavItem href = "#tooltips" key = { 6 } > Tooltips</ NavItem >
1007+ < NavItem href = "#popovers" key = { 7 } > Popovers</ NavItem >
1008+ < NavItem href = "#overlays" key = { 27 } > Overlays</ NavItem >
1009+ < NavItem href = "#progress" key = { 8 } > Progress bars</ NavItem >
1010+ < NavItem href = "#navs" key = { 9 } > Navs</ NavItem >
1011+ < NavItem href = "#navbars" key = { 10 } > Navbars</ NavItem >
1012+ < NavItem href = "#breadcrumbs" key = { 30 } > Breadcrumbs</ NavItem >
1013+ < NavItem href = "#tabs" key = { 11 } > Tabs</ NavItem >
1014+ < NavItem href = "#pager" key = { 12 } > Pager</ NavItem >
1015+ < NavItem href = "#pagination" key = { 13 } > Pagination</ NavItem >
1016+ < NavItem href = "#alerts" key = { 14 } > Alerts</ NavItem >
1017+ < NavItem href = "#carousels" key = { 15 } > Carousels</ NavItem >
1018+ < NavItem href = "#grids" key = { 16 } > Grids</ NavItem >
1019+ < NavItem href = "#images" key = { 29 } > Images</ NavItem >
1020+ < NavItem href = "#thumbnail" key = { 17 } > Thumbnail</ NavItem >
1021+ < NavItem href = "#listgroup" key = { 18 } > List group</ NavItem >
1022+ < NavItem href = "#labels" key = { 19 } > Labels</ NavItem >
1023+ < NavItem href = "#badges" key = { 20 } > Badges</ NavItem >
1024+ < NavItem href = "#jumbotron" key = { 21 } > Jumbotron</ NavItem >
1025+ < NavItem href = "#page-header" key = { 22 } > Page Header</ NavItem >
1026+ < NavItem href = "#responsive-embed" key = { 31 } > Responsive embed</ NavItem >
1027+ < NavItem href = "#wells" key = { 23 } > Wells</ NavItem >
1028+ < NavItem href = "#glyphicons" key = { 24 } > Glyphicons</ NavItem >
1029+ < NavItem href = "#tables" key = { 25 } > Tables</ NavItem >
1030+ < NavItem href = "#input" key = { 26 } > Input</ NavItem >
1031+ < NavItem href = "#utilities" key = { 28 } > Utilities</ NavItem >
1032+ < SubNav href = "#missing" key = { 32 } text = "Missing components" >
1033+ < NavItem href = "#affix" key = { 33 } > Affix</ NavItem >
1034+ < NavItem href = "#scrollspy" key = { 34 } > Scrollspy</ NavItem >
1035+ </ SubNav >
1036+ </ Nav >
1037+ < a className = "back-to-top" href = "#top" >
1038+ Back to top
1039+ </ a >
1040+ </ div >
1041+ </ AutoAffix >
10201042 </ div >
10211043 </ div >
10221044 </ div >
0 commit comments