-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Whatever this is, it works * Styling for desktop * Toggle logic updates, along with some spacing stuff * Adjust spacing on chart titles and forecast item card * Adjust spacing on chart titles and forecast item card * Adjust toggle button sizing on tablet-lg and larger * Update web/themes/new_weather_theme/assets/js/components/forecast-details-toggle.js Co-authored-by: Greg Walker <142943695+greg-does-weather@users.noreply.github.com> --------- Co-authored-by: partly-igor <igor.korenfeld@noaa.gov> Co-authored-by: Greg Walker <142943695+greg-does-weather@users.noreply.github.com>
- Loading branch information
1 parent
42371d4
commit 7a8e5d8
Showing
16 changed files
with
95 additions
and
29 deletions.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
web/themes/new_weather_theme/assets/js/components/forecast-details-toggle.js
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,25 @@ | ||
// The click event for each toggle button will | ||
// update the visual selection class and also update the | ||
// selection data attribute | ||
const toggleHandler = ({ target: button }) => { | ||
const toggleContainer = button?.closest(".wx-forecast-details-toggle"); | ||
const selectedName = button?.dataset.selectionName; | ||
|
||
toggleContainer?.setAttribute("data-selected", selectedName); | ||
|
||
const buttons = Array.from(toggleContainer.getElementsByTagName("button")); | ||
buttons.forEach((btn) => { | ||
btn.classList.add("usa-button--outline"); | ||
if (btn.dataset.selectionName === selectedName) { | ||
btn.classList.remove("usa-button--outline"); | ||
} | ||
}); | ||
}; | ||
|
||
Array.from(document.getElementsByClassName("wx-forecast-details-toggle")) | ||
.forEach(toggleContainer => { | ||
const buttons = Array.from(toggleContainer.getElementsByTagName("button")); | ||
buttons.forEach(button => { | ||
button.addEventListener("click", toggleHandler); | ||
}); | ||
}); |
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
22 changes: 22 additions & 0 deletions
22
web/themes/new_weather_theme/assets/sass/components/forecast-details-toggle.scss
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,22 @@ | ||
@use "uswds-core" as *; | ||
|
||
.wx-forecast-details-toggle ~ * { | ||
display: none; | ||
} | ||
|
||
.wx-forecast-details-toggle ~ h4 { | ||
display: block; | ||
} | ||
|
||
.wx-forecast-details-toggle[data-selected="charts"] ~ *:not(wx-hourly-table) { | ||
display: initial; | ||
} | ||
|
||
.wx-forecast-details-toggle[data-selected="charts"] ~ *:last-child { | ||
display: none; | ||
} | ||
|
||
.wx-forecast-details-toggle[data-selected="table"] ~ wx-hourly-table, | ||
.wx-forecast-details-toggle[data-selected="table"] ~ *:last-child { | ||
display: initial; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
web/themes/new_weather_theme/templates/partials/forecast-details-toggle.html.twig
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,14 @@ | ||
<div class="wx-forecast-details-toggle grid-row grid-col-12 tablet:grid-col-6 margin-y-205" data-selected="table"> | ||
<ul class="usa-button-group usa-button-group--segmented tablet-lg:grid-col-8"> | ||
<li class="usa-button-group__item flex-1 display-flex"> | ||
<button type="button" class="usa-button flex-1" data-selection-name="table"> | ||
{{"Table" | t}} | ||
</button> | ||
</li> | ||
<li class="usa-button-group__item flex-1 display-flex"> | ||
<button type="button" class="usa-button usa-button--outline flex-1" data-selection-name="charts"> | ||
{{"Charts" | t}} | ||
</button> | ||
</li> | ||
</ul> | ||
</div> |
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
1 change: 0 additions & 1 deletion
1
web/themes/new_weather_theme/templates/partials/hourly-table.html.twig
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