Skip to content

Commit

Permalink
v0.3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoo0122 authored Apr 5, 2021
2 parents 0dc0ac2 + 308bac7 commit ac0fb7b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@channel.io/design-system",
"version": "0.3.13",
"version": "0.3.14",
"description": "Design System by Channel",
"repository": {
"type": "git",
Expand Down
22 changes: 6 additions & 16 deletions src/layout/Side/SideViewContent/SideViewContent.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* External dependencies */
import React, { useEffect } from 'react'
import React from 'react'
import { noop } from 'lodash-es'

/* Internal dependencies */
import useLayoutState from '../../../hooks/useLayoutState'
import LayoutSideType from '../../../types/LayoutSideType'
import { SideArea } from '../SideArea'
import useLayoutDispatch from '../../../hooks/useLayoutDispatch'
import LayoutActions from '../../redux/LayoutActions'
import SideViewContentProps from './SideViewContent.types'

export const SIDE_VIEW_CONTENT_TEST_ID = 'ch-design-system-side-view-content'
Expand All @@ -16,20 +15,11 @@ function SideViewContent({
children,
onChangeSideWidth = noop,
}: SideViewContentProps) {
const dispatch = useLayoutDispatch()
const { showSideView } = useLayoutState()

useEffect(() => {
dispatch(LayoutActions.setShowSide({
showSideView: true,
}))

return function cleanup() {
dispatch(LayoutActions.setShowSide({
showSideView: false,
}))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
if (!showSideView) {
return null
}

return (
<SideArea
Expand Down
16 changes: 8 additions & 8 deletions src/layout/redux/LayoutReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { ColumnRef, ColumnState, LayoutActionTypes } from './LayoutActions'

export interface LayoutState {
/* Header related */
showContentHeader: boolean | undefined
showCoverableHeader: boolean | undefined
showContentHeader: boolean
showCoverableHeader: boolean
/* Side related */
sideWidth: number
showSideView: boolean | undefined
showSidePanel: boolean | undefined
showSideView: boolean
showSidePanel: boolean
/* Navigations related */
showNavigation: boolean
/* Resizing related */
Expand All @@ -24,11 +24,11 @@ export interface LayoutState {
}

export const defaultState: LayoutState = {
showContentHeader: undefined,
showCoverableHeader: undefined,
showContentHeader: false,
showCoverableHeader: false,
sideWidth: 0,
showSideView: undefined,
showSidePanel: undefined,
showSideView: false,
showSidePanel: false,
showNavigation: true,
orderedColumnKeys: [],
columnRefs: {},
Expand Down
10 changes: 3 additions & 7 deletions src/layout/stories/LayoutPlayground/LayoutPlayGround.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Navigations from '../../Navigations/Navigations'
import { SidePanelContent } from '../../Side/SidePanelContent'
import { SideViewContent } from '../../Side/SideViewContent'
import { NavigationContent } from '../../Navigations/NavigationContent'
import useLayoutState from '../../../hooks/useLayoutState'
import Content from './Content'
import ContentHeader from './ContentHeader'
import CoverableHeader from './CoverableHeader'
Expand Down Expand Up @@ -83,17 +82,14 @@ function UserChatSidePanel({ onChangeWidth }) {
}

function SideViewRoute({ onChangeWidth }) {
const { showSideView } = useLayoutState()

if (!showSideView) {
return null
}
const [state, setState] = useState(Math.random() * 100)

return (
<SideViewContent
onChangeSideWidth={onChangeWidth}
>
<Div style={{ height: 2000 }}>SideView</Div>
<Div style={{ height: 2000 }}>{ state }</Div>
<button onClick={() => setState(Math.random() * 100)} type="button">regenerate</button>
</SideViewContent>
)
}
Expand Down

0 comments on commit ac0fb7b

Please sign in to comment.