diff --git a/apps/preview/src/App.tsx b/apps/preview/src/App.tsx index 3da53562..fb117992 100644 --- a/apps/preview/src/App.tsx +++ b/apps/preview/src/App.tsx @@ -1,4 +1,4 @@ -import { Button, ThemeProvider } from '@boolti/ui'; +import { Button, TextButton, ThemeProvider } from '@boolti/ui'; const Icon = () => ( @@ -184,6 +184,12 @@ const App = () => { BUTTON + TEXT BUTTON + }>TEXT BUTTON + TEXT BUTTON + } disabled> + TEXT BUTTON + ); diff --git a/packages/ui/src/components/Button/Button.style.ts b/packages/ui/src/components/Button/Button.style.ts index 837a7591..8a2b2042 100644 --- a/packages/ui/src/components/Button/Button.style.ts +++ b/packages/ui/src/components/Button/Button.style.ts @@ -21,93 +21,93 @@ const Container = styled.button` background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out; - ${(props) => { - switch (props.size) { + ${({ size, theme }) => { + switch (size) { case 'bold': return ` height: 48px; padding: 13px 20px; - ${props.theme.typo.sh1.styles}; + ${theme.typo.sh1.styles}; `; case 'medium': return ` height: 44px; padding: 11px 18px; - ${props.theme.typo.sh1.styles}; + ${theme.typo.sh1.styles}; `; case 'regular': return ` height: 40px; padding: 9px 16px; - ${props.theme.typo.sh1.styles}; + ${theme.typo.sh1.styles}; `; case 'small': return ` height: 36px; padding: 7px 14px; - ${props.theme.typo.sh1.styles}; + ${theme.typo.sh1.styles}; `; case 'x-small': return ` height: 32px; padding: 5px 12px; - ${props.theme.typo.b1.styles}; + ${theme.typo.b1.styles}; `; } }} - ${(props) => { - switch (props.colorTheme) { + ${({ colorTheme, theme }) => { + switch (colorTheme) { case 'primary': return ` - color: ${props.theme.palette.grey.g00}; - border-color: ${props.theme.palette.primary.o1}; - background-color: ${props.theme.palette.primary.o1}; - &:hover, &:active { - border-color: ${props.theme.palette.primary.o2}; - background-color: ${props.theme.palette.primary.o2}; + color: ${theme.palette.grey.g00}; + border-color: ${theme.palette.primary.o1}; + background-color: ${theme.palette.primary.o1}; + &:hover:not(:disabled), &:active:not(:disabled) { + border-color: ${theme.palette.primary.o2}; + background-color: ${theme.palette.primary.o2}; } &:disabled { - color: ${props.theme.palette.grey.g60}; - border-color: ${props.theme.palette.grey.g20}; - background-color: ${props.theme.palette.grey.g20}; + color: ${theme.palette.grey.g60}; + border-color: ${theme.palette.grey.g20}; + background-color: ${theme.palette.grey.g20}; } `; case 'netural': return ` - color: ${props.theme.palette.grey.g00}; - border-color: ${props.theme.palette.grey.g90}; - background-color: ${props.theme.palette.grey.g90}; - &:hover { + color: ${theme.palette.grey.g00}; + border-color: ${theme.palette.grey.g90}; + background-color: ${theme.palette.grey.g90}; + &:hover:not(:disabled) { border-color: #707070; background-color: #707070; } - &:active { - border-color: ${props.theme.palette.grey.g60}; - background-color: ${props.theme.palette.grey.g60}; + &:active:not(:disabled) { + border-color: ${theme.palette.grey.g60}; + background-color: ${theme.palette.grey.g60}; } &:disabled { - color: ${props.theme.palette.grey.g60}; - border-color: ${props.theme.palette.grey.g20}; - background-color: ${props.theme.palette.grey.g20}; + color: ${theme.palette.grey.g60}; + border-color: ${theme.palette.grey.g20}; + background-color: ${theme.palette.grey.g20}; } `; case 'line': return ` - color: ${props.theme.palette.grey.g90}; - border-color: ${props.theme.palette.grey.g90}; - background-color: ${props.theme.palette.grey.g00}; - &:hover { + color: ${theme.palette.grey.g90}; + border-color: ${theme.palette.grey.g90}; + background-color: ${theme.palette.grey.g00}; + &:hover:not(:disabled) { border-color: #707070; color: #707070; } - &:active { - color: ${props.theme.palette.grey.g60}; - border-color: ${props.theme.palette.grey.g60}; + &:active:not(:disabled) { + color: ${theme.palette.grey.g60}; + border-color: ${theme.palette.grey.g60}; } &:disabled { - color: ${props.theme.palette.grey.g40}; - border-color: ${props.theme.palette.grey.g20}; - background-color: ${props.theme.palette.grey.g10}; + color: ${theme.palette.grey.g40}; + border-color: ${theme.palette.grey.g20}; + background-color: ${theme.palette.grey.g10}; } `; } diff --git a/packages/ui/src/components/TextButton/TextButton.style.ts b/packages/ui/src/components/TextButton/TextButton.style.ts new file mode 100644 index 00000000..2a2d3e08 --- /dev/null +++ b/packages/ui/src/components/TextButton/TextButton.style.ts @@ -0,0 +1,38 @@ +import styled from '@emotion/styled'; + +const Container = styled.button` + cursor: pointer; + display: flex; + justify-content: center; + align-items: center; + border-radius: 4px; + height: 44px; + padding: 11px 18px; + border: none; + background-color: transparent; + transition: + background-color 0.2s ease-in-out, + color 0.2s ease-in-out; + color: ${({ theme }) => theme.palette.grey.g90}; + ${({ theme }) => theme.typo.sh1}; + &:disabled { + cursor: unset; + } + &:hover:not(:disabled) { + background-color: ${({ theme }) => theme.palette.grey.g20}; + } + &:disabled { + color: ${({ theme }) => theme.palette.grey.g60}; + } +`; + +const Icon = styled.div` + width: 20px; + height: 20px; + margin-right: 8px; +`; + +export default { + Container, + Icon, +}; diff --git a/packages/ui/src/components/TextButton/index.tsx b/packages/ui/src/components/TextButton/index.tsx new file mode 100644 index 00000000..d72ea73f --- /dev/null +++ b/packages/ui/src/components/TextButton/index.tsx @@ -0,0 +1,17 @@ +import Styled from './TextButton.style'; + +interface Props extends React.HTMLAttributes { + icon?: React.ReactNode; + disabled?: boolean; +} + +const Button = ({ children, icon, ...rest }: Props) => { + return ( + + {icon && {icon}} + {children} + + ); +}; + +export default Button; diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts index f0d80f5b..8b4d570e 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/ui/src/components/index.ts @@ -1,4 +1,5 @@ import ThemeProvider from './ThemeProvider'; import Button from './Button'; +import TextButton from './TextButton'; -export { ThemeProvider, Button }; +export { ThemeProvider, Button, TextButton };