@@ -3,7 +3,7 @@ import styled from 'styled-components';
33import { IconType } from 'react-icons/lib' ;
44
55const IconButtonStyle = styled . button < {
6- pressed ?: boolean ;
6+ $ pressed ?: boolean ;
77 focusIndicator ?: 'browser' | 'specified' | 'none' ;
88} > `
99 display: inline-flex;
@@ -23,20 +23,20 @@ const IconButtonStyle = styled.button<{
2323 cursor: pointer;
2424 padding: 0.5rem 1rem;
2525
26- ${ ( { pressed } ) => ( {
27- borderColor : pressed ? '#2864f0' : '#d7d2d2' ,
28- background : pressed ? '#2864f0' : '#fff' ,
29- color : pressed ? '#fff' : '#323232' ,
26+ ${ ( { $ pressed } ) => ( {
27+ borderColor : $ pressed ? '#2864f0' : '#d7d2d2' ,
28+ background : $ pressed ? '#2864f0' : '#fff' ,
29+ color : $ pressed ? '#fff' : '#323232' ,
3030 } ) }
3131
3232 &:hover {
3333 color: #2864f0;
3434 border-color: #2864f0;
3535 background-color: #ebf3ff;
36- ${ ( { pressed } ) => ( {
37- color : pressed ? '#fff' : '#2864f0' ,
38- backgroundColor : pressed ? '#285ac8' : '#ebf3ff' ,
39- borderColor : pressed ? '#285ac8' : '#2864f0' ,
36+ ${ ( { $ pressed } ) => ( {
37+ color : $ pressed ? '#fff' : '#2864f0' ,
38+ backgroundColor : $ pressed ? '#285ac8' : '#ebf3ff' ,
39+ borderColor : $ pressed ? '#285ac8' : '#2864f0' ,
4040 } ) }
4141 }
4242 &:focus-visible {
@@ -68,19 +68,26 @@ export const IconButton = ({
6868 IconComponent,
6969 text,
7070 iconLabel,
71+ as,
72+ pressed,
7173 ...props
7274} : {
7375 IconComponent : IconType ;
7476 text ?: string ;
7577 iconLabel ?: string ;
76- } & React . ComponentProps < typeof IconButtonStyle > ) : JSX . Element => (
77- < IconButtonStyle { ...props } >
78+ as ?: React . ElementType ;
79+ pressed ?: boolean ;
80+ } & Omit <
81+ React . ComponentProps < typeof IconButtonStyle > ,
82+ 'as' | '$pressed'
83+ > ) : JSX . Element => (
84+ < IconButtonStyle as = { as } $pressed = { pressed } { ...props } >
7885 < span className = "icon" >
7986 < IconComponent
8087 aria-label = { iconLabel }
8188 aria-hidden = { iconLabel ? undefined : true }
8289 />
8390 </ span >
84- { text && < span className = "text" > { text } </ span > }
91+ { text ? < span className = "text" > { text } </ span > : undefined }
8592 </ IconButtonStyle >
8693) ;
0 commit comments