fixed button styling

This commit is contained in:
andres alcocer
2022-11-28 21:02:53 -05:00
parent 42f90bc175
commit 695e72b83a
3 changed files with 50 additions and 25 deletions

View File

@@ -1,4 +1,3 @@
import React from 'react'
import './button.scss' import './button.scss'
export enum ButtonType { export enum ButtonType {
@@ -7,18 +6,28 @@ export enum ButtonType {
} }
interface IButton { interface IButton {
label: string label?: string
onClick?: () => void onClick?: () => void
buttonType: ButtonType buttonType: ButtonType
Icon: JSX.Element Icon?: JSX.Element
} }
const Button = ({ label, onClick, buttonType, Icon }: IButton) => { const Button = ({ label, onClick, buttonType, Icon }: IButton) => {
const getIconClassName = (): '' | ' with-icon' => {
return Icon ? ' with-icon' : ''
}
const getLabelClassName = (): '' | ' with-label' => {
return label ? ' with-label' : ''
}
const getPrimaryClassName = (): string => {
return ButtonType[buttonType ? buttonType : ButtonType.Primary]
}
return ( return (
<button <button
className={`n-button${Icon ? ' with-icon' : ''} ${ className={`n-button${getIconClassName()}${getLabelClassName()} ${getPrimaryClassName()}`}
ButtonType[buttonType ? buttonType : ButtonType.Primary]
}`}
onClick={onClick} onClick={onClick}
> >
{Icon && Icon} {Icon && Icon}

View File

@@ -1,18 +1,19 @@
@import '../../static/sass/abstracts/functions'; @import '../../static/sass/abstracts/functions';
.n-button { .n-button {
top: 40rem;
cursor: pointer; cursor: pointer;
font-size: 1.6rem;
outline: none; outline: none;
border: none; border: none;
font-weight: 700; border-radius: 4px;
border-radius: 5px; padding: 0.8rem;
padding-left: 3.5rem; opacity: 1;
padding-right: 3.5rem; user-select: none;
margin-right: 1rem; will-change: background-color, color;
padding-top: 1rem; word-break: break-word;
padding-bottom: 1rem; white-space: nowrap;
font-size: 1.2vw;
font-weight: 500;
line-height: 2.4rem;
@include responsive(phone) { @include responsive(phone) {
top: 24rem; top: 24rem;
@@ -20,26 +21,45 @@
&.with-icon { &.with-icon {
fill: #fff; fill: #fff;
margin-right: 1rem;
display: flex; display: flex;
padding-left: 2rem;
padding-right: 2.4rem;
& > * { & > * {
width: 15px; width: 25px;
height: 15px; height: 25px;
fill: #fff; fill: #fff;
margin-right: 1rem; margin-right: 1rem;
} }
} }
&.with-label {
padding-left: 2.4rem;
padding-right: 2.4rem;
}
&.Primary { &.Primary {
color: #000; color: #000;
background-color: #fff; background-color: #fff;
transition: all 0.2s;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
& > * { & > * {
fill: #000; fill: #000;
} }
&:not(:disabled):hover {
background-color: rgba(255, 255, 255, 0.75);
}
&:not(:disabled):active {
background-color: rgba(255, 255, 255, 0.5);
color: rgba(0, 0, 0, 0.7);
}
&:not(:disabled):focus {
border: 2px solid white;
border-radius: 8px;
}
} }
&.Secondary { &.Secondary {

View File

@@ -32,14 +32,10 @@ const Header = ({ name, overview }: IHeader) => {
<Button <Button
Icon={<PlayLogo />} Icon={<PlayLogo />}
buttonType={ButtonType.Primary} buttonType={ButtonType.Primary}
onClick={() => alert('not a movie!')} onClick={() => console.log('not a movie!')}
label={'Play'} label={'Play'}
/> />
<Button <Button label={'My List'} buttonType={ButtonType.Secondary} />
label={'My List'}
Icon={<AddLogo />}
buttonType={ButtonType.Secondary}
/>
{isMuted ? ( {isMuted ? (
<MuteIcon <MuteIcon
onClick={() => setIsMuted(false)} onClick={() => setIsMuted(false)}