-
-
Couldn't load subscription status.
- Fork 245
Implement light/dark theme support #15
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f952e90
light-dark-theme
VedmaPranav 27a2469
fix pre-commit issues
VedmaPranav c7020a5
Merge branch 'main' of https://github.com/OWASP/Nest into light-dark-…
VedmaPranav 3a0e501
Revert "fix pre-commit issues"
VedmaPranav 671b093
Fixed the pre-commit issues got Pass on all checks in pre-commit
VedmaPranav 8ada7ca
changed the icons to font awesome and using dark theme attribute
VedmaPranav a3de7af
updated base html file to use static tag
VedmaPranav 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 hidden or 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,97 @@ | ||
| .page { | ||
| background-color: #f4f6fc; | ||
| } | ||
|
|
||
| .page-dark { | ||
| background-color: #000000de; | ||
| } | ||
|
|
||
| .page-dark .card { | ||
| background-color: #00000005; | ||
| color: white; | ||
| border-color: white; | ||
| } | ||
|
|
||
| .page-dark [data-bs-toggle="tooltip"] { | ||
| color: white; | ||
| border: none !important; | ||
| } | ||
|
|
||
| .switch { | ||
| position: relative; | ||
| display: inline-block; | ||
| width: 30px; | ||
| height: 19px; | ||
| margin-right: 3px; | ||
| } | ||
|
|
||
| .switch input { | ||
| opacity: 0; | ||
| width: 0; | ||
| height: 0; | ||
| } | ||
|
|
||
| .slider { | ||
| position: absolute; | ||
| cursor: pointer; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background-color: #ccc; | ||
| -webkit-transition: .4s; | ||
| transition: .4s; | ||
| } | ||
|
|
||
| .slider:before { | ||
| position: absolute; | ||
| content: ""; | ||
| height: 15px; | ||
| width: 15px; | ||
| left: 2px; | ||
| bottom: 2px; | ||
| background-color: white; | ||
| -webkit-transition: .4s; | ||
| transition: .4s; | ||
| } | ||
|
|
||
| input:checked + .slider { | ||
| background-color: black; | ||
| } | ||
|
|
||
| input:focus + .slider { | ||
| box-shadow: 0 0 1px black; | ||
| } | ||
|
|
||
| input:checked + .slider:before { | ||
| -webkit-transform: translateX(10px); | ||
| -ms-transform: translateX(10px); | ||
| transform: translateX(10px); | ||
| } | ||
|
|
||
| /* Rounded sliders */ | ||
| .slider.round { | ||
| border-radius: 15px; | ||
| } | ||
|
|
||
| .slider.round:before { | ||
| border-radius: 50%; | ||
| } | ||
|
|
||
| .toggle-btn { | ||
| margin-right: 10px; | ||
| width: 90px; | ||
| } | ||
|
|
||
| .toggle-btn img { | ||
| vertical-align: baseline; | ||
| height: 20px; | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
arkid15r marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| </title> | ||
| <link rel="stylesheet" | ||
| href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" /> | ||
| <link rel="stylesheet" href="/static/css/app.css"/> | ||
| <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
| rel="stylesheet" | ||
| integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" | ||
|
|
@@ -23,14 +24,10 @@ | |
| <script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> | ||
| <style> | ||
| .page { | ||
| background-color: #f4f6fc; | ||
| } | ||
| </style> | ||
| {% block extra_css %}{% endblock extra_css %} | ||
| </head> | ||
| <body class="page"> | ||
| {% block content %} | ||
| <div id="theme-toggle-app"> | ||
| <div class="banner"> | ||
| <nav class="navbar navbar-expand-lg sticky-top border-bottom border-body mb-4" | ||
| data-bs-theme="light" | ||
|
|
@@ -57,8 +54,63 @@ | |
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="toggle-btn"> | ||
| <theme-toggle></theme-toggle> | ||
| </div> | ||
| </nav> | ||
| </div> | ||
| {% endblock content %} | ||
| </div> | ||
| {% block content %} {% endblock content %} | ||
| <script> | ||
| const ThemeToggle = { | ||
| template: ` | ||
| <img src="/static/img/light-bulb-2-16.png" alt="Light theme"/> | ||
| <label class="switch"> | ||
| <input type="checkbox" v-model="isDarkTheme" @change="toggleTheme"> | ||
| <span class="slider round"></span> | ||
| </label> | ||
| <img src="/static/img/moon-4-16.png" alt="Dark theme"/> | ||
| `, | ||
| data() { | ||
| return { | ||
| isDarkTheme: false | ||
| } | ||
| }, | ||
| mounted() { | ||
| const currentTheme = localStorage.getItem('theme') | ||
| if (currentTheme) { | ||
| this.isDarkTheme = currentTheme === 'dark' | ||
| this.applyTheme() | ||
| } | ||
| }, | ||
| methods: { | ||
| toggleTheme() { | ||
| this.applyTheme() | ||
| localStorage.setItem('theme', this.isDarkTheme ? 'dark' : 'light') | ||
| }, | ||
| applyTheme() { | ||
| //document.documentElement.setAttribute('data-bs-theme', this.isDarkTheme ? 'dark' : 'light') | ||
| if (this.isDarkTheme){ | ||
| document.body.classList.remove("page"); | ||
| document.body.classList.add("page-dark"); | ||
|
|
||
| }else{ | ||
| document.body.classList.remove("page-dark"); | ||
| document.body.classList.add("page"); | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| const themeToggleApp = Vue.createApp({ | ||
| components: { | ||
| ThemeToggle | ||
| } | ||
| }) | ||
|
|
||
| themeToggleApp.mount('#theme-toggle-app') | ||
| </script> | ||
| {% block extra_js %}{% endblock extra_js %} | ||
| </body> | ||
| </html> | ||
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.
Uh oh!
There was an error while loading. Please reload this page.