Skip to content

Commit

Permalink
fix: add className props
Browse files Browse the repository at this point in the history
  • Loading branch information
im36-123 committed Nov 1, 2019
1 parent 821d131 commit 75d3f20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/components/AccordionPanel/AccordionPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useCallback, useState } from 'react'

import { mapToArray, arrayToMap } from './AccordionPanelHelper'
import { InjectedProps, withTheme } from '../../hocs/withTheme'

type Props = InjectedProps & {
type Props = {
children: React.ReactNode
icon?: 'left' | 'right' | 'none'
expandableMultiply?: boolean
defaultExpanded?: string[]
className?: string
onClick?: (expandedItems: string[]) => void
}

Expand All @@ -17,12 +17,13 @@ export const AccordionPanelContext = React.createContext<any>({
onClick: () => {},
})

const AccordionPanelComponent: React.FC<Props> = ({
onClick,
export const AccordionPanel: React.FC<Props> = ({
children,
icon = 'left',
expandableMultiply = false,
defaultExpanded = [],
...props
className = '',
onClick,
}) => {
const [expandedItems, setExpanded] = useState(new Map(arrayToMap(defaultExpanded)))

Expand All @@ -45,9 +46,7 @@ const AccordionPanelComponent: React.FC<Props> = ({

return (
<AccordionPanelContext.Provider value={{ onClick: handleClick, expandedItems, icon }}>
<div {...props} />
<div className={className} children={children} />
</AccordionPanelContext.Provider>
)
}

export const AccordionPanel = withTheme(AccordionPanelComponent)
8 changes: 3 additions & 5 deletions src/components/AccordionPanel/AccordionPanelItem.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react'
import { withTheme } from '../../hocs/withTheme'

type Props = {
children: React.ReactNode
name: string
className?: string
}

type ContextType = Omit<Props, 'children'>
Expand All @@ -12,16 +12,14 @@ export const AccordionPanelItemContext = React.createContext<ContextType>({
name: '',
})

const AccordionPanelItemComponent: React.FC<Props> = ({ children, name }) => {
export const AccordionPanelItem: React.FC<Props> = ({ children, name, className = '' }) => {
return (
<AccordionPanelItemContext.Provider
value={{
name,
}}
>
{children}
<div className={className}> {children}</div>
</AccordionPanelItemContext.Provider>
)
}

export const AccordionPanelItem = withTheme(AccordionPanelItemComponent)

0 comments on commit 75d3f20

Please sign in to comment.