From c43e5324c2b6d5875de067cb1aea222b9bc46b29 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 19 Sep 2023 17:17:22 +0100 Subject: [PATCH] refactor: move button styles to their own file --- frontend/src/styles/buttons.scss | 129 ++++++++++++++++++++++++++++++ frontend/src/styles/core.scss | 130 ------------------------------- frontend/src/styles/index.scss | 8 +- 3 files changed, 133 insertions(+), 134 deletions(-) create mode 100644 frontend/src/styles/buttons.scss diff --git a/frontend/src/styles/buttons.scss b/frontend/src/styles/buttons.scss new file mode 100644 index 000000000..e36b045ef --- /dev/null +++ b/frontend/src/styles/buttons.scss @@ -0,0 +1,129 @@ +a.button { + text-decoration: none; +} + +.button { + color: var(--text-color); + cursor: pointer; + transition: background 0.125s, color 0.125s; + padding: 0.5em; + border-radius: var(--roundness); + background: var(--sub-alt-color); + text-align: center; + -webkit-user-select: none; + user-select: none; + align-content: center; + height: -moz-min-content; + height: min-content; + line-height: 1.25em; + appearance: none; + border: none; + font-family: inherit; + font-size: 1em; + + &.active { + background: var(--main-color); + color: var(--bg-color); + &:hover { + background: var(--text-color); + } + &:active { + background: var(--sub-color); + color: var(--bg-color); + } + } + + &.disabled { + opacity: 0.33; + cursor: default; + pointer-events: none; + &:hover { + background: var(--text-color); + outline: none; + } + &:active { + background: var(--sub-color); + color: var(--bg-color); + } + } + + &:hover { + color: var(--bg-color); + background: var(--text-color); + outline: none; + } + &:focus-visible { + box-shadow: 0 0 0 0.15em var(--text-color); + outline: none; + } + &:active { + background: var(--sub-color); + color: var(--bg-color); + } +} + +.textButton { + color: var(--sub-color); + cursor: pointer; + transition: background 0.125s, color 0.125s; + padding: 0.5em; + border-radius: var(--roundness); + text-align: center; + -webkit-user-select: none; + user-select: none; + align-content: center; + height: -moz-min-content; + height: min-content; + line-height: 1.25em; + appearance: none; + border: none; + font-family: inherit; + font-size: 1em; + width: -moz-max-content; + width: max-content; + display: grid; + grid-auto-flow: column; + gap: 0.25em; + text-decoration: none; + + .fas, + .far { + display: grid; + place-content: center center; + } + + &.active { + color: var(--main-color); + &:hover { + color: var(--text-color); + } + &:active { + color: var(--sub-color); + } + } + + &.disabled { + opacity: 0.33; + cursor: default; + pointer-events: none; + &:hover { + background: var(--text-color); + outline: none; + } + &:active { + background: var(--sub-color); + color: var(--bg-color); + } + } + + &:hover { + color: var(--text-color); + } + &:focus { + color: var(--text-color); + outline: none; + } + &:active { + color: var(--sub-color); + } +} diff --git a/frontend/src/styles/core.scss b/frontend/src/styles/core.scss index fc42bc86a..c9d3fd875 100644 --- a/frontend/src/styles/core.scss +++ b/frontend/src/styles/core.scss @@ -89,10 +89,6 @@ a[router-link] * { pointer-events: none; } -a.button { - text-decoration: none; -} - body { margin: 0; padding: 0; @@ -296,132 +292,6 @@ key { pointer-events: none !important; } -.button { - color: var(--text-color); - cursor: pointer; - transition: background 0.125s, color 0.125s; - padding: 0.5em; - border-radius: var(--roundness); - background: var(--sub-alt-color); - text-align: center; - -webkit-user-select: none; - user-select: none; - align-content: center; - height: -moz-min-content; - height: min-content; - line-height: 1.25em; - appearance: none; - border: none; - font-family: inherit; - font-size: 1em; - - &.active { - background: var(--main-color); - color: var(--bg-color); - &:hover { - background: var(--text-color); - } - &:active { - background: var(--sub-color); - color: var(--bg-color); - } - } - - &.disabled { - opacity: 0.33; - cursor: default; - pointer-events: none; - &:hover { - background: var(--text-color); - outline: none; - } - &:active { - background: var(--sub-color); - color: var(--bg-color); - } - } - - &:hover { - color: var(--bg-color); - background: var(--text-color); - outline: none; - } - &:focus-visible { - box-shadow: 0 0 0 0.15em var(--text-color); - outline: none; - } - &:active { - background: var(--sub-color); - color: var(--bg-color); - } -} - -.textButton { - color: var(--sub-color); - cursor: pointer; - transition: background 0.125s, color 0.125s; - padding: 0.5em; - border-radius: var(--roundness); - text-align: center; - -webkit-user-select: none; - user-select: none; - align-content: center; - height: -moz-min-content; - height: min-content; - line-height: 1.25em; - appearance: none; - border: none; - font-family: inherit; - font-size: 1em; - width: -moz-max-content; - width: max-content; - display: grid; - grid-auto-flow: column; - gap: 0.25em; - text-decoration: none; - - .fas, - .far { - display: grid; - place-content: center center; - } - - &.active { - color: var(--main-color); - &:hover { - color: var(--text-color); - } - &:active { - color: var(--sub-color); - } - } - - &.disabled { - opacity: 0.33; - cursor: default; - pointer-events: none; - &:hover { - background: var(--text-color); - outline: none; - } - &:active { - background: var(--sub-color); - color: var(--bg-color); - } - } - - &:hover { - color: var(--text-color); - } - &:focus { - color: var(--text-color); - outline: none; - } - &:active { - color: var(--sub-color); - } -} - .scrollToTopButton { bottom: 2rem; right: 2rem; diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss index 4b3e3207b..4eed04717 100644 --- a/frontend/src/styles/index.scss +++ b/frontend/src/styles/index.scss @@ -1,4 +1,4 @@ -@import "normalize.css", "fonts", "404", "ads", "about", "account", "animations", - "banners", "caret", "commandline", "core", "footer", "inputs", "keymap", - "leaderboards", "login", "monkey", "nav", "notifications", "popups", "profile", - "scroll", "settings", "test", "z_media-queries"; +@import "normalize.css", "buttons", "fonts", "404", "ads", "about", "account", + "animations", "banners", "caret", "commandline", "core", "footer", "inputs", + "keymap", "leaderboards", "login", "monkey", "nav", "notifications", "popups", + "profile", "scroll", "settings", "test", "z_media-queries";