Skip to content

Commit

Permalink
Merge pull request #104 from kodiak-packages/unfuckup-buttons
Browse files Browse the repository at this point in the history
Unfuckup buttons
  • Loading branch information
bramvanhoutte authored Aug 18, 2020
2 parents b6cea19 + d5c7919 commit 20b88d4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
4 changes: 1 addition & 3 deletions src/components/Button/Button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ Buttons make common actions more obvious and help users more easily perform them
### Button sizes

<Playground>
<Button size="big">Click me</Button>
{' '}
<Button size="medium">Click me</Button>
<Button size="normal">Click me</Button>
{' '}
<Button size="small">Click me</Button>
</Playground>
Expand Down
25 changes: 15 additions & 10 deletions src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
.button {
border-radius: var(--border-radius-small);
line-height: 14px;
font-size: 14px;
padding: 5.5px 14px;
padding: 10px 14px;
border: none;
cursor: pointer;
display: inline-block;
}

.smallButton {
padding: 3.5px 10px;
}

.typePrimary:hover {
background-color: var(--color-primary-hover);
}
Expand Down Expand Up @@ -41,24 +46,24 @@
cursor: default;
}

.labelWithPrefixIcon {
margin-left: 8px;
.label {
line-height: inherit;
}

.labelWithSuffixIcon {
margin-right: 8px;
.smallLabel {
font-size: calc(var(--font-size) - 2px);
}

.medium {
line-height: 17px;
.labelWithPrefixIcon {
margin-left: 8px;
}

.small {
line-height: 14px;
max-height: 25px;
.labelWithSuffixIcon {
margin-right: 8px;
}

.spinner {
width: 14px;
height: 14px;
vertical-align: -2px;
}
12 changes: 5 additions & 7 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Props {
prefixIcon?: React.ReactElement;
suffixIcon?: React.ReactElement;
name?: string;
size?: 'big' | 'medium' | 'small';
size?: 'normal' | 'small';
}

const Button: React.FC<Props> = ({
Expand All @@ -31,25 +31,23 @@ const Button: React.FC<Props> = ({
prefixIcon,
suffixIcon,
name,
size = 'big',
size = 'normal',
}: Props) => {
const buttonClassNames = classNames(
cssReset.ventura,
styles.button,
{
[styles.typePrimary]: type === 'primary',
[styles.typeSecondary]: type === 'secondary',
[styles.small]: size === 'small',
[styles.medium]: size === 'medium',
[styles.smallButton]: size === 'small',
},
className,
);

const labelClassNames = classNames({
const labelClassNames = classNames(styles.label, {
[styles.labelWithPrefixIcon]: Boolean(prefixIcon) || isLoading,
[styles.labelWithSuffixIcon]: Boolean(suffixIcon),
[styles.small]: size === 'small',
[styles.medium]: size === 'medium',
[styles.smallLabel]: size === 'small',
});

return (
Expand Down
12 changes: 6 additions & 6 deletions src/components/Button/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Button button should have type="submit" 1`] = `
type="submit"
>
<span
class=""
class="label"
>
Click me
</span>
Expand All @@ -25,7 +25,7 @@ exports[`Button default snapshot 1`] = `
type="button"
>
<span
class=""
class="label"
>
Click me
</span>
Expand Down Expand Up @@ -56,7 +56,7 @@ exports[`Button loading button 1`] = `
/>
</svg>
<span
class="labelWithPrefixIcon"
class="label labelWithPrefixIcon"
>
Click me
</span>
Expand Down Expand Up @@ -87,7 +87,7 @@ exports[`Button prefix icon button 1`] = `
/>
</svg>
<span
class="labelWithPrefixIcon"
class="label labelWithPrefixIcon"
>
Click me
</span>
Expand All @@ -103,7 +103,7 @@ exports[`Button secondary button 1`] = `
type="button"
>
<span
class=""
class="label"
>
Click me
</span>
Expand All @@ -119,7 +119,7 @@ exports[`Button suffix icon button 1`] = `
type="button"
>
<span
class="labelWithSuffixIcon"
class="label labelWithSuffixIcon"
>
Click me
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
--font-size: 14px;
--font-color: var(--color-neutral-8);
--font-color-sub: var(--color-neutral-7);
--line-height: 1.8;
--line-height: 25px;

/* Border */
--border-radius-small: 3px;
Expand Down

0 comments on commit 20b88d4

Please sign in to comment.