Skip to content

Commit c61269d

Browse files
Siddhi TripathiSiddhi Tripathi
authored andcommitted
website: add CSS custom properties for theme support
1 parent b60308a commit c61269d

File tree

8 files changed

+144
-63
lines changed

8 files changed

+144
-63
lines changed

_includes/theme-toggle.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<style>
2+
.theme-toggle-item {
3+
display: flex;
4+
align-items: center;
5+
margin-left: 10px;
6+
}
7+
8+
.theme-toggle-wrapper {
9+
display: flex;
10+
align-items: center;
11+
}
12+
13+
.theme-toggle {
14+
background: var(--bg-secondary);
15+
border: 1px solid var(--border-color);
16+
border-radius: 50%;
17+
width: 40px;
18+
height: 40px;
19+
cursor: pointer;
20+
display: flex;
21+
align-items: center;
22+
justify-content: center;
23+
transition: all 0.3s ease;
24+
color: var(--text-primary);
25+
padding: 0;
26+
position: relative;
27+
z-index: 1000;
28+
}
29+
30+
.theme-toggle:hover {
31+
background: var(--bg-tertiary);
32+
transform: scale(1.05);
33+
}
34+
35+
.theme-toggle svg {
36+
pointer-events: none; /* Prevent SVG from blocking clicks */
37+
}
38+
39+
.theme-icon-dark {
40+
display: none;
41+
}
42+
43+
[data-theme="dark"] .theme-icon-light {
44+
display: none;
45+
}
46+
47+
[data-theme="dark"] .theme-icon-dark {
48+
display: block;
49+
}
50+
51+
/* Ensure proper alignment in navbar */
52+
.navbar-nav .theme-toggle-item {
53+
padding: 8px 0;
54+
}
55+
56+
/* Mobile responsiveness */
57+
@media (max-width: 768px) {
58+
.theme-toggle-item {
59+
margin: 10px 15px;
60+
justify-content: center;
61+
}
62+
}
63+
</style>

