-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Button into its own component
- Loading branch information
Fabricius Seifert
committed
Feb 23, 2024
1 parent
8549161
commit ae2b20f
Showing
7 changed files
with
165 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
.c_Button { | ||
--button-height: 50px; | ||
display: block; | ||
height: var(--button-height); | ||
width: 100%; | ||
border-radius: calc(var(--button-height) / 2); | ||
padding: 2px; | ||
border: 0; | ||
background: linear-gradient(180deg, rgb(168, 168, 168), rgb(255, 255, 255)), | ||
var(--accent-color); | ||
box-shadow: | ||
0 -2px 3px rgb(229, 229, 229), | ||
0 2px 3px 2px rgb(255, 255, 255), | ||
0 0 25px rgba(0, 0, 0, 0.05), | ||
0 -10px 5px rgb(255, 255, 255) inset; | ||
position: relative; | ||
text-transform: uppercase; | ||
letter-spacing: 0.3em; | ||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); | ||
text-decoration: none; | ||
font-size: 16px; | ||
} | ||
|
||
.c_Button--primary { | ||
--accent-color: #ff5a55; | ||
color: #fff; | ||
} | ||
|
||
.c_Button--secondary { | ||
--accent-color: #ffffff; | ||
color: #000; | ||
} | ||
|
||
.c_Button--rounded { | ||
--button-height: 66px; | ||
width: var(--button-height); | ||
} | ||
|
||
.c_Button[disabled] { | ||
--accent-color: #d3d3d3; | ||
pointer-events: none; | ||
} | ||
|
||
.c_Button::before { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
border-radius: inherit; | ||
left: 0; | ||
background: linear-gradient( | ||
0deg, | ||
rgba(0, 0, 0, 0.19), | ||
rgba(255, 255, 255, 0.3) | ||
), | ||
var(--accent-color); | ||
content: ""; | ||
box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.1); | ||
display: block; | ||
transition: | ||
transform 0.3s, | ||
box-shadow 0.3s, | ||
background 0.1s 0.2s; | ||
} | ||
|
||
.c_Button__inner { | ||
position: relative; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
background-color: var(--accent-color); | ||
height: calc(var(--button-height) - 4px); | ||
border-radius: inherit; | ||
display: grid; | ||
place-content: center; | ||
transition: | ||
transform 0.3s, | ||
background 0.3s, | ||
box-shadow 0.3s; | ||
-webkit-user-select: none; /* Safari */ | ||
-ms-user-select: none; /* IE 10 and IE 11 */ | ||
user-select: none; | ||
white-space: nowrap; | ||
} | ||
|
||
.c_Button:hover .c_Button__inner { | ||
background: linear-gradient(0deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)), | ||
var(--accent-color); | ||
} | ||
|
||
.c_Button:active::before { | ||
background: linear-gradient(0deg, rgba(0, 0, 0, 0.09), rgba(0, 0, 0, 0.16)), | ||
var(--accent-color); | ||
box-shadow: | ||
0 0 3px rgba(0, 0, 0, 0.6) inset, | ||
0 2px 1px -1px rgba(0, 0, 0, 0.1); | ||
transform: scale(0.97); | ||
transition: | ||
all 0.1s, | ||
background 0.05s; | ||
} | ||
|
||
.c_Button:active .c_Button__inner { | ||
transform: scale(0.97); | ||
background: linear-gradient(0deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1)), | ||
var(--accent-color); | ||
transition: all 0.1s; | ||
box-shadow: | ||
0 5px 5px rgba(0, 0, 0, 0.2) inset, | ||
0 -3px 3px rgba(255, 255, 255, 0.2) inset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { html } from "../utils.js"; | ||
|
||
export default ({ | ||
tag = "button", | ||
href, | ||
disabled, | ||
rounded, | ||
className, | ||
children, | ||
variant = "secondary", | ||
}) => { | ||
return html` <${href ? "a" : tag} | ||
${disabled ? "disabled" : ""} | ||
${href ? `href="${href}"` : ""} | ||
class="c_Button c_Button--${variant} ${className} ${rounded ? "c_Button--rounded" : ""}" | ||
ontouchstart | ||
> | ||
<div class="c_Button__inner">${children}</div> | ||
</${href ? "a" : tag}>`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.