Skip to content

Commit

Permalink
Tested styling to be workign
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhang03 committed Oct 18, 2024
1 parent e1c16fc commit 4c57593
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/plugin-spr/examples/mode2.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<script src="https://unpkg.com/@jspsych/plugin-spr"></script>
<script src="../dist/index.browser.js"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych/css/jspsych.css">
<link rel="stylesheet" href="styles.css">
</head>

<body></body>
Expand Down
11 changes: 11 additions & 0 deletions packages/plugin-spr/examples/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.text-before-current-region {
background-color: blue;
}

.text-current-region {
background-color: red;
}

.text-after-current-region {
background-color: green;
}
10 changes: 8 additions & 2 deletions packages/plugin-spr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,19 @@ class SprPlugin implements JsPsychPlugin<Info> {
this.current_display_string = new_display_string;
} else {
if (this.mode === 1 && this.inner_index > 0) {
// sets previous to blank if exists -> might want to do same with other one except just change css classifier
this.current_display_string[this.inner_index - 1] =
"<span class='text-after-current-region'>" +
this.generateBlank(this.structured_reading_string[this.index][this.inner_index - 1]) +
"</span>";
} else if (this.mode === 2 && this.inner_index > 0) {
console.log("enters modifier", this.current_display_string);
// changes classifier
this.current_display_string[this.inner_index - 1] =
"<span class='text-after-current-region'>" +
this.structured_reading_string[this.index][this.inner_index - 1] +
"</span>";
}

// shows next display
this.current_display_string[this.inner_index] =
"<span class='text-current-region'>" +
Expand Down Expand Up @@ -249,7 +256,6 @@ class SprPlugin implements JsPsychPlugin<Info> {
}

private generateBlank(text: string | string[]): string {
// todo: make sure to split on individual words
const length = text.length;
var res = "";

Expand Down

0 comments on commit 4c57593

Please sign in to comment.