Skip to content

Commit

Permalink
fix(docz-theme-default): prevent sidebar toggle on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Sep 4, 2018
1 parent 38325e5 commit 7a3b97d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/docz-theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"react-live": "^1.11.0",
"react-perfect-scrollbar": "^1.2.0",
"react-powerplug": "^1.0.0-rc.1",
"react-sizes": "^1.0.4",
"webfontloader": "^1.6.28"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import { SFC } from 'react'
import { Docs, Entry, DocsRenderProps } from 'docz'
import { Toggle, State } from 'react-powerplug'
import withSizes from 'react-sizes'
import styled from 'react-emotion'
import match from 'match-sorter'

Expand Down Expand Up @@ -137,7 +138,11 @@ const Composed: SFC<ComposedProps> = ({ children }) => (
</Docs>
)

export const Sidebar = () => (
interface SidebarProps {
isDesktop: boolean
}

const SidebarBase: SFC<SidebarProps> = ({ isDesktop }) => (
<Composed>
{({ menus, docs: initialDocs, toggle, on, state, setState }) => {
const docs = state.docs || initialDocs
Expand All @@ -161,6 +166,7 @@ export const Sidebar = () => (
}

const handleSidebarToggle = () => {
if (isDesktop) return
toggle && toggle()
}

Expand Down Expand Up @@ -208,3 +214,9 @@ export const Sidebar = () => (
}}
</Composed>
)

const mapSizesToProps = ({ width }: { width: number }) => ({
isDesktop: width >= breakpoints.desktop,
})

export const Sidebar = withSizes(mapSizesToProps)(SidebarBase)
1 change: 1 addition & 0 deletions packages/docz-theme-default/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ declare module 'react-feather/dist/icons/minimize'
declare module 'react-feather/dist/icons/refresh-cw'
declare module 'react-lightweight-tooltip'
declare module 'react-powerplug'
declare module 'react-sizes'
declare module 're-resizable'
declare module 'webfontloader'

Expand Down
1 change: 1 addition & 0 deletions packages/docz-theme-default/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const externalList = [
'react-feather/dist/icons/maximize',
'react-feather/dist/icons/minimize',
'react-feather/dist/icons/refresh-cw',
'react-sizes',
]

const deps = Object.keys(pkg.dependencies)
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12116,6 +12116,13 @@ react-router@^4.3.1:
prop-types "^15.6.1"
warning "^4.0.1"

react-sizes@^1.0.4:
version "1.0.4"
resolved "https://registry.npmjs.org/react-sizes/-/react-sizes-1.0.4.tgz#7f09beddf972afe6f8662a0ffe446baac35f6bc5"
dependencies:
lodash.throttle "^4.1.1"
prop-types "^15.6.0"

react-timer-mixin@^0.13.2, react-timer-mixin@^0.13.3:
version "0.13.4"
resolved "https://registry.yarnpkg.com/react-timer-mixin/-/react-timer-mixin-0.13.4.tgz#75a00c3c94c13abe29b43d63b4c65a88fc8264d3"
Expand Down

0 comments on commit 7a3b97d

Please sign in to comment.