diff --git a/packages/studio-web/src/app/app.module.ts b/packages/studio-web/src/app/app.module.ts index 8e291425..8aa7654f 100644 --- a/packages/studio-web/src/app/app.module.ts +++ b/packages/studio-web/src/app/app.module.ts @@ -20,6 +20,7 @@ import { PrivacyDialog } from "./app.component"; import { ErrorPageComponent } from "./error-page/error-page.component"; import { EditorComponent } from "./editor/editor.component"; import { SharedModule } from "./shared/shared.module"; +import { WcStylingComponent } from "./shared/wc-styling/wc-styling.component"; defineCustomElements(); @@ -34,6 +35,7 @@ defineCustomElements(); ErrorPageComponent, EditorComponent, // ShepherdComponent + WcStylingComponent, ], imports: [ BrowserModule, diff --git a/packages/studio-web/src/app/demo/demo.component.html b/packages/studio-web/src/app/demo/demo.component.html index f0d7136c..17f967d2 100644 --- a/packages/studio-web/src/app/demo/demo.component.html +++ b/packages/studio-web/src/app/demo/demo.component.html @@ -38,7 +38,7 @@ [(ngModel)]="studioService.slots.title" [ngStyle]="{ 'width.ch': studioService.slots.title.length, - 'min-width.ch': 20 + 'min-width.ch': 20, }" style="border: none" placeholder="Enter your title here" @@ -50,7 +50,7 @@ [(ngModel)]="studioService.slots.subtitle" [ngStyle]="{ 'width.ch': studioService.slots.subtitle.length, - 'min-width.ch': 20 + 'min-width.ch': 20, }" style="border: none" placeholder="Enter your subtitle here" @@ -60,6 +60,5 @@ -
diff --git a/packages/studio-web/src/app/demo/demo.component.ts b/packages/studio-web/src/app/demo/demo.component.ts index 6d61dcad..9144e061 100644 --- a/packages/studio-web/src/app/demo/demo.component.ts +++ b/packages/studio-web/src/app/demo/demo.component.ts @@ -8,7 +8,7 @@ import { StudioService } from "../studio/studio.service"; import { DownloadService } from "../shared/download/download.service"; import { SupportedOutputs } from "../ras.service"; import { ToastrService } from "ngx-toastr"; - +import { WcStylingService } from "../shared/wc-styling/wc-styling.service"; @Component({ selector: "app-demo", templateUrl: "./demo.component.html", @@ -24,6 +24,7 @@ export class DemoComponent implements OnDestroy, OnInit { public studioService: StudioService, private downloadService: DownloadService, private toastr: ToastrService, + private wcStylingService: WcStylingService, ) { // If we do more languages, this should be a lookup table if ($localize.locale == "fr") { @@ -31,6 +32,12 @@ export class DemoComponent implements OnDestroy, OnInit { } else if ($localize.locale == "es") { this.language = "spa"; } + this.wcStylingService.$wcStyleInput.subscribe((css) => + this.updateWCStyle(css), + ); + this.wcStylingService.$wcStyleFonts.subscribe((font) => + this.addWCCustomFont(font), + ); } ngOnInit(): void {} @@ -47,6 +54,8 @@ export class DemoComponent implements OnDestroy, OnInit { this.studioService.b64Inputs$.value[1], this.studioService.slots, this.readalong, + "Studio", + this.wcStylingService, ); } else { this.toastr.error($localize`Download failed.`, $localize`Sorry!`, { @@ -72,4 +81,12 @@ export class DemoComponent implements OnDestroy, OnInit { ); } } + async updateWCStyle($event: string) { + this.readalong?.setCss( + `data:text/css;base64,${this.b64Service.utf8_to_b64($event ?? "")}`, + ); + } + async addWCCustomFont($font: string) { + this.readalong?.addCustomFont($font); + } } diff --git a/packages/studio-web/src/app/editor/editor.component.html b/packages/studio-web/src/app/editor/editor.component.html index 22931eea..994c8082 100644 --- a/packages/studio-web/src/app/editor/editor.component.html +++ b/packages/studio-web/src/app/editor/editor.component.html @@ -53,13 +53,36 @@+ To customize the look and feel of your read-along, you need to upload or + write some Cascading Style Sheets (CSS) in the styling section. +
+
+ We are providing a table below to help you customize. Please note that
+ your design must include both the light (.theme--light) and
+ dark (.theme--dark) themes.
+
| Class | +Description | +
|---|---|
+ .sentence__word
+ |
+ The aligned text | +
+ .sentence__word.reading
+ |
+ The aligned text being read | +
+ .sentence__text
+ |
+ The unaligned text | +
+ .sentence__translation
+ |
+ The translated text | +
+ .sentence
+ |
+ The sentence container | +
+ .paragraph
+ |
+ The paragraph containing the | +
+ +/** + define your colors and variables +**/ + + +:root, +#read-along-container { + --theme-light-foreground: rgb(80, 70, 70) !important; + --theme-light-background: rgb(250, 240, 240) !important; + --theme-light-system-background: rgb(240, 230, 230) !important; + --theme-light-system-foreground: rgb(70, 60, 60) !important; + --theme-dark-foreground: rgb(250, 242, 242) !important; + --theme-dark-background: rgb(90, 80, 80) !important; + --theme-dark-system-background: rgb(80, 70, 70) !important; + --theme-dark-system-foreground: rgb(240, 232, 232) !important; +} + + +/** + change the color of the aligned read along text +**/ + + +.theme--light.sentence__word, +.theme--light.sentence__text, +.theme--dark.sentence__word.reading, +.theme--dark.sentence__word:hover { + color: var(--theme-light-foreground) !important; +} + +.theme--dark.sentence__word, +.theme--dark.sentence__text, +.theme--light.sentence__word.reading, +.theme--light.sentence__word:hover { + color: var(--theme-dark-foreground) !important; +} + + +/** + change the color of the page counter +**/ + +.theme--dark .page__counter { + color: var(--theme-dark-foreground) !important; +} + +.theme--light .page__counter { + color: var(--theme-light-foreground) !important; +} + + +/** + change the scrollbar color +**/ + +.theme--light.pages__container { + scrollbar-color: var(--theme-light-foreground) var(--theme-light-system-background) !important; +} + +.theme--dark.pages__container { + scrollbar-color: var(--theme-dark-foreground) var(--theme-dark-system-background) !important; +} + + +/** + change the background color and text color +**/ + +.theme--light.page__container, +.theme--light.page__col__image, +.page__container, +.theme--light.settings { + background-color: var(--theme-light-background) !important; + color: var(--theme-light-foreground) !important; +} + +.theme--dark.page__container, +.theme--dark.page__col__image, +.page__container, +.theme--dark.settings { + background-color: var(--theme-dark-background) !important; + color: var(--theme-dark-foreground) !important; +} + + +/** + set backgrounds +**/ + +.background--dark, +.theme--light.sentence__word.reading, +.theme--light.sentence__word:hover { + background: var(--theme-dark-system-background) !important; +} + +.background--light, +.theme--dark.sentence__word.reading, +.theme--dark.sentence__word:hover { + background: var(--theme-light-system-background) !important; +} + + +/** control panel section **/ + + +/** + change the button color +**/ + + +.theme--light.ripple, +.color--light { + color: var(--theme-light-foreground) !important; +} + + +/** style playback speed button **/ + +.theme--light input[type="range"] { + accent-color: var(--theme-light-system-foreground) !important; + background-color: var(--theme-light-background) !important; +} + +.theme--light input[type="range"]::-webkit-slider-runnable-track, +input[type="range"]::-moz-range-track { + background-color: var(--theme-light-system-background) !important; +} + +.theme--dark.ripple, +.color--dark { + color: var(--theme-dark-system-foreground) !important; +} + +.theme--dark input[type="range"] { + accent-color: var(--theme-dark-system-foreground) !important; + background-color: var(--theme-dark-system-background) !important; +} + +.theme--dark input[type="range"]::-webkit-slider-runnable-track, +input[type="range"]::-moz-range-track { + background-color: var(--theme-dark-system-foreground) !important; +} + ++