Skip to content

Commit fe857b8

Browse files
authored
v0.3.9
2 parents 8a0dc12 + 474ab04 commit fe857b8

File tree

15 files changed

+128
-48
lines changed

15 files changed

+128
-48
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@channel.io/design-system",
3-
"version": "0.3.8",
3+
"version": "0.3.9",
44
"description": "Design System by Channel",
55
"repository": {
66
"type": "git",

src/foundation/Mixins.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export const absoluteCenter = (otherTransforms: any) => `
77
transform: translate(-50%, -50%) ${otherTransforms};
88
`
99

10+
export const disableAutoMinimum = css`
11+
min-width: 0;
12+
min-height: 0;
13+
`
14+
1015
export const hideScrollbars = () => css`
1116
-ms-overflow-style: none;
1217

src/hooks/useSideWidth.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,15 @@ import { useEffect } from 'react'
55
import { SIDE_FALLBACK_WIDTH } from '../constants/LayoutSizes'
66
import { ActionType } from '../layout/Client/utils/LayoutReducer'
77
import useLayoutDispatch from './useLayoutDispatch'
8-
import useLayoutState from './useLayoutState'
98

109
export default function useSideWidth(width: number = SIDE_FALLBACK_WIDTH) {
1110
const dispatch = useLayoutDispatch()
1211

13-
const { showSideView } = useLayoutState()
14-
1512
useEffect(() => {
1613
dispatch({
1714
type: ActionType.SET_SIDE_WIDTH,
1815
payload: width,
1916
})
20-
21-
return function cleanUp() {
22-
if (!showSideView) {
23-
dispatch({
24-
type: ActionType.SET_SIDE_WIDTH,
25-
payload: 0,
26-
})
27-
}
28-
}
29-
3017
/* eslint-disable-next-line react-hooks/exhaustive-deps */
3118
}, [])
3219

src/layout/Client/utils/LayoutReducer.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { omit } from 'lodash-es'
55
import { insertItem, removeItem } from '../../../utils/arrayUtils'
66
import ColumnType from '../../../types/ColumnType'
77

8+
interface SetShowSideActionPayload {
9+
showSideView?: boolean
10+
showSidePanel?: boolean
11+
}
12+
813
type ColumnRef = {
914
target: HTMLDivElement
1015
minWidth: number
@@ -21,9 +26,10 @@ export interface ColumnState {
2126
}
2227

2328
export interface LayoutState {
24-
/* Side View related */
29+
/* Side related */
2530
sideWidth: number
2631
showSideView: boolean
32+
showSidePanel: boolean
2733
/* Navigations related */
2834
showNavigation: boolean
2935
/* Resizing related */
@@ -35,6 +41,7 @@ export interface LayoutState {
3541
export const defaultState: LayoutState = {
3642
sideWidth: 0,
3743
showSideView: false,
44+
showSidePanel: false,
3845
showNavigation: true,
3946
orderedColumnKeys: [],
4047
columnRefs: {},
@@ -43,6 +50,7 @@ export const defaultState: LayoutState = {
4350

4451
export enum ActionType {
4552
SET_SIDE_WIDTH = 'SET_SIDE_WIDTH',
53+
SET_SHOW_SIDE = 'SET_SHOW_SIDE',
4654
OPEN_SIDE_VIEW = 'OPEN_SIDE_VIEW',
4755
CLOSE_SIDE_VIEW = 'CLOSE_SIDE_VIEW',
4856
SET_SHOW_NAVIGATION = 'SET_SHOW_NAVIGATION',
@@ -58,6 +66,11 @@ interface SetSideWidthAction {
5866
payload: number
5967
}
6068

69+
interface SetShowSideAction {
70+
type: ActionType.SET_SHOW_SIDE
71+
payload: SetShowSideActionPayload
72+
}
73+
6174
interface OpenSideViewAction {
6275
type: ActionType.OPEN_SIDE_VIEW
6376
}
@@ -101,6 +114,7 @@ interface RemoveColumnRefAction {
101114

102115
export type LayoutAction = (
103116
SetSideWidthAction |
117+
SetShowSideAction |
104118
OpenSideViewAction |
105119
CloseSideViewAction |
106120
SetShowNavigationAction |
@@ -120,6 +134,13 @@ function LayoutReducer(state: LayoutState = defaultState, action: LayoutAction):
120134
}
121135
}
122136

137+
case ActionType.SET_SHOW_SIDE: {
138+
return {
139+
...state,
140+
...action.payload,
141+
}
142+
}
143+
123144
case ActionType.OPEN_SIDE_VIEW: {
124145
return {
125146
...state,
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/* Internal dependencies */
2-
import { styled } from '../../foundation'
2+
import { styled, disableAutoMinimum } from '../../foundation'
33

44
export const ContentAreaWrapper = styled.div`
55
position: relative;
66
grid-row: 2;
77
grid-column: 1;
88
background-color: ${({ foundation }) => foundation?.theme?.['bg-white-normal']};
9+
10+
${disableAutoMinimum}
911
`

src/layout/HeaderArea/HeaderArea.styled.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Internal dependencies */
2-
import { styled } from '../../foundation'
2+
import { styled, disableAutoMinimum } from '../../foundation'
33

44
interface HeaderWrapperProps {
55
showSideView: boolean
@@ -17,14 +17,20 @@ export const HeaderWrapper = styled.div.attrs(({ showSideView, sideWidth }: Head
1717
grid-column: 1 / 3;
1818
background-color: ${({ foundation }) => foundation?.theme?.['bg-header']};
1919
border-bottom: 1px solid ${({ foundation }) => foundation?.theme?.['bdr-black-light']};
20+
21+
${disableAutoMinimum}
2022
`
2123

2224
export const ContentHeader = styled.div`
2325
grid-row: 1 / 2;
2426
grid-column: 1 / 2;
27+
28+
${disableAutoMinimum}
2529
`
2630

2731
export const CoverableHeader = styled.div`
2832
grid-row: 1 / 2;
2933
grid-column: 2 / 3;
34+
35+
${disableAutoMinimum}
3036
`

src/layout/Main/Main.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function Main(
2424
}: MainProps,
2525
forwardedRef: React.Ref<HTMLDivElement>,
2626
) {
27-
const { sideWidth, showSideView } = useLayoutState()
27+
const { sideWidth, showSideView, showSidePanel } = useLayoutState()
2828

29-
const hasSide = !isNil(SidePanelComponent) || showSideView
29+
const hasSide = showSideView || showSidePanel
3030
const hasHeader = !isNil(ContentHeaderComponent || CoverableHeaderComponent)
3131

3232
return (
@@ -47,8 +47,8 @@ function Main(
4747
{ children }
4848
</ContentArea>
4949

50-
<SidePanelComponent />
51-
<SideViewComponent />
50+
<SidePanelComponent/>
51+
<SideViewComponent/>
5252
</MainWrapper>
5353
)
5454
}

src/layout/Navigations/NavigationContent/NavigationContent.styled.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ export const StyledContentWrapper = styled.div<StyledContentWrapperProps>`
3535
height: 100%;
3636
overflow-x: hidden;
3737
overflow-y: ${({ withScroll }) => (withScroll ? 'auto' : 'hidden')};
38-
39-
& > *:last-child {
40-
margin-bottom: 40px !important;
41-
}
4238
`
4339

4440
export const StyledFooterWrapper = styled.div`

src/layout/Side/SideArea/SideArea.styled.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Internal dependencies */
2-
import { css, styled } from '../../../foundation'
2+
import { css, styled, disableAutoMinimum } from '../../../foundation'
33
import LayoutSideType from '../../../constants/LayoutSideType'
44

55
interface SideAreaWrapperProps {
@@ -12,10 +12,11 @@ export const SideAreaWrapper = styled.div<SideAreaWrapperProps>`
1212
grid-row: ${({ sideType }) => (sideType === LayoutSideType.SidePanel ? '2 / 3' : '1 / 3')};
1313
grid-column: 2;
1414
background-color: ${({ foundation }) => foundation?.theme?.['bg-grey-lightest']};
15-
1615
${({ showSideView, sideType }) => showSideView && sideType === LayoutSideType.SidePanel && css`
1716
display: none;
1817
`}
18+
19+
${disableAutoMinimum}
1920
`
2021

2122
export const ScrollWrapper = styled.div`

src/layout/Side/SideArea/SideArea.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { noop, clamp } from 'lodash-es'
44
import { document } from 'ssr-window'
55

66
/* Internal dependencies */
7-
import LayoutSideType from '../../../constants/LayoutSideType'
87
import useEventHandler from '../../../hooks/useEventHandler'
98
import useLayoutState from '../../../hooks/useLayoutState'
109
import useResizingHandlers from '../../../hooks/useResizingHandlers'
@@ -40,10 +39,6 @@ function SideArea(
4039
const contentKey = useMemo(() => (orderedColumnKeys[orderedColumnKeys.length - 1]), [orderedColumnKeys])
4140
const contentRef = useMemo(() => (columnRefs[contentKey]?.target), [columnRefs, contentKey])
4241

43-
const hideSideView = useMemo(() => (
44-
sideType === LayoutSideType.SideView && !showSideView
45-
), [showSideView, sideType])
46-
4742
const handleResizerMouseMove = useCallback((e: HTMLElementEventMap['mousemove']) => {
4843
if (
4944
handleResizing(e) &&
@@ -89,10 +84,6 @@ function SideArea(
8984
useEventHandler(document, 'mousemove', handleResizerMouseMove, isDragging)
9085
useEventHandler(document, 'mouseup', handleResizerMouseUp)
9186

92-
if (hideSideView) {
93-
return null
94-
}
95-
9687
return (
9788
<SideAreaWrapper
9889
data-testId={testId}

src/layout/Side/SidePanelContent/SidePanelContent.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/* External dependencies */
2-
import React from 'react'
2+
import React, { useEffect } from 'react'
33
import { noop } from 'lodash-es'
44

55
/* Internal dependencies */
66
import LayoutSideType from '../../../constants/LayoutSideType'
77
import { SideArea } from '../SideArea'
8+
import { ActionType } from '../../Client/utils/LayoutReducer'
9+
import useLayoutDispatch from '../../../hooks/useLayoutDispatch'
810
import SidePanelContentProps from './SidePanelContent.types'
911

1012
export const SIDE_PANEL_CONTENT_TEST_ID = 'ch-design-system-side-panel-content'
@@ -14,6 +16,27 @@ function SidePanelContent({
1416
children,
1517
onChangeSideWidth = noop,
1618
}: SidePanelContentProps) {
19+
const dispatch = useLayoutDispatch()
20+
21+
useEffect(() => {
22+
dispatch({
23+
type: ActionType.SET_SHOW_SIDE,
24+
payload: {
25+
showSidePanel: true,
26+
},
27+
})
28+
29+
return function cleanup() {
30+
dispatch({
31+
type: ActionType.SET_SHOW_SIDE,
32+
payload: {
33+
showSidePanel: false,
34+
},
35+
})
36+
}
37+
// eslint-disable-next-line react-hooks/exhaustive-deps
38+
}, [])
39+
1740
return (
1841
<SideArea
1942
sideType={LayoutSideType.SidePanel}

src/layout/Side/SideViewContent/SideViewContent.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
/* External dependencies */
2-
import React from 'react'
2+
import React, { useEffect } from 'react'
33
import { noop } from 'lodash-es'
44

55
/* Internal dependencies */
66
import LayoutSideType from '../../../constants/LayoutSideType'
77
import { SideArea } from '../SideArea'
8+
import useLayoutDispatch from '../../../hooks/useLayoutDispatch'
9+
import { ActionType } from '../../Client/utils/LayoutReducer'
810
import SideViewContentProps from './SideViewContent.types'
911

1012
export const SIDE_VIEW_CONTENT_TEST_ID = 'ch-design-system-side-view-content'
1113

12-
function SidePanelContent({
14+
function SideViewContent({
1315
testId = SIDE_VIEW_CONTENT_TEST_ID,
1416
children,
1517
onChangeSideWidth = noop,
1618
}: SideViewContentProps) {
19+
const dispatch = useLayoutDispatch()
20+
21+
useEffect(() => {
22+
dispatch({
23+
type: ActionType.SET_SHOW_SIDE,
24+
payload: {
25+
showSideView: true,
26+
},
27+
})
28+
29+
return function cleanup() {
30+
dispatch({
31+
type: ActionType.SET_SHOW_SIDE,
32+
payload: {
33+
showSideView: false,
34+
},
35+
})
36+
}
37+
// eslint-disable-next-line react-hooks/exhaustive-deps
38+
}, [])
39+
1740
return (
1841
<SideArea
1942
data-testId={testId}
@@ -25,4 +48,4 @@ function SidePanelContent({
2548
)
2649
}
2750

28-
export default SidePanelContent
51+
export default SideViewContent

src/layout/stories/LayoutPlayground/Content.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import useLayoutState from '../../../hooks/useLayoutState'
77
import useSideView from '../../../hooks/useSideView'
88
import { styled } from '../../../foundation'
99
import { ActionType } from '../../Client/utils/LayoutReducer'
10+
import { Text } from '../../../components/Text'
1011

1112
const Div = styled.div`
1213
display: flex;
@@ -20,7 +21,12 @@ const Div = styled.div`
2021
function Content() {
2122
const dispatch = useLayoutDispatch()
2223

23-
const { showNavigation } = useLayoutState()
24+
const {
25+
showNavigation,
26+
sideWidth,
27+
showSideView,
28+
showSidePanel,
29+
} = useLayoutState()
2430

2531
const [handleOpenSideView, handleCloseSideView] = useSideView()
2632

@@ -33,6 +39,11 @@ function Content() {
3339

3440
return (
3541
<Div>
42+
<div>
43+
<Text as="div">{ `sideWidth: ${sideWidth}px` }</Text>
44+
<Text as="div">{ `showSideView: ${showSideView ? 'true' : 'false'}` }</Text>
45+
<Text as="div">{ `showSidePanel: ${showSidePanel ? 'true' : 'false'}` }</Text>
46+
</div>
3647
<button type="button" onClick={handleOpenSideView}>사이드뷰 열기</button>
3748
<button type="button" onClick={handleCloseSideView}>사이드뷰 닫기</button>
3849
<button type="button" onClick={handleToggleNavigation}>네비게이션 토글</button>

0 commit comments

Comments
 (0)