Skip to content

Commit

Permalink
style: change classnames code style (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js authored Oct 21, 2023
1 parent 8ad61b9 commit 8d664e3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
6 changes: 2 additions & 4 deletions src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ export const Button = ({
className,
...props
}: ButtonProps) => {
const mode = primary ? classes['btn--primary'] : classes['btn--secondary'];
const mode = primary ? classes.primary : '';
return (
<button
type="button"
className={[className, classes.btn, classes[`btn--${size}`], mode].join(
' ',
)}
className={[className, classes.btn, classes[size], mode].join(' ')}
disabled={isDisabled}
{...props}
>
Expand Down
22 changes: 12 additions & 10 deletions src/components/button/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
transition: opacity 0.3s;
cursor: pointer;
box-sizing: border-box;
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
border: 0;
border-radius: 3em;
border-radius: 2em;
background-color: transparent; // secondary
width: 100%;
color: #333; // secondary
font-weight: 700;
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;

Expand All @@ -15,27 +18,26 @@
&:disabled {
filter: invert(75%);
cursor: not-allowed;

&:hover {
opacity: inherit;
}
}

&--primary {
&.primary {
background-color: #1ea7fd;
color: white;
}
&--secondary {
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
background-color: transparent;
color: #333;
}

&--small {
&.small {
padding: 10px 16px;
font-size: 12px;
}
&--medium {
&.medium {
padding: 11px 20px;
font-size: 14px;
}
&--large {
&.large {
padding: 12px 24px;
font-size: 16px;
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ interface FormProps {
}

export const Form = ({ onSubmit, children }: PropsWithChildren<FormProps>) => (
<form onSubmit={onSubmit} className={classes.form}>
<form
onSubmit={onSubmit}
className={[classes.form, classes.container].join(' ')}
>
{children}
</form>
);
8 changes: 7 additions & 1 deletion src/components/form/form.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
display: flex;
flex-direction: column;
align-self: center;
gap: 1rem;
gap: 3rem;
box-sizing: border-box;
margin: 0 auto;
width: 100%;
max-width: 20rem;
}

.container {
padding-right: max(env(safe-area-inset-right, 1rem), 1rem);
padding-left: max(env(safe-area-inset-left, 1rem), 1rem);
}
8 changes: 5 additions & 3 deletions src/components/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ export const Input = ({
size = 'medium',
}: InputProps) => (
<>
<label htmlFor={id} className={`${classes.label} ${classes[size]}`}>
<span className={`${classes.labelText} ${classes[size]}`}>{label}</span>
<label htmlFor={id} className={[classes.label, classes[size]].join(' ')}>
<span className={[classes.labelText, classes[size]].join(' ')}>
{label}
</span>
<input
id={id}
autoFocus={autoFocus}
minLength={minLength}
placeholder={placeholder}
className={`${classes.input} ${classes[size]}`}
className={[classes.input, classes[size]].join(' ')}
type={type}
/>
</label>
Expand Down

0 comments on commit 8d664e3

Please sign in to comment.