From 7540a131aa41b9fa6d14b3cf644c1c3e21e8a713 Mon Sep 17 00:00:00 2001 From: im36-123 Date: Mon, 28 Oct 2019 19:27:20 +0900 Subject: [PATCH] feat: add style --- src/components/Accordion/AccordionTrigger.tsx | 89 ++++++++++++++----- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/src/components/Accordion/AccordionTrigger.tsx b/src/components/Accordion/AccordionTrigger.tsx index 09a984203c..9528f62194 100644 --- a/src/components/Accordion/AccordionTrigger.tsx +++ b/src/components/Accordion/AccordionTrigger.tsx @@ -1,17 +1,23 @@ import React, { useContext } from 'react' -import { withTheme } from '../../hocs/withTheme' +import { withTheme, InjectedProps } from '../../hocs/withTheme' import { AccordionContext } from './Accordion' +import styled, { css } from 'styled-components' type Props = { - children: React.ReactElement | string - disabled?: boolean + children: React.ReactNode className?: string + prefix?: React.ReactNode + suffix?: React.ReactNode } -const AccordionTriggerComponent: React.SFC = ({ +type MergedProps = Props & InjectedProps + +const AccordionTriggerComponent: React.SFC = ({ children, - disabled = false, className = '', + prefix = '', + suffix = '', + theme, }) => { const { expanded, name, onClick } = useContext(AccordionContext) @@ -20,29 +26,64 @@ const AccordionTriggerComponent: React.SFC = ({ } return ( - + {prefix && {prefix}} + {children} + {suffix && {suffix}} + ) } -AccordionTriggerComponent.displayName = 'AccordionTriggerComponent' - export const AccordionTrigger = withTheme(AccordionTriggerComponent) + +const resetButtonStyle = css` + background-color: transparent; + border: none; + outline: none; + padding: 0; + appearance: none; +` + +const Button = styled.button` + ${resetButtonStyle} + ${({ theme }: InjectedProps) => { + const { size, palette } = theme + + return css` + display:flex; + align-items: center; + width: 100%; + height: 40px; + padding: 0 ${size.pxToRem(size.space.XS)} + color: ${palette.TEXT_BLACK}; + font-size: ${size.pxToRem(size.font.TALL)}; + text-align: left; + cursor: pointer; + ` + }} +` + +const Prefix = styled.span` + ${({ theme }: InjectedProps) => { + const { size } = theme + + return css` + display: inline-flex; + margin-right: ${size.pxToRem(size.space.XXS)}; + ` + }} +` +const Suffix = styled.span` + ${({ theme }: InjectedProps) => { + const { size } = theme + + return css` + display: inline-flex; + margin-left: ${size.pxToRem(size.space.XXS)}; + ` + }} +`