Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Upd Button component to use scss module and generate classNames
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkingman-niche committed May 28, 2020
1 parent f4bb4b6 commit 784c78b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
48 changes: 48 additions & 0 deletions src/components/Button.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.button {
-webkit-appearance: none;
border: 1px solid transparent;
background: transparent;
padding: 0;
display: inline-block;
border-radius: 2px;
text-align: center;
line-height: 1;
text-decoration: none;
/* setting some defaults for the type, but mostly should come from text components */
font: 400 16px/1 'Source Sans Pro', Arial, sans-serif;
transition: background-color 0.1s, border-color 0.1s, color 0.1s;

// @include button-text-states(
// #2e9adf,
// #275E8B,
// #205177,
// #69ADD8
// );

&:focus {
outline: none;
}

// @include button-focus(scale-color(#2e9adf, $alpha: -70%));
}


/*
Width
*/

.wide {
display: block;
width: 100%;
}
.wide-mobile {
display: block;
width: 100%;

@media(min-width: 600px) {
display: inline-block;
width: auto;
};
}


15 changes: 11 additions & 4 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FunctionComponent } from 'react';

import styles from './Button.module.scss';
import { classNames } from '../utilities/css';
export type Type = 'default' | 'action';

interface Props {
Expand All @@ -10,14 +11,20 @@ interface Props {
onClick?: () => void;

/**
* Button type yo
* Button type
*/
type?: Type;
fullWidth?: boolean;
}

const Button: FunctionComponent<Props> = ({ children, type = 'default', onClick }) => {
const Button: FunctionComponent<Props> = ({ children, type = 'default', onClick, fullWidth = true }) => {
const className = classNames(
styles.button,
fullWidth && styles.wide,
);

return (
<button type="button" onClick={onClick}>
<button type="button" className={className} onClick={onClick}>
{type}: {children}
</button>
);
Expand Down

0 comments on commit 784c78b

Please sign in to comment.