summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/navigation
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-11 15:40:11 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-12 22:50:49 +0200
commit873ddacf5abafe43fbc2b6c1033e473c3366dc62 (patch)
treea2cc2ec17c7356a6097febfc648e3222617f7cac /opendc-web/opendc-web-ui/src/components/navigation
parent1ce710ebaa8b071a3b30447d431f4af422f25156 (diff)
ui: Move component styling into CSS modules
This change updates the frontend codebase by moving the component styling into CSS module files as opposed to the global styles which we used before. In addition, I have changed the syntax to the newer SCSS syntax, which is more similar to CSS. These changes reduces the styling conflicts that can occur between components and allows us to migrate to systems that do not support importing global styles in components. Moreover, we can benefit from treeshaking using CSS modules.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components/navigation')
-rw-r--r--opendc-web/opendc-web-ui/src/components/navigation/AppNavbarComponent.js2
-rw-r--r--opendc-web/opendc-web-ui/src/components/navigation/HomeNavbar.js2
-rw-r--r--opendc-web/opendc-web-ui/src/components/navigation/Navbar.js8
-rw-r--r--opendc-web/opendc-web-ui/src/components/navigation/Navbar.module.scss36
-rw-r--r--opendc-web/opendc-web-ui/src/components/navigation/Navbar.sass30
5 files changed, 42 insertions, 36 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/navigation/AppNavbarComponent.js b/opendc-web/opendc-web-ui/src/components/navigation/AppNavbarComponent.js
index c5de3d0b..8c28c542 100644
--- a/opendc-web/opendc-web-ui/src/components/navigation/AppNavbarComponent.js
+++ b/opendc-web/opendc-web-ui/src/components/navigation/AppNavbarComponent.js
@@ -3,7 +3,7 @@ import FontAwesome from 'react-fontawesome'
import { Link } from 'react-router-dom'
import { NavLink } from 'reactstrap'
import Navbar, { NavItem } from './Navbar'
-import './Navbar.sass'
+import {} from './Navbar.module.scss'
const AppNavbarComponent = ({ project, fullWidth }) => (
<Navbar fullWidth={fullWidth}>
diff --git a/opendc-web/opendc-web-ui/src/components/navigation/HomeNavbar.js b/opendc-web/opendc-web-ui/src/components/navigation/HomeNavbar.js
index 08d222ea..46d01a25 100644
--- a/opendc-web/opendc-web-ui/src/components/navigation/HomeNavbar.js
+++ b/opendc-web/opendc-web-ui/src/components/navigation/HomeNavbar.js
@@ -1,7 +1,7 @@
import React from 'react'
import { NavItem, NavLink } from 'reactstrap'
import Navbar from './Navbar'
-import './Navbar.sass'
+import {} from './Navbar.module.scss'
const ScrollNavItem = ({ id, name }) => (
<NavItem>
diff --git a/opendc-web/opendc-web-ui/src/components/navigation/Navbar.js b/opendc-web/opendc-web-ui/src/components/navigation/Navbar.js
index 55f98900..bf18f1c4 100644
--- a/opendc-web/opendc-web-ui/src/components/navigation/Navbar.js
+++ b/opendc-web/opendc-web-ui/src/components/navigation/Navbar.js
@@ -14,7 +14,7 @@ import { userIsLoggedIn } from '../../auth/index'
import Login from '../../containers/auth/Login'
import Logout from '../../containers/auth/Logout'
import ProfileName from '../../containers/auth/ProfileName'
-import './Navbar.sass'
+import { login, navbar, opendcBrand } from './Navbar.module.scss'
export const NAVBAR_HEIGHT = 60
@@ -59,7 +59,7 @@ export const LoggedInSection = () => {
) : (
<NavItem route="login">
<GitHubLink />
- <Login visible={true} />
+ <Login visible={true} className={login} />
</NavItem>
)}
</Nav>
@@ -71,10 +71,10 @@ const Navbar = ({ fullWidth, children }) => {
const toggle = () => setIsOpen(!isOpen)
return (
- <RNavbar fixed="top" color="light" light expand="lg" id="navbar">
+ <RNavbar fixed="top" color="light" light expand="lg" id="navbar" className={navbar}>
<Container fluid={fullWidth}>
<NavbarToggler onClick={toggle} />
- <NavbarBrand tag={Link} to="/" title="OpenDC" className="opendc-brand">
+ <NavbarBrand tag={Link} to="/" title="OpenDC" className={opendcBrand}>
<img src="/img/logo.png" alt="OpenDC" />
</NavbarBrand>
diff --git a/opendc-web/opendc-web-ui/src/components/navigation/Navbar.module.scss b/opendc-web/opendc-web-ui/src/components/navigation/Navbar.module.scss
new file mode 100644
index 00000000..2ea59a0f
--- /dev/null
+++ b/opendc-web/opendc-web-ui/src/components/navigation/Navbar.module.scss
@@ -0,0 +1,36 @@
+@import '../../style-globals/_mixins.scss';
+@import '../../style-globals/_variables.scss';
+
+.navbar {
+ border-top: $blue 3px solid;
+ border-bottom: $gray-semi-dark 1px solid;
+ color: $gray-very-dark;
+ background: #fafafb;
+}
+
+.opendcBrand {
+ display: inline-block;
+ color: $gray-very-dark;
+
+ transition: background $transition-length;
+
+ img {
+ position: relative;
+ bottom: 3px;
+ display: inline-block;
+ width: 30px;
+ }
+}
+
+.login {
+ height: 40px;
+ background: $blue;
+ border: none;
+ padding-top: 10px;
+
+ @include clickable;
+
+ &:hover {
+ background: $blue-dark;
+ }
+}
diff --git a/opendc-web/opendc-web-ui/src/components/navigation/Navbar.sass b/opendc-web/opendc-web-ui/src/components/navigation/Navbar.sass
deleted file mode 100644
index c9d2aad2..00000000
--- a/opendc-web/opendc-web-ui/src/components/navigation/Navbar.sass
+++ /dev/null
@@ -1,30 +0,0 @@
-@import ../../style-globals/_mixins.sass
-@import ../../style-globals/_variables.sass
-
-.navbar
- border-top: $blue 3px solid
- border-bottom: $gray-semi-dark 1px solid
- color: $gray-very-dark
- background: #fafafb
-
-.opendc-brand
- display: inline-block
- color: $gray-very-dark
-
- +transition(background, $transition-length)
-
- img
- position: relative
- bottom: 3px
- display: inline-block
- width: 30px
-
-.login
- height: 40px
- background: $blue
- border: none
- padding-top: 10px
- +clickable
-
- &:hover
- background: $blue-dark