Skip to content
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

Refactor light/dark mode to use CSS light-dark #451

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions assets/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ body {
padding: 0;
border: 0;
margin: 0;
@media (prefers-color-scheme: dark) {
background-color: var(--color-gray-100);
}
background-color: light-dark(var(--white), var(--color-gray-100));
}

.icon {
Expand Down Expand Up @@ -161,14 +159,12 @@ h3 {
font-size: 1.625rem;
}

/* Dark mode rules */
@media (prefers-color-scheme: dark) {
a {
color: var(--gray-10)
}
.lux-alert-info a {
color: var(--color-bleu-de-france-darker);
}
a {
color: light-dark(var(--color-bleu-de-france), var(--gray-10));
}

.lux-alert-info a {
color: light-dark(var(--color-cerulean-blue), var(--color-bleu-de-france-darker));
}

/* Mobile rules */
Expand Down
46 changes: 21 additions & 25 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,21 @@ if (query) {
}
}

@media (prefers-color-scheme: light) {
a:hover {
text-decoration-color: var(--color-princeton-orange-on-white);
text-decoration: underline;
}
a:focus {
outline: var(--color-princeton-orange-on-white) solid 0.25rem;
outline-offset: none;
box-shadow: none;
}
a:hover {
text-decoration-color: light-dark(
var(--color-princeton-orange-on-white),
var(--color-princeton-orange-on-black)
);
text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
a:hover {
text-decoration-color: var(--color-princeton-orange-on-black);
text-decoration: underline;
}
a:focus {
outline: var(--color-princeton-orange-on-black) solid 0.25rem;
outline-offset: none;
box-shadow: none;
}
a:focus {
outline-color: light-dark(
var(--color-princeton-orange-on-white),
var(--color-princeton-orange-on-black)
);
outline: solid 0.25rem;
outline-offset: none;
box-shadow: none;
}

.skip-to-content-link {
Expand Down Expand Up @@ -116,12 +109,15 @@ if (query) {
@media (prefers-color-scheme: dark) {
.lux-disclosure .lux-icon svg path {
stroke-width: 3;
stroke: var(--white);
}
.lux-disclosure button .lux-icon {
border: 2px solid white;
}
}
.lux-disclosure .lux-icon svg path {
stroke: light-dark(var(--black), var(--white));
}

.lux-disclosure button .lux-icon {
border: 2px solid light-dark(var(--black), var(--white));
}

.banner-wrapper {
min-height: 30px;
Expand Down
7 changes: 1 addition & 6 deletions src/components/BestBetsTray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ populateResults();

.best-bets > section {
padding: 10px;
background-color: #efefef;
}
@media (prefers-color-scheme: dark) {
.best-bets > section {
background-color: var(--color-grayscale-darker);
}
background-color: light-dark(#efefef, var(--color-grayscale-darker));
}
</style>
37 changes: 13 additions & 24 deletions src/components/JumpToSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ function toggleButton() {
list-style: none;
display: inline-flex;
justify-content: center;
background-color: var(--color-grayscale-lighter);
background-color: light-dark(
var(--color-grayscale-lighter),
var(--color-grayscale)
);

a {
text-decoration: none;
Expand All @@ -83,37 +86,23 @@ function toggleButton() {
padding: 0.5rem;
}

@media (prefers-color-scheme: dark) {
background-color: var(--color-grayscale);
a:link {
color: var(--color-grayscale-lighter);
}
a:link {
color: light-dark(var(--black), var(--color-grayscale-lighter));
}

a:visited {
color: var(--color-grayscale-lighter);
}
a:visited {
color: light-dark(var(--black), var(--color-grayscale-lighter));
}

a:hover {
color: light-dark(var(--gray-10), var(--color-grayscale-lighter));
}

&:hover {
/* color: var(--black); */
background-color: var(--orange-50);
cursor: pointer;
}

@media (prefers-color-scheme: light) {
a:link {
color: var(--black);
}

a:visited {
color: var(--black);
}

a:hover {
color: var(--gray-90);
}
}

@media (min-width: 1200px) {
flex: 1 0 15%;
}
Expand Down
34 changes: 12 additions & 22 deletions src/components/MoreResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,20 @@ if (props.resultCount) {
justify-content: right;
}

@media (prefers-color-scheme: light) {
a.more-link {
color: var(--black);
border-bottom: 2px var(--black) solid;
}

a.more-link:focus,
a.more-link:hover {
text-decoration: none;
border-bottom: 2px var(--color-princeton-orange-on-white) solid;
}
a.more-link {
color: light-dark(var(--black), var(--white));
border-bottom: 2px light-dark(var(--black), var(--white)) solid;
}

@media (prefers-color-scheme: dark) {
a.more-link {
color: var(--white);
border-bottom: 2px var(--white) solid;
}

a.more-link:focus,
a.more-link:hover {
text-decoration: none;
border-bottom: 2px var(--color-princeton-orange-on-black) solid;
}
a.more-link:focus,
a.more-link:hover {
text-decoration: none;
border-bottom: 2px
light-dark(
var(--color-princeton-orange-on-white),
var(--color-princeton-orange-on-black)
)
solid;
}

a.more-link {
Expand Down
10 changes: 3 additions & 7 deletions src/components/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,20 @@ input {
border: 2px solid var(--gray-100);
font-size: 1rem;
flex: 1;
@media (prefers-color-scheme: dark) {
background-color: var(--color-grayscale-darker);
color: var(--color-grayscale-lighter);
}
background-color: light-dark(var(--white), var(--color-grayscale-darker));
color: light-dark(var(--black), var(--color-grayscale-lighter));
}

button {
border: 2px solid var(--black);
border-left: 0px;
background-color: var(--orange-50);
background-color: light-dark(var(--orange-50), var(--color-grayscale-darker));
font-size: 1rem;
margin-top: 0;
margin-left: 0;
width: 51px;
@media (prefers-color-scheme: dark) {
border-left: 2px var(--gray-90) solid;
background-color: var(--color-grayscale-darker);
/* border-left-width: 0; */
}
}

Expand Down
13 changes: 1 addition & 12 deletions src/components/SearchTray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,13 @@ populateResults();
</script>

<style>
@media (prefers-color-scheme: light) {
li.document h3 a {
text-decoration-color: var(--gray-90);
}
}

@media (prefers-color-scheme: dark) {
li.document h3 a {
text-decoration-color: var(--gray-10);
}
}

li.document h3 {
display: inline;
}

li.document h3 a {
line-height: 2rem;
text-decoration-color: light-dark(var(--gray-90), var(--gray-10));
text-decoration-thickness: 1px;
text-underline-offset: 5px;
}
Expand Down
9 changes: 1 addition & 8 deletions src/components/TrayContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ const traysToLink = new TrayOrder().resultCompareArray();
}

.tray-grid section:not(:nth-child(-n + 2)):not(:nth-last-child(-n + 6)) {
@media (prefers-color-scheme: light) {
background-color: #efefef;
}

@media (prefers-color-scheme: dark) {
background-color: var(--color-grayscale-darker);
}

background-color: light-dark(#efefef, var(--color-grayscale-darker));
border: none;
@media (min-width: 900px) {
flex: 1 0 45%;
Expand Down
8 changes: 1 addition & 7 deletions src/components/TrayLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ const props = defineProps({
padding: 2px 15px 18px;
margin-top: 10px;
min-height: 300px;
background-color: light-dark(var(--white), var(--color-grayscale-darker));
}

@media (prefers-color-scheme: light) {
.tray-grid section {
background-color: var(--white);
border: 2px var(--gray-90) solid;
}
}

@media (prefers-color-scheme: dark) {
.tray-grid section {
background-color: var(--color-grayscale-darker);
}
}
</style>
12 changes: 2 additions & 10 deletions src/components/TrayTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ const iconClass = 'icon icon-' + props.icon;
const headingId = IdService.createDomId(props.heading);
</script>
<style>
@media (prefers-color-scheme: light) {
h3 a {
color: var(--black);
}
}

@media (prefers-color-scheme: dark) {
h3 a {
color: var(--gray-10);
}
h3 a {
color: light-dark(var(--black), var(--gray-10));
}

.description {
Expand Down