-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbutton.js
More file actions
51 lines (49 loc) · 1.19 KB
/
Copy pathbutton.js
File metadata and controls
51 lines (49 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from "react"
import { StyledButton } from "./styled"
import { Icon } from "@/components/icon"
import { LoaderIcon } from "@/components/icon/components"
import Flex from "@/components/templates/flex"
export const Button = ({
label,
icon = null,
flavour,
isLoading,
loadingLabel,
onClick = () => {},
textTransform = "firstLetter",
iconColor,
iconSize,
iconWidth,
iconHeight,
children = label,
ref,
...rest
}) => (
<StyledButton
flavour={flavour}
textTransform={textTransform}
hasIcon={!!icon || isLoading}
hasLabel={!!children}
onClick={isLoading ? undefined : onClick}
ref={ref}
iconColor={iconColor}
iconWidth={iconWidth}
iconHeight={iconHeight}
{...rest}
>
{isLoading && <LoaderIcon className="button-icon" />}
{icon && !isLoading && (
<Flex justifyContent="center" alignItems="center" width="auto" height="100%">
<Icon
size={iconSize}
className="button-icon"
title={icon}
name={icon}
width={iconWidth}
height={iconHeight}
/>
</Flex>
)}
{!!children && <span>{(isLoading && loadingLabel) || children}</span>}
</StyledButton>
)