Kaynağa Gözat

Redesign buttons

Tatiana Inama 7 yıl önce
ebeveyn
işleme
306ca37306

+ 10 - 8
recipes/src/components/Button/index.tsx

@@ -1,5 +1,4 @@
 import React, { ReactElement } from 'react';
-import Button from '@material/react-button';
 import Icon from 'components/Icon';
 import IconButton from '@material/react-icon-button';
 
@@ -19,12 +18,18 @@ type CBKButtonProps = {
   icon?: string,
   onClick?: (e: any) => void,
   small?: boolean,
-  type?: string
+  type?: 'button' | 'submit' | 'reset';
   disabled?: boolean
   style?: any;
 }
 
 export default function CBKButton(props: CBKButtonProps) {
+  const btnClassNames = classnames({
+    'cbk-btn': true,
+    'cbk-btn--raised': props.raised,
+    'cbk-btn--unelevated': props.unelevated,
+    'cbk-btn--outlined': props.outlined,
+  })
   if (props.icon) {
     return (
       <IconButton
@@ -44,18 +49,15 @@ export default function CBKButton(props: CBKButtonProps) {
     );
   } else {
     return (
-      <Button
+      <button
         disabled={props.disabled}
-        unelevated={props.unelevated}
-        raised={props.raised}
-        outlined={props.outlined}
-        className={props.className}
+        className={btnClassNames}
         onClick={props.onClick}
         style={props.style}
         type={props.type || 'button'}
       >
         { props.children }
-      </Button>
+      </button>
     )
   }
 };

+ 105 - 0
recipes/src/components/Button/styles.scss

@@ -1,3 +1,5 @@
+@import 'styles/_variables.scss';
+
 button.mdc-icon-button.btn-small {
   align-self: center;
   --mdc-ripple-fg-size: 14px;
@@ -12,4 +14,107 @@ button.mdc-icon-button.btn-small {
     font-size: 12px;
   }
 
+}
+
+button.cbk-btn {
+  @include button-reset();
+  @include button();
+  margin: 0 .5em;
+  -webkit-font-smoothing: antialiased;
+  outline: 0;
+  color: $grey-900;
+  padding: 0 $spacing-small/2;
+  line-height: 1.75rem;
+  box-sizing: border-box;
+
+  &:focus {
+    outline: 0;
+  }
+  
+  &:hover {
+    background-color: $grey-300;
+  }
+  
+  &:active {
+    border: 0;
+    background-color: $grey-400;
+  }
+
+  &--raised {
+    background-color: $black;
+    color: $white;
+    border: 3px solid $black;
+    box-shadow: 4px 4px $yellow;
+    position: relative;
+    
+    &:hover {
+      background-color: $black;
+      color: $white;
+      border: 3px solid $black;
+      box-shadow: 3px 3px $yellow;
+      top: 1px;
+      left: 1px;
+    }
+    
+    &:active {
+      background-color: $black;
+      color: $white;
+      border: 3px solid $black;
+      box-shadow: none;
+      top: 4px;
+      left: 4px
+    }
+  }
+
+  &--unelevated {
+    background-color: $black;
+    color: $white;
+    &:hover {
+      background-color: $black;
+      box-shadow: 3px 3px $yellow;
+    }
+    
+    &:active {
+      background-color: $black;
+      box-shadow: 3px 3px $yellow-dark;
+    }
+  }
+
+  &--outlined {
+    background-color: white;
+    border: 3px solid black;
+    color: black;
+    
+    &:hover {
+      border: 3px solid black;
+      color: black;
+      background-image: linear-gradient(
+        45deg,
+        $yellow 25%,
+        $white 25%,
+        $white 50%,
+        $yellow 50%,
+        $yellow 75%,
+        $white 75%,
+        $white 100%
+      );
+      background-size: 45.25px 45.25px;
+    }
+    
+    &:active {
+      border: 3px solid black;
+      color: black;
+      background-image: linear-gradient(
+        45deg,
+        $yellow-dark 25%,
+        $white 25%,
+        $white 50%,
+        $yellow-dark 50%,
+        $yellow-dark 75%,
+        $white 75%,
+        $white 100%
+      );
+      background-size: 45.25px 45.25px;
+    }
+  }
 }

+ 3 - 0
recipes/src/styles/_colors.scss

@@ -14,5 +14,8 @@ $grey-800: #424242;
 $grey-900: #212121;
 
 $pink: #e89d93;
+
 $yellow: #eec71a;
+$yellow-dark: #d0ae16;
+
 $blue: #48ACF0;