_sass/_base.scss

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ dl, dd, ol, ul, figure {
1717
*/
1818
body {
1919
font: $base-font-weight list.slash($base-font-size, $base-line-height) $base-font-family;
20-
color: $text-color;
21-
background-color: $background-color;
20+
color: var(--text-primary);
21+
background-color: var(--bg-primary);
2222
-webkit-text-size-adjust: 100%;
2323
-webkit-font-feature-settings: "kern" 1;
2424
-moz-font-feature-settings: "kern" 1;
2525
-o-font-feature-settings: "kern" 1;
2626
font-feature-settings: "kern" 1;
2727
font-kerning: normal;
28+
transition: background-color 0.3s ease, color 0.3s ease;
2829
}
2930

3031

@@ -93,15 +94,15 @@ h1, h2, h3, h4, h5, h6 {
9394
* Links
9495
*/
9596
a {
96-
color: $brand-color;
97+
color: var(--link-color);
9798
text-decoration: none;
9899

99100
&:visited {
100-
color: darken($brand-color, 15%);
101+
color: var(--link-color);
101102
}
102103

103104
&:hover {
104-
color: $text-color;
105+
color: var(--link-hover);
105106
text-decoration: underline;
106107
}
107108
}
@@ -112,8 +113,8 @@ a {
112113
* Blockquotes
113114
*/
114115
blockquote {
115-
color: $grey-color;
116-
border-left: 4px solid $grey-color-light;
116+
color: var(--text-secondary);
117+
border-left: 4px solid var(--border-color);
117118
padding-left: $spacing-unit * 0.5;
118119
font-size: 18px;
119120
letter-spacing: -1px;
@@ -132,9 +133,9 @@ blockquote {
132133
pre,
133134
code {
134135
font-size: 15px;
135-
border: 1px solid $grey-color-light;
136+
border: 1px solid var(--border-color);
136137
border-radius: 3px;
137-
background-color: #eef;
138+
background-color: var(--code-bg);
138139
}
139140

140141
code {
@@ -202,7 +203,7 @@ pre {
202203
vertical-align: middle;
203204

204205
path {
205-
fill: $grey-color;
206+
fill: var(--text-secondary);
206207
}
207208
}
208209
}

_sass/_layout.scss

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
* Site header
33
*/
44
.site-header {
5-
border-top: 5px solid $grey-color-dark;
6-
border-bottom: 1px solid $grey-color-light;
5+
border-top: 5px solid var(--header-bg);
6+
border-bottom: 1px solid var(--border-color);
77
min-height: 56px;
8+
background-color: var(--header-bg);
9+
color: var(--header-text);
810

911
// Positioning context for the mobile navigation icon
1012
position: relative;
@@ -20,7 +22,7 @@
2022

2123
&,
2224
&:visited {
23-
color: $grey-color-dark;
25+
color: var(--header-text);
2426
}
2527
}
2628

@@ -33,7 +35,7 @@
3335
}
3436

3537
.page-link {
36-
color: $text-color;
38+
color: var(--header-text);
3739
line-height: $base-line-height;
3840

3941
// Gaps between nav items, but not on the last one
@@ -46,8 +48,8 @@
4648
position: absolute;
4749
top: 9px;
4850
right: $spacing-unit * 0.5;
49-
background-color: $background-color;
50-
border: 1px solid $grey-color-light;
51+
background-color: var(--bg-primary);
52+
border: 1px solid var(--border-color);
5153
border-radius: 5px;
5254
text-align: right;
5355

@@ -65,7 +67,7 @@
6567
height: 15px;
6668

6769
path {
68-
fill: $grey-color-dark;
70+
fill: var(--header-text);
6971
}
7072
}
7173
}
@@ -98,8 +100,10 @@
98100
* Site footer
99101
*/
100102
.site-footer {
101-
border-top: 1px solid $grey-color-light;
103+
border-top: 1px solid var(--border-color);
102104
padding: $spacing-unit 0;
105+
background-color: var(--footer-bg);
106+
color: var(--footer-text);
103107
}
104108

105109
.footer-heading {
@@ -115,7 +119,7 @@
115119

116120
.footer-col-wrapper {
117121
font-size: 15px;
118-
color: $grey-color;
122+
color: var(--footer-text);
119123
margin-left: -$spacing-unit * 0.5;
120124
@extend %clearfix;
121125
}
@@ -186,7 +190,7 @@
186190

187191
.post-meta {
188192
font-size: $small-font-size;
189-
color: $grey-color;
193+
color: var(--text-secondary);
190194
}
191195

192196
.post-link {

_sass/custom/_mixins.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Custom mixins for NuttX website
2+
// Add any custom mixins here if needed

_sass/custom/_themes.scss

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// CSS Custom Properties for Theming
2+
:root {
3+
// Light theme (default)
4+
--bg-primary: #ffffff;
5+
--bg-secondary: #f8f9fa;
6+
--bg-tertiary: #e9ecef;
7+
--text-primary: #212529;
8+
--text-secondary: #6c757d;
9+
--link-color: #007bff;
10+
--link-hover: #0056b3;
11+
--border-color: #dee2e6;
12+
--code-bg: #f8f9fa;
13+
--header-bg: #343a40;
14+
--header-text: #ffffff;
15+
--footer-bg: #f8f9fa;
16+
--footer-text: #6c757d;
17+
--card-bg: #ffffff;
18+
--table-bg: #ffffff;
19+
--table-border: #dee2e6;
20+
}
21+
22+
[data-theme="dark"] {
23+
// Dark theme
24+
--bg-primary: #121212;
25+
--bg-secondary: #1e1e1e;
26+
--bg-tertiary: #2d3748;
27+
--text-primary: #e9ecef;
28+
--text-secondary: #adb5bd;
29+
--link-color: #4dabf7;
30+
--link-hover: #74c0fc;
31+
--border-color: #495057;
32+
--code-bg: #2d3748;
33+
--header-bg: #212529;
34+
--header-text: #f8f9fa;
35+
--footer-bg: #1a1a1a;
36+
--footer-text: #adb5bd;
37+
--card-bg: #1e1e1e;
38+
--table-bg: #1e1e1e;
39+
--table-border: #495057;
40+
}

_sass/custom/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Custom variables for NuttX website
2+
// Add any custom variables here if needed

css/main.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
# Only the main Sass file needs front matter (the dashes are enough)
33
---
4+
@import "custom/variables";
5+
@import "custom/mixins";
6+
@import "custom/themes";
47
@charset "utf-8";
58

69

index.md

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,57 +27,23 @@ limitations under the License.
2727

2828
## Apache NuttX
2929

30-
NuttX is a free and open-source (FOSS) real-time operating system (RTOS)
31-
with an emphasis on standards compliance and small footprint.
32-
Scalable from 8-bit to 64-bit microcontroller environments,
33-
the primary governing standards in NuttX are POSIX and ANSI standards.
34-
Additional standard APIs from Unix and other common RTOS's (such as VxWorks)
35-
are adopted for functionality not available under these standards,
36-
or for functionality that is not appropriate for deeply-embedded environments
37-
(such as fork()).
38-
39-
40-
## Get NuttX
41-
42-
Release packages are available [here]({{ site.baseurl }}/download).
43-
We use three GIT repositories to develop the project:
44-
[RTOS]({{ site.data.project.source_repository_os_mirror }}),
45-
[Applications]({{ site.data.project.source_repository_apps_mirror }}),
46-
and [Website]({{ site.data.project.source_repository_website_mirror }}).
47-
Documentation is part of the RTOS repository and then built and hosted online.
48-
49-
50-
## Join Us
51-
52-
NuttX is developed and maintained by an international
53-
[group of volunteers]({{ site.baseurl }}/community-members) from all around the
54-
world. Please take a look at our [community]({{ site.baseurl }}/community)
55-
page to see how to join us and contribute to the project.
56-
57-
[Mailing list]({{ site.data.project.dev_list_archive_mailarchive }}) is our
58-
main communication channel, but we are also present on various social media
59-
platforms such as
60-
[Discord]({{ site.data.project.socialmedia_discord }}),
61-
[Hackster]({{ site.data.project.socialmedia_hackster }}),
62-
[LinkedIn]({{ site.data.project.socialmedia_linkedin_company }}),
63-
[Reddit]({{ site.data.project.socialmedia_reddit }}).
64-
65-
[NuttX Channel on YouTube]({{ site.data.project.socialmedia_youtube }}) contains
66-
many demos, tutorials, and hands-on exercises, as well as events videos.
30+
NuttX is a real-time operating system (RTOS) with an emphasis on standards
31+
compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller
32+
environments, the primary governing standards in NuttX are POSIX and ANSI
33+
standards. Additional standard APIs from Unix and other common RTOS's (such as
34+
VxWorks) are adopted for functionality not available under these standards, or
35+
for functionality that is not appropriate for deeply-embedded environments (such
36+
as fork()).
6737

6838

6939
## Documentation
7040

71-
Full project documentation can be found [here]({{ site.baseurl }}/docs/latest).
72-
Scientific papers are [here]({{ site.baseurl }}/articles).
41+
Extensive documentation can be found [here]({{ site.baseurl }}/docs/latest).
7342

7443

7544
## Online Demo
7645

77-
NuttX is incredibly portable. It runs on over 15 different CPU architectures,
78-
over 300 popular embedded hardware boards and development kits, provides
79-
more than 1500 ready to use firmware configuration templates for your project.
80-
See yourself, try out the [NuttX WebAssembly demo]({{ site.baseurl }}/demo).
46+
Try the online demo [here]({{ site.baseurl }}/demo).
8147

8248

8349
## Community Events

0 commit comments

Comments
 (0)