forked from IsThereAnyDeal/AugmentedSteam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor app page review section toggle button
- Loading branch information
Showing
5 changed files
with
76 additions
and
70 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 was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
src/js/Content/Features/Store/App/FReviewToggleButton.svelte
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,74 @@ | ||
<script lang="ts" context="module"> | ||
// @ts-ignore | ||
import self_ from "./FReviewToggleButton.svelte"; | ||
import {Feature} from "../../../modulesContent"; | ||
import type {CApp} from "./CApp"; | ||
export class FReviewToggleButton extends Feature<CApp> { | ||
override checkPrerequisites(): boolean { | ||
this._node = document.getElementById("review_create"); | ||
return this._node !== null; | ||
} | ||
override apply(): void { | ||
const target = this._node.querySelector("h1"); | ||
if (!target) { | ||
throw new Error("Node not found"); | ||
} | ||
// Reparent review section nodes | ||
const reviewSection = document.createElement("div"); | ||
reviewSection.classList.add("es_review_section"); | ||
reviewSection.append( | ||
...this._node.querySelectorAll("p, .avatar_block, .content") | ||
); | ||
target.after(reviewSection); | ||
(new self_({ | ||
target, | ||
props: { | ||
reviewSection | ||
} | ||
})); | ||
} | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {LocalStorage, Localization} from "../../../../modulesCore"; | ||
import {onMount} from "svelte"; | ||
export let reviewSection: Element|undefined; | ||
export let state: boolean = LocalStorage.get("show_review_section"); | ||
function toggleReviews(event) { | ||
if (event) { | ||
state = !state; | ||
LocalStorage.set("show_review_section", state); | ||
} | ||
reviewSection!.style.maxHeight = state ? null : 0; | ||
} | ||
onMount(() => { | ||
toggleReviews(); | ||
}); | ||
</script> | ||
|
||
|
||
<button class="btnv6_lightblue_blue btn_medium es_review_toggle" on:click={toggleReviews}> | ||
<div data-tooltip-text="{Localization.str.expand_or_contract_slider}">{state ? "▲" : "▼"}</div> | ||
</button> | ||
|
||
|
||
<style> | ||
:global(.es_review_section) { | ||
overflow: hidden; | ||
} | ||
.es_review_toggle { | ||
float: right; | ||
font-size: 18px; | ||
} | ||
</style> |
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