-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark mode Implimentation for Desktop #1169
Draft
Shubham-Patel07
wants to merge
7
commits into
OWASP:main
Choose a base branch
from
Shubham-Patel07:dark-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+195
−4
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
713faa3
Add: added the dark mode handlers in desktop.js
Shubham-Patel07 6a61ebc
Add: added preload script
Shubham-Patel07 afa7bd1
Fix: fixed the preload and its path in desktop.js
Shubham-Patel07 fd11cb7
Add: Basic dark mode functionallity working
Shubham-Patel07 574f173
Add: Added few styles
Shubham-Patel07 77ebfb9
Add: Added few styles and resolved svg toggling
Shubham-Patel07 c58bf74
Add: All the dark-mode scss added :)
Shubham-Patel07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -14,6 +14,12 @@ | |
</b-navbar-nav> | ||
|
||
<b-navbar-nav class="ml-auto"> | ||
<b-nav-item> | ||
<b-button size="sm" variant="outline-light" @click="handleToggleDarkMode">Toggle Dark Mode</b-button> | ||
</b-nav-item> | ||
<b-nav-item> | ||
<b-button size="sm" variant="outline-light" @click="handleSetSystemTheme">System Theme</b-button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this 'set system theme' needed? there is the dark mode toggle, which will provide the system theme when off |
||
</b-nav-item> | ||
<b-nav-text v-show="username" class="logged-in-as">{{ $t('nav.loggedInAs')}} {{ username }}</b-nav-text> | ||
<b-nav-item v-show="username" @click="onLogOut" id="nav-sign-out"> | ||
<font-awesome-icon | ||
|
@@ -113,7 +119,7 @@ $icon-height: 1.2rem; | |
|
||
<script> | ||
import { mapGetters } from 'vuex'; | ||
|
||
import { toggleDarkMode, setSystemTheme } from '../plugins/dark-mode'; | ||
import { LOGOUT } from '@/store/actions/auth.js'; | ||
import TdLocaleSelect from './LocaleSelect.vue'; | ||
|
||
|
@@ -128,6 +134,12 @@ export default { | |
]) | ||
}, | ||
methods: { | ||
async handleToggleDarkMode() { | ||
await toggleDarkMode(); // Call the utility function | ||
}, | ||
async handleSetSystemTheme() { | ||
await setSystemTheme(); // Call the utility function | ||
}, | ||
onLogOut(evt) { | ||
evt.preventDefault(); | ||
this.$store.dispatch(LOGOUT); | ||
|
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,24 @@ | ||
export async function toggleDarkMode() { | ||
if (window.darkMode) { | ||
const isDark = await window.darkMode.toggle(); | ||
document.body.className = isDark ? 'dark' : 'light'; | ||
console.log('Darkmode status: ' + isDark); | ||
return isDark; | ||
} else { | ||
console.error('Dark mode API is not available.'); | ||
return null; | ||
} | ||
} | ||
|
||
export async function setSystemTheme() { | ||
if (window.darkMode) { | ||
await window.darkMode.system(); | ||
const theme = await window.darkMode.get(); | ||
document.body.className = theme.shouldUseDarkColors ? 'dark' : 'light'; | ||
console.log('Darkmode status: ' + theme.shouldUseDarkColors); | ||
return theme; | ||
} else { | ||
console.error('Dark mode API is not available.'); | ||
return null; | ||
} | ||
} |
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,103 @@ | ||
/* Dark Mode Styles */ | ||
body.dark { | ||
background-color: $dark-bg; | ||
color: $dark-text; | ||
} | ||
|
||
/* Dark mode overrides for Jumbotron when body has .dark */ | ||
body.dark .jumbotron, | ||
body.dark .b-jumbotron { | ||
background-color: $dark-but-lighter-bg !important; // from your colors.scss: e.g. #121212 | ||
color: $dark-text !important; // e.g. #e0e0e0 | ||
// If a border or other styling is needed: | ||
border: 1px solid $dark-border !important; | ||
} | ||
|
||
body.dark .jumbotron a, | ||
body.dark .b-jumbotron a { | ||
color: $orange !important; // or any accent color | ||
} | ||
|
||
body.dark .td-cupcake { | ||
filter: invert(1); | ||
} | ||
|
||
body.dark .b-form-textarea, | ||
body.dark .form-control { | ||
background-color: $dark-but-lighter-bg !important; /* or your chosen dark color */ | ||
color: $dark-text !important; | ||
border-color: $dark-border !important; | ||
} | ||
|
||
/* For <b-card> */ | ||
body.dark .card { | ||
background-color: $dark-but-lighter-bg !important; /* or your chosen dark color */ | ||
color: $dark-text !important; | ||
border-color: $dark-border !important; | ||
} | ||
|
||
body.dark .dropdown-menu { | ||
background-color: $dark-but-lighter-bg !important; /* Dark background */ | ||
color: $dark-text !important; /* Light text */ | ||
border: 1px solid $dark-border !important; /* Optional border */ | ||
} | ||
|
||
body.dark .dropdown-item { | ||
color: $dark-text !important; | ||
} | ||
|
||
/* Optional hover/focus states */ | ||
body.dark .dropdown-item:hover, | ||
body.dark .dropdown-item:focus { | ||
background-color: $dark-hover-bg !important; | ||
color: $dark-hover-text !important; | ||
} | ||
|
||
body.dark .modal-content{ | ||
background-color: $dark-bg !important; /* or your preferred dark color */ | ||
color: $dark-text !important; | ||
} | ||
|
||
body.dark .list-group-item { | ||
background-color: $dark-but-lighter-bg !important; | ||
color: $dark-text !important; | ||
border-color: $dark-border !important; /* optional border override */ | ||
} | ||
|
||
/* If you want a hover effect: */ | ||
body.dark .list-group-item:hover { | ||
background-color: $dark-bg !important; | ||
} | ||
|
||
body.dark .td-report-options { | ||
background-color: $dark-but-lighter-bg !important; | ||
color: $dark-text !important; | ||
} | ||
|
||
// body.dark .td-report-section { | ||
// background-color: $dark-but-lighter-bg !important; | ||
// color: cyan !important; | ||
// } | ||
|
||
body.dark .table { | ||
background-color: $dark-bg !important; | ||
color: $dark-text !important; | ||
} | ||
|
||
/* This ensures text inside td-diagram-detail is light on a dark background */ | ||
body.dark .x6-graph-svg { | ||
filter: invert(1); | ||
} | ||
|
||
body.dark .diagram-header-text a{ | ||
color: $dark-text !important; | ||
} | ||
|
||
body.dark .diagram-description-text a{ | ||
color: $dark-text !important; | ||
} | ||
|
||
body.dark .x6-widget-stencil { | ||
background-color: $dark-bg !important; | ||
color: $dark-text !important; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is intended to be left in, or if it is temporary debug?