Skip to content

Commit

Permalink
fix: AccordionPanel -> AccordionPanelItem
Browse files Browse the repository at this point in the history
  • Loading branch information
im36-123 committed Oct 31, 2019
1 parent 1d0dd75 commit c221c65
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/components/AccordionPanel/AccordionPanel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { storiesOf } from '@storybook/react'
import React, { useState } from 'react'
import styled from 'styled-components'

import { AccordionPanel } from './AccordionPanel'
import { AccordionPanelItem } from './AccordionPanelItem'
import { AccordionPanelTrigger } from './AccordionPanelTrigger'
import { AccordionPanelContent } from './AccordionPanelContent'
import { Base as BaseComponent } from '../Base'
Expand Down Expand Up @@ -31,7 +31,7 @@ storiesOf('AccordionPanel', module)
<ul>
{arr.map((_, index) => (
<li className="border" key={index}>
<AccordionPanel
<AccordionPanelItem
name={`left-icon-${index}`}
expanded={state === `left-icon-${index}`}
onClick={handleClick}
Expand All @@ -42,7 +42,7 @@ storiesOf('AccordionPanel', module)
<div>{lorem}</div>
</Content>
</AccordionPanelContent>
</AccordionPanel>
</AccordionPanelItem>
</li>
))}
</ul>
Expand All @@ -51,7 +51,7 @@ storiesOf('AccordionPanel', module)
<ul>
{arr.map((_, index) => (
<li className="border" key={index}>
<AccordionPanel
<AccordionPanelItem
name={`right-icon-${index}`}
expanded={state === `right-icon-${index}`}
icon="right"
Expand All @@ -61,7 +61,7 @@ storiesOf('AccordionPanel', module)
<AccordionPanelContent>
<Content>{lorem}</Content>
</AccordionPanelContent>
</AccordionPanel>
</AccordionPanelItem>
</li>
))}
</ul>
Expand All @@ -70,7 +70,7 @@ storiesOf('AccordionPanel', module)
<ul>
{arr.map((_, index) => (
<li className="border" key={index}>
<AccordionPanel
<AccordionPanelItem
name={`no-icon-${index}`}
expanded={state === `no-icon-${index}`}
icon="none"
Expand All @@ -80,7 +80,7 @@ storiesOf('AccordionPanel', module)
<AccordionPanelContent>
<Content>{lorem}</Content>
</AccordionPanelContent>
</AccordionPanel>
</AccordionPanelItem>
</li>
))}
</ul>
Expand All @@ -89,7 +89,7 @@ storiesOf('AccordionPanel', module)
<ul>
{arr.map((_, index) => (
<li key={index}>
<AccordionPanel
<AccordionPanelItem
name={`no-border-${index}`}
expanded={state === `no-border-${index}`}
icon="none"
Expand All @@ -99,7 +99,7 @@ storiesOf('AccordionPanel', module)
<AccordionPanelContent>
<Content>{lorem}</Content>
</AccordionPanelContent>
</AccordionPanel>
</AccordionPanelItem>
</li>
))}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions src/components/AccordionPanel/AccordionPanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useCallback } from 'react'
import styled from 'styled-components'
import { Transition } from 'react-transition-group'
import { InjectedProps, withTheme } from '../../hocs/withTheme'
import { AccordionPanelContext } from './AccordionPanel'
import { AccordionPanelItemContext } from './AccordionPanelItem'

type Props = {
children: React.ReactNode
Expand All @@ -13,7 +13,7 @@ const AccordionPanelContentComponent: React.FC<Props & InjectedProps> = ({
children,
className = '',
}) => {
const { expanded, name } = useContext(AccordionPanelContext)
const { expanded, name } = useContext(AccordionPanelItemContext)
const wrapperRef = React.useRef<HTMLDivElement>(null)

const handleEntering = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ type Props = {

type ContextType = Omit<Props, 'children'>

export const AccordionPanelContext = React.createContext<ContextType>({
export const AccordionPanelItemContext = React.createContext<ContextType>({
expanded: false,
name: '',
icon: 'left',
onClick: () => {},
})

const AccordionPanelComponent: React.FC<Props> = ({
const AccordionPanelItemComponent: React.FC<Props> = ({
children,
name,
expanded = false,
icon = 'left',
onClick,
}) => {
return (
<AccordionPanelContext.Provider
<AccordionPanelItemContext.Provider
value={{
expanded,
name,
Expand All @@ -35,8 +35,8 @@ const AccordionPanelComponent: React.FC<Props> = ({
}}
>
{children}
</AccordionPanelContext.Provider>
</AccordionPanelItemContext.Provider>
)
}

export const AccordionPanel = withTheme(AccordionPanelComponent)
export const AccordionPanelItem = withTheme(AccordionPanelItemComponent)
4 changes: 2 additions & 2 deletions src/components/AccordionPanel/AccordionPanelTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react'
import { withTheme, InjectedProps } from '../../hocs/withTheme'
import { AccordionPanelContext } from './AccordionPanel'
import { AccordionPanelItemContext } from './AccordionPanelItem'
import styled, { css } from 'styled-components'
import { isTouchDevice } from '../../libs/ua'
import { Icon as IconComponent } from '../Icon'
Expand All @@ -17,7 +17,7 @@ const AccordionPanelTriggerComponent: React.SFC<MergedProps> = ({
className = '',
theme,
}) => {
const { expanded, name, onClick, icon } = useContext(AccordionPanelContext)
const { expanded, name, onClick, icon } = useContext(AccordionPanelItemContext)

const expandedClassName = expanded ? 'expanded' : ''
const buttonClassNames = `${className} ${expandedClassName} ${icon}`
Expand Down
2 changes: 1 addition & 1 deletion src/components/AccordionPanel/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { AccordionPanel } from './AccordionPanel'
export { AccordionPanelItem } from './AccordionPanelItem'
export { AccordionPanelContent } from './AccordionPanelContent'
export { AccordionPanelTrigger } from './AccordionPanelTrigger'
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export { Heading } from './components/Heading'
export { HeadlineArea } from './components/HeadlineArea'
export { Select } from './components/Select'
export {
AccordionPanel,
AccordionPanelItem,
AccordionPanelContent,
AccordionPanelTrigger,
} from './components/AccordionPanel'
Expand Down

0 comments on commit c221c65

Please sign in to comment.